Changeset 4425

Show
Ignore:
Timestamp:
07/17/07 20:26:50 (6 years ago)
Author:
p_lindheimer
Message:

- Changes by Peter Kaplan (thanks!)
- separated ARI into modules for Follow-Me, VmX, etc.
- added DND and CW to features

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/includes/asi.php

    r1773 r4425  
    118118  } 
    119119 
     120  function command2($command) { 
     121 
     122    $response = ''; 
     123 
     124    fwrite($this->socket,$command); 
     125 
     126    $count = 0; 
     127    while (($buffer = fgets($this->socket)) && (!preg_match('/Response: Follows/i', $buffer))) { 
     128 
     129      if ($count>100) { 
     130        $_SESSION['ari_error'] =  _("Asterisk command not understood") . "<br />" . $buffer . "<br />\n"; 
     131        return FALSE; 
     132      } 
     133      $count++; 
     134    } 
     135 
     136    $count = 0; 
     137    while (($buffer = fgets($this->socket)) && (!preg_match('/END COMMAND/i', $buffer))) { 
     138 
     139      if (preg_match('/Value:/',$buffer)) { 
     140        $parts = split('Value:',trim($buffer)); 
     141        $response = $parts[1]; 
     142      } 
     143      if ($count>100) { 
     144        $_SESSION['ari_error'] =  _("Asterisk command not understood") . "<br />" . $buffer . "<br />\n"; 
     145        return; 
     146      } 
     147      $count++; 
     148    } 
     149 
     150    return $response; 
     151  } 
     152 
    120153 
    121154 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/includes/bootstrap.php

    r4153 r4425  
    104104    $dh = opendir($path); 
    105105    while (false!== ($item = readdir($dh))) { 
    106       if($item[0]!=".") { 
     106      if($item!="." && $item!="..") { 
    107107 
    108108        $path = fixPathSlash($path); 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/includes/login.php

    r1773 r4425  
    355355 
    356356    $ret = ''; 
    357     $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $extension/outboundcid\r\n\r\n"); 
     357    $response = $asterisk_manager_interface->Command2("Action: Command\r\nCommand: database get AMPUSER $extension/outboundcid\r\n\r\n"); 
    358358    if ($response) { 
    359       $ret = $response; 
    360     } 
    361  
     359     
     360    $posLeft  = strpos( $response, "<")+strlen("<"); 
     361    $posRight = strpos( $response, ">", $posLeft); 
     362    $ret = substr( $response,$posLeft,$posRight-$posLeft); 
     363    } 
    362364    return $ret; 
    363365  } 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/VmX.module

    r4328 r4425  
    3636   *   Common arguments 
    3737   */ 
    38   function navMenu($args) { 
    39  
    40     $ret .= " 
    41     <p> 
    42       <small> 
    43         <small> 
    44           <a href='"  
    45             . $_SESSION['ARI_ROOT'] . "?m=VmX&f=display'>" . _("VmX Locator&#8482;") .  
    46           "</a> 
    47         </small> 
    48       </small> 
    49     </p>"; 
    50  
    51   return $ret; 
    52   } 
     38  function navMenu($args) { 
     39     
     40    global $SETTINGS_ALLOW_VMX_SETTINGS; 
     41    global $ARI_ADMIN_USERNAME; 
     42     
     43    $ret = ""; 
     44 
     45    // We are only going to show the menu  
     46    // if VmX is allowed 
     47    if ($SETTINGS_ALLOW_VMX_SETTINGS) { 
     48 
     49      $exten = $_SESSION['ari_user']['extension']; 
     50       
     51      // and we are not logged in as admin 
     52      if ($exten!=$ARI_ADMIN_USERNAME) { 
     53       
     54        $vmx_enabled  = $this->getVmxState($exten,'unavail'); 
     55         
     56        // and vmx is enabled for this user 
     57        if ($vmx_enabled !== false) 
     58          $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] .  "?m=VmX&f=display'>" . _("VmX&#8482 Locator") . "</a></small></small></p>"; 
     59      } 
     60    } 
     61     
     62    return $ret; 
     63  } 
    5364 
    5465  /* 
     
    7081  $a = getArgument($args,'a'); 
    7182 
    72   $lang_code = getArgument($args,'lang_code'); 
    73  
    74   $follow_me_prering_time     = getArgument($args,'follow_me_prering_time'); 
    75   $follow_me_listring_time    = getArgument($args,'follow_me_listring_time'); 
    76   $follow_me_list         = getArgument($args,'follow_me_list'); 
    77   $follow_me_confirm        = getArgument($args,'follow_me_confirm'); 
    78   $follow_me_ddial        = getArgument($args,'follow_me_ddial'); 
    7983  $follow_me_disabled       = getArgument($args,'follow_me_disabled'); 
    8084 
     
    8993  $vmx_disabled         = getArgument($args, 'vmx_disabled'); 
    9094 
    91   $language = new Language(); 
    92  
    9395  // Lets see if we can make heads or tails of this code?!? 
    9496   
    9597  // The action is 'update 
    9698  if ($a=='update') { 
    97  
    98     // Get the extension and make sure we are not in  
    99     // admin mode 
    100     $exten = $_SESSION['ari_user']['extension']; 
    101     if ($exten!=$ARI_ADMIN_USERNAME) { 
    10299   
    103    
    104       // Make sure Follow-Me setup has not been deleted for this user since the last refresh 
    105       $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 
    106       if (! $_COOKIE['ari_follow_me_disabled']) { 
    107        
    108         $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1; 
    109          
    110         if ($follow_me_disabled) { 
    111            
    112           setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 
    113           $follow_me_disabled_delayed = $follow_me_disabled; 
    114           $_SESSION['ari_error'] =  
    115           _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" . 
    116           sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 
    117         } 
    118       } 
    119    
    120       $vmx_disabled_delayed = $_COOKIE['ari_vmx_disabled']; 
    121       if (! $_COOKIE['ari_vmx_disabled']) { 
    122          
    123         $vmx_disabled = $this->getVmxState($exten,'unavail'); 
    124         if ($vmx_disabled === false) { 
    125           $vmx_disabled = true; 
    126           $SETTINGS_ALLOW_VMX_SETTINGS=false; 
    127         } else { 
    128           $vmx_disabled = false; 
    129         } 
    130         if ($vmx_disabled) { 
    131            
    132           setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 
    133           $vmx_disabled_delayed = $vmx_disabled; 
    134           $_SESSION['ari_error'] =  
    135           _("Your Premium VmX Locator service has been disabled, REFRESH your browser to remove this message") . "<br>" . 
    136           sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 
    137         } 
    138       } 
    139    
    140       if (! $vmx_disabled_delayed) { 
    141         if (!$STANDALONE['use']) { 
    142      
    143           // set database 
    144           $this->setVmxState($exten,'unavail',$vmx_unavail_enabled); 
    145           $this->setVmxState($exten,'busy',$vmx_busy_enabled); 
    146           $this->setVmxPlayInstructions($exten,'unavail',$vmx_play_instructions); 
    147           $this->setVmxPlayInstructions($exten,'busy',$vmx_play_instructions); 
    148        
    149           // store cookie 
    150           setcookie("ari_vmx_unavail_enabled", $vmx_unavail_enabled, time()+365*24*60*60); 
    151           setcookie("ari_vmx_busy_enabled", $vmx_busy_enabled, time()+365*24*60*60); 
    152           setcookie("ari_vmx_play_instructions", $vmx_play_instructions, time()+365*24*60*60); 
    153    
    154           $stripped_vmx_option_0_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_0_number); 
    155            
    156           if ($vmx_option_0_system_default) { 
    157             $this->setVmxOptionNumber($exten,'0','unavail',""); 
    158             $this->setVmxOptionNumber($exten,'0','busy',""); 
    159             setcookie("ari_vmx_option_0_system_default", $vmx_option_0_system_default, time()+365*24*60*60); 
    160             if (is_numeric($stripped_vmx_option_0_number) || !$stripped_vmx_option_0_number) { 
    161               $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 
    162               if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 
    163               setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 
    164               } 
    165             } 
    166           } else { 
    167             if (!is_numeric($stripped_vmx_option_0_number) && $stripped_vmx_option_0_number) { 
    168               $_SESSION['ari_error'] =  
    169               _("Option 0 not changed") . "<br>" . 
    170               sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_0_number); 
    171             } 
    172             else { 
    173              
    174               // set database 
    175               $this->setVmxOptionNumber($exten,'0','unavail',$stripped_vmx_option_0_number); 
    176               $this->setVmxOptionNumber($exten,'0','busy',$stripped_vmx_option_0_number); 
    177                
    178               // store cookie 
    179               $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 
    180               if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 
    181                 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 
    182               } 
    183             } 
    184           } 
    185    
    186           $stripped_vmx_option_1_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_1_number); 
    187           if ($vmx_option_1_system_default && !$follow_me_disabled) { 
    188             $this->setVmxOptionFollowMe($exten,'1','unavail'); 
    189             $this->setVmxOptionFollowMe($exten,'1','busy'); 
    190             setcookie("ari_vmx_option_1_system_default", $vmx_option_1_system_default, time()+365*24*60*60); 
    191             if (is_numeric($stripped_vmx_option_1_number) || !$stripped_vmx_option_1_number) { 
    192               $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 
    193               if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 
    194                 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 
    195               } 
    196             } 
    197           } 
    198           else { 
    199            
    200             if (!is_numeric($stripped_vmx_option_1_number) && $stripped_vmx_option_1_number) { 
    201               $_SESSION['ari_error'] =  
    202               _("Option 1 not changed") . "<br>" . 
    203               sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_1_number); 
    204             } 
    205             else { 
    206                
    207               // set database 
    208               $this->setVmxOptionNumber($exten,'1','unavail',$stripped_vmx_option_1_number); 
    209               $this->setVmxOptionNumber($exten,'1','busy',$stripped_vmx_option_1_number); 
    210                
    211               // store cookie 
    212               $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 
    213               if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 
    214                 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 
    215               } 
    216             } 
    217           } 
    218    
    219           $stripped_vmx_option_2_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_2_number); 
    220           if (!is_numeric($stripped_vmx_option_2_number) && $stripped_vmx_option_2_number) { 
    221             $_SESSION['ari_error'] =  
    222             _("Option 2 not changed") . "<br>" . 
    223             sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_2_number); 
    224           } 
    225           else { 
    226      
    227             // set database 
    228             $this->setVmxOptionNumber($exten,'2','unavail',$stripped_vmx_option_2_number); 
    229             $this->setVmxOptionNumber($exten,'2','busy',$stripped_vmx_option_2_number); 
    230      
    231             // store cookie 
    232             $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_2_number']); 
    233             if ($vmx_option_2_number && $stripped!=$stripped_vmx_option_2_number) { 
    234               setcookie("ari_vmx_option_2_number", $call_vmx_option_2_number, time()+365*24*60*60); 
    235             } 
     100    // Make sure Follow-Me setup has not been deleted for this user since the last refresh 
     101    $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 
     102    if (! $_COOKIE['ari_follow_me_disabled']) { 
     103     
     104      $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1; 
     105       
     106      if ($follow_me_disabled) {       
     107        setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 
     108        $follow_me_disabled_delayed = $follow_me_disabled; 
     109        $_SESSION['ari_error'] =  
     110        _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" . 
     111        sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 
     112      } 
     113    } 
     114     
     115    $vmx_disabled_delayed = $_COOKIE['ari_vmx_disabled']; 
     116    if (! $_COOKIE['ari_vmx_disabled']) { 
     117     
     118      $vmx_disabled = $this->getVmxState($exten,'unavail'); 
     119      if ($vmx_disabled === false) { 
     120        $vmx_disabled = true; 
     121        $SETTINGS_ALLOW_VMX_SETTINGS=false; 
     122      } else { 
     123        $vmx_disabled = false; 
     124      } 
     125      if ($vmx_disabled) { 
     126       
     127        setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 
     128        $vmx_disabled_delayed = $vmx_disabled; 
     129        $_SESSION['ari_error'] =  
     130        _("Your Premium VmX Locator service has been disabled, REFRESH your browser to remove this message") . "<br>" . 
     131        sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 
     132      } 
     133    } 
     134     
     135    if (! $vmx_disabled_delayed) { 
     136     
     137      // set database 
     138      $this->setVmxState($exten,'unavail',$vmx_unavail_enabled); 
     139      $this->setVmxState($exten,'busy',$vmx_busy_enabled); 
     140      $this->setVmxPlayInstructions($exten,'unavail',$vmx_play_instructions); 
     141      $this->setVmxPlayInstructions($exten,'busy',$vmx_play_instructions); 
     142       
     143      // store cookie 
     144      setcookie("ari_vmx_unavail_enabled", $vmx_unavail_enabled, time()+365*24*60*60); 
     145      setcookie("ari_vmx_busy_enabled", $vmx_busy_enabled, time()+365*24*60*60); 
     146      setcookie("ari_vmx_play_instructions", $vmx_play_instructions, time()+365*24*60*60); 
     147       
     148      $stripped_vmx_option_0_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_0_number); 
     149       
     150      if ($vmx_option_0_system_default) { 
     151        $this->setVmxOptionNumber($exten,'0','unavail',""); 
     152        $this->setVmxOptionNumber($exten,'0','busy',""); 
     153        setcookie("ari_vmx_option_0_system_default", $vmx_option_0_system_default, time()+365*24*60*60); 
     154        if (is_numeric($stripped_vmx_option_0_number) || !$stripped_vmx_option_0_number) { 
     155          $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 
     156          if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 
     157            setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 
    236158          } 
    237159        } 
    238       } // vmx_disabled_delayed false 
    239    
    240       if (! $follow_me_disabled_delayed) { 
    241    
    242         // assume no errors, don't update SQL if errors occured 
    243         $follow_me_update_succeeded=1; 
    244          
    245         // update follow me pre-ring time 
    246         if (!$STANDALONE['use']) { 
    247          
    248           $stripped_follow_me_prering_time = preg_replace('/-|\s/','',$follow_me_prering_time); 
    249           if (!is_numeric($stripped_follow_me_prering_time)) { 
    250             $_SESSION['ari_error'] =  
    251             _("Follow-Me pre-ring time not changed") . "<br>" . 
    252             sprintf(_("Number %s must be an interger number of seconds"),$follow_me_prering_time); 
    253             $follow_me_update_succeeded=0; 
    254           } 
    255           else { 
    256              
    257             // set database 
    258             $this->setFollowMePreRingTime($exten,$stripped_follow_me_prering_time); 
    259              
    260             // store cookie 
    261             $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_prering_time']); 
    262             if ($follow_me_prering_time && $stripped!=$stripped_follow_me_prering_time) { 
    263               setcookie("ari_follow_me_prering_time", $follow_me_prering_time, time()+365*24*60*60); 
    264             } 
     160      } else { 
     161        if (!is_numeric($stripped_vmx_option_0_number) && $stripped_vmx_option_0_number) { 
     162          $_SESSION['ari_error'] =  
     163          _("Option 0 not changed") . "<br>" . 
     164          sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_0_number); 
     165        } 
     166        else { 
     167           
     168          // set database 
     169          $this->setVmxOptionNumber($exten,'0','unavail',$stripped_vmx_option_0_number); 
     170          $this->setVmxOptionNumber($exten,'0','busy',$stripped_vmx_option_0_number); 
     171           
     172          // store cookie 
     173          $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 
     174          if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 
     175            setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 
    265176          } 
    266177        } 
    267      
    268         // update follow me list ring time 
    269         if (!$STANDALONE['use']) { 
    270          
    271           $stripped_follow_me_listring_time = preg_replace('/-|\s/','',$follow_me_listring_time); 
    272           if (!is_numeric($stripped_follow_me_listring_time)) { 
    273             $_SESSION['ari_error'] =  
    274             _("Follow-Me list ring time not changed") . "<br>" . 
    275             sprintf(_("Number %s must be an interger number of seconds"),$follow_me_listring_time); 
    276             $follow_me_update_succeeded=0; 
    277           } 
    278           else { 
    279            
    280             // set database 
    281             $this->setFollowMeListRingTime($exten,$stripped_follow_me_listring_time); 
    282              
    283             // store cookie 
    284             $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_listring_time']); 
    285             if ($follow_me_listring_time && $stripped!=$stripped_follow_me_listring_time) { 
    286               setcookie("ari_follow_me_listring_time", $follow_me_listring_time, time()+365*24*60*60); 
    287             } 
     178      } 
     179       
     180      $stripped_vmx_option_1_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_1_number); 
     181      if ($vmx_option_1_system_default && !$follow_me_disabled) { 
     182        $this->setVmxOptionFollowMe($exten,'1','unavail'); 
     183        $this->setVmxOptionFollowMe($exten,'1','busy'); 
     184        setcookie("ari_vmx_option_1_system_default", $vmx_option_1_system_default, time()+365*24*60*60); 
     185        if (is_numeric($stripped_vmx_option_1_number) || !$stripped_vmx_option_1_number) { 
     186          $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 
     187          if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 
     188            setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 
    288189          } 
    289190        } 
    290      
    291         // update follow me list  
    292         if (!$STANDALONE['use']) { 
    293          
    294           $grplist = explode("\n", $follow_me_list); 
     191      } 
     192      else { 
     193       
     194        if (!is_numeric($stripped_vmx_option_1_number) && $stripped_vmx_option_1_number) { 
     195          $_SESSION['ari_error'] =  
     196          _("Option 1 not changed") . "<br>" . 
     197          sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_1_number); 
     198        } 
     199        else { 
    295200           
    296           if (!$grplist) { 
    297           $grplist = null
    298           } 
     201          // set database 
     202          $this->setVmxOptionNumber($exten,'1','unavail',$stripped_vmx_option_1_number)
     203          $this->setVmxOptionNumber($exten,'1','busy',$stripped_vmx_option_1_number); 
    299204           
    300           foreach (array_keys($grplist) as $key) { 
    301             //trim it 
    302             $grplist[$key] = trim($grplist[$key]); 
    303              
    304             // Lookup the extension and append hash if not a user, and remove invalid chars 
    305             $grplist[$key] = $this->lookupSetExtensionFormat($grplist[$key]); 
    306              
    307             // remove blanks 
    308             if ($grplist[$key] == "") unset($grplist[$key]); 
    309           } 
    310            
    311           // check for duplicates, and re-sequence 
    312           $grplist = array_values(array_unique($grplist)); 
    313            
    314           $stripped_follow_me_list = implode("-",$grplist); 
    315            
    316           if ($stripped_follow_me_list == "") { 
    317             $_SESSION['ari_error'] =  
    318             _("Follow-Me list must contain at least one valid number") . "<br>" . 
    319             sprintf(_("The following: %s is not valid"),$follow_me_list); 
    320             $follow_me_update_succeeded=0; 
    321           } 
    322           else { 
    323            
    324             // set database 
    325             $this->setFollowMeList($exten,$stripped_follow_me_list); 
    326              
    327             // store cookie 
    328             $stripped = preg_replace('/|\(|\)|\s/','',$_COOKIE['ari_follow_me_list']); 
    329             if ($follow_me_list && $stripped!=$stripped_follow_me_list) { 
    330               setcookie("ari_follow_me_list", $follow_me_list, time()+365*24*60*60); 
    331             } 
     205          // store cookie 
     206          $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 
     207          if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 
     208            setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 
    332209          } 
    333210        } 
    334      
    335         // update follow me confirm 
    336         if (!$STANDALONE['use']) { 
     211      } 
     212       
     213      $stripped_vmx_option_2_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_2_number); 
     214      if (!is_numeric($stripped_vmx_option_2_number) && $stripped_vmx_option_2_number) { 
     215        $_SESSION['ari_error'] =  
     216        _("Option 2 not changed") . "<br>" . 
     217        sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_2_number); 
     218      } 
     219      else { 
    337220         
    338           // set database 
    339           $this->setFollowMeConfirm($exten,$follow_me_confirm); 
    340           $this->setFollowMeDDial($exten,$follow_me_ddial); 
    341            
    342           // store cookie 
    343           setcookie("ari_follow_me_confirm", $follow_me_confirm, time()+365*24*60*60); 
    344           setcookie("ari_follow_me_ddial", $follow_me_ddial, time()+365*24*60*60); 
     221        // set database 
     222        $this->setVmxOptionNumber($exten,'2','unavail',$stripped_vmx_option_2_number); 
     223        $this->setVmxOptionNumber($exten,'2','busy',$stripped_vmx_option_2_number); 
     224         
     225        // store cookie 
     226        $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_2_number']); 
     227        if ($vmx_option_2_number && $stripped!=$stripped_vmx_option_2_number) { 
     228          setcookie("ari_vmx_option_2_number", $call_vmx_option_2_number, time()+365*24*60*60); 
    345229        } 
    346          
    347         //If no errors than update the SQL table to keep in sync 
    348         if ($follow_me_update_succeeded) { 
    349           $this->setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm); 
    350         } 
    351    
    352       } //if !follow_me_disabled 
    353     } 
     230      } 
     231    } // vmx_disabled_delayed false 
    354232  } 
    355233 
     
    374252   */ 
    375253  function display($args) { 
    376  
    377   global $STANDALONE; 
    378   global $ARI_ADMIN_USERNAME; 
    379   global $SETTINGS_PRERING_LOW; 
    380   global $SETTINGS_PRERING_HIGH; 
    381   global $SETTINGS_LISTRING_LOW; 
    382   global $SETTINGS_LISTRING_HIGH; 
    383  
    384254  global $SETTINGS_ALLOW_VMX_SETTINGS; 
    385255 
     
    395265  $exten      = $_SESSION['ari_user']['extension']; 
    396266 
    397   $language = new Language(); 
    398267  $display = new DisplaySearch(); 
    399268 
    400   // build controls 
    401   if ($exten!=$ARI_ADMIN_USERNAME) { 
    402  
    403     // call forward settings 
    404     if (!$STANDALONE['use']) { 
    405  
    406     $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 
    407  
    408         //TODO: Set this better than this? 
    409         $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 
    410     setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 
    411  
    412  
    413         $vmx_unavail_enabled=$this->getVmxState($exten,'unavail'); 
    414         if ($vmx_unavail_enabled === false) { 
    415           $vmx_disabled = true; 
    416       setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 
    417       $SETTINGS_ALLOW_VMX_SETTINGS=false; 
    418         } else { 
    419           $vmx_disabled = false; 
    420       setcookie("ari_vmx_disabled", false, time()+365*24*60*60); 
    421           $vmx_busy_enabled=$this->getVmxState($exten,'busy'); 
    422           $vmx_play_instructions=$this->getVmxPlayInstructions($exten); 
    423           $vmx_option_0_number=$this->getVmxOptionNumber($exten,'0');; 
    424           $vmx_option_1_number=$this->getVmxOptionNumber($exten,'1');; 
    425           $vmx_option_2_number=$this->getVmxOptionNumber($exten,'2');; 
    426  
    427           if (is_numeric($vmx_option_0_number)) { 
    428             $vmx_option_0_system_default=''; 
    429             $vmx_option_0_number_text_box_options=''; 
    430           } else { 
    431             $vmx_option_0_system_default='checked'; 
    432             $vmx_option_0_number_text_box_options="disabled style='background: #DDD;'"; 
    433           } 
    434  
    435           // if follow-me is enabled then the options are a numberic value (dial a phone number) 
    436           // or a followme target (FMnnn) which should not be displayed but means the box is checked 
    437           // or otherwise blank (or garbage in which case blank it) 
    438           // 
    439       if (!$follow_me_disabled) { 
    440             $vmx_option_1_system_default=$this->getVmxOptionFollowMe($exten,'1'); 
    441             if ($vmx_option_1_system_default) { 
    442               $vmx_option_1_number = ''; 
    443               $vmx_option_1_number_text_box_options="disabled style='background: #DDD;'"; 
    444             } 
    445           } 
    446         } 
    447     $set_vmx_text .= (!$SETTINGS_ALLOW_VMX_SETTINGS)?'':" 
     269  $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 
     270 
     271  //TODO: Set this better than this? 
     272  $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 
     273  setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 
     274 
     275 
     276  $vmx_unavail_enabled=$this->getVmxState($exten,'unavail'); 
     277  if ($vmx_unavail_enabled === false) { 
     278    $vmx_disabled = true; 
     279    setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 
     280    $SETTINGS_ALLOW_VMX_SETTINGS=false; 
     281  } else { 
     282    $vmx_disabled = false; 
     283    setcookie("ari_vmx_disabled", false, time()+365*24*60*60); 
     284    $vmx_busy_enabled=$this->getVmxState($exten,'busy'); 
     285    $vmx_play_instructions=$this->getVmxPlayInstructions($exten); 
     286    $vmx_option_0_number=$this->getVmxOptionNumber($exten,'0');; 
     287    $vmx_option_1_number=$this->getVmxOptionNumber($exten,'1');; 
     288    $vmx_option_2_number=$this->getVmxOptionNumber($exten,'2');; 
     289     
     290    if (is_numeric($vmx_option_0_number)) { 
     291      $vmx_option_0_system_default=''; 
     292      $vmx_option_0_number_text_box_options=''; 
     293    } else { 
     294      $vmx_option_0_system_default='checked'; 
     295      $vmx_option_0_number_text_box_options="disabled style='background: #DDD;'"; 
     296    } 
     297     
     298    // if follow-me is enabled then the options are a numberic value (dial a phone number) 
     299    // or a followme target (FMnnn) which should not be displayed but means the box is checked 
     300    // or otherwise blank (or garbage in which case blank it) 
     301    // 
     302    if (!$follow_me_disabled) { 
     303      $vmx_option_1_system_default=$this->getVmxOptionFollowMe($exten,'1'); 
     304      if ($vmx_option_1_system_default) { 
     305        $vmx_option_1_number = ''; 
     306        $vmx_option_1_number_text_box_options="disabled style='background: #DDD;'"; 
     307      } 
     308    } 
     309  } 
     310     
     311  $set_vmx_text .=  
     312    " 
     313    <br> 
    448314    <table class='settings'> 
    449     <tr> 
    450         <td><h3>" . _("Voicemail VmX Locator&#8482;") . "</h3></td> 
    451     </tr> 
    452     <tr> 
     315      <tr> 
    453316        <td><a href='#' class='info'>" . _("Use When:") . "<span>" . _("Menu options below are available during your personal voicemail greeting playback. <br/><br/>Check both to use at all times.") . "<br></span></a></td> <td> 
    454317          <input " . $vmx_unavail_enabled . " type=checkbox name='vmx_unavail_enabled' value='checked'> 
     
    460323        </td> 
    461324      </tr> 
    462     <tr> 
     325    <tr> 
    463326        <td><a href='#' class='info'>" . _("Voicemail Instructions:") ."<span>" . _("Uncheck to play a beep after your personal voicemail greeting.") . "<br></span></a></td> 
    464327        <td> 
     
    468331      </tr> 
    469332    </table> 
     333    <br> 
     334    <br> 
    470335    <table class='settings'> 
    471336      <tr> 
    472         <td>&nbsp;</td> 
    473337        <td><a href='#' class='info'>" . _("Press 0:") . "<span>" . _("Pressing 0 during your personal voicemail greeing goes to the Operator.  
    474 Uncheck to enter another destination here.") . "<br></span></a></td> 
     338          Uncheck to enter another destination here.") . "<br></span></a> 
     339        </td> 
    475340        <td> 
    476341          <input " . $vmx_option_0_number_text_box_options . " name='vmx_option_0_number' type='text' size=24 value='" . $vmx_option_0_number . "'> 
    477342        </td> 
    478343        <td> 
    479             <input " . $vmx_option_0_system_default . " type=checkbox name='vmx_option_0_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 
    480             <small>" . _("Go To Operator") . "</small> 
    481           </td> 
    482         </tr> 
    483         "; 
    484  
    485     $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled))?'':" 
    486         <tr> 
    487           <td>&nbsp;</td> 
    488           <td><a href='#' class='info'>" . _("Press 1:") . "<span>" . _("Enter an alternate number here, then change your personal voicemail greeting to let callers know to press 1 to reach that number. <br/><br/>If you'd like to use your Follow Me List, check \"Send to Follow Me\" and disable Follow Me above.") . "<br></span></a></td> 
    489           <td> 
    490             <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 
    491           </td> 
    492           <td> 
    493             <input " . $vmx_option_1_system_default . " type=checkbox name='vmx_option_1_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 
    494             <small>" . _("Send to Follow-Me") . "</small> 
    495           </td> 
    496         </tr> 
    497         <tr> 
    498           <td>&nbsp;</td> 
    499           <td><a href='#' class='info'>" . _("Press 2:") . "<span>" . _("Use any extensions, ringgroups, queues or external numbers. <br/><br/>Remember to re-record your personal voicemail greeting and include instructions. Run a test to make sure that the number is functional.") . "<br></span></a></td> 
    500           <td> 
    501             <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 
    502           </td> 
    503         </tr> 
    504       </table> 
    505       "; 
    506  
    507     $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && $follow_me_disabled))?'':" 
    508         <tr> 
    509           <td><a href='#' class='info'>" . _("Option 1:") . "<span>" . _("The remaining options can have internal extensions, ringgroups, queues and external numbers that may be rung. It is often used to include your cell phone. You should run a test to make sure that the number is functional any time a change is made so you don't leave a caller stranded or receiving invalid number messages.") . "<br></span></a></td> 
    510           <td> 
    511             <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 
    512           </td> 
    513         </tr> 
    514         <tr> 
    515           <td>" . _("Option 2:") . "</td> 
    516           <td> 
    517             <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 
    518           </td> 
    519         </tr> 
    520       </table> 
    521       "; 
    522  
    523  
    524         } 
    525  
    526       } 
    527  
    528       // javascript enable options 
    529       if (isset($_SESSION['ari_user']['voicemail_email']) && 
    530             in_array('voicemail',array_keys($loaded_modules))) { 
    531         foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
    532           $var = "voicemail_email_$key"; 
    533           $js_voicemail_email_disable .= " 
    534             document.ari_settings.$var.disabled = false;"; 
    535           $js_voicemail_email_enable .= " 
    536             document.ari_settings.$var.disabled = true;"; 
    537         } 
    538  
    539         $js_voicemail_script = ""; 
    540       } 
    541  
    542       // build page content 
    543       $ret .= checkErrorMessage(); 
    544  
    545       if ($_SESSION['ari_user']['admin_settings']) { 
    546         $headerText = _("VmX Locator&#8482; Settings"); 
    547       } else { 
    548         $headerText = sprintf(_("VmX Locator&#8482; Settings for %s (%s)"),$displayname,$exten); 
    549       } 
    550  
    551       $ret .= $display->displayHeaderText($headerText); 
    552       $ret .= $display->displayLine(); 
    553  
    554       $ret .= " 
    555         <SCRIPT LANGUAGE='JavaScript'> 
    556         <!-- Begin 
    557     function rowCounter(field, maxlimit) { 
    558       temp = field.value.split('\u000A',maxlimit+1) 
    559       field.value = temp.join('\u000A') 
    560       if (temp.length == maxlimit+1) { 
    561         field.value = field.value.substring(0, field.value.length-1) 
    562       } 
    563     } 
    564  
    565           function disable_fields() {"; 
    566       if ($SETTINGS_ALLOW_VMX_SETTINGS) { 
    567         $ret .= " 
    568             if (document.ari_settings.vmx_option_0_system_default.checked) { 
    569               document.ari_settings.vmx_option_0_number.style.backgroundColor = '#DDD'; 
    570               document.ari_settings.vmx_option_0_number.disabled = true; 
    571             }  
    572             else { 
    573               document.ari_settings.vmx_option_0_number.style.backgroundColor = '#FFF'; 
    574               document.ari_settings.vmx_option_0_number.disabled = false; 
    575             }"; 
    576         } 
    577       if ($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled) { 
    578         $ret .= " 
    579             if (document.ari_settings.vmx_option_1_system_default.checked) { 
    580               document.ari_settings.vmx_option_1_number.style.backgroundColor = '#DDD'; 
    581               document.ari_settings.vmx_option_1_number.disabled = true; 
    582             }  
    583             else { 
    584               document.ari_settings.vmx_option_1_number.style.backgroundColor = '#FFF'; 
    585               document.ari_settings.vmx_option_1_number.disabled = false; 
    586             }"; 
    587         } 
    588         $ret .= $js_voicemail_script . " 
    589     } 
    590     // End --> 
    591     </script>"; 
    592  
    593   $ret .= " 
    594     " . $setLangText . " 
    595     <form class='settings' name='ari_settings' action='' method='GET'> 
    596     <input type=hidden name=m value=" . $m . "> 
    597     <input type=hidden name=f value='action'> 
    598     <input type=hidden name=a value='update'> 
    599     " . $set_vmx_text . " 
     344          <input " . $vmx_option_0_system_default . " type=checkbox name='vmx_option_0_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 
     345          <small>" . _("Go To Operator") . "</small> 
     346        </td> 
     347      </tr> 
     348      <tr> 
     349        <td><a href='#' class='info'>" . _("Press 1:") . "<span>"; 
     350       
     351  if ($follow_me_disabled) 
     352    $set_vmx_text .= _("The remaining options can have internal extensions, ringgroups, queues and external numbers that may be rung. It is often used to include your cell phone. You should run a test to make sure that the number is functional any time a change is made so you don't leave a caller stranded or receiving invalid number messages."); 
     353  else 
     354    $set_vmx_text .= _("Enter an alternate number here, then change your personal voicemail greeting to let callers know to press 1 to reach that number. <br/><br/>If you'd like to use your Follow Me List, check \"Send to Follow Me\" and disable Follow Me above."); 
     355   
     356   
     357  $set_vmx_text .=   
     358    "     <br></span></a> 
     359        </td> 
     360        <td> 
     361          <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 
     362        </td> 
     363        <td>"; 
     364         
     365         
     366  if (!$follow_me_disabled) 
     367    $set_vmx_text .=  "<input " . $vmx_option_1_system_default . " type=checkbox name='vmx_option_1_system_default' value='checked' OnClick=\"disable_fields(); return true;\"><small>" . _("Send to Follow-Me") . "</small>"; 
     368           
     369           
     370  $set_vmx_text .=   
     371        "  
     372        </td> 
     373      </tr> 
     374      <tr> 
     375        <td><a href='#' class='info'>" . _("Press 2:") . "<span>" . _("Use any extensions, ringgroups, queues or external numbers. <br/><br/>Remember to re-record your personal voicemail greeting and include instructions. Run a test to make sure that the number is functional.") . "<br></span></a></td> 
     376        <td> 
     377          <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 
     378        </td> 
     379      </tr> 
     380    </table> 
    600381    <br> 
    601     <input name='submit' type='submit' value='" . _("Update") . "'> 
    602     </form>"; 
     382    <br>     
     383    "; 
     384 
     385 
     386  // Now we should be ready to build the page 
     387  $ret .= checkErrorMessage(); 
     388 
     389  $headerText = sprintf(_("VmX Locator&#8482; Settings for %s (%s)"),$displayname,$exten); 
     390 
     391  $ret .= $display->displayHeaderText($headerText); 
     392  $ret .= $display->displayLine(); 
     393 
     394  $ret .=  
     395    "<SCRIPT LANGUAGE='JavaScript'> 
     396      <!-- Begin 
     397        function disable_fields() { 
     398         
     399          if (document.ari_settings.vmx_option_0_system_default.checked) { 
     400            document.ari_settings.vmx_option_0_number.style.backgroundColor = '#DDD'; 
     401            document.ari_settings.vmx_option_0_number.disabled = true; 
     402          }  
     403          else { 
     404            document.ari_settings.vmx_option_0_number.style.backgroundColor = '#FFF'; 
     405            document.ari_settings.vmx_option_0_number.disabled = false; 
     406          }"; 
     407           
     408          if (!$follow_me_disabled) { 
     409            $ret .= " 
     410              if (document.ari_settings.vmx_option_1_system_default.checked) { 
     411                document.ari_settings.vmx_option_1_number.style.backgroundColor = '#DDD'; 
     412                document.ari_settings.vmx_option_1_number.disabled = true; 
     413              }  
     414              else { 
     415                document.ari_settings.vmx_option_1_number.style.backgroundColor = '#FFF'; 
     416                document.ari_settings.vmx_option_1_number.disabled = false; 
     417              }"; 
     418          } 
     419          $ret .=   
     420        "} 
     421      // End --> 
     422    </script>"; 
     423 
     424  $ret .=  
     425    "<form class='settings' name='ari_settings' action='' method='GET'> 
     426      <input type=hidden name=m value=" . $m . "> 
     427      <input type=hidden name=f value='action'> 
     428      <input type=hidden name=a value='update'> 
     429      " . $set_vmx_text . " 
     430      <br> 
     431      <input name='submit' type='submit' value='" . _("Update") . "'> 
     432    </form>"; 
    603433 
    604434  return $ret; 
     
    814644  } 
    815645 
    816   /* 
    817    * Sets Follow Me Pre-Ring Time 
    818    * 
    819    * @param $exten 
    820    *   Extension to modify 
    821    * @param $follow_me_prering_time 
    822    *   Pre-Ring Time to ring 
    823    */ 
    824  
    825  
    826646 
    827647  /* 
     
    852672  } 
    853673 
    854   /* 
    855    * Sets Follow-Me Settings in FreePBX MySQL Database 
    856    * 
    857    * @param $exten 
    858    *   Extension to modify 
    859    * @param $follow_me_prering_time 
    860    *   Pre-Ring Time to ring 
    861    * @param $follow_me_listring_time 
    862    *   List Ring Time to ring 
    863    * @param $follow_me_list 
    864    *   Follow Me List 
    865    * @param $follow_me_list 
    866    *   Follow Me Confirm Setting 
    867    * 
    868    */ 
    869   function setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm) { 
    870  
    871   if (isset($_SESSION['dbh_asterisk'])) { 
    872  
    873     //format for SQL database 
    874     $follow_me_confirm = ($follow_me_confirm)?'CHECKED':''; 
    875  
    876     $sql = "UPDATE findmefollow SET grptime = '" . $follow_me_listring_time . "', grplist = '". 
    877        str_replace("'", "''", trim($follow_me_list)) . "', pre_ring = '" . $follow_me_prering_time . 
    878        "', needsconf = '" . $follow_me_confirm . "' WHERE grpnum = $exten LIMIT 1"; 
    879     $results = $_SESSION['dbh_asterisk']->query($sql); 
    880  
    881     if(DB::IsError($results)) { 
    882     $_SESSION['ari_error'] = $results->getMessage(); 
    883     } 
    884  
    885     return 1; 
    886   } 
    887   } 
    888  
    889   function lookupSetExtensionFormat($exten) { 
    890  
    891   if (trim($exten) == "") return $exten; 
    892  
    893   $exten = preg_replace("/[^0-9*]/", "", $exten); 
    894  
    895   $sql = "SELECT extension FROM users WHERE extension = '".$exten."'"; 
    896   $asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC); 
    897   if (!is_array($asa)) {  
    898     return $exten.'#'; 
    899   } else { 
    900     return $exten; 
    901   } 
    902   } 
    903  
    904674 
    905675} // class 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/callmonitor.module

    r4328 r4425  
    3434  function navMenu($args) { 
    3535 
    36     $ret .= " 
    37       <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small></p><br>"; 
     36    $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small></p><br>"; 
    3837 
    3938    return $ret; 
     
    8685        </script> 
    8786      </head>"; 
    88        
    89      echo $ret; 
    9087 
    9188    return $ret; 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/featurecodes.module

    r4328 r4425  
    3434  function navMenu($args) { 
    3535 
    36     // put if statement in return string, because do not know $logout until page is built 
    37     $ret .= " 
    38       <?php if ($logout !='') { ?> 
    39         <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=featurecodes&f=display'>" . _("Feature Codes") . "</a></small></small></p><br> 
    40       <?php } ?>"; 
     36    $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=featurecodes&f=display'>" . _("Feature Codes") . "</a></small></small></p><br>"; 
    4137 
    4238    return $ret; 
     
    6561    $ret .= checkErrorMessage(); 
    6662 
    67     if ($_SESSION['ari_user']['admin_help']) { 
    68       $header_text = _("Feature Codes"); 
    69     } else { 
    70       $header_text = sprintf(_("Feature Codes for %s (%s)"),$displayname,$extension); 
    71     } 
     63  $header_text = _("Feature Codes"); 
     64  if (!$_SESSION['ari_user']['admin_help']) { 
     65    $header_text .= sprintf(_(" for %s (%s)"), $displayname, $extension); 
     66  } 
    7267 
    7368    // handset feature code header 
     
    10297             "; 
    10398 
    104       $results = $_SESSION['dbh_asterisk']->getAll($sql, DB_FETCHMODE_ASSOC); 
    105       if(DB::IsError($results)) { 
    106         $_SESSION['ari_error'] = $results->getMessage(); 
    107       } 
    108       else { 
    109         foreach ($results as $item ) { 
    110  
    111         $handset_feature_codes_body .=  
    112           "<tr> 
    113              <td class='feature_codes'> 
    114                " . $item['keycode'] . " 
    115              </td> 
    116              <td> 
    117                " . $item['description'] . " 
    118              </td> 
    119            </tr>"; 
    120         } 
    121       } 
     99    $results = $_SESSION['dbh_asterisk']->getAll($sql, DB_FETCHMODE_ASSOC); 
     100    if(DB::IsError($results)) { 
     101      $_SESSION['ari_error'] = $results->getMessage(); 
     102    } 
     103    else { 
     104      foreach ($results as $item ) { 
     105        $handset_feature_codes_body .=  
     106          "<tr> 
     107          <td class='feature_codes'> 
     108          " . $item['keycode'] . " 
     109          </td> 
     110          <td> 
     111          " . $item['description'] . " 
     112          </td> 
     113          </tr>"; 
     114      } 
     115    } 
    122116    } 
    123117    else { 
     
    156150} 
    157151 
    158  
    159152?> 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/followme.module

    r4328 r4425  
    3737   */ 
    3838  function navMenu($args) { 
    39  
    40     $ret .= " 
    41     <p> 
    42       <small> 
    43         <small> 
    44           <a href='"  
    45             . $_SESSION['ARI_ROOT'] . "?m=followme&f=display'>" . _("Follow Me") .  
    46           "</a> 
    47         </small> 
    48       </small> 
    49     </p>"; 
     39  global $ARI_ADMIN_USERNAME; 
     40   
     41  $exten = $_SESSION['ari_user']['extension']; 
     42  if ($exten!=$ARI_ADMIN_USERNAME) { 
     43    $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=followme&f=display'>" . _("Follow Me") . "</a></small></small></p>"; 
     44  } 
    5045 
    5146  return $ret; 
     
    276271      if (!$STANDALONE['use']) { 
    277272         
    278         $follow_me_prering_time = $this->getFollowMePreRingTime($exten); 
    279         $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 
    280         $follow_me_list =  explode("-", $this->getFollowMeList($exten) ); 
    281         $follow_me_confirm = $this->getFollowMeConfirm($exten); 
    282         $follow_me_ddial = $this->getFollowMeDDial($exten); 
     273        $follow_me_prering_time = $this->getFollowMePreRingTime($exten); 
     274        $follow_me_listring_time   = $this->getFollowMeListRingTime($exten); 
     275        $follow_me_list      =  explode("-", $this->getFollowMeList($exten) ); 
     276        $follow_me_confirm       = $this->getFollowMeConfirm($exten); 
     277        $follow_me_ddial       = $this->getFollowMeDDial($exten); 
    283278         
    284279        $FOLLOW_ME_LIST_MAX = (count($follow_me_list) > $SETTINGS_FOLLOW_ME_LIST_MAX) ? count($follow_me_list):$SETTINGS_FOLLOW_ME_LIST_MAX; 
     
    287282        $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 
    288283        setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 
    289                 
     284         
    290285        $followme_text.= "<table class='settings'>"; 
    291286         
    292287        if (!$follow_me_disabled) { 
    293           $followme_text .= "<tr><td><h3><br>" . _("Follow Me") . "</h3></td></tr>"; 
     288          // $followme_text .= "<tr><td><h3><br>" . _("Follow Me") . "</h3></td></tr>"; 
     289          $followme_text .= "<tr><td>&nbsp;</td></tr>"; // Blank Line 
     290           
    294291          $followme_text .= "<tr><td><a href='#' class='info'>" . _("Enable") . "<span>"; 
    295292          $followme_text .= _(  "Dial-by-name Directory, IVR, and internal  
     
    302299          $followme_text .= "<td><input " . $follow_me_ddial . " type=checkbox name='follow_me_ddial' value='checked'>"; 
    303300          $followme_text .= "<small>" . _("") . "</small></td></tr>"; 
     301             
     302 
     303          $followme_text .= "<tr><td>&nbsp;</td></tr>"; // Blank Line                    
     304          $followme_text .= "<tr><td valign='top'><a href='#' class='info'>" . _("Follow Me List:"); 
     305          $followme_text .= "<span>" . sprintf(_("Extensions and outside numbers to ring next.")) ."<br/><br/>"; 
     306          $followme_text .= sprintf(_("Include %s to keep it ringing."),"<strong>".$exten."</strong>") . "<br></span></a></td>"; 
     307          $followme_text .= "<td><textarea " . $follow_me_list_options . " id='follow_me_list' name='follow_me_list' type='text' cols='20' rows='".$FOLLOW_ME_LIST_MAX."' value='' onKeyUp='rowCounter(this.form.follow_me_list, ".$FOLLOW_ME_LIST_MAX.");' onKeyDown='rowCounter(this.form.follow_me_list, ".$FOLLOW_ME_LIST_MAX.");'>".implode("\n",$follow_me_list)."</textarea>"; 
     308          $followme_text .= "</td></tr>"; 
     309           
     310          $followme_text .= "<tr><td>&nbsp;</td></tr>"; // Blank Line                              
    304311          $followme_text .= "<tr><td><a href='#' class='info'>"; 
    305312          $followme_text .= sprintf(_("Ring %s First For:"), $exten); 
     
    315322         
    316323          $followme_text .= "<small>" . _("seconds") . "</small>"; 
    317           $followme_text .= "</td>"; 
    318            
    319           $followme_text .= "<tr><td valign='top'><a href='#' class='info'>" . _("Follow Me List:"); 
    320           $followme_text .= "<span>" . sprintf(_("Extensions and outside numbers to ring next.")) ."<br/><br/>"; 
    321           $followme_text .= sprintf(_("Include %s to keep it ringing."),"<strong>".$exten."</strong>") . "<br></span></a></td>"; 
    322           $followme_text .= "<td><textarea " . $follow_me_list_options . " id='follow_me_list' name='follow_me_list' type='text' cols='20' rows='".$FOLLOW_ME_LIST_MAX."' value='' onKeyUp='rowCounter(this.form.follow_me_list, ".$FOLLOW_ME_LIST_MAX.");' onKeyDown='rowCounter(this.form.follow_me_list, ".$FOLLOW_ME_LIST_MAX.");'>".implode("\n",$follow_me_list)."</textarea>"; 
    323           $followme_text .= "</td>"; 
    324           $followme_text .= "<tr><td><a href='#' class='info'>" . _("List Ring Time:") . "<span>" . _("Time to ring the Follow Me List.") . "<br></span></a></td>"; 
     324          $followme_text .= "</td></tr>";  
     325           
     326          $followme_text .= "<tr><td><a href='#' class='info'>" . _("Ring Followme List for:") . "<span>" . _("Time to ring the Follow Me List.") . "<br></span></a></td>"; 
    325327          $followme_text .= "<td>"; 
    326328           
     
    332334          $followme_text .= "</select>"; 
    333335         
    334           $followme_text .= "<small>" . _("seconds") . "</small></td>"; 
     336          $followme_text .= "<small>" . _("seconds") . "</small></td></tr>"; 
     337           
     338           
     339          $followme_text .= "<tr><td>&nbsp;</td></tr>"; // Blank Line  
     340           
    335341          $followme_text .= "<tr><td><a href='#' class='info'>" . _("Use Confirmation:") . "<span>". _("Outside lines that are part of the Follow Me List will be called and offered a menu:<br/><br/> \"You have an incoming call. Press 1 to accept or 2 to decline.\"<br/><br/> This keeps calls from ending up in external voicemail. Make sure that the List Ring Time is long enough to allow for you to hear and react to this message."); 
    336342          $followme_text .= "<br></span></a></td><td>"; 
    337343          $followme_text .= "<input " . $follow_me_confirm . " type=checkbox name='follow_me_confirm' value='checked'>"; 
    338344          $followme_text .= "<small>" . _("Enable") . "</small></td></tr>"; 
    339            
    340           $followme_text .= "</tr></table>"; 
     345          $followme_text .= "<tr><td>&nbsp;</td></tr>";  // Blank Line                    
     346          $followme_text .= "</table>"; 
    341347        } 
    342348      } 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/settings.module

    r4328 r4425  
    4949  function navMenu($args) { 
    5050 
    51     global $ARI_NO_LOGIN; 
    52  
    53     // check logout 
    54     if ($_SESSION['ari_user'] && !$ARI_NO_LOGIN) { 
    55       $logout = 1; 
    56     } 
    57  
    58     if ($logout!='') {  
    59       $ret .= " 
    60          
    61         <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p><br>"; 
    62     }  
     51  $ret = ""; 
     52  $exten = $_SESSION['ari_user']['extension']; 
     53   
     54  // and we are not logged in as admin 
     55  if ($exten!=$ARI_ADMIN_USERNAME) { 
     56    $ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p><br>"; 
     57  } 
    6358 
    6459    return $ret; 
     
    7570  function action($args) { 
    7671 
    77     global $STANDALONE; 
    7872    global $ARI_ADMIN_USERNAME; 
    7973    global $ASTERISK_VOICEMAIL_CONF; 
     74    global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; 
    8075    global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 
    8176    global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 
     
    8782    $a = getArgument($args,'a'); 
    8883 
    89     $lang_code = getArgument($args,'lang_code'); 
    90  
    91     $call_forward_enable  = getArgument($args,'call_forward_enable'); 
    92     $call_forward_number  = getArgument($args,'call_forward_number'); 
    93  
    94     $voicemail_password = getArgument($args,'voicemail_password'); 
     84    $voicemail_password     = getArgument($args,'voicemail_password'); 
    9585    $voicemail_password_confirm = getArgument($args,'voicemail_password_confirm'); 
    96     $voicemail_email_address = getArgument($args,'voicemail_email_address'); 
    97     $voicemail_pager_address = getArgument($args,'voicemail_pager_address'); 
    98     $voicemail_email_enable = getArgument($args,'voicemail_email_enable'); 
    99  
     86    $voicemail_email_address  = getArgument($args,'voicemail_email_address'); 
     87    $voicemail_pager_address  = getArgument($args,'voicemail_pager_address'); 
     88    $voicemail_email_enable   = getArgument($args,'voicemail_email_enable'); 
     89    $voicemail_audio_format   = getArgument($args,'voicemail_audio_format'); 
     90    $record_in          = getArgument($args,'record_in'); 
     91    $record_out         = getArgument($args,'record_out'); 
     92     
    10093    if (isset($_SESSION['ari_user']['voicemail_email'])) { 
    10194      foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
     
    10598    } 
    10699 
    107     $voicemail_audio_format = getArgument($args,'voicemail_audio_format'); 
    108  
    109     $record_in = getArgument($args,'record_in'); 
    110     $record_out = getArgument($args,'record_out'); 
    111  
    112     $language = new Language(); 
    113  
    114100    if ($a=='update') { 
    115101 
    116       $exten = $_SESSION['ari_user']['extension']; 
    117       if ($exten!=$ARI_ADMIN_USERNAME) { 
    118  
    119         // update call forward number 
    120         if (!$STANDALONE['use']) { 
    121  
    122           $stripped_call_forward_number = preg_replace('/-|\(|\)|\s/','',$call_forward_number); 
    123           if ($call_forward_enable && !is_numeric($stripped_call_forward_number)) { 
    124             $_SESSION['ari_error'] =  
    125               _("Call forward number not changed") . "<br>" . 
    126               sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_number); 
    127           } 
    128           else { 
    129  
    130             // set database 
    131             $this->setCallForward($exten,$call_forward_enable,$stripped_call_forward_number); 
    132  
    133             // store cookie 
    134             $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 
    135             if ($call_forward_number && $stripped!=$stripped_call_forward_number) { 
    136               setcookie("ari_call_forward_number", $call_forward_number, time()+365*24*60*60); 
    137             } 
    138           } 
    139         } 
    140  
    141         // voicemail settings 
    142         if ($_SESSION['ari_user']['voicemail_enabled']==1) { 
    143  
    144  
    145           // update voicemail password 
    146           if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 
    147  
    148             // update voicemail password 
    149             if ($voicemail_password=='' || $voicemail_password_confirm=='') { 
    150               $_SESSION['ari_error'] =  
    151                 _("Voicemail password not changed") . "<br>" . 
    152                 _("Password and password confirm must not be blank"); 
    153             }   
    154             else if ((strlen($voicemail_password)<$SETTINGS_VOICEMAIL_PASSWORD_LENGTH) || !is_numeric($voicemail_password)) { 
    155               $_SESSION['ari_error'] =  
    156                 _("Voicemail password not changed") . "<br>" . 
    157                 sprintf(_("Passwords must be all numbers and greater than %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
    158             } 
    159             else if (strlen($voicemail_password)!=$SETTINGS_VOICEMAIL_PASSWORD_LENGTH && $SETTINGS_VOICEMAIL_PASSWORD_EXACT || !is_numeric($voicemail_password)) { 
    160               $_SESSION['ari_error'] =  
    161                 _("Voicemail password not changed") . "<br>" . 
    162                 sprintf(_("Passwords must be all numbers and only %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
    163             } 
    164             else if ($voicemail_password!=$voicemail_password_confirm) { 
    165               $_SESSION['ari_error'] =  
    166                 _("Voicemail password not changed") . "<br>" . 
    167                 _("Password and password confirm do not match"); 
    168             } 
    169             else { 
    170  
    171               // check for writable the files 
    172               $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 
    173               $fp = fopen($temp_file, "w"); 
    174               if (!$fp) { 
    175                 $_SESSION['ari_error'] =  
    176                   _("Voicemail password not changed") . "<br>" . 
    177                   sprintf(_("%s does not exist or is not writable"),$temp_file); 
    178               } 
    179               else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 
    180                 $_SESSION['ari_error'] =  
    181                   _("Voicemail password not changed") . "<br>" . 
    182                   sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 
    183               } 
    184               else { 
    185  
    186                 // update session 
    187                 $_SESSION['ari_user']['voicemail_password'] = $voicemail_password; 
    188  
    189                 // save password 
    190                 $lines = file($ASTERISK_VOICEMAIL_CONF); 
    191                 foreach ($lines as $key => $line) { 
    192                   unset($value); 
    193                   list($var,$value) = split('=>',$line); 
    194                   $var = trim($var); 
    195                   if ($var==$exten && $value) { 
    196  
    197                     // write out line with password change 
    198                     $buf = split(',',$value); 
    199                     $buf[0] = $voicemail_password; 
    200                     $line = $var . " => " . join(',', $buf); 
    201  
    202                     fwrite($fp, $line); 
    203                   } 
    204                   else { 
    205  
    206                     // write out original line with no changes 
    207                     fwrite($fp, $line); 
    208                   } 
    209                 } 
    210                 fclose($fp); 
    211                 unlink($ASTERISK_VOICEMAIL_CONF); 
    212                 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 
    213   
    214                 $voicemail_reload = 1; 
    215               } 
    216             } 
    217  
    218             // voicemail email address 
    219             if ($voicemail_email_enable &&  
    220                  ($voicemail_email_address && !preg_match('/@/',$voicemail_email_address) ||  
    221                  ($voicemail_pager_address && !preg_match('/@/',$voicemail_pager_address)))) { 
    222               $_SESSION['ari_error'] =  
    223                 _("Voicemail email and pager address not changed") . "<br>" . 
    224                 ("'$voicemail_email_address' and '$voicemail_pager_address' must be a valid email addresses"); 
    225             } 
    226             else { 
    227  
    228               // check for writable the files 
    229               $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 
    230               $fp = fopen($temp_file, "w"); 
    231               if (!$fp) { 
    232                 $_SESSION['ari_error'] =  
    233                   _("Voicemail email settings not changed") . "<br>" . 
    234                   sprintf(_("%s does not exist or is not writable"),$temp_file); 
    235               } 
    236               else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 
    237                 $_SESSION['ari_error'] =  
    238                   _("Voicemail email settings not changed") . "<br>" . 
    239                   sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 
    240               } 
    241               else { 
    242  
    243                 // store cookie 
    244                 if ($voicemail_email_enable) { 
    245                   setcookie("ari_voicemail_email_address", $voicemail_email_address, time()+365*24*60*60); 
    246                   setcookie("ari_voicemail_pager_address", $voicemail_pager_address, time()+365*24*60*60); 
    247                   foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
    248                     $var = "voicemail_email_$key"; 
    249                     $var_cookie = "ari_" . $var; 
    250                     setcookie("$var_cookie", $$var, time()+365*24*60*60); 
    251                   } 
    252                 } 
    253          
    254                 // update session 
    255                 $_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable; 
    256                 if ($voicemail_email_enable) { 
    257                   $_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address; 
    258                   $_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address; 
    259                   foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
    260                     $option = "voicemail_email_$key"; 
    261                     $_SESSION['ari_user']['voicemail_email'][$key] = $$option; 
    262                   } 
    263                 } 
    264  
    265                 // save settings 
    266                 if (!$voicemail_email_enable) { 
    267                   $voicemail_email_address = ''; 
    268                   $voicemail_pager_address = ''; 
    269                 } 
    270  
    271                 $lines = file($ASTERISK_VOICEMAIL_CONF); 
    272                 foreach ($lines as $key => $line) { 
    273                   unset($value); 
    274                   list($var,$value) = split('=>',$line); 
    275                   $var = trim($var); 
    276                   if ($var==$exten && $value) { 
    277  
    278                     // write out line with voicemail email change 
    279                     $buf = split(',',$value); 
    280                     $buf[2] = $voicemail_email_address; 
    281                     $buf[3] = $voicemail_pager_address; 
    282  
    283                     foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
    284                       $option = "voicemail_email_$key"; 
    285                       if ($$option && $key) { 
    286                         $options .= $key . "=" . $value; 
    287                       } 
    288                       else { 
    289                         $options .= $key . "=no"; 
    290                       } 
    291                       $options .= "|"; 
    292                     } 
    293                     $buf[4] = substr($options, 0, -1); 
    294  
    295                     $line = $var . " =>" . join(',', $buf); 
    296                     if (substr($line, 0, -1)!="\n") { 
    297                       $line .= "\n"; 
    298                     } 
    299   
    300                     fwrite($fp, $line); 
    301                   } 
    302                   else { 
    303  
    304                     // write out original line with no changes 
    305                     fwrite($fp, $line); 
    306                   } 
    307                 } 
    308                 fclose($fp); 
    309                 unlink($ASTERISK_VOICEMAIL_CONF); 
    310                 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 
    311  
    312                 $voicemail_reload = 1; 
    313               } 
    314             } 
    315  
    316             // reload asterisk voicemail 
    317             if ($voicemail_reload) { 
    318               $this->reloadAsteriskVoicemail(); 
    319             } 
    320           } 
    321  
    322           // update voicemail audio format setting 
    323           setcookie("ari_voicemail_audio_format", $voicemail_audio_format, time()+365*24*60*60); 
    324         } 
    325  
    326         // update call monitor record setting 
    327         if ($SETTINGS_ALLOW_CALL_RECORDING_SET) { 
    328           if ($record_in && $record_out) { 
    329             $this->setRecordSettings($exten,$record_in,$record_out); 
    330           } 
    331         } 
    332       } 
     102    $exten = $_SESSION['ari_user']['extension']; 
     103    if ($exten!=$ARI_ADMIN_USERNAME) { 
     104       
     105      // Make sure Follow-Me setup has not been deleted for this user since the last refresh 
     106      $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 
     107       
     108      // voicemail settings 
     109      if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1) { 
     110         
     111         
     112        // update voicemail password 
     113        if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 
     114           
     115          // update voicemail password 
     116          if ($voicemail_password=='' || $voicemail_password_confirm=='') { 
     117            $_SESSION['ari_error'] =  
     118            _("Voicemail password not changed") . "<br>" . 
     119            _("Password and password confirm must not be blank"); 
     120          }   
     121          else if ((strlen($voicemail_password)<$SETTINGS_VOICEMAIL_PASSWORD_LENGTH) || !is_numeric($voicemail_password)) { 
     122            $_SESSION['ari_error'] =  
     123            _("Voicemail password not changed") . "<br>" . 
     124            sprintf(_("Passwords must be all numbers and greater than %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
     125          } 
     126          else if (strlen($voicemail_password)!=$SETTINGS_VOICEMAIL_PASSWORD_LENGTH && $SETTINGS_VOICEMAIL_PASSWORD_EXACT || !is_numeric($voicemail_password)) { 
     127            $_SESSION['ari_error'] =  
     128            _("Voicemail password not changed") . "<br>" . 
     129            sprintf(_("Passwords must be all numbers and only %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
     130          } 
     131          else if ($voicemail_password!=$voicemail_password_confirm) { 
     132            $_SESSION['ari_error'] =  
     133            _("Voicemail password not changed") . "<br>" . 
     134            _("Password and password confirm do not match"); 
     135          } 
     136          else { 
     137           
     138            // check for writable the files 
     139            $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 
     140            $fp = fopen($temp_file, "w"); 
     141            if (!$fp) { 
     142              $_SESSION['ari_error'] =  
     143              _("Voicemail password not changed") . "<br>" . 
     144              sprintf(_("%s does not exist or is not writable"),$temp_file); 
     145            } 
     146            else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 
     147              $_SESSION['ari_error'] =  
     148              _("Voicemail password not changed") . "<br>" . 
     149              sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 
     150            } 
     151            else { 
     152               
     153              // update session 
     154              $_SESSION['ari_user']['voicemail_password'] = $voicemail_password; 
     155               
     156              // save password 
     157              $lines = file($ASTERISK_VOICEMAIL_CONF); 
     158              foreach ($lines as $key => $line) { 
     159                unset($value); 
     160                list($var,$value) = split('=>',$line); 
     161                $var = trim($var); 
     162                if ($var==$exten && $value) { 
     163                 
     164                  // write out line with password change 
     165                  $buf = split(',',$value); 
     166                  $buf[0] = $voicemail_password; 
     167                  $line = $var . " => " . join(',', $buf); 
     168                   
     169                  fwrite($fp, $line); 
     170                } 
     171                else { 
     172                  // write out original line with no changes 
     173                  fwrite($fp, $line); 
     174                } 
     175              } 
     176              fclose($fp); 
     177              unlink($ASTERISK_VOICEMAIL_CONF); 
     178              rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 
     179               
     180              $voicemail_reload = 1; 
     181            } 
     182          } 
     183           
     184          // voicemail email address 
     185          if ($voicemail_email_enable &&  
     186          ($voicemail_email_address && !preg_match('/@/',$voicemail_email_address) ||  
     187          ($voicemail_pager_address && !preg_match('/@/',$voicemail_pager_address)))) { 
     188            $_SESSION['ari_error'] =  
     189            _("Voicemail email and pager address not changed") . "<br>" . 
     190            ("'$voicemail_email_address' and '$voicemail_pager_address' must be a valid email addresses"); 
     191          } 
     192          else { 
     193           
     194            // check for writable the files 
     195            $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 
     196            $fp = fopen($temp_file, "w"); 
     197            if (!$fp) { 
     198              $_SESSION['ari_error'] =  
     199              _("Voicemail email settings not changed") . "<br>" . 
     200              sprintf(_("%s does not exist or is not writable"),$temp_file); 
     201            } 
     202            else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 
     203              $_SESSION['ari_error'] =  
     204              _("Voicemail email settings not changed") . "<br>" . 
     205              sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 
     206            } 
     207            else { 
     208               
     209              // store cookie 
     210              if ($voicemail_email_enable) { 
     211                setcookie("ari_voicemail_email_address", $voicemail_email_address, time()+365*24*60*60); 
     212                setcookie("ari_voicemail_pager_address", $voicemail_pager_address, time()+365*24*60*60); 
     213                foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
     214                  $var = "voicemail_email_$key"; 
     215                  $var_cookie = "ari_" . $var; 
     216                  setcookie("$var_cookie", $$var, time()+365*24*60*60); 
     217                } 
     218              } 
     219               
     220              // update session 
     221              $_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable; 
     222              if ($voicemail_email_enable) { 
     223                $_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address; 
     224                $_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address; 
     225                foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
     226                  $option = "voicemail_email_$key"; 
     227                  $_SESSION['ari_user']['voicemail_email'][$key] = $$option; 
     228                } 
     229              } 
     230               
     231              // save settings 
     232              if (!$voicemail_email_enable) { 
     233                $voicemail_email_address = ''; 
     234                $voicemail_pager_address = ''; 
     235              } 
     236               
     237              $lines = file($ASTERISK_VOICEMAIL_CONF); 
     238              foreach ($lines as $key => $line) { 
     239                unset($value); 
     240                list($var,$value) = split('=>',$line); 
     241                $var = trim($var); 
     242                if ($var==$exten && $value) { 
     243                 
     244                  // write out line with voicemail email change 
     245                  $buf = split(',',$value); 
     246                  $buf[2] = $voicemail_email_address; 
     247                  $buf[3] = $voicemail_pager_address; 
     248                   
     249                  foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
     250                    $option = "voicemail_email_$key"; 
     251                    if ($$option && $key) { 
     252                      $options .= $key . "=" . $value; 
     253                    } 
     254                    else { 
     255                      $options .= $key . "=no"; 
     256                    } 
     257                    $options .= "|"; 
     258                  } 
     259                  $buf[4] = substr($options, 0, -1); 
     260                   
     261                  $line = $var . " =>" . join(',', $buf); 
     262                  if (substr($line, 0, -1)!="\n") { 
     263                    $line .= "\n"; 
     264                  } 
     265                   
     266                  fwrite($fp, $line); 
     267                } 
     268                else { 
     269                 
     270                // write out original line with no changes 
     271                fwrite($fp, $line); 
     272                } 
     273              } 
     274              fclose($fp); 
     275              unlink($ASTERISK_VOICEMAIL_CONF); 
     276              rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 
     277               
     278              $voicemail_reload = 1; 
     279            } 
     280          } 
     281           
     282          // reload asterisk voicemail 
     283          if ($voicemail_reload) { 
     284          $this->reloadAsteriskVoicemail(); 
     285          } 
     286        } 
     287         
     288        // update voicemail audio format setting 
     289        setcookie("ari_voicemail_audio_format", $voicemail_audio_format, time()+365*24*60*60); 
     290      } 
     291   
     292      // update call monitor record setting 
     293      if ($SETTINGS_ALLOW_CALL_RECORDING_SET) { 
     294        if ($record_in && $record_out) { 
     295          $this->setRecordSettings($exten,$record_in,$record_out); 
     296        } 
     297      } 
     298    } 
    333299    } 
    334300 
     
    353319   */ 
    354320  function display($args) { 
    355  
    356     global $STANDALONE; 
    357     global $ARI_ADMIN_USERNAME; 
     321    global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; 
    358322    global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 
    359323    global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 
     
    365329 
    366330    // args 
    367     $m = getArgument($args,'m'); 
    368     $q = getArgument($args,'q'); 
    369     $start = getArgument($args,'start'); 
    370     $span = getArgument($args,'span'); 
     331    $m     = getArgument($args,'m'); 
     332    $q     = getArgument($args,'q'); 
     333    $start   = getArgument($args,'start'); 
     334    $span = getArgument($args,'span'); 
    371335 
    372336    $displayname = $_SESSION['ari_user']['displayname']; 
     
    381345    // lang setting options 
    382346    if (extension_loaded('gettext')) {  
    383       $setLangText = " 
    384           <p class='lang'> 
    385       " . _("Language:") . " 
    386       " . $language->GetForm() . " 
    387           </p>"; 
     347      $setLangText = "<p class='lang'>" . _("Language:") . " " . $language->GetForm() . "</p>"; 
    388348    }  
    389349 
    390     // build controls 
    391     if ($exten!=$ARI_ADMIN_USERNAME) { 
    392  
    393       // call forward settings 
    394       if (!$STANDALONE['use']) { 
    395  
    396         $call_forward_number = $this->getCallForwardNumber($exten); 
    397         if ($call_forward_number) {  
    398           $call_forward_enable = 'checked'; 
    399         } 
    400         else { 
    401           $call_forward_number = $_COOKIE['ari_call_forward_number']; 
    402           $call_forward_text_box_options = "disabled style='background: #DDD;'"; 
    403         } 
    404  
    405         $set_call_forward_text = " 
    406           <table class='settings'> 
    407       <tr> 
    408               <td><h3>" . _("Call Routing") . "</h3></td> 
    409       </tr> 
    410       <tr> 
    411               <td>" . _("Call Forwarding:") . "</td> 
    412               <td> 
    413                 <input " . $call_forward_text_box_options . " name='call_forward_number' type='text' size=24 value='" . $call_forward_number . "'> 
    414               </td> 
    415       <tr> 
    416               <td></td> 
    417               <td> 
    418                 <input " . $call_forward_enable . " type=checkbox name='call_forward_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 
    419                 <small>" . _("Enable") . "</small> 
    420               </td> 
    421       </tr> 
    422           </table>"; 
    423       } 
    424  
    425       // voicemail settings 
    426       if ($_SESSION['ari_user']['voicemail_enabled']==1 &&  
    427             in_array('voicemail',array_keys($loaded_modules))) { 
    428         if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 
    429  
    430           if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) { 
    431             $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
    432           } 
    433           else { 
    434             $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
    435           } 
    436  
    437           $set_voicemail_password_text = " 
    438       <tr> 
    439               <td>" . _("Voicemail Password:") . "</td> 
    440               <td> 
    441                 <input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 
    442               </td> 
    443       </tr> 
    444       <tr> 
    445               <td>" . _("Enter again to confirm:") . "</td> 
    446               <td> 
    447                 <input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 
    448               </td> 
    449       </tr> 
    450       <tr> 
    451              <td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td> 
    452       </tr>"; 
    453         } 
    454  
    455         if (isset($_SESSION['ari_user']['voicemail_email'])) { 
    456  
    457           if ($_SESSION['ari_user']['voicemail_email_enable']) {  
    458             $voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address']; 
    459             $voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address']; 
    460             $voicemail_email_enable = 'checked'; 
    461  
    462             foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
    463               $var = "voicemail_email_$key"; 
    464               $var_enable = $var . "enable"; 
    465               if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') { 
    466                 $$var_enable = 'checked'; 
    467               } 
    468             } 
    469           } 
    470           else { 
    471  
    472             $voicemail_email_address = $_COOKIE['ari_voicemail_email_address']; 
    473             $voicemail_email_text_box_options = "disabled style='background: #DDD;'"; 
    474             $voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address']; 
    475             $voicemail_pager_text_box_options = "disabled style='background: #DDD;'"; 
    476  
    477             foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
    478               $var = "voicemail_email_$key"; 
    479               $var_cookie = "ari_" . $var; 
    480               $var_enable = $var . "enable"; 
    481               $var_text_box_options = $var . "text_box_options"; 
    482  
    483               $$var_text_box_options = "disabled"; 
    484               if ($_COOKIE[$var_cookie]=='yes') { 
    485                 $$var_enable = 'checked'; 
    486               } 
    487             } 
    488           } 
    489  
    490           $set_voicemail_email_text = " 
    491       <tr> 
    492               <td>" . _("Email Voicemail To:") . "</td> 
    493               <td> 
    494                 <input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'> 
    495               </td> 
    496       </tr> 
    497       <tr> 
    498               <td>" . _("Pager Voicemail To:") . "</td> 
    499               <td> 
    500                 <input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'> 
    501               </td> 
    502       </tr> 
    503             <tr> 
    504               <td></td> 
    505               <td> 
    506                 <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\"> 
    507                 <small>" . _("Enable") . "</small> 
    508               </td> 
    509            </tr>"; 
    510  
    511           foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
    512  
    513             $var = "voicemail_email_$key"; 
    514             $var_enable = $var . "enable"; 
    515             $var_text_box_options = $var . "text_box_options"; 
    516             if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) { 
    517               $var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]; 
    518             } 
    519             else { 
    520               $var_text = $key; 
    521             } 
    522  
    523             if ($value != 'yes' && $value != 'no' && $value !='') { 
    524  
    525               $size = strlen($value) - 1; 
    526               $set_voicemail_email_text .= " 
    527                 <tr> 
    528                   <td></td> 
    529                   <td> 
    530                     <input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "' OnClick=\"disable_fields(); return true;\"> 
    531                     <small>" . $var_text . "</small> 
    532                   </td> 
    533                 </tr>"; 
    534             }  
    535             else { 
    536  
    537               $set_voicemail_email_text .= " 
    538                 <tr> 
    539                   <td></td> 
    540                   <td> 
    541                     <input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "' value='yes' OnClick=\"disable_fields(); return true;\"> 
    542                     <small>" . $var_text . "</small> 
    543                   </td> 
    544                 </tr>"; 
    545             } 
    546           } 
    547         } 
    548   
    549         $wav_enable = 'selected'; 
    550         if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'||  
    551               ($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) { 
    552           $wav_enable = ''; 
    553           $gsm_enable = 'selected'; 
    554         }  
    555  
    556         $set_voicemail_audio_format_text = " 
    557     <tr> 
    558             <td>" . _("Audio Format:") . "</td> 
    559             <td> 
    560               <select name='voicemail_audio_format'> 
    561                 <option value='.wav' " . $wav_enable .  ">" . _("Best Quality") . " (.wav)</option> 
    562                 <option value='.gsm' " . $gsm_enable .  ">" . _("Smallest Download") . " (.gsm)</option> 
    563               </select> 
    564             </td> 
    565           </tr>"; 
    566  
    567         $set_voicemail_text = " 
    568           <table class='settings'> 
    569             <tr> 
    570               <td><h3>" . _("Voicemail Settings") . "</h3></td> 
    571       </tr> 
    572             " . $set_voicemail_password_text . " 
    573             " . $set_voicemail_email_text . " 
    574             " . $set_voicemail_audio_format_text . " 
    575           </table>"; 
    576       } 
    577  
    578       // call monitor settings 
    579       if ($this->getFreePBXVersion() && 
    580             $SETTINGS_ALLOW_CALL_RECORDING_SET &&  
    581             in_array('callmonitor',array_keys($loaded_modules))) { 
    582  
    583         foreach($data as $key=>$value) { 
    584           if ($key=='record_in') { 
    585             if ($value=='Always') { 
    586               $ri_always = 'checked=checked'; 
    587             } 
    588             elseif ($value=='Never') { 
    589               $ri_never = 'checked=checked'; 
    590             } 
    591             elseif ($value=='Adhoc') { 
    592               $ri_on_demand = 'checked=checked'; 
    593             } 
    594           } 
    595           if ($key=='record_out') { 
    596             if ($value=='Always') { 
    597               $ro_always = 'checked=checked'; 
    598             } 
    599             elseif ($value=='Never') { 
    600               $ro_never = 'checked=checked'; 
    601             } 
    602             elseif ($value=='Adhoc') { 
    603               $ro_on_demand = 'checked=checked'; 
    604             } 
    605           } 
    606         } 
    607  
    608         $set_callmonitor_text = " 
    609           <table class='settings'> 
    610       <tr> 
    611               <td><h3>" . _("Call Monitor Settings") . "</h3></td> 
    612       </tr> 
    613       <tr> 
    614               <td>" . _("Record INCOMING:") . " </td> 
    615               <td> 
    616                 <input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . "  
    617                 <input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . "        
    618                 <input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . " 
    619               </td> 
    620             </tr> 
    621             <tr> 
    622               <td>" . _("Record OUTGOING:") . " </td> 
    623               <td> 
    624                 <input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . " 
    625                 <input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . "         
    626                 <input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . " 
    627               </td> 
    628             </tr> 
    629           </table>"; 
    630       } 
    631     } 
    632  
    633     // javascript enable options 
    634     if (isset($_SESSION['ari_user']['voicemail_email']) && 
    635           in_array('voicemail',array_keys($loaded_modules))) { 
    636       foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
    637         $var = "voicemail_email_$key"; 
    638         $js_voicemail_email_disable .= " 
    639           document.ari_settings.$var.disabled = false;"; 
    640         $js_voicemail_email_enable .= " 
    641           document.ari_settings.$var.disabled = true;"; 
    642       } 
    643  
    644       $js_voicemail_script = " 
    645           if (document.ari_settings.voicemail_email_enable.checked) { 
    646             document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; 
    647             document.ari_settings.voicemail_email_address.disabled = false; 
    648             document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; 
    649             document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; 
    650             document.ari_settings.voicemail_pager_address.disabled = false; 
    651             document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; 
    652             " . $js_voicemail_email_disable . " 
    653           } 
    654           else { 
    655             document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; 
    656             document.ari_settings.voicemail_email_address.disabled = true; 
    657             document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; 
    658             document.ari_settings.voicemail_pager_address.disabled = true; 
    659             " . $js_voicemail_email_enable . " 
    660           }"; 
    661     } 
    662  
    663     // build page content 
    664     $ret .= checkErrorMessage(); 
    665  
    666     if ($_SESSION['ari_user']['admin_settings']) { 
    667       $headerText = _("Settings"); 
    668     } else { 
    669       $headerText = sprintf(_("Settings for %s (%s)"),$displayname,$exten); 
    670     } 
    671  
    672     $ret .= $display->displayHeaderText($headerText); 
    673     $ret .= $display->displayLine(); 
    674  
    675     $ret .= " 
    676       <SCRIPT LANGUAGE='JavaScript'> 
    677       <!-- Begin 
    678         function disable_fields() { 
    679           if (document.ari_settings.call_forward_enable.checked) { 
    680             document.ari_settings.call_forward_number.style.backgroundColor = '#FFF'; 
    681             document.ari_settings.call_forward_number.disabled = false; 
    682           } 
    683           else { 
    684             document.ari_settings.call_forward_number.style.backgroundColor = '#DDD'; 
    685             document.ari_settings.call_forward_number.disabled = true; 
    686           } 
    687           " . $js_voicemail_script . " 
    688         } 
    689       // End --> 
    690       </script>"; 
    691  
    692     $ret .= " 
    693       " . $setLangText . " 
    694       <form class='settings' name='ari_settings' action='' method='GET'> 
    695         <input type=hidden name=m value=" . $m . "> 
    696         <input type=hidden name=f value='action'> 
    697         <input type=hidden name=a value='update'> 
    698         <br> 
    699         " . $set_voicemail_text . " 
    700         <br> 
    701         " . $set_callmonitor_text . " 
    702         <br> 
    703         <input name='submit' type='submit' value='" . _("Update") . "'> 
    704       </form>"; 
    705  
    706     return $ret; 
    707   } 
    708  
    709   /* 
    710    * Sets Asterisk call forward setting 
    711    * 
    712    * @param $exten 
    713    *   Extension to modify 
    714    * @param $state 
    715    *   Call forward enable or disable 
    716    * @param $call_forward_number 
    717    *   Call forward number 
    718    */ 
    719   function setCallForward($exten,$state,$call_forward_number) { 
    720  
    721     global $asterisk_manager_interface; 
    722  
    723     if ($state) { 
    724       $type_opt = "put"; 
    725       $value_opt = $call_forward_number; 
    726     } 
    727     else { 
    728       $type_opt = "del"; 
    729     } 
    730  
    731     $variable_opt = "CF"; 
    732  
    733     $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt $variable_opt $exten $value_opt\r\n\r\n"); 
    734   } 
    735  
    736   /* 
    737    * Gets call forward number if set 
    738    * 
    739    * @param $exten 
    740    *   Extension to get information about 
    741    * @return $number 
    742    *   call forward number returned if set 
    743    */ 
    744   function getCallForwardNumber($exten) { 
    745  
    746     global $asterisk_manager_interface; 
    747  
    748     $number = ''; 
    749  
    750     $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get CF $exten\r\n\r\n"); 
    751     if (is_numeric($response)) { 
    752       $number = $response; 
    753     } 
    754  
    755     $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 
    756     if ($stripped==$number) { 
    757       $number = $_COOKIE['ari_call_forward_number']; 
    758     } 
    759  
    760     return $number; 
    761   } 
     350 
     351  // voicemail settings 
     352  if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1 &&  
     353  in_array('voicemail',array_keys($loaded_modules))) { 
     354    if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 
     355       
     356      if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) { 
     357        $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
     358      } 
     359      else { 
     360        $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 
     361      } 
     362       
     363      $set_voicemail_password_text = " 
     364      <tr> 
     365      <td>" . _("Voicemail Password:") . "</td> 
     366      <td> 
     367      <input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 
     368      </td> 
     369      </tr> 
     370      <tr> 
     371      <td>" . _("Enter again to confirm:") . "</td> 
     372      <td> 
     373      <input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 
     374      </td> 
     375      </tr> 
     376      <tr> 
     377      <td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td> 
     378      </tr>"; 
     379    } 
     380     
     381    if (isset($_SESSION['ari_user']['voicemail_email'])) { 
     382       
     383      if ($_SESSION['ari_user']['voicemail_email_enable']) {  
     384        $voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address']; 
     385        $voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address']; 
     386        $voicemail_email_enable = 'checked'; 
     387         
     388        foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 
     389          $var = "voicemail_email_$key"; 
     390          $var_enable = $var . "enable"; 
     391          if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') { 
     392            $$var_enable = 'checked'; 
     393          } 
     394        } 
     395      } 
     396      else { 
     397         
     398        $voicemail_email_address = $_COOKIE['ari_voicemail_email_address']; 
     399        $voicemail_email_text_box_options = "disabled style='background: #DDD;'"; 
     400        $voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address']; 
     401        $voicemail_pager_text_box_options = "disabled style='background: #DDD;'"; 
     402         
     403        foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
     404          $var = "voicemail_email_$key"; 
     405          $var_cookie = "ari_" . $var; 
     406          $var_enable = $var . "enable"; 
     407          $var_text_box_options = $var . "text_box_options"; 
     408           
     409          $$var_text_box_options = "disabled"; 
     410          if ($_COOKIE[$var_cookie]=='yes') { 
     411            $$var_enable = 'checked'; 
     412          } 
     413        } 
     414      } 
     415       
     416      $set_voicemail_email_text = " 
     417       
     418        <tr> 
     419        <td> " . _("Email Notification") . " <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\"> 
     420        <small> " ._("Enable") . " </small>       
     421        </td> 
     422        </tr><tr> 
     423        <td><a href='#' class='info'>" . _("Email Voicemail To:") . "<span>" . ("Email a notification, including audio file if indicated below.") . " </span></a></td> 
     424        <td> 
     425        <input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'> 
     426        </td> 
     427        </tr> 
     428        <tr> 
     429        <td><a href='#' class='info'>" . _("Pager Email Notification To:") . "<span>" . ("Email a short notification") . " </span></a></td> 
     430        <td> 
     431        <input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'> 
     432        </td> 
     433        </tr> 
     434        <tr> 
     435        <td></td> 
     436        </tr>"; 
     437       
     438      foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
     439         
     440        $var = "voicemail_email_$key"; 
     441        $var_enable = $var . "enable"; 
     442        $var_text_box_options = $var . "text_box_options"; 
     443        if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) { 
     444          $var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]; 
     445        } 
     446        else { 
     447          $var_text = $key; 
     448        } 
     449         
     450        if ($value != 'yes' && $value != 'no' && $value !='') { 
     451           
     452          $size = strlen($value) - 1; 
     453          $set_voicemail_email_text .= " 
     454          <tr> 
     455          <td></td> 
     456          <td> 
     457          <input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "' OnClick=\"disable_fields(); return true;\"> 
     458          <small>" . $var_text . "</small> 
     459          </td> 
     460          </tr>"; 
     461        }  
     462        else { 
     463           
     464          $set_voicemail_email_text .= " 
     465          <tr> 
     466          <td></td> 
     467          <td> 
     468          <input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "' value='yes' OnClick=\"disable_fields(); return true;\"> 
     469          <small>" . $var_text . "</small> 
     470          </td> 
     471          </tr>"; 
     472        } 
     473      } 
     474    } 
     475     
     476    $wav_enable = 'selected'; 
     477    if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'||  
     478    ($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) { 
     479      $wav_enable = ''; 
     480      $gsm_enable = 'selected'; 
     481    }  
     482     
     483    $set_voicemail_audio_format_text = " 
     484      <tr> 
     485      <td>" . _("Audio Format:") . "</td> 
     486      <td> 
     487      <select name='voicemail_audio_format'> 
     488      <option value='.wav' " . $wav_enable .  ">" . _("Best Quality") . " (.wav)</option> 
     489      <option value='.gsm' " . $gsm_enable .  ">" . _("Smallest Download") . " (.gsm)</option> 
     490      </select> 
     491      </td> 
     492      </tr>"; 
     493     
     494    $set_voicemail_text = " 
     495      <table class='settings'> 
     496      <tr> 
     497      <td><h3>" . _("Voicemail Settings") . "</h3></td> 
     498      </tr> 
     499      " . $set_voicemail_password_text . " 
     500      " . $set_voicemail_email_text . " 
     501      " . $set_voicemail_audio_format_text . " 
     502      </table>"; 
     503  } 
     504 
     505  // call monitor settings 
     506  if ($this->getFreePBXVersion() && 
     507  $SETTINGS_ALLOW_CALL_RECORDING_SET &&  
     508  in_array('callmonitor',array_keys($loaded_modules))) { 
     509     
     510    foreach($data as $key=>$value) { 
     511      if ($key=='record_in') { 
     512        if ($value=='Always') { 
     513          $ri_always = 'checked=checked'; 
     514        } 
     515        elseif ($value=='Never') { 
     516          $ri_never = 'checked=checked'; 
     517        } 
     518        elseif ($value=='Adhoc') { 
     519          $ri_on_demand = 'checked=checked'; 
     520        } 
     521      } 
     522      if ($key=='record_out') { 
     523        if ($value=='Always') { 
     524          $ro_always = 'checked=checked'; 
     525        } 
     526        elseif ($value=='Never') { 
     527          $ro_never = 'checked=checked'; 
     528        } 
     529        elseif ($value=='Adhoc') { 
     530          $ro_on_demand = 'checked=checked'; 
     531        } 
     532      } 
     533    } 
     534     
     535    $set_callmonitor_text = " 
     536      <table class='settings'> 
     537      <tr> 
     538      <td><h3>" . _("Call Monitor Settings") . "</h3></td> 
     539      </tr> 
     540      <tr> 
     541      <td>" . _("Record INCOMING:") . " </td> 
     542      <td> 
     543      <input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . "  
     544      <input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . "        
     545      <input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . " 
     546      </td> 
     547      </tr> 
     548      <tr> 
     549      <td>" . _("Record OUTGOING:") . " </td> 
     550      <td> 
     551      <input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . " 
     552      <input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . "         
     553      <input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . " 
     554      </td> 
     555      </tr> 
     556      </table>"; 
     557  } 
     558 
     559  // javascript enable options 
     560  if (isset($_SESSION['ari_user']['voicemail_email']) && 
     561  in_array('voicemail',array_keys($loaded_modules))) { 
     562    foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 
     563      $var = "voicemail_email_$key"; 
     564      $js_voicemail_email_disable .= " 
     565      document.ari_settings.$var.disabled = false;"; 
     566      $js_voicemail_email_enable .= " 
     567      document.ari_settings.$var.disabled = true;"; 
     568    } 
     569     
     570    $js_voicemail_script = " 
     571      if (document.ari_settings.voicemail_email_enable.checked) { 
     572      document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; 
     573      document.ari_settings.voicemail_email_address.disabled = false; 
     574      document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; 
     575      document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; 
     576      document.ari_settings.voicemail_pager_address.disabled = false; 
     577      document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; 
     578      " . $js_voicemail_email_disable . " 
     579      } 
     580      else { 
     581      document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; 
     582      document.ari_settings.voicemail_email_address.disabled = true; 
     583      document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; 
     584      document.ari_settings.voicemail_pager_address.disabled = true; 
     585      " . $js_voicemail_email_enable . " 
     586      }"; 
     587  } 
     588   
     589  // build page content 
     590  $ret .= checkErrorMessage(); 
     591   
     592  $headerText = sprintf(_("Settings for %s (%s)"),$displayname,$exten); 
     593   
     594  $ret .= $display->displayHeaderText($headerText); 
     595  $ret .= $display->displayLine(); 
     596   
     597  $ret .= " 
     598    <SCRIPT LANGUAGE='JavaScript'> 
     599    <!-- Begin 
     600    function rowCounter(field, maxlimit) { 
     601      temp = field.value.split('\u000A',maxlimit+1) 
     602      field.value = temp.join('\u000A') 
     603      if (temp.length == maxlimit+1) { 
     604        field.value = field.value.substring(0, field.value.length-1) 
     605      } 
     606    } 
     607     
     608    function disable_fields() {"; 
     609      $ret .= $js_voicemail_script . " 
     610    } 
     611    // End --> 
     612    </script>"; 
     613   
     614  $ret .= " 
     615    " . $setLangText . " 
     616    <form class='settings' name='ari_settings' action='' method='GET'> 
     617    <input type=hidden name=m value=" . $m . "> 
     618    <input type=hidden name=f value='action'> 
     619    <input type=hidden name=a value='update'> 
     620    <br> 
     621    " . $set_voicemail_text . " 
     622    <br> 
     623    " . $set_callmonitor_text . " 
     624    <br> 
     625    <input name='submit' type='submit' value='" . _("Update") . "'> 
     626    </form>"; 
     627   
     628  return $ret; 
     629  } 
     630 
     631 
     632 
     633 
     634 
    762635 
    763636  /* 
     
    920793  } 
    921794 
    922  
    923 
    924  
     795  /* 
     796   * Sets Follow-Me Settings in FreePBX MySQL Database 
     797   * 
     798   * @param $exten 
     799   *   Extension to modify 
     800   * @param $follow_me_prering_time 
     801   *   Pre-Ring Time to ring 
     802   * @param $follow_me_listring_time 
     803   *   List Ring Time to ring 
     804   * @param $follow_me_list 
     805   *   Follow Me List 
     806   * @param $follow_me_list 
     807   *   Follow Me Confirm Setting 
     808   * 
     809   */ 
     810  function setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm) { 
     811 
     812    if (isset($_SESSION['dbh_asterisk'])) { 
     813 
     814      //format for SQL database 
     815      $follow_me_confirm = ($follow_me_confirm)?'CHECKED':''; 
     816 
     817      $sql = "UPDATE findmefollow SET grptime = '" . $follow_me_listring_time . "', grplist = '". 
     818           str_replace("'", "''", trim($follow_me_list)) . "', pre_ring = '" . $follow_me_prering_time . 
     819           "', needsconf = '" . $follow_me_confirm . "' WHERE grpnum = $exten LIMIT 1"; 
     820      $results = $_SESSION['dbh_asterisk']->query($sql); 
     821 
     822      if(DB::IsError($results)) { 
     823        $_SESSION['ari_error'] = $results->getMessage(); 
     824      } 
     825 
     826      return 1; 
     827    } 
     828  } 
     829 
     830  function lookupSetExtensionFormat($exten) { 
     831 
     832    if (trim($exten) == "") return $exten; 
     833 
     834    $exten = preg_replace("/[^0-9*]/", "", $exten); 
     835 
     836    $sql = "SELECT extension FROM users WHERE extension = '".$exten."'"; 
     837    $asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC); 
     838    if (!is_array($asa)) {  
     839      return $exten.'#'; 
     840    } else { 
     841      return $exten; 
     842    } 
     843  } 
     844 
     845 
     846} // class 
    925847 
    926848?> 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/voicemail.module

    r4328 r4425  
    273273    if (is_readable($ASTERISK_VOICEMAIL_CONF)) { 
    274274      $lines = file($ASTERISK_VOICEMAIL_CONF); 
     275      $ext_array = array(); 
    275276      foreach ($lines as $key => $line) { 
    276277 
     
    285286          $username = trim($username); 
    286287          if ($username!=$_SESSION['ari_user']['extension']) { 
    287             $forward_options .= "<option VALUE='" . $forwardContext . "/" . $username . "'>" . $username; 
     288            //$ext_array[] = $username . "|" . $forwardContext; 
     289            list(,$real_name,) = split(",",$value,3); 
     290            $ext_array[] = $real_name . "|" . $username . "|" . $forwardContext; 
    288291          } 
    289292        } 
     293      } //foreach 
     294      //sort the array 
     295      sort($ext_array); 
     296 
     297      //get the size of the array 
     298      $array_size = count($ext_array) - 1; 
     299 
     300      //loop through the array and build the drop down list 
     301      foreach ($ext_array as $item) 
     302      { 
     303         //split the values apart 
     304         list($real_name,$username,$context) = explode("|",$item); 
     305 
     306         //add it to the drop down 
     307         $forward_options .= "<option VALUE='" . $context . "/" . $username . "'>" . substr($real_name,0,15) . " <" . $username . ">"; 
    290308      } 
    291309    } 
     
    421439    // ajax page refresh script 
    422440    if ($AJAX_PAGE_REFRESH_ENABLE) { 
    423  //     $ret .= ajaxRefreshScript($args); 
     441//      $ret .= ajaxRefreshScript($args); 
    424442    } 
    425443 
  • freepbx/branches/2.3/amp_conf/htdocs/recordings/theme/page.tpl.php

    r4328 r4425  
    22<html xmlns="http://www.w3.org/1999/xhtml"> 
    33  <head> 
    4     <TITLE>ARI</TITLE> 
     4    <TITLE>User Portal</TITLE> 
    55    <link rel="stylesheet" href="theme/main.css" type="text/css"> 
    66    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
     
    1010  <div class="minwidth"> 
    1111  <div class="container"> 
    12     <h2 class="ariBlockHide">Header And Logo</h2> 
    13     <div id="ariHeader"> 
    14       <div class="spacer"></div> 
    15       <span id="left"> 
    16         <a href="<?=$_SERVER['PHP_SELF']?>" alt="ARI"><img src="theme/logo.gif" height=72 alt="" /></a> 
    17       </span> 
    18       <span id="right"></span> 
    19       <div class="spacer"></div> 
    20     </div> 
    2112    <div id="topnav"> 
    2213      <div class="spacer"></div> 
    2314      <span class="left"> 
    24         <small>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&middot;&nbsp;&middot;&nbsp;&middot;&nbsp;&middot;&nbsp;&middot;&nbsp;&middot;&nbsp;&middot;&nbsp;</small> 
    2515      </span> 
    2616      <div class="spacer"></div>