Day/Night LED does not work on extension module

olivier1010

Joined
Jul 18, 2009
Messages
38
Likes
0
Points
0
#1
Day/Night LED does not work on extension module. It seems that the context is not right :


Application daynight
Array
(
[key] => expmod1
[last] => 0
)

The expmod1 key number is missing.


Is there a way to patch this inside PHP scripts, or is it a problem with the Aastra Firmware ?
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#2
Hi olivier1010,

You are right, this is definitely a bug in the scripts. The bug is in /var/www/html/aastra/asterisk/sync.php where we parse the configuration file to extract the keys attached to the special functions, the function assumes only one word for the key name which is not valid for an expansion module.

Here the fix, it is in the function "init_special_keys" in sync.php around line 402

Replace the whole block within
Code:
# Some data
if($array_config!=NULL)
	{
	foreach($array_config as $key=>$value) 
		{
		BLOCK to change
		}
	}
with the following block

Code:
if(strstr($value,'dnd.php')) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $dnd['key']=$pieces[0].' '.$pieces[1];
	else $dnd['key']=$pieces[0];
	}
if(strstr($value,'cfwd.php')) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $cfwd['key']=$pieces[0].' '.$pieces[1];
	else $cfwd['key']=$pieces[0];
	}
if(strstr($value,'daynight.php')) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $daynight['key']=$pieces[0].' '.$pieces[1];
	else $daynight['key']=$pieces[0];
	}
if(strstr($value,'away.php')) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $away['key']=$pieces[0].' '.$pieces[1];
	else $away['key']=$pieces[0];
	}
if(strstr($value,'agent.php')) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $agent['key']=$pieces[0].' '.$pieces[1];
	else $agent['key']=$pieces[0];
	}
if(strstr($value,'follow.php')) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $follow['key']=$pieces[0].' '.$pieces[1];
	else $follow['key']=$pieces[0];
	}
if(strstr($value,'park.php') and $is_sip_notify_supported) 
	{
	$pieces=explode(' ',$key);
	if(stristr($pieces[0],'expmod')) $parking['key']=$pieces[0].' '.$pieces[1];
	else $parking['key']=$pieces[0];
	Aastra_add_parking_Asterisk($user);
	}
if(strstr($value,'vmail.php') and $is_sip_notify_supported) 
	{
	$url=parse_url($value);
	parse_str($url['query'],$parse);
	if($parse['user']!='') 
		{
		Aastra_add_vmail_Asterisk($parse['user'],$user,$count);
		$pieces=explode(' ',$key);
		if(stristr($pieces[0],'expmod'))
			{
			$vmail[$parse['user']]['key']=$pieces[0].' '.$pieces[1];
			$vmail[$parse['user']]['label']=$array_config[$pieces[0].' '.$pieces[1].' label'];
			}
		else
			{
			$vmail[$parse['user']]['key']=$pieces[0];
			$vmail[$parse['user']]['label']=$array_config[$pieces[0].' label'];
			}
		}
	}
Be careful when you paste the code, the editor has added a '\' before each '.
That should fix your problem.

Regards

aastra1
 

olivier1010

Joined
Jul 18, 2009
Messages
38
Likes
0
Points
0
#3
Thanks a lot Aastra1. It does work now.


I've just found two small other problems :

1)

If using more than one Day/Night feature, only the first one is checked by the LED.

This is quite troubling because the script does allow to setup more than one.

It would be very nice if the LED would stay lighted if there is one Day/Night feature enabled in the group.

2) The first Day/Night always report "MODE JOUR" on screen, even if it is actually mode nuit. But the seconde day night show the right state, in english : "NIGHT MODE" or "DAY-MODE"

Seems like a small problem with translation variables.


Thanks a lot for your efficient support.
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#4
You are welcome, it was an easy one.

1) If using more than one Day/Night feature, only the first one is checked by the LED.
This is quite troubling because the script does allow to setup more than one.
It would be very nice if the LED would stay lighted if there is one Day/Night feature enabled in the group.
I agree, the day/night key behavior is pretty confusing as we added the control of the other indexes at the last minutes. Somewhere, if you have more than one index, it does not make sense to even change the key label as it applies only for the "main" index. We will do some changes in the next version as we plan to rewrite this feature, we might need to bounce some ideas, would you be OK to help us?

2) The first Day/Night always report "MODE JOUR" on screen, even if it is actually mode nuit. But the seconde day night show the right state, in english : "NIGHT MODE" or "DAY-MODE"
Seems like a small problem with translation variables.
I can't reproduce that on my test server, does it display "Mode JOUR" in the list when you have more than one index? I just checked the code and I don't see any reason why it would switch to French, the only one I can see is that I am a French citizen :cheer: but the code is first developped in English.

I will try to reproduce.

Regards

aastra1
 

olivier1010

Joined
Jul 18, 2009
Messages
38
Likes
0
Points
0
#5
We will do some changes in the next version as we plan to rewrite this feature, we might need to bounce some ideas, would you be OK to help us?
Yes certainly for ideas and ergonomics or testing, but i think that at Aastra development team you are ten times beter than us for programming. It was a bit hard to understand the Aastra code when we did the phonebook application, because it is very well programmed with advanced object programming. We learned a lot studying it, thanks for this.

You can contact me at : contact2 / at / nerim.net


I just checked the code and I don't see any reason why it would switch to French
I think i'm French :=) So we are using French language in aastra scripts.


I will try to explain a bit better :

When using more than one Day/Night, the first line show this every time :

PRINC-MODE JOUR

regardless the mode.



the second line show :

DNname - DAY MODE
or
DNname - NIGHT MODE

according to the mode we are, and update in realtime when we change the mode with the "Inverser" key.


Problems :

1) the first line never update

2) the second line is not translated to French but update correctly.


Good things :

1) The LED does show the mode of the first Day/Night correctly.

2) The day night always update correctly inside Asterisk.
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#6
Translation problem and status update

Hey Olivier1010

Just had a second look at the code and found the bugs.

In /var/www/html/aastra/asterisk/daynight.php, within the "case list" section

Around line 205
Replace
Code:
if($array_night[$AA_DAYNIGHT_INDEX]=='1') $display=Aastra_get_label('MAIN-NIGHT MODE',$language);
by
Code:
if($array_night[$AA_DAYNIGHT_INDEX]['night']=='1') $display=Aastra_get_label('MAIN-NIGHT MODE',$language);
Around line 212
Replace
Code:
if($value['night']=='1') $display=sprintf('%s-NIGHT MODE',$value['desc']);
else $display=sprintf('%s-DAY MODE',$value['desc']);
by
Code:
if($value['night']=='1') $display=sprintf(Aastra_get_label('%s-NIGHT MODE',$language),$value['desc']);
else $display=sprintf(Aastra_get_label('%s-DAY MODE',$language),$value['desc']);
That will do the trick.

Cordialement

aastra1
 

olivier1010

Joined
Jul 18, 2009
Messages
38
Likes
0
Points
0
#7
Re:Translation problem and status update

Still a small problem :


The Main index is now updating correctly in French.

But the second line stay in english.

Other small issues :

I've notified that when changing the Main Day/Night, we get a confirmation BIP. This is not the case for other Day/Nights and can be disturbing for users.


Last, i'm not sure that it is good to have "Main" as description for the first Index. It would certainly be better for homogeneity that the first Index take its name inside FreePBX like other ones.
 

aastra1

Joined
Mar 5, 2009
Messages
46
Likes
0
Points
0
#8
Re:Translation problem and status update

But the second line stay in english.
Sorry, the code has been changed to support localization but the labels are not translated. To fix that add the following lines at the end of /var/www/html/aastra/language.ini

Code:
[%s-NIGHT MODE]
en=%s-NIGHT MODE
fr=%s-MODE NUIT
[%s-DAY MODE]
en=%s-DAY MODE
fr=%s-MODE JOUR
I've notified that when changing the Main Day/Night, we get a confirmation BIP. This is not the case for other Day/Nights and can be disturbing for users.
To add the beep for every change, add the following line
Code:
$object->setBeep();
in /var/www/html/aastra/asterisk/daynight.php around line 276 to look like this.

Code:
# Back to the list
$object->setBeep();
$object->addEntry($XML_SERVER.'&action=list&index='.$index);
Last, i'm not sure that it is good to have "Main" as description for the first Index. It would certainly be better for homogeneity that the first Index take its name inside FreePBX like other ones.
I can probably retrieve the day/night names in the freePBX database, just need to find the right table and field. Next version...

Thanks again for the feedback.

Regards

aastra1
 

olivier1010

Joined
Jul 18, 2009
Messages
38
Likes
0
Points
0
#9
Re:Translation problem and status update

I can probably retrieve the day/night names in the freePBX database, just need to find the right table and field. Next version...

It seems that you ever did get the name for Day/Night indexes. Only the first line does have "MAIN" or "PRINC" in french instead of the Day/Night FreePBX name.

The First line show :

PRINC-MODE JOUR


The second line show :


DayNightname-MODE JOUR


Thanks again for your efficient help.
 

olivier1010

Joined
Jul 18, 2009
Messages
38
Likes
0
Points
0
#10
Re:Translation problem and status update

I did find a solution :

Locate this block of code around line 202 :

Code:
if(Aastra_is_style_textmenu_supported()) $object->setStyle('none');
		$object->setTitle(Aastra_get_label('Day/Night Control',$language));
		if($array_night[$AA_DAYNIGHT_INDEX]['night']=='1') $display=Aastra_get_label('MAIN-NIGHT MODE',$language);
		else $display=Aastra_get_label('MAIN-DAY MODE',$language);
		$object->addEntry($display,$XML_SERVER.'&action=change2&index='.$AA_DAYNIGHT_INDEX);
		foreach($array_night as $i=>$value)
			{
			if($i!=$AA_DAYNIGHT_INDEX)
				{
				if($value['night']=='1') $display=sprintf(Aastra_get_label('%s-NIGHT MODE',$language),$value['desc']);
				else $display=sprintf(Aastra_get_label('%s-DAY MODE',$language),$value['desc']);
				$object->addEntry($display,$XML_SERVER.'&action=change2&index='.$i);
				}
			}

And replace it by :

Code:
if(Aastra_is_style_textmenu_supported()) $object->setStyle('none');
		$object->setTitle(Aastra_get_label('Day/Night Control',$language));
		foreach($array_night as $i=>$value)
			{
				if($value['night']=='1') $display=sprintf(Aastra_get_label('%s-NIGHT MODE',$language),$value['desc']);
				else $display=sprintf(Aastra_get_label('%s-DAY MODE',$language),$value['desc']);
				$object->addEntry($display,$XML_SERVER.'&action=change2&index='.$i);
			}
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,886
Members
17,563
Latest member
dineshr
Top