Changeset 4328 for freepbx/branches/2.3
- Timestamp:
- 07/07/07 14:21:56 (6 years ago)
- Files:
-
- freepbx/branches/2.3/amp_conf/htdocs/recordings/includes/main.conf.php (modified) (1 diff)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/VmX.module (copied) (copied from freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/settings.module) (32 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/callmonitor.module (modified) (3 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/featurecodes.module (moved) (moved from freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/help.module) (4 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/followme.module (copied) (copied from freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/settings.module) (19 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/phonefeatures.module (copied) (copied from freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/settings.module) (3 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/settings.module (modified) (17 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/voicemail.module (modified) (4 diffs)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/theme/layout.css (modified) (1 diff)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/theme/page.tpl.php (modified) (1 diff)
- freepbx/branches/2.3/amp_conf/htdocs/recordings/version.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.3/amp_conf/htdocs/recordings/includes/main.conf.php
r3629 r4328 321 321 # 1 - show controls 322 322 # 323 $SETTINGS_ALLOW_CALL_RECORDING_SET = 0; 323 $SETTINGS_ALLOW_CALL_RECORDING_SET = 1; 324 325 326 $SETTINGS_ALLOW_PHONE_SETTINGS = 1; 327 324 328 325 329 freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/VmX.module
r4170 r4328 7 7 8 8 /** 9 * Class for settings9 * Class for Followme 10 10 */ 11 class Settings{11 class VmX { 12 12 13 13 var $protocol_table; … … 19 19 function rank() { 20 20 21 $rank = 100000;22 return $rank;21 $rank = 6; 22 return $rank; 23 23 } 24 24 … … 28 28 function init() { 29 29 30 // determine what protocol user is using31 global $ASTERISK_PROTOCOLS;32 33 foreach ($ASTERISK_PROTOCOLS as $protocol => $value) {34 $data = $this->getProtocolRecordSettings($value['table'],$_SESSION['ari_user']['extension']);35 if (count($data)) {36 $this->protocol_table = $value['table'];37 $this->protocol_config_files = $value['config_files'];38 break;39 }40 }41 30 } 42 31 … … 49 38 function navMenu($args) { 50 39 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 <br> 61 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p>"; 62 } 63 64 return $ret; 40 $ret .= " 41 <p> 42 <small> 43 <small> 44 <a href='" 45 . $_SESSION['ARI_ROOT'] . "?m=VmX&f=display'>" . _("VmX Locator™") . 46 "</a> 47 </small> 48 </small> 49 </p>"; 50 51 return $ret; 65 52 } 66 53 … … 75 62 function action($args) { 76 63 77 global $STANDALONE; 78 global $ARI_ADMIN_USERNAME; 79 global $ASTERISK_VOICEMAIL_CONF; 80 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 81 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; 82 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 83 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 84 global $SETTINGS_VOICEMAIL_PASSWORD_EXACT; 85 global $SETTINGS_ALLOW_CALL_RECORDING_SET; 86 global $SETTINGS_ALLOW_VMX_SETTINGS; 87 88 // args 89 $m = getArgument($args,'m'); 90 $a = getArgument($args,'a'); 91 92 $lang_code = getArgument($args,'lang_code'); 93 94 $call_forward_enable = getArgument($args,'call_forward_enable'); 95 $call_forward_number = getArgument($args,'call_forward_number'); 96 97 $call_forward_busy_enable = getArgument($args,'call_forward_busy_enable'); 98 $call_forward_busy_number = getArgument($args,'call_forward_busy_number'); 99 100 $call_forward_unavailable_enable = getArgument($args,'call_forward_unavailable_enable'); 101 $call_forward_unavailable_number = getArgument($args,'call_forward_unavailable_number'); 102 103 $follow_me_prering_time = getArgument($args,'follow_me_prering_time'); 104 $follow_me_listring_time = getArgument($args,'follow_me_listring_time'); 105 $follow_me_list = getArgument($args,'follow_me_list'); 106 $follow_me_confirm = getArgument($args,'follow_me_confirm'); 107 $follow_me_ddial = getArgument($args,'follow_me_ddial'); 108 $follow_me_disabled = getArgument($args,'follow_me_disabled'); 109 110 $vmx_option_0_number = getArgument($args, 'vmx_option_0_number'); 111 $vmx_option_0_system_default = getArgument($args, 'vmx_option_0_system_default'); 112 $vmx_option_1_number = getArgument($args, 'vmx_option_1_number'); 113 $vmx_option_1_system_default = getArgument($args, 'vmx_option_1_system_default'); 114 $vmx_option_2_number = getArgument($args, 'vmx_option_2_number'); 115 $vmx_unavail_enabled = getArgument($args, 'vmx_unavail_enabled'); 116 $vmx_busy_enabled = getArgument($args, 'vmx_busy_enabled'); 117 $vmx_play_instructions = getArgument($args, 'vmx_play_instructions'); 118 $vmx_disabled = getArgument($args,'vmx_disabled'); 119 120 $voicemail_password = getArgument($args,'voicemail_password'); 121 $voicemail_password_confirm = getArgument($args,'voicemail_password_confirm'); 122 $voicemail_email_address = getArgument($args,'voicemail_email_address'); 123 $voicemail_pager_address = getArgument($args,'voicemail_pager_address'); 124 $voicemail_email_enable = getArgument($args,'voicemail_email_enable'); 125 126 if (isset($_SESSION['ari_user']['voicemail_email'])) { 127 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 128 $var = "voicemail_email_$key"; 129 $$var = getArgument($args,$var); 130 } 131 } 132 133 $voicemail_audio_format = getArgument($args,'voicemail_audio_format'); 134 135 $record_in = getArgument($args,'record_in'); 136 $record_out = getArgument($args,'record_out'); 137 138 $language = new Language(); 139 140 if ($a=='update') { 141 142 $exten = $_SESSION['ari_user']['extension']; 143 if ($exten!=$ARI_ADMIN_USERNAME) { 144 145 // update call forward number 146 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS && !$STANDALONE['use']) { 147 148 // normal call forward 149 $stripped_call_forward_number = preg_replace('/-|\(|\)|\s/','',$call_forward_number); 150 if ($call_forward_enable && !is_numeric($stripped_call_forward_number)) { 151 $_SESSION['ari_error'] = 152 _("Call forward number not changed") . "<br>" . 153 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_number); 154 } 155 else { 156 157 // set database 158 $this->setCallForward($exten,$call_forward_enable,$stripped_call_forward_number); 159 160 // store cookie 161 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 162 if ($call_forward_number && $stripped!=$stripped_call_forward_number) { 163 setcookie("ari_call_forward_number", $call_forward_number, time()+365*24*60*60); 164 } 165 } 166 167 // call forward busy 168 $stripped_call_forward_busy_number = preg_replace('/-|\(|\)|\s/','',$call_forward_busy_number); 169 if ($call_forward_busy_enable && !is_numeric($stripped_call_forward_busy_number)) { 170 $_SESSION['ari_error'] = 171 _("Call forward number not changed") . "<br>" . 172 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_busy_number); 173 } 174 else { 175 176 // set database 177 $this->setCallForward($exten,$call_forward_busy_enable,$stripped_call_forward_busy_number, "CFB"); 178 179 // store cookie 180 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_busy_number']); 181 if ($call_forward_busy_number && $stripped!=$stripped_call_forward_busy_number) { 182 setcookie("ari_call_forward_busy_number", $call_forward_busy_number, time()+365*24*60*60); 183 } 184 } 185 186 // call forward unavailable 187 $stripped_call_forward_unavailable_number = preg_replace('/-|\(|\)|\s/','',$call_forward_unavailable_number); 188 if ($call_forward_unavailable_enable && !is_numeric($stripped_call_forward_unavailable_number)) { 189 $_SESSION['ari_error'] = 190 _("Call forward number not changed") . "<br>" . 191 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_unavailable_number); 192 } 193 else { 194 195 // set database 196 $this->setCallForward($exten,$call_forward_unavailable_enable,$stripped_call_forward_unavailable_number, "CFU"); 197 198 // store cookie 199 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_unavailable_number']); 200 if ($call_forward_unavailable_number && $stripped!=$stripped_call_forward_unavailable_number) { 201 setcookie("ari_call_forward_unavailable_number", $call_forward_unavailable_number, time()+365*24*60*60); 202 } 203 } 204 205 } 206 207 // Make sure Follow-Me setup has not been deleted for this user since the last refresh 208 $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 209 210 if (! $_COOKIE['ari_follow_me_disabled']) { 211 212 $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1; 213 214 if ($follow_me_disabled) { 215 216 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 217 $follow_me_disabled_delayed = $follow_me_disabled; 218 $_SESSION['ari_error'] = 219 _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" . 220 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 221 } 222 } 223 224 $vmx_disabled_delayed = $_COOKIE['ari_vmx_disabled']; 225 if (! $_COOKIE['ari_vmx_disabled']) { 226 227 $vmx_disabled = $this->getVmxState($exten,'unavail'); 228 if ($vmx_disabled === false) { 229 $vmx_disabled = true; 230 $SETTINGS_ALLOW_VMX_SETTINGS=false; 64 global $STANDALONE; 65 global $ARI_ADMIN_USERNAME; 66 global $SETTINGS_ALLOW_VMX_SETTINGS; 67 68 // args 69 $m = getArgument($args,'m'); 70 $a = getArgument($args,'a'); 71 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'); 79 $follow_me_disabled = getArgument($args,'follow_me_disabled'); 80 81 $vmx_option_0_number = getArgument($args, 'vmx_option_0_number'); 82 $vmx_option_0_system_default = getArgument($args, 'vmx_option_0_system_default'); 83 $vmx_option_1_number = getArgument($args, 'vmx_option_1_number'); 84 $vmx_option_1_system_default = getArgument($args, 'vmx_option_1_system_default'); 85 $vmx_option_2_number = getArgument($args, 'vmx_option_2_number'); 86 $vmx_unavail_enabled = getArgument($args, 'vmx_unavail_enabled'); 87 $vmx_busy_enabled = getArgument($args, 'vmx_busy_enabled'); 88 $vmx_play_instructions = getArgument($args, 'vmx_play_instructions'); 89 $vmx_disabled = getArgument($args, 'vmx_disabled'); 90 91 $language = new Language(); 92 93 // Lets see if we can make heads or tails of this code?!? 94 95 // The action is 'update 96 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) { 102 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 } 231 166 } else { 232 $vmx_disabled = false; 233 } 234 if ($vmx_disabled) { 235 236 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 237 $vmx_disabled_delayed = $vmx_disabled; 238 $_SESSION['ari_error'] = 239 _("Your Premium VmX Locator service has been disabled, REFRESH your browser to remove this message") . "<br>" . 240 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 241 } 242 } 243 244 if (! $vmx_disabled_delayed) { 245 if (!$STANDALONE['use']) { 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 } 236 } 237 } 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 } 265 } 266 } 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 } 288 } 289 } 290 291 // update follow me list 292 if (!$STANDALONE['use']) { 293 294 $grplist = explode("\n", $follow_me_list); 295 296 if (!$grplist) { 297 $grplist = null; 298 } 299 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 } 332 } 333 } 334 335 // update follow me confirm 336 if (!$STANDALONE['use']) { 337 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); 345 } 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 } 354 } 355 356 // redirect to see updated page 357 $ret .= " 358 <head> 359 <script> 360 <!-- 361 window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\" 362 // --> 363 </script> 364 </head>"; 246 365 247 // set database 248 $this->setVmxState($exten,'unavail',$vmx_unavail_enabled); 249 $this->setVmxState($exten,'busy',$vmx_busy_enabled); 250 $this->setVmxPlayInstructions($exten,'unavail',$vmx_play_instructions); 251 $this->setVmxPlayInstructions($exten,'busy',$vmx_play_instructions); 252 253 // store cookie 254 setcookie("ari_vmx_unavail_enabled", $vmx_unavail_enabled, time()+365*24*60*60); 255 setcookie("ari_vmx_busy_enabled", $vmx_busy_enabled, time()+365*24*60*60); 256 setcookie("ari_vmx_play_instructions", $vmx_play_instructions, time()+365*24*60*60); 257 258 $stripped_vmx_option_0_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_0_number); 259 if ($vmx_option_0_system_default) { 260 $this->setVmxOptionNumber($exten,'0','unavail',""); 261 $this->setVmxOptionNumber($exten,'0','busy',""); 262 setcookie("ari_vmx_option_0_system_default", $vmx_option_0_system_default, time()+365*24*60*60); 263 if (is_numeric($stripped_vmx_option_0_number) || !$stripped_vmx_option_0_number) { 264 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 265 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 266 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 267 } 268 } 269 } else { 270 if (!is_numeric($stripped_vmx_option_0_number) && $stripped_vmx_option_0_number) { 271 $_SESSION['ari_error'] = 272 _("Option 0 not changed") . "<br>" . 273 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_0_number); 274 } 275 else { 276 277 // set database 278 $this->setVmxOptionNumber($exten,'0','unavail',$stripped_vmx_option_0_number); 279 $this->setVmxOptionNumber($exten,'0','busy',$stripped_vmx_option_0_number); 280 281 // store cookie 282 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 283 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 284 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 285 } 286 } 287 } 288 289 $stripped_vmx_option_1_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_1_number); 290 if ($vmx_option_1_system_default && !$follow_me_disabled) { 291 $this->setVmxOptionFollowMe($exten,'1','unavail'); 292 $this->setVmxOptionFollowMe($exten,'1','busy'); 293 setcookie("ari_vmx_option_1_system_default", $vmx_option_1_system_default, time()+365*24*60*60); 294 if (is_numeric($stripped_vmx_option_1_number) || !$stripped_vmx_option_1_number) { 295 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 296 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 297 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 298 } 299 } 300 } 301 else { 302 303 if (!is_numeric($stripped_vmx_option_1_number) && $stripped_vmx_option_1_number) { 304 $_SESSION['ari_error'] = 305 _("Option 1 not changed") . "<br>" . 306 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_1_number); 307 } 308 else { 309 310 // set database 311 $this->setVmxOptionNumber($exten,'1','unavail',$stripped_vmx_option_1_number); 312 $this->setVmxOptionNumber($exten,'1','busy',$stripped_vmx_option_1_number); 313 314 // store cookie 315 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 316 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 317 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 318 } 319 } 320 } 321 322 $stripped_vmx_option_2_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_2_number); 323 if (!is_numeric($stripped_vmx_option_2_number) && $stripped_vmx_option_2_number) { 324 $_SESSION['ari_error'] = 325 _("Option 2 not changed") . "<br>" . 326 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_2_number); 327 } 328 else { 329 330 // set database 331 $this->setVmxOptionNumber($exten,'2','unavail',$stripped_vmx_option_2_number); 332 $this->setVmxOptionNumber($exten,'2','busy',$stripped_vmx_option_2_number); 333 334 // store cookie 335 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_2_number']); 336 if ($vmx_option_2_number && $stripped!=$stripped_vmx_option_2_number) { 337 setcookie("ari_vmx_option_2_number", $call_vmx_option_2_number, time()+365*24*60*60); 338 } 339 } 340 } 341 } // vmx_disabled_delayed false 342 343 if (! $follow_me_disabled_delayed) { 344 345 // assume no errors, don't update SQL if errors occured 346 $follow_me_update_succeeded=1; 347 348 // update follow me pre-ring time 349 if (!$STANDALONE['use']) { 350 351 $stripped_follow_me_prering_time = preg_replace('/-|\s/','',$follow_me_prering_time); 352 if (!is_numeric($stripped_follow_me_prering_time)) { 353 $_SESSION['ari_error'] = 354 _("Follow-Me pre-ring time not changed") . "<br>" . 355 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_prering_time); 356 $follow_me_update_succeeded=0; 357 } 358 else { 359 360 // set database 361 $this->setFollowMePreRingTime($exten,$stripped_follow_me_prering_time); 362 363 // store cookie 364 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_prering_time']); 365 if ($follow_me_prering_time && $stripped!=$stripped_follow_me_prering_time) { 366 setcookie("ari_follow_me_prering_time", $follow_me_prering_time, time()+365*24*60*60); 367 } 368 } 369 } 370 371 // update follow me list ring time 372 if (!$STANDALONE['use']) { 373 374 $stripped_follow_me_listring_time = preg_replace('/-|\s/','',$follow_me_listring_time); 375 if (!is_numeric($stripped_follow_me_listring_time)) { 376 $_SESSION['ari_error'] = 377 _("Follow-Me list ring time not changed") . "<br>" . 378 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_listring_time); 379 $follow_me_update_succeeded=0; 380 } 381 else { 382 383 // set database 384 $this->setFollowMeListRingTime($exten,$stripped_follow_me_listring_time); 385 386 // store cookie 387 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_listring_time']); 388 if ($follow_me_listring_time && $stripped!=$stripped_follow_me_listring_time) { 389 setcookie("ari_follow_me_listring_time", $follow_me_listring_time, time()+365*24*60*60); 390 } 391 } 392 } 393 394 // update follow me list 395 if (!$STANDALONE['use']) { 396 397 $grplist = explode("\n", $follow_me_list); 398 399 if (!$grplist) { 400 $grplist = null; 401 } 402 403 foreach (array_keys($grplist) as $key) { 404 //trim it 405 $grplist[$key] = trim($grplist[$key]); 406 407 // Lookup the extension and append hash if not a user, and remove invalid chars 408 $grplist[$key] = $this->lookupSetExtensionFormat($grplist[$key]); 409 410 // remove blanks 411 if ($grplist[$key] == "") unset($grplist[$key]); 412 } 413 414 // check for duplicates, and re-sequence 415 $grplist = array_values(array_unique($grplist)); 416 417 $stripped_follow_me_list = implode("-",$grplist); 418 419 if ($stripped_follow_me_list == "") { 420 $_SESSION['ari_error'] = 421 _("Follow-Me list must contain at least one valid number") . "<br>" . 422 sprintf(_("The following: %s is not valid"),$follow_me_list); 423 $follow_me_update_succeeded=0; 424 } 425 else { 426 427 // set database 428 $this->setFollowMeList($exten,$stripped_follow_me_list); 429 430 // store cookie 431 $stripped = preg_replace('/|\(|\)|\s/','',$_COOKIE['ari_follow_me_list']); 432 if ($follow_me_list && $stripped!=$stripped_follow_me_list) { 433 setcookie("ari_follow_me_list", $follow_me_list, time()+365*24*60*60); 434 } 435 } 436 } 437 438 // update follow me confirm 439 if (!$STANDALONE['use']) { 440 441 // set database 442 $this->setFollowMeConfirm($exten,$follow_me_confirm); 443 $this->setFollowMeDDial($exten,$follow_me_ddial); 444 445 // store cookie 446 setcookie("ari_follow_me_confirm", $follow_me_confirm, time()+365*24*60*60); 447 setcookie("ari_follow_me_ddial", $follow_me_ddial, time()+365*24*60*60); 448 } 449 450 //If no errors than update the SQL table to keep in sync 451 if ($follow_me_update_succeeded) { 452 $this->setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm); 453 } 454 455 } //if !follow_me_disabled 456 457 // voicemail settings 458 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1) { 459 460 461 // update voicemail password 462 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 463 464 // update voicemail password 465 if ($voicemail_password=='' || $voicemail_password_confirm=='') { 466 $_SESSION['ari_error'] = 467 _("Voicemail password not changed") . "<br>" . 468 _("Password and password confirm must not be blank"); 469 } 470 else if ((strlen($voicemail_password)<$SETTINGS_VOICEMAIL_PASSWORD_LENGTH) || !is_numeric($voicemail_password)) { 471 $_SESSION['ari_error'] = 472 _("Voicemail password not changed") . "<br>" . 473 sprintf(_("Passwords must be all numbers and greater than %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 474 } 475 else if (strlen($voicemail_password)!=$SETTINGS_VOICEMAIL_PASSWORD_LENGTH && $SETTINGS_VOICEMAIL_PASSWORD_EXACT || !is_numeric($voicemail_password)) { 476 $_SESSION['ari_error'] = 477 _("Voicemail password not changed") . "<br>" . 478 sprintf(_("Passwords must be all numbers and only %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 479 } 480 else if ($voicemail_password!=$voicemail_password_confirm) { 481 $_SESSION['ari_error'] = 482 _("Voicemail password not changed") . "<br>" . 483 _("Password and password confirm do not match"); 484 } 485 else { 486 487 // check for writable the files 488 $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 489 $fp = fopen($temp_file, "w"); 490 if (!$fp) { 491 $_SESSION['ari_error'] = 492 _("Voicemail password not changed") . "<br>" . 493 sprintf(_("%s does not exist or is not writable"),$temp_file); 494 } 495 else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 496 $_SESSION['ari_error'] = 497 _("Voicemail password not changed") . "<br>" . 498 sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 499 } 500 else { 501 502 // update session 503 $_SESSION['ari_user']['voicemail_password'] = $voicemail_password; 504 505 // save password 506 $lines = file($ASTERISK_VOICEMAIL_CONF); 507 foreach ($lines as $key => $line) { 508 unset($value); 509 list($var,$value) = split('=>',$line); 510 $var = trim($var); 511 if ($var==$exten && $value) { 512 513 // write out line with password change 514 $buf = split(',',$value); 515 $buf[0] = $voicemail_password; 516 $line = $var . " => " . join(',', $buf); 517 518 fwrite($fp, $line); 519 } 520 else { 521 522 // write out original line with no changes 523 fwrite($fp, $line); 524 } 525 } 526 fclose($fp); 527 unlink($ASTERISK_VOICEMAIL_CONF); 528 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 529 530 $voicemail_reload = 1; 531 } 532 } 533 534 // voicemail email address 535 if ($voicemail_email_enable && 536 ($voicemail_email_address && !preg_match('/@/',$voicemail_email_address) || 537 ($voicemail_pager_address && !preg_match('/@/',$voicemail_pager_address)))) { 538 $_SESSION['ari_error'] = 539 _("Voicemail email and pager address not changed") . "<br>" . 540 ("'$voicemail_email_address' and '$voicemail_pager_address' must be a valid email addresses"); 541 } 542 else { 543 544 // check for writable the files 545 $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 546 $fp = fopen($temp_file, "w"); 547 if (!$fp) { 548 $_SESSION['ari_error'] = 549 _("Voicemail email settings not changed") . "<br>" . 550 sprintf(_("%s does not exist or is not writable"),$temp_file); 551 } 552 else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 553 $_SESSION['ari_error'] = 554 _("Voicemail email settings not changed") . "<br>" . 555 sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 556 } 557 else { 558 559 // store cookie 560 if ($voicemail_email_enable) { 561 setcookie("ari_voicemail_email_address", $voicemail_email_address, time()+365*24*60*60); 562 setcookie("ari_voicemail_pager_address", $voicemail_pager_address, time()+365*24*60*60); 563 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 564 $var = "voicemail_email_$key"; 565 $var_cookie = "ari_" . $var; 566 setcookie("$var_cookie", $$var, time()+365*24*60*60); 567 } 568 } 569 570 // update session 571 $_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable; 572 if ($voicemail_email_enable) { 573 $_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address; 574 $_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address; 575 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 576 $option = "voicemail_email_$key"; 577 $_SESSION['ari_user']['voicemail_email'][$key] = $$option; 578 } 579 } 580 581 // save settings 582 if (!$voicemail_email_enable) { 583 $voicemail_email_address = ''; 584 $voicemail_pager_address = ''; 585 } 586 587 $lines = file($ASTERISK_VOICEMAIL_CONF); 588 foreach ($lines as $key => $line) { 589 unset($value); 590 list($var,$value) = split('=>',$line); 591 $var = trim($var); 592 if ($var==$exten && $value) { 593 594 // write out line with voicemail email change 595 $buf = split(',',$value); 596 $buf[2] = $voicemail_email_address; 597 $buf[3] = $voicemail_pager_address; 598 599 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 600 $option = "voicemail_email_$key"; 601 if ($$option && $key) { 602 $options .= $key . "=" . $value; 603 } 604 else { 605 $options .= $key . "=no"; 606 } 607 $options .= "|"; 608 } 609 $buf[4] = substr($options, 0, -1); 610 611 $line = $var . " =>" . join(',', $buf); 612 if (substr($line, 0, -1)!="\n") { 613 $line .= "\n"; 614 } 615 616 fwrite($fp, $line); 617 } 618 else { 619 620 // write out original line with no changes 621 fwrite($fp, $line); 622 } 623 } 624 fclose($fp); 625 unlink($ASTERISK_VOICEMAIL_CONF); 626 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 627 628 $voicemail_reload = 1; 629 } 630 } 631 632 // reload asterisk voicemail 633 if ($voicemail_reload) { 634 $this->reloadAsteriskVoicemail(); 635 } 636 } 637 638 // update voicemail audio format setting 639 setcookie("ari_voicemail_audio_format", $voicemail_audio_format, time()+365*24*60*60); 640 } 641 642 // update call monitor record setting 643 if ($SETTINGS_ALLOW_CALL_RECORDING_SET) { 644 if ($record_in && $record_out) { 645 $this->setRecordSettings($exten,$record_in,$record_out); 646 } 647 } 648 } 649 } 650 651 // redirect to see updated page 652 $ret .= " 653 <head> 654 <script> 655 <!-- 656 window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\" 657 // --> 658 </script> 659 </head>"; 660 661 return $ret; 366 return $ret; 662 367 } 663 368 … … 670 375 function display($args) { 671 376 672 global $STANDALONE; 673 global $ARI_ADMIN_USERNAME; 674 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 675 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; 676 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 677 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 678 global $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS; 679 global $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT; 680 global $SETTINGS_ALLOW_CALL_RECORDING_SET; 681 global $SETTINGS_PRERING_LOW; 682 global $SETTINGS_PRERING_HIGH; 683 global $SETTINGS_LISTRING_LOW; 684 global $SETTINGS_LISTRING_HIGH; 685 686 global $SETTINGS_FOLLOW_ME_LIST_MAX; 687 global $SETTINGS_ALLOW_VMX_SETTINGS; 688 689 global $loaded_modules; 690 691 // args 692 $m = getArgument($args,'m'); 693 $q = getArgument($args,'q'); 694 $start = getArgument($args,'start'); 695 $span = getArgument($args,'span'); 696 697 $displayname = $_SESSION['ari_user']['displayname']; 698 $exten = $_SESSION['ari_user']['extension']; 699 700 $language = new Language(); 701 $display = new DisplaySearch(); 702 703 // get data 704 $data = $this->getRecordSettings($_SESSION['ari_user']['extension']); 705 706 // lang setting options 707 if (extension_loaded('gettext')) { 708 $setLangText = " 709 <p class='lang'> 710 " . _("Language:") . " 711 " . $language->GetForm() . " 712 </p>"; 713 } 714 715 // build controls 716 if ($exten!=$ARI_ADMIN_USERNAME) { 717 718 // call forward settings 719 if (!$STANDALONE['use']) { 720 721 722 $call_forward_number = $this->getCallForwardNumber($exten); 723 if ($call_forward_number) { 724 $call_forward_enable = 'checked'; 725 } 726 else { 727 $call_forward_number = $_COOKIE['ari_call_forward_number']; 728 $call_forward_text_box_options = "disabled style='background: #DDD;'"; 729 } 730 731 $call_forward_busy_number = $this->getCallForwardNumber($exten, 'CFB'); 732 if ($call_forward_busy_number) { 733 $call_forward_busy_enable = 'checked'; 734 } 735 else { 736 $call_forward_busy_number = $_COOKIE['ari_call_forward_busy_number']; 737 $call_forward_busy_text_box_options = "disabled style='background: #DDD;'"; 738 } 739 740 $call_forward_unavailable_number = $this->getCallForwardNumber($exten, 'CFU'); 741 if ($call_forward_unavailable_number) { 742 $call_forward_unavailable_enable = 'checked'; 743 } 744 else { 745 $call_forward_unavailable_number = $_COOKIE['ari_call_forward_unavailable_number']; 746 $call_forward_unavailable_text_box_options = "disabled style='background: #DDD;'"; 747 } 748 749 $follow_me_prering_time = $this->getFollowMePreRingTime($exten); 750 $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 751 $follow_me_list = explode("-", $this->getFollowMeList($exten) ); 752 $follow_me_confirm = $this->getFollowMeConfirm($exten); 753 $follow_me_ddial = $this->getFollowMeDDial($exten); 754 755 $FOLLOW_ME_LIST_MAX = (count($follow_me_list) > $SETTINGS_FOLLOW_ME_LIST_MAX) ? count($follow_me_list):$SETTINGS_FOLLOW_ME_LIST_MAX; 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 384 global $SETTINGS_ALLOW_VMX_SETTINGS; 385 386 global $loaded_modules; 387 388 // args 389 $m = getArgument($args,'m'); 390 $q = getArgument($args,'q'); 391 $start = getArgument($args,'start'); 392 $span = getArgument($args,'span'); 393 394 $displayname = $_SESSION['ari_user']['displayname']; 395 $exten = $_SESSION['ari_user']['extension']; 396 397 $language = new Language(); 398 $display = new DisplaySearch(); 399 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); 756 407 757 408 //TODO: Set this better than this? 758 409 $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 759 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 760 761 $set_call_forward_text = "<table class='settings'>"; 762 763 $set_call_forward_text .= (!$SETTINGS_ALLOW_CALLFORWARD_SETTINGS)?'':" 764 <table class='settings'> 765 <tr> 766 <td><h3>" . _("Call Forwarding") . "</h3></td> 767 </tr> 768 <tr> 769 <td>" . _("Unconditional:") . "</td> 770 <td> 771 <input " . $call_forward_text_box_options . " name='call_forward_number' type='text' size=24 value='" . $call_forward_number . "'> 772 </td> 773 <td> 774 <input " . $call_forward_enable . " type=checkbox name='call_forward_enable' value='checked' OnClick=\"disable_fields(); return 775 true;\"> 776 <small>" . _("Enable") . "</small> 777 </td> 778 </tr> 779 <tr> 780 <td>" . _("Unavailable:") . "</td> 781 <td> 782 <input " . $call_forward_unavailable_text_box_options . " name='call_forward_unavailable_number' type='text' size=24 value='" . $call_forward_unavailable_number . "'> 783 </td> 784 <td> 785 <input " . $call_forward_unavailable_enable . " type=checkbox name='call_forward_unavailable_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 786 <small>" . _("Enable") . "</small> 787 </td> 788 </tr> 789 <tr> 790 <td>" . _("Busy:") . "</td> 791 <td> 792 <input " . $call_forward_busy_text_box_options . " name='call_forward_busy_number' type='text' size=24 value='" . $call_forward_busy_number . "'> 793 </td> 794 <td> 795 <input " . $call_forward_busy_enable . " type=checkbox name='call_forward_busy_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 796 <small>" . _("Enable") . "</small> 797 </td> 798 </tr> 799 800 "; 801 802 $set_call_forward_text .= ($follow_me_disabled)?'':" 803 <tr> 804 <td><h3><br>" . _("Follow Me") . "</h3></td> 805 </tr> 806 <tr> 807 <td><a href='#' class='info'>" . _("Enable") . "<span>". _(" 808 Dial-by-name Directory, IVR, and internal calls will ring the numbers in the FollowMe List. Any FreePBX routes that directly reference a FollowMe are unaffected by this enable/disable setting. 809 ") . "<br></span></a></td> 810 <td> 811 <input " . $follow_me_ddial . " type=checkbox name='follow_me_ddial' value='checked'> 812 <small>" . _("") . "</small> 813 </td> 814 </tr> 815 <tr> 816 <td><a href='#' class='info'>" . sprintf(_("Ring %s First For:"),$exten) . "<span>" .sprintf( _("Time to ring extension %s before ringing the %s Follow Me List %s"),"<strong>".$exten."</strong>","<strong>","</strong>") . 817 "<br></span></a></td> 818 <td> 819 <select " . $follow_me_prering_time_text_box_options . " name='follow_me_prering_time'/>"; 820 if (!$follow_me_disabled) { 821 $default_prering = $follow_me_prering_time; 822 for ($i=$SETTINGS_PRERING_LOW; $i <= $SETTINGS_PRERING_HIGH; $i++) { 823 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_prering ? 'SELECTED' : '').'>'.$i.'</option>'; 824 } 825 } 826 $set_call_forward_text .= ($follow_me_disabled)?'':" 827 </select> 828 <small>" . _("seconds") . "</small> 829 </td> 830 <tr> 831 <td valign='top'><a href='#' class='info'>" . _("Follow Me List:") . "<span>" . sprintf(_("Extensions and outside numbers to ring next.")) ."<br/><br/>". sprintf(_("Include %s to keep it ringing."),"<strong>".$exten."</strong>") . "<br></span></a></td> 832 <td> 833 <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> 834 </td> 835 <tr> 836 <td><a href='#' class='info'>" . _("List Ring Time:") . "<span>" . _("Time to ring the Follow Me List.") . "<br></span></a></td> 837 <td> 838 <select " . $follow_me_listring_time_text_box_options . " name='follow_me_listring_time'/>"; 839 if (!$follow_me_disabled) { 840 $default_listring = $follow_me_listring_time; 841 for ($i=$SETTINGS_LISTRING_LOW; $i <= $SETTINGS_LISTRING_HIGH; $i++) { 842 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_listring ? 'SELECTED' : '').'>'.$i.'</option>'; 843 } 844 } 845 $set_call_forward_text .= ($follow_me_disabled)?'':" 846 </select> 847 <small>" . _("seconds") . "</small> 848 </td> 849 <tr> 850 <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.") . "<br></span></a></td> 851 <td> 852 <input " . $follow_me_confirm . " type=checkbox name='follow_me_confirm' value='checked'> 853 <small>" . _("Enable") . "</small> 854 </td> 855 </tr> 856 "; 857 858 $set_call_forward_text .= " 859 </tr> 860 </table> 861 "; 410 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 411 862 412 863 413 $vmx_unavail_enabled=$this->getVmxState($exten,'unavail'); 864 414 if ($vmx_unavail_enabled === false) { 865 415 $vmx_disabled = true; 866 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60);867 $SETTINGS_ALLOW_VMX_SETTINGS=false;416 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 417 $SETTINGS_ALLOW_VMX_SETTINGS=false; 868 418 } else { 869 419 $vmx_disabled = false; 870 setcookie("ari_vmx_disabled", false, time()+365*24*60*60);420 setcookie("ari_vmx_disabled", false, time()+365*24*60*60); 871 421 $vmx_busy_enabled=$this->getVmxState($exten,'busy'); 872 422 $vmx_play_instructions=$this->getVmxPlayInstructions($exten); … … 887 437 // or otherwise blank (or garbage in which case blank it) 888 438 // 889 if (!$follow_me_disabled) {439 if (!$follow_me_disabled) { 890 440 $vmx_option_1_system_default=$this->getVmxOptionFollowMe($exten,'1'); 891 441 if ($vmx_option_1_system_default) { … … 895 445 } 896 446 } 897 $set_vmx_text .= (!$SETTINGS_ALLOW_VMX_SETTINGS)?'':"447 $set_vmx_text .= (!$SETTINGS_ALLOW_VMX_SETTINGS)?'':" 898 448 <table class='settings'> 899 <tr>900 <td><h3>" . _("Voicemail VmX Locator ") . "</h3></td>901 </tr>902 <tr>449 <tr> 450 <td><h3>" . _("Voicemail VmX Locator™") . "</h3></td> 451 </tr> 452 <tr> 903 453 <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> 904 454 <input " . $vmx_unavail_enabled . " type=checkbox name='vmx_unavail_enabled' value='checked'> … … 910 460 </td> 911 461 </tr> 912 <tr>462 <tr> 913 463 <td><a href='#' class='info'>" . _("Voicemail Instructions:") ."<span>" . _("Uncheck to play a beep after your personal voicemail greeting.") . "<br></span></a></td> 914 464 <td> … … 933 483 "; 934 484 935 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled))?'':"485 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled))?'':" 936 486 <tr> 937 487 <td> </td> … … 955 505 "; 956 506 957 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && $follow_me_disabled))?'':"507 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && $follow_me_disabled))?'':" 958 508 <tr> 959 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> … … 974 524 } 975 525 976 // voicemail settings977 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1 &&978 in_array('voicemail',array_keys($loaded_modules))) {979 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) {980 981 if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) {982 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH);983 }984 else {985 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH);986 }987 988 $set_voicemail_password_text = "989 <tr>990 <td>" . _("Voicemail Password:") . "</td>991 <td>992 <input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . ">993 </td>994 </tr>995 <tr>996 <td>" . _("Enter again to confirm:") . "</td>997 <td>998 <input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . ">999 </td>1000 </tr>1001 <tr>1002 <td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td>1003 </tr>";1004 }1005 1006 if (isset($_SESSION['ari_user']['voicemail_email'])) {1007 1008 if ($_SESSION['ari_user']['voicemail_email_enable']) {1009 $voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address'];1010 $voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address'];1011 $voicemail_email_enable = 'checked';1012 1013 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) {1014 $var = "voicemail_email_$key";1015 $var_enable = $var . "enable";1016 if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') {1017 $$var_enable = 'checked';1018 }1019 }1020 }1021 else {1022 1023 $voicemail_email_address = $_COOKIE['ari_voicemail_email_address'];1024 $voicemail_email_text_box_options = "disabled style='background: #DDD;'";1025 $voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address'];1026 $voicemail_pager_text_box_options = "disabled style='background: #DDD;'";1027 1028 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) {1029 $var = "voicemail_email_$key";1030 $var_cookie = "ari_" . $var;1031 $var_enable = $var . "enable";1032 $var_text_box_options = $var . "text_box_options";1033 1034 $$var_text_box_options = "disabled";1035 if ($_COOKIE[$var_cookie]=='yes') {1036 $$var_enable = 'checked';1037 }1038 }1039 }1040 1041 $set_voicemail_email_text = "1042 1043 <tr>1044 <td> " . _("Email Notification") . " <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\">1045 <small> " ._("Enable") . " </small>1046 </td>1047 </tr><tr>1048 <td><a href='#' class='info'>" . _("Email Voicemail To:") . "<span>" . ("Email a notification, including audio file if indicated below.") . " </span></a></td>1049 <td>1050 <input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'>1051 </td>1052 </tr>1053 <tr>1054 <td><a href='#' class='info'>" . _("Pager Email Notification To:") . "<span>" . ("Email a short notification") . " </span></a></td>1055 <td>1056 <input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'>1057 </td>1058 </tr>1059 <tr>1060 <td></td>1061 </tr>";1062 1063 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) {1064 1065 $var = "voicemail_email_$key";1066 $var_enable = $var . "enable";1067 $var_text_box_options = $var . "text_box_options";1068 if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) {1069 $var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key];1070 }1071 else {1072 $var_text = $key;1073 }1074 1075 if ($value != 'yes' && $value != 'no' && $value !='') {1076 1077 $size = strlen($value) - 1;1078 $set_voicemail_email_text .= "1079 <tr>1080 <td></td>1081 <td>1082 <input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "' OnClick=\"disable_fields(); return true;\">1083 <small>" . $var_text . "</small>1084 </td>1085 </tr>";1086 }1087 else {1088 1089 $set_voicemail_email_text .= "1090 <tr>1091 <td></td>1092 <td>1093 <input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "' value='yes' OnClick=\"disable_fields(); return true;\">1094 <small>" . $var_text . "</small>1095 </td>1096 </tr>";1097 }1098 }1099 }1100 1101 $wav_enable = 'selected';1102 if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'||1103 ($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) {1104 $wav_enable = '';1105 $gsm_enable = 'selected';1106 }1107 1108 $set_voicemail_audio_format_text = "1109 <tr>1110 <td>" . _("Audio Format:") . "</td>1111 <td>1112 <select name='voicemail_audio_format'>1113 <option value='.wav' " . $wav_enable . ">" . _("Best Quality") . " (.wav)</option>1114 <option value='.gsm' " . $gsm_enable . ">" . _("Smallest Download") . " (.gsm)</option>1115 </select>1116 </td>1117 </tr>";1118 1119 $set_voicemail_text = "1120 <table class='settings'>1121 <tr>1122 <td><h3>" . _("Voicemail Settings") . "</h3></td>1123 </tr>1124 " . $set_voicemail_password_text . "1125 " . $set_voicemail_email_text . "1126 " . $set_voicemail_audio_format_text . "1127 </table>";1128 }1129 1130 // call monitor settings1131 if ($this->getFreePBXVersion() &&1132 $SETTINGS_ALLOW_CALL_RECORDING_SET &&1133 in_array('callmonitor',array_keys($loaded_modules))) {1134 1135 foreach($data as $key=>$value) {1136 if ($key=='record_in') {1137 if ($value=='Always') {1138 $ri_always = 'checked=checked';1139 }1140 elseif ($value=='Never') {1141 $ri_never = 'checked=checked';1142 }1143 elseif ($value=='Adhoc') {1144 $ri_on_demand = 'checked=checked';1145 }1146 }1147 if ($key=='record_out') {1148 if ($value=='Always') {1149 $ro_always = 'checked=checked';1150 }1151 elseif ($value=='Never') {1152 $ro_never = 'checked=checked';1153 }1154 elseif ($value=='Adhoc') {1155 $ro_on_demand = 'checked=checked';1156 }1157 }1158 }1159 1160 $set_callmonitor_text = "1161 <table class='settings'>1162 <tr>1163 <td><h3>" . _("Call Monitor Settings") . "</h3></td>1164 </tr>1165 <tr>1166 <td>" . _("Record INCOMING:") . " </td>1167 <td>1168 <input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . "1169 <input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . "1170 <input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . "1171 </td>1172 </tr>1173 <tr>1174 <td>" . _("Record OUTGOING:") . " </td>1175 <td>1176 <input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . "1177 <input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . "1178 <input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . "1179 </td>1180 </tr>1181 </table>";1182 }1183 526 } 1184 527 … … 1194 537 } 1195 538 1196 $js_voicemail_script = " 1197 if (document.ari_settings.voicemail_email_enable.checked) { 1198 document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; 1199 document.ari_settings.voicemail_email_address.disabled = false; 1200 document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; 1201 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; 1202 document.ari_settings.voicemail_pager_address.disabled = false; 1203 document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; 1204 " . $js_voicemail_email_disable . " 1205 } 1206 else { 1207 document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; 1208 document.ari_settings.voicemail_email_address.disabled = true; 1209 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; 1210 document.ari_settings.voicemail_pager_address.disabled = true; 1211 " . $js_voicemail_email_enable . " 1212 }"; 539 $js_voicemail_script = ""; 1213 540 } 1214 541 … … 1217 544 1218 545 if ($_SESSION['ari_user']['admin_settings']) { 1219 $headerText = _(" Settings");546 $headerText = _("VmX Locator™ Settings"); 1220 547 } else { 1221 $headerText = sprintf(_(" Settings for %s (%s)"),$displayname,$exten);548 $headerText = sprintf(_("VmX Locator™ Settings for %s (%s)"),$displayname,$exten); 1222 549 } 1223 550 … … 1237 564 1238 565 function disable_fields() {"; 1239 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS) {1240 $ret .= "1241 if (document.ari_settings.call_forward_enable.checked) {1242 document.ari_settings.call_forward_number.style.backgroundColor = '#FFF';1243 document.ari_settings.call_forward_number.disabled = false;1244 }1245 else {1246 document.ari_settings.call_forward_number.style.backgroundColor = '#DDD';1247 document.ari_settings.call_forward_number.disabled = true;1248 }1249 1250 if (document.ari_settings.call_forward_busy_enable.checked) {1251 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#FFF';1252 document.ari_settings.call_forward_busy_number.disabled = false;1253 }1254 else {1255 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#DDD';1256 document.ari_settings.call_forward_busy_number.disabled = true;1257 }1258 1259 if (document.ari_settings.call_forward_unavailable_enable.checked) {1260 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#FFF';1261 document.ari_settings.call_forward_unavailable_number.disabled = false;1262 }1263 else {1264 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#DDD';1265 document.ari_settings.call_forward_unavailable_number.disabled = true;1266 }";1267 }1268 566 if ($SETTINGS_ALLOW_VMX_SETTINGS) { 1269 567 $ret .= " … … 1289 587 } 1290 588 $ret .= $js_voicemail_script . " 1291 } 1292 // End --> 1293 </script>"; 1294 1295 $ret .= " 1296 " . $setLangText . " 1297 <form class='settings' name='ari_settings' action='' method='GET'> 1298 <input type=hidden name=m value=" . $m . "> 1299 <input type=hidden name=f value='action'> 1300 <input type=hidden name=a value='update'> 1301 <br> 1302 " . $set_call_forward_text . " 1303 <br> 1304 " . $set_vmx_text . " 1305 <br> 1306 " . $set_voicemail_text . " 1307 <br> 1308 " . $set_callmonitor_text . " 1309 <br> 1310 <input name='submit' type='submit' value='" . _("Update") . "'> 1311 </form>"; 1312 1313 return $ret; 1314 } 1315 1316 /* 1317 * Sets Asterisk call forward setting 1318 * 1319 * @param $exten 1320 * Extension to modify 1321 * @param $state 1322 * Call forward enable or disable 1323 * @param $call_forward_number 1324 * Call forward number 1325 * @param $variable_opt 1326 * Call forward type (CF, CFU, CFB) 1327 */ 1328 function setCallForward($exten,$state,$call_forward_number, $variable_opt = "CF") { 1329 1330 global $asterisk_manager_interface; 1331 1332 if ($state) { 1333 $type_opt = "put"; 1334 $value_opt = $call_forward_number; 1335 } 1336 else { 1337 $type_opt = "del"; 1338 } 1339 1340 //$variable_opt = "CF"; 1341 1342 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt $variable_opt $exten $value_opt\r\n\r\n"); 1343 } 1344 1345 /* 1346 * Gets call forward number if set 1347 * 1348 * @param $exten 1349 * Extension to get information about 1350 * @return $number 1351 * call forward number returned if set 1352 * @param $variable_opt 1353 * Call forward type (CF, CFU, CFB) 1354 */ 1355 function getCallForwardNumber($exten, $variable_opt = "CF") { 1356 1357 global $asterisk_manager_interface; 1358 1359 $number = ''; 1360 1361 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get $variable_opt $exten\r\n\r\n"); 1362 if (is_numeric($response)) { 1363 $number = $response; 1364 } 1365 1366 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 1367 if ($stripped==$number) { 1368 $number = $_COOKIE['ari_call_forward_number']; 1369 } 1370 1371 return $number; 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 . " 600 <br> 601 <input name='submit' type='submit' value='" . _("Update") . "'> 602 </form>"; 603 604 return $ret; 1372 605 } 1373 606 … … 1380 613 * Option number to get 1381 614 * @param $mode 1382 * Mode to get (unavail/busy)615 * Mode to get (unavail/busy) 1383 616 * @return $response 1384 617 * checked if set to got to extesion's follow-me on this option … … 1386 619 function getVmxOptionFollowMe($exten, $digit, $mode='unavail') { 1387 620 1388 global $asterisk_manager_interface;621 global $asterisk_manager_interface; 1389 622 1390 623 $digit = trim($digit); 1391 624 1392 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n");1393 return (($response == 'FM'.$exten) ? 'checked':'');625 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n"); 626 return (($response == 'FM'.$exten) ? 'checked':''); 1394 627 } 1395 628 … … 1402 635 * Option number to set 1403 636 * @param $mode 1404 * Mode to set (unavail/busy)637 * Mode to set (unavail/busy) 1405 638 * @param $context 1406 * Context to set ext to (default from-findmefollow)639 * Context to set ext to (default from-findmefollow) 1407 640 * @param $priority 1408 * Priority to set ext to (default 1)641 * Priority to set ext to (default 1) 1409 642 */ 1410 643 function setVmxOptionFollowMe($exten, $digit, $mode, $context='ext-findmefollow', $priority='1') { 1411 644 1412 global $asterisk_manager_interface;1413 1414 $value_opt = "FM$exten";1415 1416 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n");1417 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n");1418 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n");645 global $asterisk_manager_interface; 646 647 $value_opt = "FM$exten"; 648 649 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n"); 650 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n"); 651 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n"); 1419 652 } 1420 653 … … 1427 660 * Option number to get 1428 661 * @param $mode 1429 * Mode to get (unavail/busy)662 * Mode to get (unavail/busy) 1430 663 * @return $number 1431 664 * Number to use or blank if disabled … … 1433 666 function getVmxOptionNumber($exten, $digit, $mode='unavail') { 1434 667 1435 global $asterisk_manager_interface;1436 1437 $number = '';668 global $asterisk_manager_interface; 669 670 $number = ''; 1438 671 $digit = trim($digit); 1439 672 1440 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n");1441 if (is_numeric($response)) {1442 $number = $response;1443 }1444 1445 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE["ari_vmx_option_${digit}_number"]);1446 if ($stripped==$number) {1447 $number = $_COOKIE["ari_vmx_option_${digit}_number"];1448 }1449 1450 return $number;673 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n"); 674 if (is_numeric($response)) { 675 $number = $response; 676 } 677 678 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE["ari_vmx_option_${digit}_number"]); 679 if ($stripped==$number) { 680 $number = $_COOKIE["ari_vmx_option_${digit}_number"]; 681 } 682 683 return $number; 1451 684 } 1452 685 … … 1459 692 * Option number to set 1460 693 * @param $mode 1461 * Mode to set (unavail/busy)694 * Mode to set (unavail/busy) 1462 695 * @param $number 1463 * Number to set ext to (blank will delete it)696 * Number to set ext to (blank will delete it) 1464 697 * @param $context 1465 * Context to set ext to (default from-internal)698 * Context to set ext to (default from-internal) 1466 699 * @param $priority 1467 * Priority to set ext to (default 1)700 * Priority to set ext to (default 1) 1468 701 */ 1469 702 function setVmxOptionNumber($exten, $digit, $mode, $number, $context='from-internal', $priority='1') { 1470 703 1471 global $asterisk_manager_interface;1472 1473 $value_opt = trim($number);704 global $asterisk_manager_interface; 705 706 $value_opt = trim($number); 1474 707 1475 708 if (is_numeric($value_opt)) { 1476 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n");1477 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n");1478 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n");709 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n"); 710 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n"); 711 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n"); 1479 712 } else { 1480 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database deltree AMPUSER $exten/vmx/$mode/$digit\r\n\r\n");713 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database deltree AMPUSER $exten/vmx/$mode/$digit\r\n\r\n"); 1481 714 } 1482 715 } … … 1488 721 * Extension to modify 1489 722 * @param $mode 1490 * Mode to set (unavail/busy)723 * Mode to set (unavail/busy) 1491 724 * @param $vmx_state 1492 725 * enabled/disabled state based on check box value … … 1494 727 function setVmxState($exten,$mode,$vmx_state) { 1495 728 1496 global $asterisk_manager_interface;1497 1498 $value_opt = ($vmx_state)?'enabled':'disabled';1499 1500 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/state $value_opt\r\n\r\n");729 global $asterisk_manager_interface; 730 731 $value_opt = ($vmx_state)?'enabled':'disabled'; 732 733 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/state $value_opt\r\n\r\n"); 1501 734 } 1502 735 … … 1507 740 * Extension to get information about 1508 741 * @param $mode 1509 * Mode to get (unavail/busy)742 * Mode to get (unavail/busy) 1510 743 * @return $data 1511 744 * state of variable (checked/blank) or false if no poper value … … 1513 746 function getVmxState($exten, $mode='unavail') { 1514 747 1515 global $asterisk_manager_interface;1516 1517 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/state\r\n\r\n");1518 1519 if (preg_match("/enabled/",$response)) {748 global $asterisk_manager_interface; 749 750 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/state\r\n\r\n"); 751 752 if (preg_match("/enabled/",$response)) { 1520 753 $response='checked'; 1521 }1522 elseif (preg_match("/disabled/",$response)) {754 } 755 elseif (preg_match("/disabled/",$response)) { 1523 756 $response=''; 1524 }757 } 1525 758 else { 1526 759 $response = false; 1527 760 } 1528 761 1529 //TODO: really need to check for a bogus response, see how other side does it1530 //1531 return $response;762 //TODO: really need to check for a bogus response, see how other side does it 763 // 764 return $response; 1532 765 1533 766 } … … 1541 774 * play instructions or just beep (checked, blank) 1542 775 * @param $mode 1543 * Mode to set (unavail/busy)776 * Mode to set (unavail/busy) 1544 777 */ 1545 778 function setVmxPlayInstructions($exten,$mode,$vmx_play_instructions) { 1546 779 1547 global $asterisk_manager_interface;1548 1549 $value_opt = ($vmx_play_instructions)?'""':'s';1550 1551 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/vmxopts/timeout $value_opt\r\n\r\n");780 global $asterisk_manager_interface; 781 782 $value_opt = ($vmx_play_instructions)?'""':'s'; 783 784 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/vmxopts/timeout $value_opt\r\n\r\n"); 1552 785 } 1553 786 … … 1558 791 * Extension to get information about 1559 792 * @param $mode 1560 * Mode to get (unavail/busy)793 * Mode to get (unavail/busy) 1561 794 * @return $data 1562 795 * state of variable (checked/blank) or false if no poper value … … 1564 797 function getVmxPlayInstructions($exten, $mode='unavail') { 1565 798 1566 global $asterisk_manager_interface;1567 1568 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/vmxopts/timeout\r\n\r\n");1569 1570 if (preg_match("/s/",$response)) {799 global $asterisk_manager_interface; 800 801 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/vmxopts/timeout\r\n\r\n"); 802 803 if (preg_match("/s/",$response)) { 1571 804 $response=''; 1572 }805 } 1573 806 else { 1574 807 $response='checked'; 1575 808 } 1576 809 1577 //TODO: really need to check for a bogus response, see how other side does it1578 //1579 return $response;810 //TODO: really need to check for a bogus response, see how other side does it 811 // 812 return $response; 1580 813 1581 814 } … … 1589 822 * Pre-Ring Time to ring 1590 823 */ 1591 function setFollowMePreRingTime($exten,$follow_me_prering_time) { 1592 1593 global $asterisk_manager_interface; 1594 1595 $value_opt = $follow_me_prering_time; 1596 1597 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/prering $value_opt\r\n\r\n"); 1598 } 1599 1600 /* 1601 * Gets Follow Me Pre-Ring Time if set 1602 * 1603 * @param $exten 1604 * Extension to get information about 1605 * @return $number 1606 * follow me pre-ring time returned if set 1607 */ 1608 function getFollowMePreRingTime($exten) { 1609 1610 global $asterisk_manager_interface; 1611 1612 $number = ''; 1613 1614 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/prering\r\n\r\n"); 1615 if (is_numeric($response)) { 1616 $number = $response; 1617 } 1618 1619 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_prering_time']); 1620 if ($stripped==$number) { 1621 $number = $_COOKIE['ari_follow_me_prering_time']; 1622 } 1623 1624 return $number; 1625 } 1626 1627 /* 1628 * Sets Follow Me List Ring Time 1629 * 1630 * @param $exten 1631 * Extension to modify 1632 * @param $follow_me_listring_time 1633 * List Ring Time to ring 1634 */ 1635 function setFollowMeListRingTime($exten,$follow_me_listring_time) { 1636 1637 global $asterisk_manager_interface; 1638 1639 $value_opt = $follow_me_listring_time; 1640 1641 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grptime $value_opt\r\n\r\n"); 1642 } 824 825 1643 826 1644 827 /* … … 1652 835 function getFollowMeListRingTime($exten) { 1653 836 1654 global $asterisk_manager_interface; 1655 1656 $number = ''; 1657 1658 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grptime\r\n\r\n"); 1659 if (is_numeric($response)) { 1660 $number = $response; 1661 } 1662 1663 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_listring_time']); 1664 if ($stripped==$number) { 1665 $number = $_COOKIE['ari_follow_me_listring_time']; 1666 } 1667 1668 return $number; 1669 } 1670 1671 /* 1672 * Sets Follow Me List 1673 * 1674 * @param $exten 1675 * Extension to modify 1676 * @param $follow_me_list 1677 * Follow Me List 1678 */ 1679 function setFollowMeList($exten,$follow_me_list) { 1680 1681 global $asterisk_manager_interface; 1682 1683 $value_opt = $follow_me_list; 1684 1685 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grplist $value_opt\r\n\r\n"); 1686 } 1687 1688 /* 1689 * Gets Follow Me List if set 1690 * 1691 * @param $exten 1692 * Extension to get information about 1693 * @return $data 1694 * follow me list if set 1695 */ 1696 function getFollowMeList($exten) { 1697 1698 global $asterisk_manager_interface; 1699 1700 $number = ''; 1701 1702 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grplist\r\n\r\n"); 1703 1704 //TODO: really need to check for a bogus response, see how other side does it 1705 // 1706 return preg_replace("/[^0-9*\-]/", "", $response); 1707 } 1708 1709 /* 1710 * Sets Follow Confirmation Setting 1711 * 1712 * @param $exten 1713 * Extension to modify 1714 * @param $follow_me_cofirm 1715 * Follow Me Confirm Setting 1716 */ 1717 function setFollowMeConfirm($exten,$follow_me_confirm) { 1718 1719 global $asterisk_manager_interface; 1720 1721 $value_opt = ($follow_me_confirm)?'ENABLED':'DISABLED'; 1722 1723 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grpconf $value_opt\r\n\r\n"); 1724 } 1725 1726 /* 1727 * Gets Follow Me Confirmation Setting 1728 * 1729 * @param $exten 1730 * Extension to get information about 1731 * @return $data 1732 * follow me confirm setting 1733 */ 1734 function getFollowMeConfirm($exten) { 1735 1736 global $asterisk_manager_interface; 1737 1738 $number = ''; 1739 1740 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grpconf\r\n\r\n"); 1741 1742 if (preg_match("/ENABLED/",$response)) { 1743 $response='checked'; 1744 } 1745 else { 1746 $response=''; 1747 } 1748 1749 //TODO: really need to check for a bogus response, see how other side does it 1750 // 1751 return $response; 1752 1753 } 1754 1755 /* 1756 * Sets Follow Ddial Setting 1757 * 1758 * @param $exten 1759 * Extension to modify 1760 * @param $follow_me_ddial 1761 * Follow Me Ddial Setting 1762 */ 1763 function setFollowMeDDial($exten,$follow_me_ddial) { 1764 1765 global $asterisk_manager_interface; 1766 1767 $value_opt = ($follow_me_ddial)?'DIRECT':'EXTENSION'; 1768 1769 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/ddial $value_opt\r\n\r\n"); 1770 } 1771 1772 /* 1773 * Gets Follow Me Ddial Setting 1774 * 1775 * @param $exten 1776 * Extension to get information about 1777 * @return $data 1778 * follow me ddial setting 1779 */ 1780 function getFollowMeDDial($exten) { 1781 1782 global $asterisk_manager_interface; 1783 1784 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/ddial\r\n\r\n"); 1785 1786 if (preg_match("/EXTENSION/",$response)) { 1787 $response=''; 1788 } 1789 else { 1790 $response='checked'; 1791 } 1792 1793 //TODO: really need to check for a bogus response, see how other side does it 1794 // 1795 return $response; 1796 1797 } 1798 1799 1800 1801 1802 /* 1803 * Sets Asterisk call recording setting 1804 * 1805 * @param $exten 1806 * Extension to modify 1807 * @param $direction 1808 * Call direction 1809 * @param $state 1810 * State to set to 1811 */ 1812 function setRecordSettings($exten,$state_in,$state_out) { 1813 1814 global $asterisk_manager_interface; 1815 1816 if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { 1817 1818 if ($state_in=="Always") { 1819 $type_opt = "put"; 1820 $value_opt = " " . "ENABLED"; 1821 } 1822 elseif ($state_in=="Never") { 1823 $type_opt = "put"; 1824 $value_opt = " " . "DISABLED"; 1825 } 1826 else { 1827 $type_opt = "del"; 1828 $value_opt = ""; 1829 } 1830 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-IN $exten $value_opt\r\n\r\n"); 1831 1832 if ($state_out=="Always") { 1833 $type_opt = "put"; 1834 $value_opt = " " . "ENABLED"; 1835 } 1836 elseif ($state_out=="Never") { 1837 $type_opt = "put"; 1838 $value_opt = " " . "DISABLED"; 1839 } 1840 else { 1841 $type_opt = "del"; 1842 $value_opt = ""; 1843 } 1844 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-OUT $exten $value_opt\r\n\r\n"); 1845 } 1846 else { 1847 1848 $value_opt= "out=".$state_out."|in=".$state_in; 1849 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/recording $value_opt\r\n\r\n"); 1850 } 1851 } 1852 1853 /* 1854 * Gets record settings for a protocol 1855 * 1856 * @param $table 1857 * Table to pull information from 1858 * @param $exten 1859 * Extension to get information about 1860 * @return $data 1861 * call monitor record settings 1862 */ 1863 function getProtocolRecordSettings($table,$exten) { 1864 1865 global $asterisk_manager_interface; 1866 1867 $data = array(); 1868 1869 if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { 1870 1871 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-IN $exten\r\n\r\n"); 1872 if (preg_match("/ENABLED/",$response)) { 1873 $data['record_in'] = 'Always'; 1874 } 1875 elseif (preg_match("/DISABLED/",$response)) { 1876 $data['record_in'] = 'Never'; 1877 } 1878 else { 1879 $data['record_in'] = 'Adhoc'; 1880 } 1881 1882 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-OUT $exten\r\n\r\n"); 1883 if (preg_match("/ENABLED/",$response)) { 1884 $data['record_out'] = 'Always'; 1885 } 1886 elseif (preg_match("/DISABLED/",$response)) { 1887 $data['record_out'] = 'Never'; 1888 } 1889 else { 1890 $data['record_out'] = 'Adhoc'; 1891 } 1892 } 1893 else { 1894 1895 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/recording\r\n\r\n"); 1896 if (strstr($response,"in=Always")) { 1897 $data['record_in'] = 'Always'; 1898 } 1899 elseif (strstr($response,"in=Never")) { 1900 $data['record_in'] = 'Never'; 1901 } 1902 else { 1903 $data['record_in'] = 'Adhoc'; 1904 } 1905 if (strstr($response,"out=Always")) { 1906 $data['record_out'] = 'Always'; 1907 } 1908 elseif (strstr($response,"out=Never")) { 1909 $data['record_out'] = 'Never'; 1910 } 1911 else { 1912 $data['record_out'] = 'Adhoc'; 1913 } 1914 } 1915 1916 return $data; 1917 } 1918 1919 /* 1920 * Gets record settings 1921 * 1922 * @param $exten 1923 * Extension to get information about 1924 * @param $data 1925 * Reference to the variable to store the data in 1926 */ 1927 function getRecordSettings($exten) { 1928 1929 // check protocol tables first 1930 $data = $this->getProtocolRecordSettings($this->protocol_table,$exten); 1931 1932 return $data; 1933 } 1934 1935 /* 1936 * Reloads Asterisk Configuration 1937 */ 1938 function reloadAsteriskVoicemail() { 1939 1940 global $asterisk_manager_interface; 1941 1942 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: Reload app_voicemail.so\r\n\r\n"); 1943 } 1944 1945 /* 1946 * Gets FreePBX Version 1947 */ 1948 function getFreePBXVersion() { 1949 1950 if (isset($_SESSION['dbh_asterisk'])) { 1951 $sql = "SELECT * FROM admin WHERE variable = 'version'"; 1952 $results = $_SESSION['dbh_asterisk']->getAll($sql); 1953 if(DB::IsError($results)) { 1954 $_SESSION['ari_error'] = $results->getMessage(); 1955 } 1956 1957 return $results[0][1]; 1958 } 837 global $asterisk_manager_interface; 838 839 $number = ''; 840 841 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grptime\r\n\r\n"); 842 if (is_numeric($response)) { 843 $number = $response; 844 } 845 846 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_listring_time']); 847 if ($stripped==$number) { 848 $number = $_COOKIE['ari_follow_me_listring_time']; 849 } 850 851 return $number; 1959 852 } 1960 853 … … 1976 869 function setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm) { 1977 870 1978 if (isset($_SESSION['dbh_asterisk'])) {1979 1980 //format for SQL database1981 $follow_me_confirm = ($follow_me_confirm)?'CHECKED':'';1982 1983 $sql = "UPDATE findmefollow SET grptime = '" . $follow_me_listring_time . "', grplist = '".1984 str_replace("'", "''", trim($follow_me_list)) . "', pre_ring = '" . $follow_me_prering_time .1985 "', needsconf = '" . $follow_me_confirm . "' WHERE grpnum = $exten LIMIT 1";1986 $results = $_SESSION['dbh_asterisk']->query($sql);1987 1988 if(DB::IsError($results)) {1989 $_SESSION['ari_error'] = $results->getMessage();1990 }1991 1992 return 1;1993 }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 } 1994 887 } 1995 888 1996 889 function lookupSetExtensionFormat($exten) { 1997 890 1998 if (trim($exten) == "") return $exten;1999 2000 $exten = preg_replace("/[^0-9*]/", "", $exten);2001 2002 $sql = "SELECT extension FROM users WHERE extension = '".$exten."'";2003 $asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC);2004 if (!is_array($asa)) {2005 return $exten.'#';2006 } else {2007 return $exten;2008 }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 } 2009 902 } 2010 903 freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/callmonitor.module
r3996 r4328 35 35 36 36 $ret .= " 37 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small></p> ";37 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Callmonitor&f=display'>" . _("Call Monitor") . "</a></small></small></p><br>"; 38 38 39 39 return $ret; … … 86 86 </script> 87 87 </head>"; 88 89 echo $ret; 88 90 89 91 return $ret; … … 250 252 // ajax page refresh script 251 253 if ($AJAX_PAGE_REFRESH_ENABLE) { 252 $ret .= ajaxRefreshScript($args);254 // $ret .= ajaxRefreshScript($args); 253 255 } 254 256 freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/featurecodes.module
r3629 r4328 9 9 * Class for help 10 10 */ 11 class Help{11 class featurecodes { 12 12 13 13 /* … … 16 16 function rank() { 17 17 18 $rank = 4;18 $rank = 7; 19 19 return $rank; 20 20 } … … 37 37 $ret .= " 38 38 <?php if ($logout !='') { ?> 39 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m= Help&f=display'>" . _("Help") . "</a></small></small></p>39 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=featurecodes&f=display'>" . _("Feature Codes") . "</a></small></small></p><br> 40 40 <?php } ?>"; 41 41 … … 66 66 67 67 if ($_SESSION['ari_user']['admin_help']) { 68 $header_text = _(" Help");68 $header_text = _("Feature Codes"); 69 69 } else { 70 $header_text = sprintf(_(" Helpfor %s (%s)"),$displayname,$extension);70 $header_text = sprintf(_("Feature Codes for %s (%s)"),$displayname,$extension); 71 71 } 72 72 freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/followme.module
r4170 r4328 7 7 8 8 /** 9 * Class for settings9 * Class for Followme 10 10 */ 11 class Settings{11 class followme { 12 12 13 13 var $protocol_table; … … 19 19 function rank() { 20 20 21 $rank = 100000;22 return $rank;21 $rank = 5; 22 return $rank; 23 23 } 24 24 … … 28 28 function init() { 29 29 30 // determine what protocol user is using31 global $ASTERISK_PROTOCOLS;32 33 foreach ($ASTERISK_PROTOCOLS as $protocol => $value) {34 $data = $this->getProtocolRecordSettings($value['table'],$_SESSION['ari_user']['extension']);35 if (count($data)) {36 $this->protocol_table = $value['table'];37 $this->protocol_config_files = $value['config_files'];38 break;39 }40 }41 30 } 42 31 … … 49 38 function navMenu($args) { 50 39 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 <br> 61 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p>"; 62 } 63 64 return $ret; 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>"; 50 51 return $ret; 65 52 } 66 53 … … 75 62 function action($args) { 76 63 77 global $STANDALONE; 78 global $ARI_ADMIN_USERNAME; 79 global $ASTERISK_VOICEMAIL_CONF; 80 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 81 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; 82 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 83 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 84 global $SETTINGS_VOICEMAIL_PASSWORD_EXACT; 85 global $SETTINGS_ALLOW_CALL_RECORDING_SET; 86 global $SETTINGS_ALLOW_VMX_SETTINGS; 87 88 // args 89 $m = getArgument($args,'m'); 90 $a = getArgument($args,'a'); 91 92 $lang_code = getArgument($args,'lang_code'); 93 94 $call_forward_enable = getArgument($args,'call_forward_enable'); 95 $call_forward_number = getArgument($args,'call_forward_number'); 96 97 $call_forward_busy_enable = getArgument($args,'call_forward_busy_enable'); 98 $call_forward_busy_number = getArgument($args,'call_forward_busy_number'); 99 100 $call_forward_unavailable_enable = getArgument($args,'call_forward_unavailable_enable'); 101 $call_forward_unavailable_number = getArgument($args,'call_forward_unavailable_number'); 102 103 $follow_me_prering_time = getArgument($args,'follow_me_prering_time'); 104 $follow_me_listring_time = getArgument($args,'follow_me_listring_time'); 105 $follow_me_list = getArgument($args,'follow_me_list'); 106 $follow_me_confirm = getArgument($args,'follow_me_confirm'); 107 $follow_me_ddial = getArgument($args,'follow_me_ddial'); 108 $follow_me_disabled = getArgument($args,'follow_me_disabled'); 109 110 $vmx_option_0_number = getArgument($args, 'vmx_option_0_number'); 111 $vmx_option_0_system_default = getArgument($args, 'vmx_option_0_system_default'); 112 $vmx_option_1_number = getArgument($args, 'vmx_option_1_number'); 113 $vmx_option_1_system_default = getArgument($args, 'vmx_option_1_system_default'); 114 $vmx_option_2_number = getArgument($args, 'vmx_option_2_number'); 115 $vmx_unavail_enabled = getArgument($args, 'vmx_unavail_enabled'); 116 $vmx_busy_enabled = getArgument($args, 'vmx_busy_enabled'); 117 $vmx_play_instructions = getArgument($args, 'vmx_play_instructions'); 118 $vmx_disabled = getArgument($args,'vmx_disabled'); 119 120 $voicemail_password = getArgument($args,'voicemail_password'); 121 $voicemail_password_confirm = getArgument($args,'voicemail_password_confirm'); 122 $voicemail_email_address = getArgument($args,'voicemail_email_address'); 123 $voicemail_pager_address = getArgument($args,'voicemail_pager_address'); 124 $voicemail_email_enable = getArgument($args,'voicemail_email_enable'); 125 126 if (isset($_SESSION['ari_user']['voicemail_email'])) { 127 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 128 $var = "voicemail_email_$key"; 129 $$var = getArgument($args,$var); 130 } 131 } 132 133 $voicemail_audio_format = getArgument($args,'voicemail_audio_format'); 134 135 $record_in = getArgument($args,'record_in'); 136 $record_out = getArgument($args,'record_out'); 137 138 $language = new Language(); 139 140 if ($a=='update') { 141 142 $exten = $_SESSION['ari_user']['extension']; 143 if ($exten!=$ARI_ADMIN_USERNAME) { 144 145 // update call forward number 146 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS && !$STANDALONE['use']) { 147 148 // normal call forward 149 $stripped_call_forward_number = preg_replace('/-|\(|\)|\s/','',$call_forward_number); 150 if ($call_forward_enable && !is_numeric($stripped_call_forward_number)) { 151 $_SESSION['ari_error'] = 152 _("Call forward number not changed") . "<br>" . 153 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_number); 154 } 155 else { 156 157 // set database 158 $this->setCallForward($exten,$call_forward_enable,$stripped_call_forward_number); 159 160 // store cookie 161 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 162 if ($call_forward_number && $stripped!=$stripped_call_forward_number) { 163 setcookie("ari_call_forward_number", $call_forward_number, time()+365*24*60*60); 164 } 165 } 166 167 // call forward busy 168 $stripped_call_forward_busy_number = preg_replace('/-|\(|\)|\s/','',$call_forward_busy_number); 169 if ($call_forward_busy_enable && !is_numeric($stripped_call_forward_busy_number)) { 170 $_SESSION['ari_error'] = 171 _("Call forward number not changed") . "<br>" . 172 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_busy_number); 173 } 174 else { 175 176 // set database 177 $this->setCallForward($exten,$call_forward_busy_enable,$stripped_call_forward_busy_number, "CFB"); 178 179 // store cookie 180 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_busy_number']); 181 if ($call_forward_busy_number && $stripped!=$stripped_call_forward_busy_number) { 182 setcookie("ari_call_forward_busy_number", $call_forward_busy_number, time()+365*24*60*60); 183 } 184 } 185 186 // call forward unavailable 187 $stripped_call_forward_unavailable_number = preg_replace('/-|\(|\)|\s/','',$call_forward_unavailable_number); 188 if ($call_forward_unavailable_enable && !is_numeric($stripped_call_forward_unavailable_number)) { 189 $_SESSION['ari_error'] = 190 _("Call forward number not changed") . "<br>" . 191 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_unavailable_number); 192 } 193 else { 194 195 // set database 196 $this->setCallForward($exten,$call_forward_unavailable_enable,$stripped_call_forward_unavailable_number, "CFU"); 197 198 // store cookie 199 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_unavailable_number']); 200 if ($call_forward_unavailable_number && $stripped!=$stripped_call_forward_unavailable_number) { 201 setcookie("ari_call_forward_unavailable_number", $call_forward_unavailable_number, time()+365*24*60*60); 202 } 203 } 204 205 } 206 207 // Make sure Follow-Me setup has not been deleted for this user since the last refresh 208 $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 209 210 if (! $_COOKIE['ari_follow_me_disabled']) { 211 212 $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1; 213 214 if ($follow_me_disabled) { 215 216 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 217 $follow_me_disabled_delayed = $follow_me_disabled; 218 $_SESSION['ari_error'] = 219 _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" . 220 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 221 } 64 global $STANDALONE; 65 global $ARI_ADMIN_USERNAME; 66 global $SETTINGS_ALLOW_VMX_SETTINGS; 67 68 // args 69 $m = getArgument($args,'m'); 70 $a = getArgument($args,'a'); 71 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'); 79 $follow_me_disabled = getArgument($args,'follow_me_disabled'); 80 81 $language = new Language(); 82 83 // Lets see if we can make heads or tails of this code?!? 84 85 // The action is 'update 86 if ($a=='update') { 87 88 // Get the extension and make sure we are not in 89 // admin mode 90 $exten = $_SESSION['ari_user']['extension']; 91 if ($exten!=$ARI_ADMIN_USERNAME) { 92 93 94 // Make sure Follow-Me setup has not been deleted for this user since the last refresh 95 $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 96 if (! $_COOKIE['ari_follow_me_disabled']) { 97 98 $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1; 99 100 if ($follow_me_disabled) { 101 102 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 103 $follow_me_disabled_delayed = $follow_me_disabled; 104 $_SESSION['ari_error'] = 105 _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" . 106 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 222 107 } 223 224 $vmx_disabled_delayed = $_COOKIE['ari_vmx_disabled']; 225 if (! $_COOKIE['ari_vmx_disabled']) { 226 227 $vmx_disabled = $this->getVmxState($exten,'unavail'); 228 if ($vmx_disabled === false) { 229 $vmx_disabled = true; 230 $SETTINGS_ALLOW_VMX_SETTINGS=false; 231 } else { 232 $vmx_disabled = false; 233 } 234 if ($vmx_disabled) { 235 236 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 237 $vmx_disabled_delayed = $vmx_disabled; 238 $_SESSION['ari_error'] = 239 _("Your Premium VmX Locator service has been disabled, REFRESH your browser to remove this message") . "<br>" . 240 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 241 } 108 } 109 110 111 112 if (! $follow_me_disabled_delayed) { 113 114 // assume no errors, don't update SQL if errors occured 115 $follow_me_update_succeeded=1; 116 117 // update follow me pre-ring time 118 if (!$STANDALONE['use']) { 119 120 $stripped_follow_me_prering_time = preg_replace('/-|\s/','',$follow_me_prering_time); 121 if (!is_numeric($stripped_follow_me_prering_time)) { 122 $_SESSION['ari_error'] = 123 _("Follow-Me pre-ring time not changed") . "<br>" . 124 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_prering_time); 125 $follow_me_update_succeeded=0; 126 } 127 else { 128 129 // set database 130 $this->setFollowMePreRingTime($exten,$stripped_follow_me_prering_time); 131 132 // store cookie 133 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_prering_time']); 134 if ($follow_me_prering_time && $stripped!=$stripped_follow_me_prering_time) { 135 setcookie("ari_follow_me_prering_time", $follow_me_prering_time, time()+365*24*60*60); 136 } 137 } 242 138 } 243 244 if (! $vmx_disabled_delayed) { 245 if (!$STANDALONE['use']) { 139 140 // update follow me list ring time 141 if (!$STANDALONE['use']) { 142 143 $stripped_follow_me_listring_time = preg_replace('/-|\s/','',$follow_me_listring_time); 144 if (!is_numeric($stripped_follow_me_listring_time)) { 145 $_SESSION['ari_error'] = 146 _("Follow-Me list ring time not changed") . "<br>" . 147 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_listring_time); 148 $follow_me_update_succeeded=0; 149 } 150 else { 151 152 // set database 153 $this->setFollowMeListRingTime($exten,$stripped_follow_me_listring_time); 154 155 // store cookie 156 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_listring_time']); 157 if ($follow_me_listring_time && $stripped!=$stripped_follow_me_listring_time) { 158 setcookie("ari_follow_me_listring_time", $follow_me_listring_time, time()+365*24*60*60); 159 } 160 } 161 } 162 163 // update follow me list 164 if (!$STANDALONE['use']) { 165 166 $grplist = explode("\n", $follow_me_list); 167 168 if (!$grplist) { 169 $grplist = null; 170 } 171 172 foreach (array_keys($grplist) as $key) { 173 //trim it 174 $grplist[$key] = trim($grplist[$key]); 175 176 // Lookup the extension and append hash if not a user, and remove invalid chars 177 $grplist[$key] = $this->lookupSetExtensionFormat($grplist[$key]); 178 179 // remove blanks 180 if ($grplist[$key] == "") unset($grplist[$key]); 181 } 182 183 // check for duplicates, and re-sequence 184 $grplist = array_values(array_unique($grplist)); 185 186 $stripped_follow_me_list = implode("-",$grplist); 187 188 if ($stripped_follow_me_list == "") { 189 $_SESSION['ari_error'] = 190 _("Follow-Me list must contain at least one valid number") . "<br>" . 191 sprintf(_("The following: %s is not valid"),$follow_me_list); 192 $follow_me_update_succeeded=0; 193 } 194 else { 195 196 // set database 197 $this->setFollowMeList($exten,$stripped_follow_me_list); 198 199 // store cookie 200 $stripped = preg_replace('/|\(|\)|\s/','',$_COOKIE['ari_follow_me_list']); 201 if ($follow_me_list && $stripped!=$stripped_follow_me_list) { 202 setcookie("ari_follow_me_list", $follow_me_list, time()+365*24*60*60); 203 } 204 } 205 } 206 207 // update follow me confirm 208 if (!$STANDALONE['use']) { 209 210 // set database 211 $this->setFollowMeConfirm($exten,$follow_me_confirm); 212 $this->setFollowMeDDial($exten,$follow_me_ddial); 213 214 // store cookie 215 setcookie("ari_follow_me_confirm", $follow_me_confirm, time()+365*24*60*60); 216 setcookie("ari_follow_me_ddial", $follow_me_ddial, time()+365*24*60*60); 217 } 218 219 //If no errors than update the SQL table to keep in sync 220 if ($follow_me_update_succeeded) { 221 $this->setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm); 222 } 223 224 } //if !follow_me_disabled 225 } 226 } 227 228 // redirect to see updated page 229 $ret .= " 230 <head> 231 <script> 232 <!-- 233 window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\" 234 // --> 235 </script> 236 </head>"; 246 237 247 // set database 248 $this->setVmxState($exten,'unavail',$vmx_unavail_enabled); 249 $this->setVmxState($exten,'busy',$vmx_busy_enabled); 250 $this->setVmxPlayInstructions($exten,'unavail',$vmx_play_instructions); 251 $this->setVmxPlayInstructions($exten,'busy',$vmx_play_instructions); 252 253 // store cookie 254 setcookie("ari_vmx_unavail_enabled", $vmx_unavail_enabled, time()+365*24*60*60); 255 setcookie("ari_vmx_busy_enabled", $vmx_busy_enabled, time()+365*24*60*60); 256 setcookie("ari_vmx_play_instructions", $vmx_play_instructions, time()+365*24*60*60); 257 258 $stripped_vmx_option_0_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_0_number); 259 if ($vmx_option_0_system_default) { 260 $this->setVmxOptionNumber($exten,'0','unavail',""); 261 $this->setVmxOptionNumber($exten,'0','busy',""); 262 setcookie("ari_vmx_option_0_system_default", $vmx_option_0_system_default, time()+365*24*60*60); 263 if (is_numeric($stripped_vmx_option_0_number) || !$stripped_vmx_option_0_number) { 264 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 265 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 266 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 267 } 268 } 269 } else { 270 if (!is_numeric($stripped_vmx_option_0_number) && $stripped_vmx_option_0_number) { 271 $_SESSION['ari_error'] = 272 _("Option 0 not changed") . "<br>" . 273 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_0_number); 274 } 275 else { 276 277 // set database 278 $this->setVmxOptionNumber($exten,'0','unavail',$stripped_vmx_option_0_number); 279 $this->setVmxOptionNumber($exten,'0','busy',$stripped_vmx_option_0_number); 280 281 // store cookie 282 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 283 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 284 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 285 } 286 } 287 } 288 289 $stripped_vmx_option_1_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_1_number); 290 if ($vmx_option_1_system_default && !$follow_me_disabled) { 291 $this->setVmxOptionFollowMe($exten,'1','unavail'); 292 $this->setVmxOptionFollowMe($exten,'1','busy'); 293 setcookie("ari_vmx_option_1_system_default", $vmx_option_1_system_default, time()+365*24*60*60); 294 if (is_numeric($stripped_vmx_option_1_number) || !$stripped_vmx_option_1_number) { 295 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 296 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 297 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 298 } 299 } 300 } 301 else { 302 303 if (!is_numeric($stripped_vmx_option_1_number) && $stripped_vmx_option_1_number) { 304 $_SESSION['ari_error'] = 305 _("Option 1 not changed") . "<br>" . 306 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_1_number); 307 } 308 else { 309 310 // set database 311 $this->setVmxOptionNumber($exten,'1','unavail',$stripped_vmx_option_1_number); 312 $this->setVmxOptionNumber($exten,'1','busy',$stripped_vmx_option_1_number); 313 314 // store cookie 315 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 316 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 317 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 318 } 319 } 320 } 321 322 $stripped_vmx_option_2_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_2_number); 323 if (!is_numeric($stripped_vmx_option_2_number) && $stripped_vmx_option_2_number) { 324 $_SESSION['ari_error'] = 325 _("Option 2 not changed") . "<br>" . 326 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_2_number); 327 } 328 else { 329 330 // set database 331 $this->setVmxOptionNumber($exten,'2','unavail',$stripped_vmx_option_2_number); 332 $this->setVmxOptionNumber($exten,'2','busy',$stripped_vmx_option_2_number); 333 334 // store cookie 335 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_2_number']); 336 if ($vmx_option_2_number && $stripped!=$stripped_vmx_option_2_number) { 337 setcookie("ari_vmx_option_2_number", $call_vmx_option_2_number, time()+365*24*60*60); 338 } 339 } 340 } 341 } // vmx_disabled_delayed false 342 343 if (! $follow_me_disabled_delayed) { 344 345 // assume no errors, don't update SQL if errors occured 346 $follow_me_update_succeeded=1; 347 348 // update follow me pre-ring time 349 if (!$STANDALONE['use']) { 350 351 $stripped_follow_me_prering_time = preg_replace('/-|\s/','',$follow_me_prering_time); 352 if (!is_numeric($stripped_follow_me_prering_time)) { 353 $_SESSION['ari_error'] = 354 _("Follow-Me pre-ring time not changed") . "<br>" . 355 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_prering_time); 356 $follow_me_update_succeeded=0; 357 } 358 else { 359 360 // set database 361 $this->setFollowMePreRingTime($exten,$stripped_follow_me_prering_time); 362 363 // store cookie 364 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_prering_time']); 365 if ($follow_me_prering_time && $stripped!=$stripped_follow_me_prering_time) { 366 setcookie("ari_follow_me_prering_time", $follow_me_prering_time, time()+365*24*60*60); 367 } 368 } 369 } 370 371 // update follow me list ring time 372 if (!$STANDALONE['use']) { 373 374 $stripped_follow_me_listring_time = preg_replace('/-|\s/','',$follow_me_listring_time); 375 if (!is_numeric($stripped_follow_me_listring_time)) { 376 $_SESSION['ari_error'] = 377 _("Follow-Me list ring time not changed") . "<br>" . 378 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_listring_time); 379 $follow_me_update_succeeded=0; 380 } 381 else { 382 383 // set database 384 $this->setFollowMeListRingTime($exten,$stripped_follow_me_listring_time); 385 386 // store cookie 387 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_listring_time']); 388 if ($follow_me_listring_time && $stripped!=$stripped_follow_me_listring_time) { 389 setcookie("ari_follow_me_listring_time", $follow_me_listring_time, time()+365*24*60*60); 390 } 391 } 392 } 393 394 // update follow me list 395 if (!$STANDALONE['use']) { 396 397 $grplist = explode("\n", $follow_me_list); 398 399 if (!$grplist) { 400 $grplist = null; 401 } 402 403 foreach (array_keys($grplist) as $key) { 404 //trim it 405 $grplist[$key] = trim($grplist[$key]); 406 407 // Lookup the extension and append hash if not a user, and remove invalid chars 408 $grplist[$key] = $this->lookupSetExtensionFormat($grplist[$key]); 409 410 // remove blanks 411 if ($grplist[$key] == "") unset($grplist[$key]); 412 } 413 414 // check for duplicates, and re-sequence 415 $grplist = array_values(array_unique($grplist)); 416 417 $stripped_follow_me_list = implode("-",$grplist); 418 419 if ($stripped_follow_me_list == "") { 420 $_SESSION['ari_error'] = 421 _("Follow-Me list must contain at least one valid number") . "<br>" . 422 sprintf(_("The following: %s is not valid"),$follow_me_list); 423 $follow_me_update_succeeded=0; 424 } 425 else { 426 427 // set database 428 $this->setFollowMeList($exten,$stripped_follow_me_list); 429 430 // store cookie 431 $stripped = preg_replace('/|\(|\)|\s/','',$_COOKIE['ari_follow_me_list']); 432 if ($follow_me_list && $stripped!=$stripped_follow_me_list) { 433 setcookie("ari_follow_me_list", $follow_me_list, time()+365*24*60*60); 434 } 435 } 436 } 437 438 // update follow me confirm 439 if (!$STANDALONE['use']) { 440 441 // set database 442 $this->setFollowMeConfirm($exten,$follow_me_confirm); 443 $this->setFollowMeDDial($exten,$follow_me_ddial); 444 445 // store cookie 446 setcookie("ari_follow_me_confirm", $follow_me_confirm, time()+365*24*60*60); 447 setcookie("ari_follow_me_ddial", $follow_me_ddial, time()+365*24*60*60); 448 } 449 450 //If no errors than update the SQL table to keep in sync 451 if ($follow_me_update_succeeded) { 452 $this->setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm); 453 } 454 455 } //if !follow_me_disabled 456 457 // voicemail settings 458 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1) { 459 460 461 // update voicemail password 462 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 463 464 // update voicemail password 465 if ($voicemail_password=='' || $voicemail_password_confirm=='') { 466 $_SESSION['ari_error'] = 467 _("Voicemail password not changed") . "<br>" . 468 _("Password and password confirm must not be blank"); 469 } 470 else if ((strlen($voicemail_password)<$SETTINGS_VOICEMAIL_PASSWORD_LENGTH) || !is_numeric($voicemail_password)) { 471 $_SESSION['ari_error'] = 472 _("Voicemail password not changed") . "<br>" . 473 sprintf(_("Passwords must be all numbers and greater than %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 474 } 475 else if (strlen($voicemail_password)!=$SETTINGS_VOICEMAIL_PASSWORD_LENGTH && $SETTINGS_VOICEMAIL_PASSWORD_EXACT || !is_numeric($voicemail_password)) { 476 $_SESSION['ari_error'] = 477 _("Voicemail password not changed") . "<br>" . 478 sprintf(_("Passwords must be all numbers and only %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 479 } 480 else if ($voicemail_password!=$voicemail_password_confirm) { 481 $_SESSION['ari_error'] = 482 _("Voicemail password not changed") . "<br>" . 483 _("Password and password confirm do not match"); 484 } 485 else { 486 487 // check for writable the files 488 $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 489 $fp = fopen($temp_file, "w"); 490 if (!$fp) { 491 $_SESSION['ari_error'] = 492 _("Voicemail password not changed") . "<br>" . 493 sprintf(_("%s does not exist or is not writable"),$temp_file); 494 } 495 else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 496 $_SESSION['ari_error'] = 497 _("Voicemail password not changed") . "<br>" . 498 sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 499 } 500 else { 501 502 // update session 503 $_SESSION['ari_user']['voicemail_password'] = $voicemail_password; 504 505 // save password 506 $lines = file($ASTERISK_VOICEMAIL_CONF); 507 foreach ($lines as $key => $line) { 508 unset($value); 509 list($var,$value) = split('=>',$line); 510 $var = trim($var); 511 if ($var==$exten && $value) { 512 513 // write out line with password change 514 $buf = split(',',$value); 515 $buf[0] = $voicemail_password; 516 $line = $var . " => " . join(',', $buf); 517 518 fwrite($fp, $line); 519 } 520 else { 521 522 // write out original line with no changes 523 fwrite($fp, $line); 524 } 525 } 526 fclose($fp); 527 unlink($ASTERISK_VOICEMAIL_CONF); 528 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 529 530 $voicemail_reload = 1; 531 } 532 } 533 534 // voicemail email address 535 if ($voicemail_email_enable && 536 ($voicemail_email_address && !preg_match('/@/',$voicemail_email_address) || 537 ($voicemail_pager_address && !preg_match('/@/',$voicemail_pager_address)))) { 538 $_SESSION['ari_error'] = 539 _("Voicemail email and pager address not changed") . "<br>" . 540 ("'$voicemail_email_address' and '$voicemail_pager_address' must be a valid email addresses"); 541 } 542 else { 543 544 // check for writable the files 545 $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 546 $fp = fopen($temp_file, "w"); 547 if (!$fp) { 548 $_SESSION['ari_error'] = 549 _("Voicemail email settings not changed") . "<br>" . 550 sprintf(_("%s does not exist or is not writable"),$temp_file); 551 } 552 else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 553 $_SESSION['ari_error'] = 554 _("Voicemail email settings not changed") . "<br>" . 555 sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 556 } 557 else { 558 559 // store cookie 560 if ($voicemail_email_enable) { 561 setcookie("ari_voicemail_email_address", $voicemail_email_address, time()+365*24*60*60); 562 setcookie("ari_voicemail_pager_address", $voicemail_pager_address, time()+365*24*60*60); 563 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 564 $var = "voicemail_email_$key"; 565 $var_cookie = "ari_" . $var; 566 setcookie("$var_cookie", $$var, time()+365*24*60*60); 567 } 568 } 569 570 // update session 571 $_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable; 572 if ($voicemail_email_enable) { 573 $_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address; 574 $_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address; 575 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 576 $option = "voicemail_email_$key"; 577 $_SESSION['ari_user']['voicemail_email'][$key] = $$option; 578 } 579 } 580 581 // save settings 582 if (!$voicemail_email_enable) { 583 $voicemail_email_address = ''; 584 $voicemail_pager_address = ''; 585 } 586 587 $lines = file($ASTERISK_VOICEMAIL_CONF); 588 foreach ($lines as $key => $line) { 589 unset($value); 590 list($var,$value) = split('=>',$line); 591 $var = trim($var); 592 if ($var==$exten && $value) { 593 594 // write out line with voicemail email change 595 $buf = split(',',$value); 596 $buf[2] = $voicemail_email_address; 597 $buf[3] = $voicemail_pager_address; 598 599 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 600 $option = "voicemail_email_$key"; 601 if ($$option && $key) { 602 $options .= $key . "=" . $value; 603 } 604 else { 605 $options .= $key . "=no"; 606 } 607 $options .= "|"; 608 } 609 $buf[4] = substr($options, 0, -1); 610 611 $line = $var . " =>" . join(',', $buf); 612 if (substr($line, 0, -1)!="\n") { 613 $line .= "\n"; 614 } 615 616 fwrite($fp, $line); 617 } 618 else { 619 620 // write out original line with no changes 621 fwrite($fp, $line); 622 } 623 } 624 fclose($fp); 625 unlink($ASTERISK_VOICEMAIL_CONF); 626 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 627 628 $voicemail_reload = 1; 629 } 630 } 631 632 // reload asterisk voicemail 633 if ($voicemail_reload) { 634 $this->reloadAsteriskVoicemail(); 635 } 636 } 637 638 // update voicemail audio format setting 639 setcookie("ari_voicemail_audio_format", $voicemail_audio_format, time()+365*24*60*60); 640 } 641 642 // update call monitor record setting 643 if ($SETTINGS_ALLOW_CALL_RECORDING_SET) { 644 if ($record_in && $record_out) { 645 $this->setRecordSettings($exten,$record_in,$record_out); 646 } 647 } 648 } 649 } 650 651 // redirect to see updated page 652 $ret .= " 653 <head> 654 <script> 655 <!-- 656 window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\" 657 // --> 658 </script> 659 </head>"; 660 661 return $ret; 238 return $ret; 662 239 } 663 240 … … 668 245 * Common arguments 669 246 */ 670 function display($args) { 671 672 global $STANDALONE; 673 global $ARI_ADMIN_USERNAME; 674 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 675 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; 676 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 677 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 678 global $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS; 679 global $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT; 680 global $SETTINGS_ALLOW_CALL_RECORDING_SET; 681 global $SETTINGS_PRERING_LOW; 682 global $SETTINGS_PRERING_HIGH; 683 global $SETTINGS_LISTRING_LOW; 684 global $SETTINGS_LISTRING_HIGH; 685 686 global $SETTINGS_FOLLOW_ME_LIST_MAX; 687 global $SETTINGS_ALLOW_VMX_SETTINGS; 688 689 global $loaded_modules; 690 691 // args 692 $m = getArgument($args,'m'); 693 $q = getArgument($args,'q'); 694 $start = getArgument($args,'start'); 695 $span = getArgument($args,'span'); 696 697 $displayname = $_SESSION['ari_user']['displayname']; 698 $exten = $_SESSION['ari_user']['extension']; 699 700 $language = new Language(); 701 $display = new DisplaySearch(); 702 703 // get data 704 $data = $this->getRecordSettings($_SESSION['ari_user']['extension']); 705 706 // lang setting options 707 if (extension_loaded('gettext')) { 708 $setLangText = " 709 <p class='lang'> 710 " . _("Language:") . " 711 " . $language->GetForm() . " 712 </p>"; 713 } 714 715 // build controls 716 if ($exten!=$ARI_ADMIN_USERNAME) { 717 718 // call forward settings 719 if (!$STANDALONE['use']) { 720 721 722 $call_forward_number = $this->getCallForwardNumber($exten); 723 if ($call_forward_number) { 724 $call_forward_enable = 'checked'; 725 } 726 else { 727 $call_forward_number = $_COOKIE['ari_call_forward_number']; 728 $call_forward_text_box_options = "disabled style='background: #DDD;'"; 729 } 730 731 $call_forward_busy_number = $this->getCallForwardNumber($exten, 'CFB'); 732 if ($call_forward_busy_number) { 733 $call_forward_busy_enable = 'checked'; 734 } 735 else { 736 $call_forward_busy_number = $_COOKIE['ari_call_forward_busy_number']; 737 $call_forward_busy_text_box_options = "disabled style='background: #DDD;'"; 738 } 739 740 $call_forward_unavailable_number = $this->getCallForwardNumber($exten, 'CFU'); 741 if ($call_forward_unavailable_number) { 742 $call_forward_unavailable_enable = 'checked'; 743 } 744 else { 745 $call_forward_unavailable_number = $_COOKIE['ari_call_forward_unavailable_number']; 746 $call_forward_unavailable_text_box_options = "disabled style='background: #DDD;'"; 747 } 748 749 $follow_me_prering_time = $this->getFollowMePreRingTime($exten); 750 $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 751 $follow_me_list = explode("-", $this->getFollowMeList($exten) ); 752 $follow_me_confirm = $this->getFollowMeConfirm($exten); 753 $follow_me_ddial = $this->getFollowMeDDial($exten); 754 247 function display($args) { 248 249 global $STANDALONE; 250 global $ARI_ADMIN_USERNAME; 251 global $SETTINGS_PRERING_LOW; 252 global $SETTINGS_PRERING_HIGH; 253 global $SETTINGS_LISTRING_LOW; 254 global $SETTINGS_LISTRING_HIGH; 255 256 global $SETTINGS_FOLLOW_ME_LIST_MAX; 257 258 global $loaded_modules; 259 260 // args 261 $m = getArgument($args,'m'); 262 $q = getArgument($args,'q'); 263 $start = getArgument($args,'start'); 264 $span = getArgument($args,'span'); 265 266 $displayname = $_SESSION['ari_user']['displayname']; 267 $exten = $_SESSION['ari_user']['extension']; 268 269 $language = new Language(); 270 $display = new DisplaySearch(); 271 272 // build controls 273 if ($exten!=$ARI_ADMIN_USERNAME) { 274 275 // call forward settings 276 if (!$STANDALONE['use']) { 277 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); 283 755 284 $FOLLOW_ME_LIST_MAX = (count($follow_me_list) > $SETTINGS_FOLLOW_ME_LIST_MAX) ? count($follow_me_list):$SETTINGS_FOLLOW_ME_LIST_MAX; 756 285 757 286 //TODO: Set this better than this? 758 287 $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 759 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 760 761 $set_call_forward_text = "<table class='settings'>"; 762 763 $set_call_forward_text .= (!$SETTINGS_ALLOW_CALLFORWARD_SETTINGS)?'':" 764 <table class='settings'> 765 <tr> 766 <td><h3>" . _("Call Forwarding") . "</h3></td> 767 </tr> 768 <tr> 769 <td>" . _("Unconditional:") . "</td> 770 <td> 771 <input " . $call_forward_text_box_options . " name='call_forward_number' type='text' size=24 value='" . $call_forward_number . "'> 772 </td> 773 <td> 774 <input " . $call_forward_enable . " type=checkbox name='call_forward_enable' value='checked' OnClick=\"disable_fields(); return 775 true;\"> 776 <small>" . _("Enable") . "</small> 777 </td> 778 </tr> 779 <tr> 780 <td>" . _("Unavailable:") . "</td> 781 <td> 782 <input " . $call_forward_unavailable_text_box_options . " name='call_forward_unavailable_number' type='text' size=24 value='" . $call_forward_unavailable_number . "'> 783 </td> 784 <td> 785 <input " . $call_forward_unavailable_enable . " type=checkbox name='call_forward_unavailable_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 786 <small>" . _("Enable") . "</small> 787 </td> 788 </tr> 789 <tr> 790 <td>" . _("Busy:") . "</td> 791 <td> 792 <input " . $call_forward_busy_text_box_options . " name='call_forward_busy_number' type='text' size=24 value='" . $call_forward_busy_number . "'> 793 </td> 794 <td> 795 <input " . $call_forward_busy_enable . " type=checkbox name='call_forward_busy_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 796 <small>" . _("Enable") . "</small> 797 </td> 798 </tr> 799 800 "; 801 802 $set_call_forward_text .= ($follow_me_disabled)?'':" 803 <tr> 804 <td><h3><br>" . _("Follow Me") . "</h3></td> 805 </tr> 806 <tr> 807 <td><a href='#' class='info'>" . _("Enable") . "<span>". _(" 808 Dial-by-name Directory, IVR, and internal calls will ring the numbers in the FollowMe List. Any FreePBX routes that directly reference a FollowMe are unaffected by this enable/disable setting. 809 ") . "<br></span></a></td> 810 <td> 811 <input " . $follow_me_ddial . " type=checkbox name='follow_me_ddial' value='checked'> 812 <small>" . _("") . "</small> 813 </td> 814 </tr> 815 <tr> 816 <td><a href='#' class='info'>" . sprintf(_("Ring %s First For:"),$exten) . "<span>" .sprintf( _("Time to ring extension %s before ringing the %s Follow Me List %s"),"<strong>".$exten."</strong>","<strong>","</strong>") . 817 "<br></span></a></td> 818 <td> 819 <select " . $follow_me_prering_time_text_box_options . " name='follow_me_prering_time'/>"; 820 if (!$follow_me_disabled) { 821 $default_prering = $follow_me_prering_time; 822 for ($i=$SETTINGS_PRERING_LOW; $i <= $SETTINGS_PRERING_HIGH; $i++) { 823 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_prering ? 'SELECTED' : '').'>'.$i.'</option>'; 824 } 825 } 826 $set_call_forward_text .= ($follow_me_disabled)?'':" 827 </select> 828 <small>" . _("seconds") . "</small> 829 </td> 830 <tr> 831 <td valign='top'><a href='#' class='info'>" . _("Follow Me List:") . "<span>" . sprintf(_("Extensions and outside numbers to ring next.")) ."<br/><br/>". sprintf(_("Include %s to keep it ringing."),"<strong>".$exten."</strong>") . "<br></span></a></td> 832 <td> 833 <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> 834 </td> 835 <tr> 836 <td><a href='#' class='info'>" . _("List Ring Time:") . "<span>" . _("Time to ring the Follow Me List.") . "<br></span></a></td> 837 <td> 838 <select " . $follow_me_listring_time_text_box_options . " name='follow_me_listring_time'/>"; 839 if (!$follow_me_disabled) { 840 $default_listring = $follow_me_listring_time; 841 for ($i=$SETTINGS_LISTRING_LOW; $i <= $SETTINGS_LISTRING_HIGH; $i++) { 842 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_listring ? 'SELECTED' : '').'>'.$i.'</option>'; 843 } 844 } 845 $set_call_forward_text .= ($follow_me_disabled)?'':" 846 </select> 847 <small>" . _("seconds") . "</small> 848 </td> 849 <tr> 850 <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.") . "<br></span></a></td> 851 <td> 852 <input " . $follow_me_confirm . " type=checkbox name='follow_me_confirm' value='checked'> 853 <small>" . _("Enable") . "</small> 854 </td> 855 </tr> 856 "; 857 858 $set_call_forward_text .= " 859 </tr> 860 </table> 861 "; 862 863 $vmx_unavail_enabled=$this->getVmxState($exten,'unavail'); 864 if ($vmx_unavail_enabled === false) { 865 $vmx_disabled = true; 866 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 867 $SETTINGS_ALLOW_VMX_SETTINGS=false; 868 } else { 869 $vmx_disabled = false; 870 setcookie("ari_vmx_disabled", false, time()+365*24*60*60); 871 $vmx_busy_enabled=$this->getVmxState($exten,'busy'); 872 $vmx_play_instructions=$this->getVmxPlayInstructions($exten); 873 $vmx_option_0_number=$this->getVmxOptionNumber($exten,'0');; 874 $vmx_option_1_number=$this->getVmxOptionNumber($exten,'1');; 875 $vmx_option_2_number=$this->getVmxOptionNumber($exten,'2');; 876 877 if (is_numeric($vmx_option_0_number)) { 878 $vmx_option_0_system_default=''; 879 $vmx_option_0_number_text_box_options=''; 880 } else { 881 $vmx_option_0_system_default='checked'; 882 $vmx_option_0_number_text_box_options="disabled style='background: #DDD;'"; 883 } 884 885 // if follow-me is enabled then the options are a numberic value (dial a phone number) 886 // or a followme target (FMnnn) which should not be displayed but means the box is checked 887 // or otherwise blank (or garbage in which case blank it) 888 // 889 if (!$follow_me_disabled) { 890 $vmx_option_1_system_default=$this->getVmxOptionFollowMe($exten,'1'); 891 if ($vmx_option_1_system_default) { 892 $vmx_option_1_number = ''; 893 $vmx_option_1_number_text_box_options="disabled style='background: #DDD;'"; 894 } 895 } 896 } 897 $set_vmx_text .= (!$SETTINGS_ALLOW_VMX_SETTINGS)?'':" 898 <table class='settings'> 899 <tr> 900 <td><h3>" . _("Voicemail VmX Locator") . "</h3></td> 901 </tr> 902 <tr> 903 <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> 904 <input " . $vmx_unavail_enabled . " type=checkbox name='vmx_unavail_enabled' value='checked'> 905 <small>" . _("unavailable") . "</small> 906 </td> 907 <td> 908 <input " . $vmx_busy_enabled . " type=checkbox name='vmx_busy_enabled' value='checked'> 909 <small>" . _("busy") . "</small> 910 </td> 911 </tr> 912 <tr> 913 <td><a href='#' class='info'>" . _("Voicemail Instructions:") ."<span>" . _("Uncheck to play a beep after your personal voicemail greeting.") . "<br></span></a></td> 914 <td> 915 <input " . $vmx_play_instructions . " type=checkbox name='vmx_play_instructions' value='checked'> 916 <small>" . _("Standard voicemail prompts.") . "</small> 917 </td> 918 </tr> 919 </table> 920 <table class='settings'> 921 <tr> 922 <td> </td> 923 <td><a href='#' class='info'>" . _("Press 0:") . "<span>" . _("Pressing 0 during your personal voicemail greeing goes to the Operator. 924 Uncheck to enter another destination here.") . "<br></span></a></td> 925 <td> 926 <input " . $vmx_option_0_number_text_box_options . " name='vmx_option_0_number' type='text' size=24 value='" . $vmx_option_0_number . "'> 927 </td> 928 <td> 929 <input " . $vmx_option_0_system_default . " type=checkbox name='vmx_option_0_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 930 <small>" . _("Go To Operator") . "</small> 931 </td> 932 </tr> 933 "; 934 935 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled))?'':" 936 <tr> 937 <td> </td> 938 <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> 939 <td> 940 <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 941 </td> 942 <td> 943 <input " . $vmx_option_1_system_default . " type=checkbox name='vmx_option_1_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 944 <small>" . _("Send to Follow-Me") . "</small> 945 </td> 946 </tr> 947 <tr> 948 <td> </td> 949 <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> 950 <td> 951 <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 952 </td> 953 </tr> 954 </table> 955 "; 956 957 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && $follow_me_disabled))?'':" 958 <tr> 959 <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> 960 <td> 961 <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 962 </td> 963 </tr> 964 <tr> 965 <td>" . _("Option 2:") . "</td> 966 <td> 967 <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 968 </td> 969 </tr> 970 </table> 971 "; 972 973 974 } 975 976 // voicemail settings 977 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1 && 978 in_array('voicemail',array_keys($loaded_modules))) { 979 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 980 981 if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) { 982 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 983 } 984 else { 985 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 986 } 987 988 $set_voicemail_password_text = " 989 <tr> 990 <td>" . _("Voicemail Password:") . "</td> 991 <td> 992 <input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 993 </td> 994 </tr> 995 <tr> 996 <td>" . _("Enter again to confirm:") . "</td> 997 <td> 998 <input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 999 </td> 1000 </tr> 1001 <tr> 1002 <td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td> 1003 </tr>"; 1004 } 1005 1006 if (isset($_SESSION['ari_user']['voicemail_email'])) { 1007 1008 if ($_SESSION['ari_user']['voicemail_email_enable']) { 1009 $voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address']; 1010 $voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address']; 1011 $voicemail_email_enable = 'checked'; 1012 1013 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 1014 $var = "voicemail_email_$key"; 1015 $var_enable = $var . "enable"; 1016 if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') { 1017 $$var_enable = 'checked'; 1018 } 1019 } 1020 } 1021 else { 1022 1023 $voicemail_email_address = $_COOKIE['ari_voicemail_email_address']; 1024 $voicemail_email_text_box_options = "disabled style='background: #DDD;'"; 1025 $voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address']; 1026 $voicemail_pager_text_box_options = "disabled style='background: #DDD;'"; 1027 1028 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1029 $var = "voicemail_email_$key"; 1030 $var_cookie = "ari_" . $var; 1031 $var_enable = $var . "enable"; 1032 $var_text_box_options = $var . "text_box_options"; 1033 1034 $$var_text_box_options = "disabled"; 1035 if ($_COOKIE[$var_cookie]=='yes') { 1036 $$var_enable = 'checked'; 1037 } 1038 } 1039 } 1040 1041 $set_voicemail_email_text = " 1042 1043 <tr> 1044 <td> " . _("Email Notification") . " <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\"> 1045 <small> " ._("Enable") . " </small> 1046 </td> 1047 </tr><tr> 1048 <td><a href='#' class='info'>" . _("Email Voicemail To:") . "<span>" . ("Email a notification, including audio file if indicated below.") . " </span></a></td> 1049 <td> 1050 <input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'> 1051 </td> 1052 </tr> 1053 <tr> 1054 <td><a href='#' class='info'>" . _("Pager Email Notification To:") . "<span>" . ("Email a short notification") . " </span></a></td> 1055 <td> 1056 <input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'> 1057 </td> 1058 </tr> 1059 <tr> 1060 <td></td> 1061 </tr>"; 1062 1063 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1064 1065 $var = "voicemail_email_$key"; 1066 $var_enable = $var . "enable"; 1067 $var_text_box_options = $var . "text_box_options"; 1068 if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) { 1069 $var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]; 1070 } 1071 else { 1072 $var_text = $key; 1073 } 1074 1075 if ($value != 'yes' && $value != 'no' && $value !='') { 1076 1077 $size = strlen($value) - 1; 1078 $set_voicemail_email_text .= " 1079 <tr> 1080 <td></td> 1081 <td> 1082 <input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "' OnClick=\"disable_fields(); return true;\"> 1083 <small>" . $var_text . "</small> 1084 </td> 1085 </tr>"; 1086 } 1087 else { 1088 1089 $set_voicemail_email_text .= " 1090 <tr> 1091 <td></td> 1092 <td> 1093 <input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "' value='yes' OnClick=\"disable_fields(); return true;\"> 1094 <small>" . $var_text . "</small> 1095 </td> 1096 </tr>"; 1097 } 1098 } 1099 } 1100 1101 $wav_enable = 'selected'; 1102 if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'|| 1103 ($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) { 1104 $wav_enable = ''; 1105 $gsm_enable = 'selected'; 1106 } 1107 1108 $set_voicemail_audio_format_text = " 1109 <tr> 1110 <td>" . _("Audio Format:") . "</td> 1111 <td> 1112 <select name='voicemail_audio_format'> 1113 <option value='.wav' " . $wav_enable . ">" . _("Best Quality") . " (.wav)</option> 1114 <option value='.gsm' " . $gsm_enable . ">" . _("Smallest Download") . " (.gsm)</option> 1115 </select> 1116 </td> 1117 </tr>"; 1118 1119 $set_voicemail_text = " 1120 <table class='settings'> 1121 <tr> 1122 <td><h3>" . _("Voicemail Settings") . "</h3></td> 1123 </tr> 1124 " . $set_voicemail_password_text . " 1125 " . $set_voicemail_email_text . " 1126 " . $set_voicemail_audio_format_text . " 1127 </table>"; 1128 } 1129 1130 // call monitor settings 1131 if ($this->getFreePBXVersion() && 1132 $SETTINGS_ALLOW_CALL_RECORDING_SET && 1133 in_array('callmonitor',array_keys($loaded_modules))) { 1134 1135 foreach($data as $key=>$value) { 1136 if ($key=='record_in') { 1137 if ($value=='Always') { 1138 $ri_always = 'checked=checked'; 1139 } 1140 elseif ($value=='Never') { 1141 $ri_never = 'checked=checked'; 1142 } 1143 elseif ($value=='Adhoc') { 1144 $ri_on_demand = 'checked=checked'; 1145 } 1146 } 1147 if ($key=='record_out') { 1148 if ($value=='Always') { 1149 $ro_always = 'checked=checked'; 1150 } 1151 elseif ($value=='Never') { 1152 $ro_never = 'checked=checked'; 1153 } 1154 elseif ($value=='Adhoc') { 1155 $ro_on_demand = 'checked=checked'; 1156 } 1157 } 1158 } 1159 1160 $set_callmonitor_text = " 1161 <table class='settings'> 1162 <tr> 1163 <td><h3>" . _("Call Monitor Settings") . "</h3></td> 1164 </tr> 1165 <tr> 1166 <td>" . _("Record INCOMING:") . " </td> 1167 <td> 1168 <input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . " 1169 <input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . " 1170 <input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . " 1171 </td> 1172 </tr> 1173 <tr> 1174 <td>" . _("Record OUTGOING:") . " </td> 1175 <td> 1176 <input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . " 1177 <input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . " 1178 <input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . " 1179 </td> 1180 </tr> 1181 </table>"; 288 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 289 290 $followme_text.= "<table class='settings'>"; 291 292 if (!$follow_me_disabled) { 293 $followme_text .= "<tr><td><h3><br>" . _("Follow Me") . "</h3></td></tr>"; 294 $followme_text .= "<tr><td><a href='#' class='info'>" . _("Enable") . "<span>"; 295 $followme_text .= _( "Dial-by-name Directory, IVR, and internal 296 calls will ring the numbers in the FollowMe 297 List. Any FreePBX routes that directly 298 reference a FollowMe are unaffected by this 299 enable/disable setting."); 300 $followme_text .= "<br></span></a></td>"; 301 302 $followme_text .= "<td><input " . $follow_me_ddial . " type=checkbox name='follow_me_ddial' value='checked'>"; 303 $followme_text .= "<small>" . _("") . "</small></td></tr>"; 304 $followme_text .= "<tr><td><a href='#' class='info'>"; 305 $followme_text .= sprintf(_("Ring %s First For:"), $exten); 306 $followme_text .= "<span>" . sprintf( _("Time to ring extension %s before ringing the %s Follow Me List %s"), "<strong>".$exten."</strong>","<strong>","</strong>"); 307 $followme_text .= "<br></span></a></td><td>"; 308 309 $followme_text .= "<select " . $follow_me_prering_time_text_box_options . " name='follow_me_prering_time'/>"; 310 $default_prering = $follow_me_prering_time; 311 for ($i=$SETTINGS_PRERING_LOW; $i <= $SETTINGS_PRERING_HIGH; $i++) { 312 $followme_text .= '<option value="'.$i.'" '.($i == $default_prering ? 'SELECTED' : '').'>'.$i.'</option>'; 313 } 314 $followme_text .= "</select>"; 315 316 $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>"; 325 $followme_text .= "<td>"; 326 327 $followme_text .= "<select " . $follow_me_listring_time_text_box_options . " name='follow_me_listring_time'/>"; 328 $default_listring = $follow_me_listring_time; 329 for ($i=$SETTINGS_LISTRING_LOW; $i <= $SETTINGS_LISTRING_HIGH; $i++) { 330 $followme_text .= '<option value="'.$i.'" '.($i == $default_listring ? 'SELECTED' : '').'>'.$i.'</option>'; 331 } 332 $followme_text .= "</select>"; 333 334 $followme_text .= "<small>" . _("seconds") . "</small></td>"; 335 $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."); 336 $followme_text .= "<br></span></a></td><td>"; 337 $followme_text .= "<input " . $follow_me_confirm . " type=checkbox name='follow_me_confirm' value='checked'>"; 338 $followme_text .= "<small>" . _("Enable") . "</small></td></tr>"; 339 340 $followme_text .= "</tr></table>"; 1182 341 } 1183 342 } 1184 1185 // javascript enable options 1186 if (isset($_SESSION['ari_user']['voicemail_email']) && 1187 in_array('voicemail',array_keys($loaded_modules))) { 1188 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1189 $var = "voicemail_email_$key"; 1190 $js_voicemail_email_disable .= " 1191 document.ari_settings.$var.disabled = false;"; 1192 $js_voicemail_email_enable .= " 1193 document.ari_settings.$var.disabled = true;"; 1194 } 1195 1196 $js_voicemail_script = " 1197 if (document.ari_settings.voicemail_email_enable.checked) { 1198 document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; 1199 document.ari_settings.voicemail_email_address.disabled = false; 1200 document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; 1201 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; 1202 document.ari_settings.voicemail_pager_address.disabled = false; 1203 document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; 1204 " . $js_voicemail_email_disable . " 1205 } 1206 else { 1207 document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; 1208 document.ari_settings.voicemail_email_address.disabled = true; 1209 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; 1210 document.ari_settings.voicemail_pager_address.disabled = true; 1211 " . $js_voicemail_email_enable . " 1212 }"; 1213 } 1214 1215 // build page content 1216 $ret .= checkErrorMessage(); 1217 1218 if ($_SESSION['ari_user']['admin_settings']) { 1219 $headerText = _("Settings"); 1220 } else { 1221 $headerText = sprintf(_("Settings for %s (%s)"),$displayname,$exten); 1222 } 1223 1224 $ret .= $display->displayHeaderText($headerText); 1225 $ret .= $display->displayLine(); 1226 1227 $ret .= " 1228 <SCRIPT LANGUAGE='JavaScript'> 1229 <!-- Begin 343 344 } 345 346 // build page content 347 $ret .= checkErrorMessage(); 348 349 if ($_SESSION['ari_user']['admin_settings']) { 350 $headerText = _("Followme Settings"); 351 } else { 352 $headerText = sprintf(_("Followme Settings for %s (%s)"),$displayname,$exten); 353 } 354 355 $ret .= $display->displayHeaderText($headerText); 356 $ret .= $display->displayLine(); 357 358 $ret .= 359 "\n<SCRIPT LANGUAGE='JavaScript'> 360 <!-- Begin 1230 361 function rowCounter(field, maxlimit) { 1231 362 temp = field.value.split('\u000A',maxlimit+1) … … 1235 366 } 1236 367 } 1237 1238 function disable_fields() {"; 1239 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS) { 1240 $ret .= " 1241 if (document.ari_settings.call_forward_enable.checked) { 1242 document.ari_settings.call_forward_number.style.backgroundColor = '#FFF'; 1243 document.ari_settings.call_forward_number.disabled = false; 1244 } 1245 else { 1246 document.ari_settings.call_forward_number.style.backgroundColor = '#DDD'; 1247 document.ari_settings.call_forward_number.disabled = true; 1248 } 1249 1250 if (document.ari_settings.call_forward_busy_enable.checked) { 1251 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#FFF'; 1252 document.ari_settings.call_forward_busy_number.disabled = false; 1253 } 1254 else { 1255 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#DDD'; 1256 document.ari_settings.call_forward_busy_number.disabled = true; 1257 } 1258 1259 if (document.ari_settings.call_forward_unavailable_enable.checked) { 1260 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#FFF'; 1261 document.ari_settings.call_forward_unavailable_number.disabled = false; 1262 } 1263 else { 1264 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#DDD'; 1265 document.ari_settings.call_forward_unavailable_number.disabled = true; 1266 }"; 1267 } 1268 if ($SETTINGS_ALLOW_VMX_SETTINGS) { 1269 $ret .= " 1270 if (document.ari_settings.vmx_option_0_system_default.checked) { 1271 document.ari_settings.vmx_option_0_number.style.backgroundColor = '#DDD'; 1272 document.ari_settings.vmx_option_0_number.disabled = true; 1273 } 1274 else { 1275 document.ari_settings.vmx_option_0_number.style.backgroundColor = '#FFF'; 1276 document.ari_settings.vmx_option_0_number.disabled = false; 1277 }"; 1278 } 1279 if ($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled) { 1280 $ret .= " 1281 if (document.ari_settings.vmx_option_1_system_default.checked) { 1282 document.ari_settings.vmx_option_1_number.style.backgroundColor = '#DDD'; 1283 document.ari_settings.vmx_option_1_number.disabled = true; 1284 } 1285 else { 1286 document.ari_settings.vmx_option_1_number.style.backgroundColor = '#FFF'; 1287 document.ari_settings.vmx_option_1_number.disabled = false; 1288 }"; 1289 } 1290 $ret .= $js_voicemail_script . " 1291 } 1292 // End --> 1293 </script>"; 1294 1295 $ret .= " 1296 " . $setLangText . " 1297 <form class='settings' name='ari_settings' action='' method='GET'> 1298 <input type=hidden name=m value=" . $m . "> 1299 <input type=hidden name=f value='action'> 1300 <input type=hidden name=a value='update'> 1301 <br> 1302 " . $set_call_forward_text . " 1303 <br> 1304 " . $set_vmx_text . " 1305 <br> 1306 " . $set_voicemail_text . " 1307 <br> 1308 " . $set_callmonitor_text . " 1309 <br> 1310 <input name='submit' type='submit' value='" . _("Update") . "'> 1311 </form>"; 1312 1313 return $ret; 1314 } 1315 1316 /* 1317 * Sets Asterisk call forward setting 1318 * 1319 * @param $exten 1320 * Extension to modify 1321 * @param $state 1322 * Call forward enable or disable 1323 * @param $call_forward_number 1324 * Call forward number 1325 * @param $variable_opt 1326 * Call forward type (CF, CFU, CFB) 1327 */ 1328 function setCallForward($exten,$state,$call_forward_number, $variable_opt = "CF") { 1329 1330 global $asterisk_manager_interface; 1331 1332 if ($state) { 1333 $type_opt = "put"; 1334 $value_opt = $call_forward_number; 1335 } 1336 else { 1337 $type_opt = "del"; 1338 } 1339 1340 //$variable_opt = "CF"; 1341 1342 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt $variable_opt $exten $value_opt\r\n\r\n"); 1343 } 1344 1345 /* 1346 * Gets call forward number if set 1347 * 1348 * @param $exten 1349 * Extension to get information about 1350 * @return $number 1351 * call forward number returned if set 1352 * @param $variable_opt 1353 * Call forward type (CF, CFU, CFB) 1354 */ 1355 function getCallForwardNumber($exten, $variable_opt = "CF") { 1356 1357 global $asterisk_manager_interface; 1358 1359 $number = ''; 1360 1361 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get $variable_opt $exten\r\n\r\n"); 1362 if (is_numeric($response)) { 1363 $number = $response; 1364 } 1365 1366 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 1367 if ($stripped==$number) { 1368 $number = $_COOKIE['ari_call_forward_number']; 1369 } 1370 1371 return $number; 1372 } 1373 1374 /* 1375 * Gets VMX option FollowMe 1376 * 1377 * @param $exten 1378 * Extension to get information about 1379 * @param $digit 1380 * Option number to get 1381 * @param $mode 1382 * Mode to get (unavail/busy) 1383 * @return $response 1384 * checked if set to got to extesion's follow-me on this option 1385 */ 1386 function getVmxOptionFollowMe($exten, $digit, $mode='unavail') { 1387 1388 global $asterisk_manager_interface; 1389 1390 $digit = trim($digit); 1391 1392 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n"); 1393 return (($response == 'FM'.$exten) ? 'checked':''); 1394 } 1395 1396 /* 1397 * Sets VMX option FollowMe 1398 * 1399 * @param $exten 1400 * Extension to set information about 1401 * @param $digit 1402 * Option number to set 1403 * @param $mode 1404 * Mode to set (unavail/busy) 1405 * @param $context 1406 * Context to set ext to (default from-findmefollow) 1407 * @param $priority 1408 * Priority to set ext to (default 1) 1409 */ 1410 function setVmxOptionFollowMe($exten, $digit, $mode, $context='ext-findmefollow', $priority='1') { 1411 1412 global $asterisk_manager_interface; 1413 1414 $value_opt = "FM$exten"; 1415 1416 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n"); 1417 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n"); 1418 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n"); 1419 } 1420 1421 /* 1422 * Gets VMX option number 1423 * 1424 * @param $exten 1425 * Extension to get information about 1426 * @param $digit 1427 * Option number to get 1428 * @param $mode 1429 * Mode to get (unavail/busy) 1430 * @return $number 1431 * Number to use or blank if disabled 1432 */ 1433 function getVmxOptionNumber($exten, $digit, $mode='unavail') { 1434 1435 global $asterisk_manager_interface; 1436 1437 $number = ''; 1438 $digit = trim($digit); 1439 1440 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n"); 1441 if (is_numeric($response)) { 1442 $number = $response; 1443 } 1444 1445 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE["ari_vmx_option_${digit}_number"]); 1446 if ($stripped==$number) { 1447 $number = $_COOKIE["ari_vmx_option_${digit}_number"]; 1448 } 1449 1450 return $number; 1451 } 1452 1453 /* 1454 * Sets VMX option number 1455 * 1456 * @param $exten 1457 * Extension to set information about 1458 * @param $digit 1459 * Option number to set 1460 * @param $mode 1461 * Mode to set (unavail/busy) 1462 * @param $number 1463 * Number to set ext to (blank will delete it) 1464 * @param $context 1465 * Context to set ext to (default from-internal) 1466 * @param $priority 1467 * Priority to set ext to (default 1) 1468 */ 1469 function setVmxOptionNumber($exten, $digit, $mode, $number, $context='from-internal', $priority='1') { 1470 1471 global $asterisk_manager_interface; 1472 1473 $value_opt = trim($number); 1474 1475 if (is_numeric($value_opt)) { 1476 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n"); 1477 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n"); 1478 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n"); 1479 } else { 1480 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database deltree AMPUSER $exten/vmx/$mode/$digit\r\n\r\n"); 1481 } 1482 } 1483 1484 /* 1485 * Sets VMX State 1486 * 1487 * @param $exten 1488 * Extension to modify 1489 * @param $mode 1490 * Mode to set (unavail/busy) 1491 * @param $vmx_state 1492 * enabled/disabled state based on check box value 1493 */ 1494 function setVmxState($exten,$mode,$vmx_state) { 1495 1496 global $asterisk_manager_interface; 1497 1498 $value_opt = ($vmx_state)?'enabled':'disabled'; 1499 1500 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/state $value_opt\r\n\r\n"); 1501 } 1502 1503 /* 1504 * Gets VMX State 1505 * 1506 * @param $exten 1507 * Extension to get information about 1508 * @param $mode 1509 * Mode to get (unavail/busy) 1510 * @return $data 1511 * state of variable (checked/blank) or false if no poper value 1512 */ 1513 function getVmxState($exten, $mode='unavail') { 1514 1515 global $asterisk_manager_interface; 1516 1517 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/state\r\n\r\n"); 1518 1519 if (preg_match("/enabled/",$response)) { 1520 $response='checked'; 1521 } 1522 elseif (preg_match("/disabled/",$response)) { 1523 $response=''; 1524 } 1525 else { 1526 $response = false; 1527 } 1528 1529 //TODO: really need to check for a bogus response, see how other side does it 1530 // 1531 return $response; 1532 1533 } 1534 1535 /* 1536 * Sets VMX Play Instructions 1537 * 1538 * @param $exten 1539 * Extension to modify 1540 * @param $vmx_play_instructions 1541 * play instructions or just beep (checked, blank) 1542 * @param $mode 1543 * Mode to set (unavail/busy) 1544 */ 1545 function setVmxPlayInstructions($exten,$mode,$vmx_play_instructions) { 1546 1547 global $asterisk_manager_interface; 1548 1549 $value_opt = ($vmx_play_instructions)?'""':'s'; 1550 1551 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/vmxopts/timeout $value_opt\r\n\r\n"); 1552 } 1553 1554 /* 1555 * Get VMX Play Instructions 1556 * 1557 * @param $exten 1558 * Extension to get information about 1559 * @param $mode 1560 * Mode to get (unavail/busy) 1561 * @return $data 1562 * state of variable (checked/blank) or false if no poper value 1563 */ 1564 function getVmxPlayInstructions($exten, $mode='unavail') { 1565 1566 global $asterisk_manager_interface; 1567 1568 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/vmxopts/timeout\r\n\r\n"); 1569 1570 if (preg_match("/s/",$response)) { 1571 $response=''; 1572 } 1573 else { 1574 $response='checked'; 1575 } 1576 1577 //TODO: really need to check for a bogus response, see how other side does it 1578 // 1579 return $response; 1580 1581 } 368 // End --> 369 </script>\n"; 370 371 $ret .= 372 "<form class='settings' name='ari_settings' action='' method='GET'> 373 <input type=hidden name=m value=" . $m . "> 374 <input type=hidden name=f value='action'> 375 <input type=hidden name=a value='update'> 376 " . $followme_text . " 377 <br> 378 <input name='submit' type='submit' value='" . _("Update") . "'> 379 </form>"; 380 381 return $ret; 382 } 383 1582 384 1583 385 /* … … 1591 393 function setFollowMePreRingTime($exten,$follow_me_prering_time) { 1592 394 1593 global $asterisk_manager_interface;1594 1595 $value_opt = $follow_me_prering_time;1596 1597 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/prering $value_opt\r\n\r\n");395 global $asterisk_manager_interface; 396 397 $value_opt = $follow_me_prering_time; 398 399 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/prering $value_opt\r\n\r\n"); 1598 400 } 1599 401 … … 1608 410 function getFollowMePreRingTime($exten) { 1609 411 1610 global $asterisk_manager_interface;1611 1612 $number = '';1613 1614 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/prering\r\n\r\n");1615 if (is_numeric($response)) {1616 $number = $response;1617 }1618 1619 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_prering_time']);1620 if ($stripped==$number) {1621 $number = $_COOKIE['ari_follow_me_prering_time'];1622 }1623 1624 return $number;412 global $asterisk_manager_interface; 413 414 $number = ''; 415 416 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/prering\r\n\r\n"); 417 if (is_numeric($response)) { 418 $number = $response; 419 } 420 421 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_prering_time']); 422 if ($stripped==$number) { 423 $number = $_COOKIE['ari_follow_me_prering_time']; 424 } 425 426 return $number; 1625 427 } 1626 428 … … 1635 437 function setFollowMeListRingTime($exten,$follow_me_listring_time) { 1636 438 1637 global $asterisk_manager_interface;1638 1639 $value_opt = $follow_me_listring_time;1640 1641 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grptime $value_opt\r\n\r\n");439 global $asterisk_manager_interface; 440 441 $value_opt = $follow_me_listring_time; 442 443 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grptime $value_opt\r\n\r\n"); 1642 444 } 1643 445 … … 1652 454 function getFollowMeListRingTime($exten) { 1653 455 1654 global $asterisk_manager_interface;1655 1656 $number = '';1657 1658 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grptime\r\n\r\n");1659 if (is_numeric($response)) {1660 $number = $response;1661 }1662 1663 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_listring_time']);1664 if ($stripped==$number) {1665 $number = $_COOKIE['ari_follow_me_listring_time'];1666 }1667 1668 return $number;456 global $asterisk_manager_interface; 457 458 $number = ''; 459 460 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grptime\r\n\r\n"); 461 if (is_numeric($response)) { 462 $number = $response; 463 } 464 465 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_listring_time']); 466 if ($stripped==$number) { 467 $number = $_COOKIE['ari_follow_me_listring_time']; 468 } 469 470 return $number; 1669 471 } 1670 472 … … 1679 481 function setFollowMeList($exten,$follow_me_list) { 1680 482 1681 global $asterisk_manager_interface;1682 1683 $value_opt = $follow_me_list;1684 1685 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grplist $value_opt\r\n\r\n");483 global $asterisk_manager_interface; 484 485 $value_opt = $follow_me_list; 486 487 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grplist $value_opt\r\n\r\n"); 1686 488 } 1687 489 … … 1696 498 function getFollowMeList($exten) { 1697 499 1698 global $asterisk_manager_interface;1699 1700 $number = '';1701 1702 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grplist\r\n\r\n");1703 1704 //TODO: really need to check for a bogus response, see how other side does it1705 //1706 return preg_replace("/[^0-9*\-]/", "", $response);500 global $asterisk_manager_interface; 501 502 $number = ''; 503 504 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grplist\r\n\r\n"); 505 506 //TODO: really need to check for a bogus response, see how other side does it 507 // 508 return preg_replace("/[^0-9*\-]/", "", $response); 1707 509 } 1708 510 … … 1717 519 function setFollowMeConfirm($exten,$follow_me_confirm) { 1718 520 1719 global $asterisk_manager_interface;1720 1721 $value_opt = ($follow_me_confirm)?'ENABLED':'DISABLED';1722 1723 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grpconf $value_opt\r\n\r\n");521 global $asterisk_manager_interface; 522 523 $value_opt = ($follow_me_confirm)?'ENABLED':'DISABLED'; 524 525 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grpconf $value_opt\r\n\r\n"); 1724 526 } 1725 527 … … 1734 536 function getFollowMeConfirm($exten) { 1735 537 1736 global $asterisk_manager_interface;1737 1738 $number = '';1739 1740 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grpconf\r\n\r\n");1741 1742 if (preg_match("/ENABLED/",$response)) {1743 $response='checked';1744 }1745 else {1746 $response='';1747 }1748 1749 //TODO: really need to check for a bogus response, see how other side does it1750 //1751 return $response;538 global $asterisk_manager_interface; 539 540 $number = ''; 541 542 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grpconf\r\n\r\n"); 543 544 if (preg_match("/ENABLED/",$response)) { 545 $response='checked'; 546 } 547 else { 548 $response=''; 549 } 550 551 //TODO: really need to check for a bogus response, see how other side does it 552 // 553 return $response; 1752 554 1753 555 } … … 1763 565 function setFollowMeDDial($exten,$follow_me_ddial) { 1764 566 1765 global $asterisk_manager_interface;1766 1767 $value_opt = ($follow_me_ddial)?'DIRECT':'EXTENSION';1768 1769 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/ddial $value_opt\r\n\r\n");567 global $asterisk_manager_interface; 568 569 $value_opt = ($follow_me_ddial)?'DIRECT':'EXTENSION'; 570 571 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/ddial $value_opt\r\n\r\n"); 1770 572 } 1771 573 … … 1780 582 function getFollowMeDDial($exten) { 1781 583 1782 global $asterisk_manager_interface; 1783 1784 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/ddial\r\n\r\n"); 1785 1786 if (preg_match("/EXTENSION/",$response)) { 1787 $response=''; 1788 } 1789 else { 1790 $response='checked'; 1791 } 1792 1793 //TODO: really need to check for a bogus response, see how other side does it 1794 // 1795 return $response; 1796 1797 } 1798 1799 1800 1801 1802 /* 1803 * Sets Asterisk call recording setting 1804 * 1805 * @param $exten 1806 * Extension to modify 1807 * @param $direction 1808 * Call direction 1809 * @param $state 1810 * State to set to 1811 */ 1812 function setRecordSettings($exten,$state_in,$state_out) { 1813 1814 global $asterisk_manager_interface; 1815 1816 if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { 1817 1818 if ($state_in=="Always") { 1819 $type_opt = "put"; 1820 $value_opt = " " . "ENABLED"; 1821 } 1822 elseif ($state_in=="Never") { 1823 $type_opt = "put"; 1824 $value_opt = " " . "DISABLED"; 1825 } 1826 else { 1827 $type_opt = "del"; 1828 $value_opt = ""; 1829 } 1830 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-IN $exten $value_opt\r\n\r\n"); 1831 1832 if ($state_out=="Always") { 1833 $type_opt = "put"; 1834 $value_opt = " " . "ENABLED"; 1835 } 1836 elseif ($state_out=="Never") { 1837 $type_opt = "put"; 1838 $value_opt = " " . "DISABLED"; 1839 } 1840 else { 1841 $type_opt = "del"; 1842 $value_opt = ""; 1843 } 1844 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-OUT $exten $value_opt\r\n\r\n"); 1845 } 1846 else { 1847 1848 $value_opt= "out=".$state_out."|in=".$state_in; 1849 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/recording $value_opt\r\n\r\n"); 1850 } 1851 } 1852 1853 /* 1854 * Gets record settings for a protocol 1855 * 1856 * @param $table 1857 * Table to pull information from 1858 * @param $exten 1859 * Extension to get information about 1860 * @return $data 1861 * call monitor record settings 1862 */ 1863 function getProtocolRecordSettings($table,$exten) { 1864 1865 global $asterisk_manager_interface; 1866 1867 $data = array(); 1868 1869 if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { 1870 1871 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-IN $exten\r\n\r\n"); 1872 if (preg_match("/ENABLED/",$response)) { 1873 $data['record_in'] = 'Always'; 1874 } 1875 elseif (preg_match("/DISABLED/",$response)) { 1876 $data['record_in'] = 'Never'; 1877 } 1878 else { 1879 $data['record_in'] = 'Adhoc'; 1880 } 1881 1882 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-OUT $exten\r\n\r\n"); 1883 if (preg_match("/ENABLED/",$response)) { 1884 $data['record_out'] = 'Always'; 1885 } 1886 elseif (preg_match("/DISABLED/",$response)) { 1887 $data['record_out'] = 'Never'; 1888 } 1889 else { 1890 $data['record_out'] = 'Adhoc'; 1891 } 1892 } 1893 else { 1894 1895 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/recording\r\n\r\n"); 1896 if (strstr($response,"in=Always")) { 1897 $data['record_in'] = 'Always'; 1898 } 1899 elseif (strstr($response,"in=Never")) { 1900 $data['record_in'] = 'Never'; 1901 } 1902 else { 1903 $data['record_in'] = 'Adhoc'; 1904 } 1905 if (strstr($response,"out=Always")) { 1906 $data['record_out'] = 'Always'; 1907 } 1908 elseif (strstr($response,"out=Never")) { 1909 $data['record_out'] = 'Never'; 1910 } 1911 else { 1912 $data['record_out'] = 'Adhoc'; 1913 } 1914 } 1915 1916 return $data; 1917 } 1918 1919 /* 1920 * Gets record settings 1921 * 1922 * @param $exten 1923 * Extension to get information about 1924 * @param $data 1925 * Reference to the variable to store the data in 1926 */ 1927 function getRecordSettings($exten) { 1928 1929 // check protocol tables first 1930 $data = $this->getProtocolRecordSettings($this->protocol_table,$exten); 1931 1932 return $data; 1933 } 1934 1935 /* 1936 * Reloads Asterisk Configuration 1937 */ 1938 function reloadAsteriskVoicemail() { 1939 1940 global $asterisk_manager_interface; 1941 1942 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: Reload app_voicemail.so\r\n\r\n"); 1943 } 584 global $asterisk_manager_interface; 585 586 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/ddial\r\n\r\n"); 587 588 if (preg_match("/EXTENSION/",$response)) { 589 $response=''; 590 } 591 else { 592 $response='checked'; 593 } 594 595 //TODO: really need to check for a bogus response, see how other side does it 596 // 597 return $response; 598 599 } 600 601 602 603 1944 604 1945 605 /* … … 1948 608 function getFreePBXVersion() { 1949 609 1950 if (isset($_SESSION['dbh_asterisk'])) {1951 $sql = "SELECT * FROM admin WHERE variable = 'version'";1952 $results = $_SESSION['dbh_asterisk']->getAll($sql);1953 if(DB::IsError($results)) {1954 $_SESSION['ari_error'] = $results->getMessage();1955 }1956 1957 return $results[0][1];1958 }610 if (isset($_SESSION['dbh_asterisk'])) { 611 $sql = "SELECT * FROM admin WHERE variable = 'version'"; 612 $results = $_SESSION['dbh_asterisk']->getAll($sql); 613 if(DB::IsError($results)) { 614 $_SESSION['ari_error'] = $results->getMessage(); 615 } 616 617 return $results[0][1]; 618 } 1959 619 } 1960 620 … … 1976 636 function setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm) { 1977 637 1978 if (isset($_SESSION['dbh_asterisk'])) {1979 1980 //format for SQL database1981 $follow_me_confirm = ($follow_me_confirm)?'CHECKED':'';1982 1983 $sql = "UPDATE findmefollow SET grptime = '" . $follow_me_listring_time . "', grplist = '".1984 str_replace("'", "''", trim($follow_me_list)) . "', pre_ring = '" . $follow_me_prering_time .1985 "', needsconf = '" . $follow_me_confirm . "' WHERE grpnum = $exten LIMIT 1";1986 $results = $_SESSION['dbh_asterisk']->query($sql);1987 1988 if(DB::IsError($results)) {1989 $_SESSION['ari_error'] = $results->getMessage();1990 }1991 1992 return 1;1993 }638 if (isset($_SESSION['dbh_asterisk'])) { 639 640 //format for SQL database 641 $follow_me_confirm = ($follow_me_confirm)?'CHECKED':''; 642 643 $sql = "UPDATE findmefollow SET grptime = '" . $follow_me_listring_time . "', grplist = '". 644 str_replace("'", "''", trim($follow_me_list)) . "', pre_ring = '" . $follow_me_prering_time . 645 "', needsconf = '" . $follow_me_confirm . "' WHERE grpnum = $exten LIMIT 1"; 646 $results = $_SESSION['dbh_asterisk']->query($sql); 647 648 if(DB::IsError($results)) { 649 $_SESSION['ari_error'] = $results->getMessage(); 650 } 651 652 return 1; 653 } 1994 654 } 1995 655 1996 656 function lookupSetExtensionFormat($exten) { 1997 657 1998 if (trim($exten) == "") return $exten;1999 2000 $exten = preg_replace("/[^0-9*]/", "", $exten);2001 2002 $sql = "SELECT extension FROM users WHERE extension = '".$exten."'";2003 $asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC);2004 if (!is_array($asa)) {2005 return $exten.'#';2006 } else {2007 return $exten;2008 }658 if (trim($exten) == "") return $exten; 659 660 $exten = preg_replace("/[^0-9*]/", "", $exten); 661 662 $sql = "SELECT extension FROM users WHERE extension = '".$exten."'"; 663 $asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC); 664 if (!is_array($asa)) { 665 return $exten.'#'; 666 } else { 667 return $exten; 668 } 2009 669 } 2010 670 freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/phonefeatures.module
r4170 r4328 1 1 <?php 2 3 /** 4 * @file 5 * Functions for the interface to the call monitor recordings 6 */ 7 8 /** 9 * Class for settings 10 */ 11 class Settings { 12 13 var $protocol_table; 14 var $protocol_config_files; 15 16 /* 17 * rank (for prioritizing modules) 18 */ 2 //***************************************************************************** 3 class PhoneFeatures { 4 //***************************************************************************** 19 5 function rank() { 20 6 21 $rank = 100000;7 $rank = 4; 22 8 return $rank; 23 9 } 24 10 25 /* 26 * init 27 */ 11 //***************************************************************************** 28 12 function init() { 29 30 // determine what protocol user is using 31 global $ASTERISK_PROTOCOLS; 32 33 foreach ($ASTERISK_PROTOCOLS as $protocol => $value) { 34 $data = $this->getProtocolRecordSettings($value['table'],$_SESSION['ari_user']['extension']); 35 if (count($data)) { 36 $this->protocol_table = $value['table']; 37 $this->protocol_config_files = $value['config_files']; 38 break; 39 } 40 } 41 } 42 43 /* 44 * Adds menu item to nav menu 45 * 46 * @param $args 47 * Common arguments 48 */ 13 } 14 //***************************************************************************** 49 15 function navMenu($args) { 50 16 51 17 global $ARI_NO_LOGIN; 52 53 // check logout 54 if ($_SESSION['ari_user'] && !$ARI_NO_LOGIN) { 55 $logout = 1; 56 } 57 58 if ($logout!='') { 18 global $SETTINGS_ALLOW_PHONE_SETTINGS; 19 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 20 21 // If we're not allowing call forwarding AND PHONE SETTINGS get out of here 22 if (!$SETTINGS_ALLOW_PHONE_SETTINGS && !$SETTINGS_ALLOW_CALLFORWARD_SETTINGS) return ""; 23 59 24 $ret .= " 60 <br> 61 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p>"; 62 } 25 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=PhoneFeatures&f=display'>" . _("Phone Features") . "</a></small></small></p>"; 63 26 64 27 return $ret; 65 28 } 66 67 /* 68 * Acts on the user settings 69 * 70 * @param $args 71 * Common arguments 72 * @param $a 73 * action 74 */ 29 //***************************************************************************** 75 30 function action($args) { 76 31 77 global $STANDALONE;78 32 global $ARI_ADMIN_USERNAME; 79 global $ ASTERISK_VOICEMAIL_CONF;33 global $SETTINGS_ALLOW_PHONE_SETTINGS; 80 34 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 81 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS;82 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET;83 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH;84 global $SETTINGS_VOICEMAIL_PASSWORD_EXACT;85 global $SETTINGS_ALLOW_CALL_RECORDING_SET;86 global $SETTINGS_ALLOW_VMX_SETTINGS;87 35 88 36 // args 89 37 $m = getArgument($args,'m'); 90 38 $a = getArgument($args,'a'); 91 92 $lang_code = getArgument($args,'lang_code'); 93 94 $call_forward_enable = getArgument($args,'call_forward_enable'); 95 $call_forward_number = getArgument($args,'call_forward_number'); 96 97 $call_forward_busy_enable = getArgument($args,'call_forward_busy_enable'); 98 $call_forward_busy_number = getArgument($args,'call_forward_busy_number'); 99 100 $call_forward_unavailable_enable = getArgument($args,'call_forward_unavailable_enable'); 101 $call_forward_unavailable_number = getArgument($args,'call_forward_unavailable_number'); 102 103 $follow_me_prering_time = getArgument($args,'follow_me_prering_time'); 104 $follow_me_listring_time = getArgument($args,'follow_me_listring_time'); 105 $follow_me_list = getArgument($args,'follow_me_list'); 106 $follow_me_confirm = getArgument($args,'follow_me_confirm'); 107 $follow_me_ddial = getArgument($args,'follow_me_ddial'); 108 $follow_me_disabled = getArgument($args,'follow_me_disabled'); 109 110 $vmx_option_0_number = getArgument($args, 'vmx_option_0_number'); 111 $vmx_option_0_system_default = getArgument($args, 'vmx_option_0_system_default'); 112 $vmx_option_1_number = getArgument($args, 'vmx_option_1_number'); 113 $vmx_option_1_system_default = getArgument($args, 'vmx_option_1_system_default'); 114 $vmx_option_2_number = getArgument($args, 'vmx_option_2_number'); 115 $vmx_unavail_enabled = getArgument($args, 'vmx_unavail_enabled'); 116 $vmx_busy_enabled = getArgument($args, 'vmx_busy_enabled'); 117 $vmx_play_instructions = getArgument($args, 'vmx_play_instructions'); 118 $vmx_disabled = getArgument($args,'vmx_disabled'); 119 120 $voicemail_password = getArgument($args,'voicemail_password'); 121 $voicemail_password_confirm = getArgument($args,'voicemail_password_confirm'); 122 $voicemail_email_address = getArgument($args,'voicemail_email_address'); 123 $voicemail_pager_address = getArgument($args,'voicemail_pager_address'); 124 $voicemail_email_enable = getArgument($args,'voicemail_email_enable'); 125 126 if (isset($_SESSION['ari_user']['voicemail_email'])) { 127 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 128 $var = "voicemail_email_$key"; 129 $$var = getArgument($args,$var); 130 } 131 } 132 133 $voicemail_audio_format = getArgument($args,'voicemail_audio_format'); 134 135 $record_in = getArgument($args,'record_in'); 136 $record_out = getArgument($args,'record_out'); 137 138 $language = new Language(); 139 140 if ($a=='update') { 141 142 $exten = $_SESSION['ari_user']['extension']; 143 if ($exten!=$ARI_ADMIN_USERNAME) { 144 145 // update call forward number 146 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS && !$STANDALONE['use']) { 147 148 // normal call forward 149 $stripped_call_forward_number = preg_replace('/-|\(|\)|\s/','',$call_forward_number); 150 if ($call_forward_enable && !is_numeric($stripped_call_forward_number)) { 151 $_SESSION['ari_error'] = 152 _("Call forward number not changed") . "<br>" . 153 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_number); 154 } 155 else { 156 157 // set database 158 $this->setCallForward($exten,$call_forward_enable,$stripped_call_forward_number); 159 160 // store cookie 161 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 162 if ($call_forward_number && $stripped!=$stripped_call_forward_number) { 163 setcookie("ari_call_forward_number", $call_forward_number, time()+365*24*60*60); 164 } 165 } 166 167 // call forward busy 168 $stripped_call_forward_busy_number = preg_replace('/-|\(|\)|\s/','',$call_forward_busy_number); 169 if ($call_forward_busy_enable && !is_numeric($stripped_call_forward_busy_number)) { 170 $_SESSION['ari_error'] = 171 _("Call forward number not changed") . "<br>" . 172 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_busy_number); 173 } 174 else { 175 176 // set database 177 $this->setCallForward($exten,$call_forward_busy_enable,$stripped_call_forward_busy_number, "CFB"); 178 179 // store cookie 180 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_busy_number']); 181 if ($call_forward_busy_number && $stripped!=$stripped_call_forward_busy_number) { 182 setcookie("ari_call_forward_busy_number", $call_forward_busy_number, time()+365*24*60*60); 183 } 184 } 185 186 // call forward unavailable 187 $stripped_call_forward_unavailable_number = preg_replace('/-|\(|\)|\s/','',$call_forward_unavailable_number); 188 if ($call_forward_unavailable_enable && !is_numeric($stripped_call_forward_unavailable_number)) { 189 $_SESSION['ari_error'] = 190 _("Call forward number not changed") . "<br>" . 191 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_unavailable_number); 192 } 193 else { 194 195 // set database 196 $this->setCallForward($exten,$call_forward_unavailable_enable,$stripped_call_forward_unavailable_number, "CFU"); 197 198 // store cookie 199 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_unavailable_number']); 200 if ($call_forward_unavailable_number && $stripped!=$stripped_call_forward_unavailable_number) { 201 setcookie("ari_call_forward_unavailable_number", $call_forward_unavailable_number, time()+365*24*60*60); 202 } 203 } 204 205 } 206 207 // Make sure Follow-Me setup has not been deleted for this user since the last refresh 208 $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; 209 210 if (! $_COOKIE['ari_follow_me_disabled']) { 211 212 $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1; 213 214 if ($follow_me_disabled) { 215 216 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 217 $follow_me_disabled_delayed = $follow_me_disabled; 218 $_SESSION['ari_error'] = 219 _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" . 220 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 221 } 222 } 223 224 $vmx_disabled_delayed = $_COOKIE['ari_vmx_disabled']; 225 if (! $_COOKIE['ari_vmx_disabled']) { 226 227 $vmx_disabled = $this->getVmxState($exten,'unavail'); 228 if ($vmx_disabled === false) { 229 $vmx_disabled = true; 230 $SETTINGS_ALLOW_VMX_SETTINGS=false; 231 } else { 232 $vmx_disabled = false; 233 } 234 if ($vmx_disabled) { 235 236 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 237 $vmx_disabled_delayed = $vmx_disabled; 238 $_SESSION['ari_error'] = 239 _("Your Premium VmX Locator service has been disabled, REFRESH your browser to remove this message") . "<br>" . 240 sprintf(_("Check with your Telephone System Administrator if you think there is a problem")); 241 } 242 } 243 244 if (! $vmx_disabled_delayed) { 245 if (!$STANDALONE['use']) { 246 247 // set database 248 $this->setVmxState($exten,'unavail',$vmx_unavail_enabled); 249 $this->setVmxState($exten,'busy',$vmx_busy_enabled); 250 $this->setVmxPlayInstructions($exten,'unavail',$vmx_play_instructions); 251 $this->setVmxPlayInstructions($exten,'busy',$vmx_play_instructions); 252 253 // store cookie 254 setcookie("ari_vmx_unavail_enabled", $vmx_unavail_enabled, time()+365*24*60*60); 255 setcookie("ari_vmx_busy_enabled", $vmx_busy_enabled, time()+365*24*60*60); 256 setcookie("ari_vmx_play_instructions", $vmx_play_instructions, time()+365*24*60*60); 257 258 $stripped_vmx_option_0_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_0_number); 259 if ($vmx_option_0_system_default) { 260 $this->setVmxOptionNumber($exten,'0','unavail',""); 261 $this->setVmxOptionNumber($exten,'0','busy',""); 262 setcookie("ari_vmx_option_0_system_default", $vmx_option_0_system_default, time()+365*24*60*60); 263 if (is_numeric($stripped_vmx_option_0_number) || !$stripped_vmx_option_0_number) { 264 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 265 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 266 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 267 } 268 } 269 } else { 270 if (!is_numeric($stripped_vmx_option_0_number) && $stripped_vmx_option_0_number) { 271 $_SESSION['ari_error'] = 272 _("Option 0 not changed") . "<br>" . 273 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_0_number); 274 } 275 else { 276 277 // set database 278 $this->setVmxOptionNumber($exten,'0','unavail',$stripped_vmx_option_0_number); 279 $this->setVmxOptionNumber($exten,'0','busy',$stripped_vmx_option_0_number); 280 281 // store cookie 282 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']); 283 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) { 284 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60); 285 } 286 } 287 } 288 289 $stripped_vmx_option_1_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_1_number); 290 if ($vmx_option_1_system_default && !$follow_me_disabled) { 291 $this->setVmxOptionFollowMe($exten,'1','unavail'); 292 $this->setVmxOptionFollowMe($exten,'1','busy'); 293 setcookie("ari_vmx_option_1_system_default", $vmx_option_1_system_default, time()+365*24*60*60); 294 if (is_numeric($stripped_vmx_option_1_number) || !$stripped_vmx_option_1_number) { 295 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 296 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 297 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 298 } 299 } 300 } 301 else { 302 303 if (!is_numeric($stripped_vmx_option_1_number) && $stripped_vmx_option_1_number) { 304 $_SESSION['ari_error'] = 305 _("Option 1 not changed") . "<br>" . 306 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_1_number); 307 } 308 else { 309 310 // set database 311 $this->setVmxOptionNumber($exten,'1','unavail',$stripped_vmx_option_1_number); 312 $this->setVmxOptionNumber($exten,'1','busy',$stripped_vmx_option_1_number); 313 314 // store cookie 315 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']); 316 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) { 317 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60); 318 } 319 } 320 } 321 322 $stripped_vmx_option_2_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_2_number); 323 if (!is_numeric($stripped_vmx_option_2_number) && $stripped_vmx_option_2_number) { 324 $_SESSION['ari_error'] = 325 _("Option 2 not changed") . "<br>" . 326 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_2_number); 327 } 328 else { 329 330 // set database 331 $this->setVmxOptionNumber($exten,'2','unavail',$stripped_vmx_option_2_number); 332 $this->setVmxOptionNumber($exten,'2','busy',$stripped_vmx_option_2_number); 333 334 // store cookie 335 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_2_number']); 336 if ($vmx_option_2_number && $stripped!=$stripped_vmx_option_2_number) { 337 setcookie("ari_vmx_option_2_number", $call_vmx_option_2_number, time()+365*24*60*60); 338 } 339 } 340 } 341 } // vmx_disabled_delayed false 342 343 if (! $follow_me_disabled_delayed) { 344 345 // assume no errors, don't update SQL if errors occured 346 $follow_me_update_succeeded=1; 347 348 // update follow me pre-ring time 349 if (!$STANDALONE['use']) { 350 351 $stripped_follow_me_prering_time = preg_replace('/-|\s/','',$follow_me_prering_time); 352 if (!is_numeric($stripped_follow_me_prering_time)) { 353 $_SESSION['ari_error'] = 354 _("Follow-Me pre-ring time not changed") . "<br>" . 355 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_prering_time); 356 $follow_me_update_succeeded=0; 357 } 358 else { 359 360 // set database 361 $this->setFollowMePreRingTime($exten,$stripped_follow_me_prering_time); 362 363 // store cookie 364 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_prering_time']); 365 if ($follow_me_prering_time && $stripped!=$stripped_follow_me_prering_time) { 366 setcookie("ari_follow_me_prering_time", $follow_me_prering_time, time()+365*24*60*60); 367 } 368 } 369 } 370 371 // update follow me list ring time 372 if (!$STANDALONE['use']) { 373 374 $stripped_follow_me_listring_time = preg_replace('/-|\s/','',$follow_me_listring_time); 375 if (!is_numeric($stripped_follow_me_listring_time)) { 376 $_SESSION['ari_error'] = 377 _("Follow-Me list ring time not changed") . "<br>" . 378 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_listring_time); 379 $follow_me_update_succeeded=0; 380 } 381 else { 382 383 // set database 384 $this->setFollowMeListRingTime($exten,$stripped_follow_me_listring_time); 385 386 // store cookie 387 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_listring_time']); 388 if ($follow_me_listring_time && $stripped!=$stripped_follow_me_listring_time) { 389 setcookie("ari_follow_me_listring_time", $follow_me_listring_time, time()+365*24*60*60); 390 } 391 } 392 } 393 394 // update follow me list 395 if (!$STANDALONE['use']) { 396 397 $grplist = explode("\n", $follow_me_list); 398 399 if (!$grplist) { 400 $grplist = null; 401 } 402 403 foreach (array_keys($grplist) as $key) { 404 //trim it 405 $grplist[$key] = trim($grplist[$key]); 406 407 // Lookup the extension and append hash if not a user, and remove invalid chars 408 $grplist[$key] = $this->lookupSetExtensionFormat($grplist[$key]); 409 410 // remove blanks 411 if ($grplist[$key] == "") unset($grplist[$key]); 412 } 413 414 // check for duplicates, and re-sequence 415 $grplist = array_values(array_unique($grplist)); 416 417 $stripped_follow_me_list = implode("-",$grplist); 418 419 if ($stripped_follow_me_list == "") { 420 $_SESSION['ari_error'] = 421 _("Follow-Me list must contain at least one valid number") . "<br>" . 422 sprintf(_("The following: %s is not valid"),$follow_me_list); 423 $follow_me_update_succeeded=0; 424 } 425 else { 426 427 // set database 428 $this->setFollowMeList($exten,$stripped_follow_me_list); 429 430 // store cookie 431 $stripped = preg_replace('/|\(|\)|\s/','',$_COOKIE['ari_follow_me_list']); 432 if ($follow_me_list && $stripped!=$stripped_follow_me_list) { 433 setcookie("ari_follow_me_list", $follow_me_list, time()+365*24*60*60); 434 } 435 } 436 } 437 438 // update follow me confirm 439 if (!$STANDALONE['use']) { 440 441 // set database 442 $this->setFollowMeConfirm($exten,$follow_me_confirm); 443 $this->setFollowMeDDial($exten,$follow_me_ddial); 444 445 // store cookie 446 setcookie("ari_follow_me_confirm", $follow_me_confirm, time()+365*24*60*60); 447 setcookie("ari_follow_me_ddial", $follow_me_ddial, time()+365*24*60*60); 448 } 449 450 //If no errors than update the SQL table to keep in sync 451 if ($follow_me_update_succeeded) { 452 $this->setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm); 453 } 454 455 } //if !follow_me_disabled 456 457 // voicemail settings 458 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1) { 459 460 461 // update voicemail password 462 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 463 464 // update voicemail password 465 if ($voicemail_password=='' || $voicemail_password_confirm=='') { 466 $_SESSION['ari_error'] = 467 _("Voicemail password not changed") . "<br>" . 468 _("Password and password confirm must not be blank"); 469 } 470 else if ((strlen($voicemail_password)<$SETTINGS_VOICEMAIL_PASSWORD_LENGTH) || !is_numeric($voicemail_password)) { 471 $_SESSION['ari_error'] = 472 _("Voicemail password not changed") . "<br>" . 473 sprintf(_("Passwords must be all numbers and greater than %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 474 } 475 else if (strlen($voicemail_password)!=$SETTINGS_VOICEMAIL_PASSWORD_LENGTH && $SETTINGS_VOICEMAIL_PASSWORD_EXACT || !is_numeric($voicemail_password)) { 476 $_SESSION['ari_error'] = 477 _("Voicemail password not changed") . "<br>" . 478 sprintf(_("Passwords must be all numbers and only %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 479 } 480 else if ($voicemail_password!=$voicemail_password_confirm) { 481 $_SESSION['ari_error'] = 482 _("Voicemail password not changed") . "<br>" . 483 _("Password and password confirm do not match"); 484 } 485 else { 486 487 // check for writable the files 488 $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 489 $fp = fopen($temp_file, "w"); 490 if (!$fp) { 491 $_SESSION['ari_error'] = 492 _("Voicemail password not changed") . "<br>" . 493 sprintf(_("%s does not exist or is not writable"),$temp_file); 494 } 495 else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 496 $_SESSION['ari_error'] = 497 _("Voicemail password not changed") . "<br>" . 498 sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 499 } 500 else { 501 502 // update session 503 $_SESSION['ari_user']['voicemail_password'] = $voicemail_password; 504 505 // save password 506 $lines = file($ASTERISK_VOICEMAIL_CONF); 507 foreach ($lines as $key => $line) { 508 unset($value); 509 list($var,$value) = split('=>',$line); 510 $var = trim($var); 511 if ($var==$exten && $value) { 512 513 // write out line with password change 514 $buf = split(',',$value); 515 $buf[0] = $voicemail_password; 516 $line = $var . " => " . join(',', $buf); 517 518 fwrite($fp, $line); 519 } 520 else { 521 522 // write out original line with no changes 523 fwrite($fp, $line); 524 } 525 } 526 fclose($fp); 527 unlink($ASTERISK_VOICEMAIL_CONF); 528 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 529 530 $voicemail_reload = 1; 531 } 532 } 533 534 // voicemail email address 535 if ($voicemail_email_enable && 536 ($voicemail_email_address && !preg_match('/@/',$voicemail_email_address) || 537 ($voicemail_pager_address && !preg_match('/@/',$voicemail_pager_address)))) { 538 $_SESSION['ari_error'] = 539 _("Voicemail email and pager address not changed") . "<br>" . 540 ("'$voicemail_email_address' and '$voicemail_pager_address' must be a valid email addresses"); 541 } 542 else { 543 544 // check for writable the files 545 $temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; 546 $fp = fopen($temp_file, "w"); 547 if (!$fp) { 548 $_SESSION['ari_error'] = 549 _("Voicemail email settings not changed") . "<br>" . 550 sprintf(_("%s does not exist or is not writable"),$temp_file); 551 } 552 else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { 553 $_SESSION['ari_error'] = 554 _("Voicemail email settings not changed") . "<br>" . 555 sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); 556 } 557 else { 558 559 // store cookie 560 if ($voicemail_email_enable) { 561 setcookie("ari_voicemail_email_address", $voicemail_email_address, time()+365*24*60*60); 562 setcookie("ari_voicemail_pager_address", $voicemail_pager_address, time()+365*24*60*60); 563 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 564 $var = "voicemail_email_$key"; 565 $var_cookie = "ari_" . $var; 566 setcookie("$var_cookie", $$var, time()+365*24*60*60); 567 } 568 } 569 570 // update session 571 $_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable; 572 if ($voicemail_email_enable) { 573 $_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address; 574 $_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address; 575 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 576 $option = "voicemail_email_$key"; 577 $_SESSION['ari_user']['voicemail_email'][$key] = $$option; 578 } 579 } 580 581 // save settings 582 if (!$voicemail_email_enable) { 583 $voicemail_email_address = ''; 584 $voicemail_pager_address = ''; 585 } 586 587 $lines = file($ASTERISK_VOICEMAIL_CONF); 588 foreach ($lines as $key => $line) { 589 unset($value); 590 list($var,$value) = split('=>',$line); 591 $var = trim($var); 592 if ($var==$exten && $value) { 593 594 // write out line with voicemail email change 595 $buf = split(',',$value); 596 $buf[2] = $voicemail_email_address; 597 $buf[3] = $voicemail_pager_address; 598 599 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 600 $option = "voicemail_email_$key"; 601 if ($$option && $key) { 602 $options .= $key . "=" . $value; 603 } 604 else { 605 $options .= $key . "=no"; 606 } 607 $options .= "|"; 608 } 609 $buf[4] = substr($options, 0, -1); 610 611 $line = $var . " =>" . join(',', $buf); 612 if (substr($line, 0, -1)!="\n") { 613 $line .= "\n"; 614 } 615 616 fwrite($fp, $line); 617 } 618 else { 619 620 // write out original line with no changes 621 fwrite($fp, $line); 622 } 623 } 624 fclose($fp); 625 unlink($ASTERISK_VOICEMAIL_CONF); 626 rename($temp_file,$ASTERISK_VOICEMAIL_CONF); 627 628 $voicemail_reload = 1; 629 } 630 } 631 632 // reload asterisk voicemail 633 if ($voicemail_reload) { 634 $this->reloadAsteriskVoicemail(); 635 } 636 } 637 638 // update voicemail audio format setting 639 setcookie("ari_voicemail_audio_format", $voicemail_audio_format, time()+365*24*60*60); 640 } 641 642 // update call monitor record setting 643 if ($SETTINGS_ALLOW_CALL_RECORDING_SET) { 644 if ($record_in && $record_out) { 645 $this->setRecordSettings($exten,$record_in,$record_out); 646 } 647 } 648 } 649 } 39 $lang_code = getArgument( $args,'lang_code'); 40 $exten = $_SESSION['ari_user']['extension']; 41 42 if ($a=='update') { 43 44 if ($SETTINGS_ALLOW_PHONE_SETTINGS) { 45 if ($exten!=$ARI_ADMIN_USERNAME) { 46 $this->storePhoneSetting( $args, $exten, 'call_waiting', 'CW', 'ENABLED'); 47 $this->storePhoneSetting( $args, $exten, 'do_not_disturb', 'DND', 'YES'); 48 } 49 } 50 51 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS) { 52 if ($exten!=$ARI_ADMIN_USERNAME) { 53 $this->storeCallForwardNumber( $args, $exten, 'call_forward', 'CF'); 54 $this->storeCallForwardNumber( $args, $exten, 'call_forward_busy', 'CFB'); 55 $this->storeCallForwardNumber( $args, $exten, 'call_forward_unavailable', 'CFU'); 56 } 57 } 58 } 650 59 651 60 // redirect to see updated page 652 $ret .= "653 <head>654 <script>655 <!--656 window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\"657 // -->658 </script>659 </head>";61 $ret .= " 62 <head> 63 <script> 64 <!-- 65 window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\" 66 // --> 67 </script> 68 </head>"; 660 69 661 70 return $ret; 662 71 } 663 664 /* 665 * Displays stats page 666 * 667 * @param $args 668 * Common arguments 669 */ 670 function display($args) { 671 672 global $STANDALONE; 673 global $ARI_ADMIN_USERNAME; 72 //***************************************************************************** 73 function display($args) { 74 75 global $STANDALONE; 76 global $ARI_ADMIN_USERNAME; 77 global $SETTINGS_ALLOW_PHONE_SETTINGS; 674 78 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS; 675 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS;676 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET;677 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH;678 global $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS;679 global $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT;680 global $SETTINGS_ALLOW_CALL_RECORDING_SET;681 global $SETTINGS_PRERING_LOW;682 global $SETTINGS_PRERING_HIGH;683 global $SETTINGS_LISTRING_LOW;684 global $SETTINGS_LISTRING_HIGH;685 686 global $SETTINGS_FOLLOW_ME_LIST_MAX;687 global $SETTINGS_ALLOW_VMX_SETTINGS;688 689 global $loaded_modules;690 79 691 80 // args 692 81 $m = getArgument($args,'m'); 693 $q = getArgument($args,'q'); 694 $start = getArgument($args,'start'); 695 $span = getArgument($args,'span'); 696 697 $displayname = $_SESSION['ari_user']['displayname']; 698 $exten = $_SESSION['ari_user']['extension']; 699 700 $language = new Language(); 701 $display = new DisplaySearch(); 702 703 // get data 704 $data = $this->getRecordSettings($_SESSION['ari_user']['extension']); 705 706 // lang setting options 707 if (extension_loaded('gettext')) { 708 $setLangText = " 709 <p class='lang'> 710 " . _("Language:") . " 711 " . $language->GetForm() . " 712 </p>"; 713 } 714 715 // build controls 716 if ($exten!=$ARI_ADMIN_USERNAME) { 717 718 // call forward settings 719 if (!$STANDALONE['use']) { 720 721 722 $call_forward_number = $this->getCallForwardNumber($exten); 723 if ($call_forward_number) { 724 $call_forward_enable = 'checked'; 725 } 726 else { 727 $call_forward_number = $_COOKIE['ari_call_forward_number']; 728 $call_forward_text_box_options = "disabled style='background: #DDD;'"; 729 } 730 731 $call_forward_busy_number = $this->getCallForwardNumber($exten, 'CFB'); 732 if ($call_forward_busy_number) { 733 $call_forward_busy_enable = 'checked'; 734 } 735 else { 736 $call_forward_busy_number = $_COOKIE['ari_call_forward_busy_number']; 737 $call_forward_busy_text_box_options = "disabled style='background: #DDD;'"; 738 } 739 740 $call_forward_unavailable_number = $this->getCallForwardNumber($exten, 'CFU'); 741 if ($call_forward_unavailable_number) { 742 $call_forward_unavailable_enable = 'checked'; 743 } 744 else { 745 $call_forward_unavailable_number = $_COOKIE['ari_call_forward_unavailable_number']; 746 $call_forward_unavailable_text_box_options = "disabled style='background: #DDD;'"; 747 } 748 749 $follow_me_prering_time = $this->getFollowMePreRingTime($exten); 750 $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 751 $follow_me_list = explode("-", $this->getFollowMeList($exten) ); 752 $follow_me_confirm = $this->getFollowMeConfirm($exten); 753 $follow_me_ddial = $this->getFollowMeDDial($exten); 754 755 $FOLLOW_ME_LIST_MAX = (count($follow_me_list) > $SETTINGS_FOLLOW_ME_LIST_MAX) ? count($follow_me_list):$SETTINGS_FOLLOW_ME_LIST_MAX; 756 757 //TODO: Set this better than this? 758 $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 759 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 760 761 $set_call_forward_text = "<table class='settings'>"; 762 763 $set_call_forward_text .= (!$SETTINGS_ALLOW_CALLFORWARD_SETTINGS)?'':" 764 <table class='settings'> 765 <tr> 766 <td><h3>" . _("Call Forwarding") . "</h3></td> 767 </tr> 768 <tr> 769 <td>" . _("Unconditional:") . "</td> 770 <td> 771 <input " . $call_forward_text_box_options . " name='call_forward_number' type='text' size=24 value='" . $call_forward_number . "'> 772 </td> 773 <td> 774 <input " . $call_forward_enable . " type=checkbox name='call_forward_enable' value='checked' OnClick=\"disable_fields(); return 775 true;\"> 776 <small>" . _("Enable") . "</small> 777 </td> 778 </tr> 779 <tr> 780 <td>" . _("Unavailable:") . "</td> 781 <td> 782 <input " . $call_forward_unavailable_text_box_options . " name='call_forward_unavailable_number' type='text' size=24 value='" . $call_forward_unavailable_number . "'> 783 </td> 784 <td> 785 <input " . $call_forward_unavailable_enable . " type=checkbox name='call_forward_unavailable_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 786 <small>" . _("Enable") . "</small> 787 </td> 788 </tr> 789 <tr> 790 <td>" . _("Busy:") . "</td> 791 <td> 792 <input " . $call_forward_busy_text_box_options . " name='call_forward_busy_number' type='text' size=24 value='" . $call_forward_busy_number . "'> 793 </td> 794 <td> 795 <input " . $call_forward_busy_enable . " type=checkbox name='call_forward_busy_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 796 <small>" . _("Enable") . "</small> 797 </td> 798 </tr> 799 800 "; 801 802 $set_call_forward_text .= ($follow_me_disabled)?'':" 803 <tr> 804 <td><h3><br>" . _("Follow Me") . "</h3></td> 805 </tr> 806 <tr> 807 <td><a href='#' class='info'>" . _("Enable") . "<span>". _(" 808 Dial-by-name Directory, IVR, and internal calls will ring the numbers in the FollowMe List. Any FreePBX routes that directly reference a FollowMe are unaffected by this enable/disable setting. 809 ") . "<br></span></a></td> 810 <td> 811 <input " . $follow_me_ddial . " type=checkbox name='follow_me_ddial' value='checked'> 812 <small>" . _("") . "</small> 813 </td> 814 </tr> 815 <tr> 816 <td><a href='#' class='info'>" . sprintf(_("Ring %s First For:"),$exten) . "<span>" .sprintf( _("Time to ring extension %s before ringing the %s Follow Me List %s"),"<strong>".$exten."</strong>","<strong>","</strong>") . 817 "<br></span></a></td> 818 <td> 819 <select " . $follow_me_prering_time_text_box_options . " name='follow_me_prering_time'/>"; 820 if (!$follow_me_disabled) { 821 $default_prering = $follow_me_prering_time; 822 for ($i=$SETTINGS_PRERING_LOW; $i <= $SETTINGS_PRERING_HIGH; $i++) { 823 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_prering ? 'SELECTED' : '').'>'.$i.'</option>'; 824 } 825 } 826 $set_call_forward_text .= ($follow_me_disabled)?'':" 827 </select> 828 <small>" . _("seconds") . "</small> 829 </td> 830 <tr> 831 <td valign='top'><a href='#' class='info'>" . _("Follow Me List:") . "<span>" . sprintf(_("Extensions and outside numbers to ring next.")) ."<br/><br/>". sprintf(_("Include %s to keep it ringing."),"<strong>".$exten."</strong>") . "<br></span></a></td> 832 <td> 833 <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> 834 </td> 835 <tr> 836 <td><a href='#' class='info'>" . _("List Ring Time:") . "<span>" . _("Time to ring the Follow Me List.") . "<br></span></a></td> 837 <td> 838 <select " . $follow_me_listring_time_text_box_options . " name='follow_me_listring_time'/>"; 839 if (!$follow_me_disabled) { 840 $default_listring = $follow_me_listring_time; 841 for ($i=$SETTINGS_LISTRING_LOW; $i <= $SETTINGS_LISTRING_HIGH; $i++) { 842 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_listring ? 'SELECTED' : '').'>'.$i.'</option>'; 843 } 844 } 845 $set_call_forward_text .= ($follow_me_disabled)?'':" 846 </select> 847 <small>" . _("seconds") . "</small> 848 </td> 849 <tr> 850 <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.") . "<br></span></a></td> 851 <td> 852 <input " . $follow_me_confirm . " type=checkbox name='follow_me_confirm' value='checked'> 853 <small>" . _("Enable") . "</small> 854 </td> 855 </tr> 856 "; 857 858 $set_call_forward_text .= " 859 </tr> 860 </table> 861 "; 862 863 $vmx_unavail_enabled=$this->getVmxState($exten,'unavail'); 864 if ($vmx_unavail_enabled === false) { 865 $vmx_disabled = true; 866 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 867 $SETTINGS_ALLOW_VMX_SETTINGS=false; 868 } else { 869 $vmx_disabled = false; 870 setcookie("ari_vmx_disabled", false, time()+365*24*60*60); 871 $vmx_busy_enabled=$this->getVmxState($exten,'busy'); 872 $vmx_play_instructions=$this->getVmxPlayInstructions($exten); 873 $vmx_option_0_number=$this->getVmxOptionNumber($exten,'0');; 874 $vmx_option_1_number=$this->getVmxOptionNumber($exten,'1');; 875 $vmx_option_2_number=$this->getVmxOptionNumber($exten,'2');; 876 877 if (is_numeric($vmx_option_0_number)) { 878 $vmx_option_0_system_default=''; 879 $vmx_option_0_number_text_box_options=''; 880 } else { 881 $vmx_option_0_system_default='checked'; 882 $vmx_option_0_number_text_box_options="disabled style='background: #DDD;'"; 883 } 884 885 // if follow-me is enabled then the options are a numberic value (dial a phone number) 886 // or a followme target (FMnnn) which should not be displayed but means the box is checked 887 // or otherwise blank (or garbage in which case blank it) 888 // 889 if (!$follow_me_disabled) { 890 $vmx_option_1_system_default=$this->getVmxOptionFollowMe($exten,'1'); 891 if ($vmx_option_1_system_default) { 892 $vmx_option_1_number = ''; 893 $vmx_option_1_number_text_box_options="disabled style='background: #DDD;'"; 894 } 895 } 896 } 897 $set_vmx_text .= (!$SETTINGS_ALLOW_VMX_SETTINGS)?'':" 898 <table class='settings'> 899 <tr> 900 <td><h3>" . _("Voicemail VmX Locator") . "</h3></td> 901 </tr> 902 <tr> 903 <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> 904 <input " . $vmx_unavail_enabled . " type=checkbox name='vmx_unavail_enabled' value='checked'> 905 <small>" . _("unavailable") . "</small> 906 </td> 907 <td> 908 <input " . $vmx_busy_enabled . " type=checkbox name='vmx_busy_enabled' value='checked'> 909 <small>" . _("busy") . "</small> 910 </td> 911 </tr> 912 <tr> 913 <td><a href='#' class='info'>" . _("Voicemail Instructions:") ."<span>" . _("Uncheck to play a beep after your personal voicemail greeting.") . "<br></span></a></td> 914 <td> 915 <input " . $vmx_play_instructions . " type=checkbox name='vmx_play_instructions' value='checked'> 916 <small>" . _("Standard voicemail prompts.") . "</small> 917 </td> 918 </tr> 919 </table> 920 <table class='settings'> 921 <tr> 922 <td> </td> 923 <td><a href='#' class='info'>" . _("Press 0:") . "<span>" . _("Pressing 0 during your personal voicemail greeing goes to the Operator. 924 Uncheck to enter another destination here.") . "<br></span></a></td> 925 <td> 926 <input " . $vmx_option_0_number_text_box_options . " name='vmx_option_0_number' type='text' size=24 value='" . $vmx_option_0_number . "'> 927 </td> 928 <td> 929 <input " . $vmx_option_0_system_default . " type=checkbox name='vmx_option_0_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 930 <small>" . _("Go To Operator") . "</small> 931 </td> 932 </tr> 933 "; 934 935 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled))?'':" 936 <tr> 937 <td> </td> 938 <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> 939 <td> 940 <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 941 </td> 942 <td> 943 <input " . $vmx_option_1_system_default . " type=checkbox name='vmx_option_1_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 944 <small>" . _("Send to Follow-Me") . "</small> 945 </td> 946 </tr> 947 <tr> 948 <td> </td> 949 <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> 950 <td> 951 <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 952 </td> 953 </tr> 954 </table> 955 "; 956 957 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && $follow_me_disabled))?'':" 958 <tr> 959 <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> 960 <td> 961 <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 962 </td> 963 </tr> 964 <tr> 965 <td>" . _("Option 2:") . "</td> 966 <td> 967 <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 968 </td> 969 </tr> 970 </table> 971 "; 972 973 974 } 975 976 // voicemail settings 977 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1 && 978 in_array('voicemail',array_keys($loaded_modules))) { 979 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 980 981 if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) { 982 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 983 } 984 else { 985 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 986 } 987 988 $set_voicemail_password_text = " 989 <tr> 990 <td>" . _("Voicemail Password:") . "</td> 991 <td> 992 <input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 993 </td> 994 </tr> 995 <tr> 996 <td>" . _("Enter again to confirm:") . "</td> 997 <td> 998 <input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 999 </td> 1000 </tr> 1001 <tr> 1002 <td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td> 1003 </tr>"; 1004 } 1005 1006 if (isset($_SESSION['ari_user']['voicemail_email'])) { 1007 1008 if ($_SESSION['ari_user']['voicemail_email_enable']) { 1009 $voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address']; 1010 $voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address']; 1011 $voicemail_email_enable = 'checked'; 1012 1013 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 1014 $var = "voicemail_email_$key"; 1015 $var_enable = $var . "enable"; 1016 if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') { 1017 $$var_enable = 'checked'; 1018 } 1019 } 1020 } 1021 else { 1022 1023 $voicemail_email_address = $_COOKIE['ari_voicemail_email_address']; 1024 $voicemail_email_text_box_options = "disabled style='background: #DDD;'"; 1025 $voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address']; 1026 $voicemail_pager_text_box_options = "disabled style='background: #DDD;'"; 1027 1028 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1029 $var = "voicemail_email_$key"; 1030 $var_cookie = "ari_" . $var; 1031 $var_enable = $var . "enable"; 1032 $var_text_box_options = $var . "text_box_options"; 1033 1034 $$var_text_box_options = "disabled"; 1035 if ($_COOKIE[$var_cookie]=='yes') { 1036 $$var_enable = 'checked'; 1037 } 1038 } 1039 } 1040 1041 $set_voicemail_email_text = " 1042 1043 <tr> 1044 <td> " . _("Email Notification") . " <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\"> 1045 <small> " ._("Enable") . " </small> 1046 </td> 1047 </tr><tr> 1048 <td><a href='#' class='info'>" . _("Email Voicemail To:") . "<span>" . ("Email a notification, including audio file if indicated below.") . " </span></a></td> 1049 <td> 1050 <input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'> 1051 </td> 1052 </tr> 1053 <tr> 1054 <td><a href='#' class='info'>" . _("Pager Email Notification To:") . "<span>" . ("Email a short notification") . " </span></a></td> 1055 <td> 1056 <input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'> 1057 </td> 1058 </tr> 1059 <tr> 1060 <td></td> 1061 </tr>"; 1062 1063 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1064 1065 $var = "voicemail_email_$key"; 1066 $var_enable = $var . "enable"; 1067 $var_text_box_options = $var . "text_box_options"; 1068 if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) { 1069 $var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]; 1070 } 1071 else { 1072 $var_text = $key; 1073 } 1074 1075 if ($value != 'yes' && $value != 'no' && $value !='') { 1076 1077 $size = strlen($value) - 1; 1078 $set_voicemail_email_text .= " 1079 <tr> 1080 <td></td> 1081 <td> 1082 <input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "' OnClick=\"disable_fields(); return true;\"> 1083 <small>" . $var_text . "</small> 1084 </td> 1085 </tr>"; 1086 } 1087 else { 1088 1089 $set_voicemail_email_text .= " 1090 <tr> 1091 <td></td> 1092 <td> 1093 <input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "' value='yes' OnClick=\"disable_fields(); return true;\"> 1094 <small>" . $var_text . "</small> 1095 </td> 1096 </tr>"; 1097 } 1098 } 1099 } 1100 1101 $wav_enable = 'selected'; 1102 if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'|| 1103 ($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) { 1104 $wav_enable = ''; 1105 $gsm_enable = 'selected'; 1106 } 1107 1108 $set_voicemail_audio_format_text = " 1109 <tr> 1110 <td>" . _("Audio Format:") . "</td> 1111 <td> 1112 <select name='voicemail_audio_format'> 1113 <option value='.wav' " . $wav_enable . ">" . _("Best Quality") . " (.wav)</option> 1114 <option value='.gsm' " . $gsm_enable . ">" . _("Smallest Download") . " (.gsm)</option> 1115 </select> 1116 </td> 1117 </tr>"; 1118 1119 $set_voicemail_text = " 1120 <table class='settings'> 1121 <tr> 1122 <td><h3>" . _("Voicemail Settings") . "</h3></td> 1123 </tr> 1124 " . $set_voicemail_password_text . " 1125 " . $set_voicemail_email_text . " 1126 " . $set_voicemail_audio_format_text . " 1127 </table>"; 1128 } 1129 1130 // call monitor settings 1131 if ($this->getFreePBXVersion() && 1132 $SETTINGS_ALLOW_CALL_RECORDING_SET && 1133 in_array('callmonitor',array_keys($loaded_modules))) { 1134 1135 foreach($data as $key=>$value) { 1136 if ($key=='record_in') { 1137 if ($value=='Always') { 1138 $ri_always = 'checked=checked'; 1139 } 1140 elseif ($value=='Never') { 1141 $ri_never = 'checked=checked'; 1142 } 1143 elseif ($value=='Adhoc') { 1144 $ri_on_demand = 'checked=checked'; 1145 } 1146 } 1147 if ($key=='record_out') { 1148 if ($value=='Always') { 1149 $ro_always = 'checked=checked'; 1150 } 1151 elseif ($value=='Never') { 1152 $ro_never = 'checked=checked'; 1153 } 1154 elseif ($value=='Adhoc') { 1155 $ro_on_demand = 'checked=checked'; 1156 } 1157 } 1158 } 1159 1160 $set_callmonitor_text = " 1161 <table class='settings'> 1162 <tr> 1163 <td><h3>" . _("Call Monitor Settings") . "</h3></td> 1164 </tr> 1165 <tr> 1166 <td>" . _("Record INCOMING:") . " </td> 1167 <td> 1168 <input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . " 1169 <input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . " 1170 <input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . " 1171 </td> 1172 </tr> 1173 <tr> 1174 <td>" . _("Record OUTGOING:") . " </td> 1175 <td> 1176 <input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . " 1177 <input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . " 1178 <input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . " 1179 </td> 1180 </tr> 1181 </table>"; 1182 } 1183 } 1184 1185 // javascript enable options 1186 if (isset($_SESSION['ari_user']['voicemail_email']) && 1187 in_array('voicemail',array_keys($loaded_modules))) { 1188 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1189 $var = "voicemail_email_$key"; 1190 $js_voicemail_email_disable .= " 1191 document.ari_settings.$var.disabled = false;"; 1192 $js_voicemail_email_enable .= " 1193 document.ari_settings.$var.disabled = true;"; 1194 } 1195 1196 $js_voicemail_script = " 1197 if (document.ari_settings.voicemail_email_enable.checked) { 1198 document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; 1199 document.ari_settings.voicemail_email_address.disabled = false; 1200 document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; 1201 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; 1202 document.ari_settings.voicemail_pager_address.disabled = false; 1203 document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; 1204 " . $js_voicemail_email_disable . " 1205 } 1206 else { 1207 document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; 1208 document.ari_settings.voicemail_email_address.disabled = true; 1209 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; 1210 document.ari_settings.voicemail_pager_address.disabled = true; 1211 " . $js_voicemail_email_enable . " 1212 }"; 1213 } 1214 1215 // build page content 1216 $ret .= checkErrorMessage(); 1217 1218 if ($_SESSION['ari_user']['admin_settings']) { 1219 $headerText = _("Settings"); 1220 } else { 1221 $headerText = sprintf(_("Settings for %s (%s)"),$displayname,$exten); 1222 } 1223 1224 $ret .= $display->displayHeaderText($headerText); 1225 $ret .= $display->displayLine(); 1226 1227 $ret .= " 1228 <SCRIPT LANGUAGE='JavaScript'> 1229 <!-- Begin 1230 function rowCounter(field, maxlimit) { 1231 temp = field.value.split('\u000A',maxlimit+1) 1232 field.value = temp.join('\u000A') 1233 if (temp.length == maxlimit+1) { 1234 field.value = field.value.substring(0, field.value.length-1) 1235 } 1236 } 1237 1238 function disable_fields() {"; 1239 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS) { 1240 $ret .= " 1241 if (document.ari_settings.call_forward_enable.checked) { 1242 document.ari_settings.call_forward_number.style.backgroundColor = '#FFF'; 1243 document.ari_settings.call_forward_number.disabled = false; 1244 } 1245 else { 1246 document.ari_settings.call_forward_number.style.backgroundColor = '#DDD'; 1247 document.ari_settings.call_forward_number.disabled = true; 1248 } 1249 1250 if (document.ari_settings.call_forward_busy_enable.checked) { 1251 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#FFF'; 1252 document.ari_settings.call_forward_busy_number.disabled = false; 1253 } 1254 else { 1255 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#DDD'; 1256 document.ari_settings.call_forward_busy_number.disabled = true; 1257 } 1258 1259 if (document.ari_settings.call_forward_unavailable_enable.checked) { 1260 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#FFF'; 1261 document.ari_settings.call_forward_unavailable_number.disabled = false; 1262 } 1263 else { 1264 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#DDD'; 1265 document.ari_settings.call_forward_unavailable_number.disabled = true; 1266 }"; 1267 } 1268 if ($SETTINGS_ALLOW_VMX_SETTINGS) { 1269 $ret .= " 1270 if (document.ari_settings.vmx_option_0_system_default.checked) { 1271 document.ari_settings.vmx_option_0_number.style.backgroundColor = '#DDD'; 1272 document.ari_settings.vmx_option_0_number.disabled = true; 1273 } 1274 else { 1275 document.ari_settings.vmx_option_0_number.style.backgroundColor = '#FFF'; 1276 document.ari_settings.vmx_option_0_number.disabled = false; 1277 }"; 1278 } 1279 if ($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled) { 1280 $ret .= " 1281 if (document.ari_settings.vmx_option_1_system_default.checked) { 1282 document.ari_settings.vmx_option_1_number.style.backgroundColor = '#DDD'; 1283 document.ari_settings.vmx_option_1_number.disabled = true; 1284 } 1285 else { 1286 document.ari_settings.vmx_option_1_number.style.backgroundColor = '#FFF'; 1287 document.ari_settings.vmx_option_1_number.disabled = false; 1288 }"; 1289 } 1290 $ret .= $js_voicemail_script . " 1291 } 1292 // End --> 1293 </script>"; 1294 1295 $ret .= " 1296 " . $setLangText . " 1297 <form class='settings' name='ari_settings' action='' method='GET'> 1298 <input type=hidden name=m value=" . $m . "> 1299 <input type=hidden name=f value='action'> 1300 <input type=hidden name=a value='update'> 1301 <br> 1302 " . $set_call_forward_text . " 1303 <br> 1304 " . $set_vmx_text . " 1305 <br> 1306 " . $set_voicemail_text . " 1307 <br> 1308 " . $set_callmonitor_text . " 1309 <br> 1310 <input name='submit' type='submit' value='" . _("Update") . "'> 1311 </form>"; 1312 1313 return $ret; 1314 } 1315 82 $a = getArgument($args,'a'); 83 $lang_code = getArgument( $args,'lang_code'); 84 $exten = $_SESSION['ari_user']['extension']; 85 86 $displayname = $_SESSION['ari_user']['displayname']; 87 $exten = $_SESSION['ari_user']['extension']; 88 89 $display = new DisplaySearch(); 90 91 // build controls 92 if ($exten!=$ARI_ADMIN_USERNAME) { 93 94 if ($SETTINGS_ALLOW_PHONE_SETTINGS) { 95 $dnd_cw_text = "<table class='settings'>"; 96 $dnd_cw_text.= "<tr><td><h3>" . _("Phone Features") . "</h3></td></tr>"; 97 98 $dnd_cw_text.= $this->displayPhoneControls( $exten, 'call_waiting', 'CW', "Call Waiting"); 99 $dnd_cw_text.= $this->displayPhoneControls( $exten, 'do_not_disturb', 'DND', "Do Not Disturb"); 100 101 $dnd_cw_text .= "</table>"; 102 } 103 104 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS) { 105 106 $set_call_forward_text .= "<SCRIPT LANGUAGE='JavaScript'> 107 <!-- Begin 108 function rowCounter(field, maxlimit) { 109 temp = field.value.split('\u000A',maxlimit+1) 110 field.value = temp.join('\u000A') 111 if (temp.length == maxlimit+1) { 112 field.value = field.value.substring(0, field.value.length-1) 113 } 114 } 115 116 function disable_fields() { 117 118 if (document.ari_settings.call_forward_enable.checked) { 119 document.ari_settings.call_forward_number.style.backgroundColor = '#FFF'; 120 document.ari_settings.call_forward_number.disabled = false; 121 } 122 else { 123 document.ari_settings.call_forward_number.style.backgroundColor = '#DDD'; 124 document.ari_settings.call_forward_number.disabled = true; 125 } 126 127 if (document.ari_settings.call_forward_busy_enable.checked) { 128 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#FFF'; 129 document.ari_settings.call_forward_busy_number.disabled = false; 130 } 131 else { 132 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#DDD'; 133 document.ari_settings.call_forward_busy_number.disabled = true; 134 } 135 136 if (document.ari_settings.call_forward_unavailable_enable.checked) { 137 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#FFF'; 138 document.ari_settings.call_forward_unavailable_number.disabled = false; 139 } 140 else { 141 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#DDD'; 142 document.ari_settings.call_forward_unavailable_number.disabled = true; 143 } 144 } 145 // End --> 146 </script>"; 147 148 $set_call_forward_text.= "<table class='settings'>"; 149 $set_call_forward_text.= "<tr><td><h3>" . _("Call Forwarding") . "</h3></td></tr>"; 150 151 $set_call_forward_text.= $this->displayCallForwardControls( $exten, 'call_forward', 'CF', "Unconditional:"); 152 $set_call_forward_text.= $this->displayCallForwardControls( $exten, 'call_forward_unavailable', 'CFU', "Unavailable:"); 153 $set_call_forward_text.= $this->displayCallForwardControls( $exten, 'call_forward_busy', 'CFB', "Busy:"); 154 155 $set_call_forward_text .= "</table>"; 156 } 157 } 158 159 // build page content 160 $ret .= checkErrorMessage(); 161 162 if ($_SESSION['ari_user']['admin_settings']) { 163 $headerText = _("Phone Features"); 164 } else { 165 $headerText = sprintf(_("Phone Features for %s (%s)"),$displayname,$exten); 166 } 167 168 $ret .= $display->displayHeaderText($headerText); 169 $ret .= $display->displayLine(); 170 $ret .= " 171 <form class='settings' name='ari_settings' action='' method='GET'> 172 <input type=hidden name=m value=" . $m . "> 173 <input type=hidden name=f value='action'> 174 <input type=hidden name=a value='update'> 175 <br> 176 " . $dnd_cw_text . " 177 <br> 178 " . $set_call_forward_text . " 179 <br> 180 <input name='submit' type='submit' value='" . _("Update") . "'> 181 </form>"; 182 183 return $ret; 184 } 185 //***************************************************************************** 186 function setPhoneSetting( $databaseCallFwdType, $exten, $state_value) { 187 188 global $asterisk_manager_interface; 189 190 $type_opt = ($state_value != "") ? "put":"del"; 191 192 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt $databaseCallFwdType $exten $state_value\r\n\r\n"); 193 } 194 195 //***************************************************************************** 196 function getPhoneSetting($exten, $databaseCallFwdType) { 197 198 global $asterisk_manager_interface; 199 $number = ''; 200 201 $result = false; 202 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get $databaseCallFwdType $exten\r\n\r\n"); 203 if (stristr($response, 'ENABLED')) { 204 $result = true; 205 } 206 elseif (stristr($response, 'YES')) { 207 $result = true; 208 } 209 210 return $result; 211 } 212 //***************************************************************************** 213 function storePhoneSetting( $args, $exten, $settingType, $databaseCallFwdType, $state_value) 214 { 215 $setting_enable = getArgument( $args, $settingType . '_enable'); 216 217 $this->setPhoneSetting( $databaseCallFwdType, $exten, ($setting_enable == 'checked')?$state_value:""); 218 } 219 220 //***************************************************************************** 221 function displayPhoneControls( $exten, $callFwdType, $databaseCallFwdType, $title) 222 { 223 224 $phone_setting_enable = ($this->getPhoneSetting($exten, $databaseCallFwdType)) ? 'checked':''; 225 226 $ret = "\n<tr>"; 227 $ret.= "<td>"; 228 $ret.= "<label><input " . $phone_setting_enable . " type=checkbox name='" . $callFwdType . "_enable' value='checked' >"; 229 $ret.= "<small>" . _($title) . "</small></label>"; 230 $ret.= "</td>"; 231 $ret.= "</tr>\n"; 232 233 return $ret; 234 } 235 //***************************************************************************** 1316 236 /* 1317 237 * Sets Asterisk call forward setting … … 1338 258 } 1339 259 1340 //$variable_opt = "CF";1341 1342 260 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt $variable_opt $exten $value_opt\r\n\r\n"); 1343 261 } … … 1353 271 * Call forward type (CF, CFU, CFB) 1354 272 */ 1355 function getCallForwardNumber($exten, $variable_opt = "CF") { 1356 1357 global $asterisk_manager_interface; 1358 1359 $number = ''; 1360 1361 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get $variable_opt $exten\r\n\r\n"); 1362 if (is_numeric($response)) { 1363 $number = $response; 1364 } 1365 1366 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 1367 if ($stripped==$number) { 1368 $number = $_COOKIE['ari_call_forward_number']; 1369 } 1370 1371 return $number; 1372 } 1373 1374 /* 1375 * Gets VMX option FollowMe 1376 * 1377 * @param $exten 1378 * Extension to get information about 1379 * @param $digit 1380 * Option number to get 1381 * @param $mode 1382 * Mode to get (unavail/busy) 1383 * @return $response 1384 * checked if set to got to extesion's follow-me on this option 1385 */ 1386 function getVmxOptionFollowMe($exten, $digit, $mode='unavail') { 1387 1388 global $asterisk_manager_interface; 1389 1390 $digit = trim($digit); 1391 1392 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n"); 1393 return (($response == 'FM'.$exten) ? 'checked':''); 1394 } 1395 1396 /* 1397 * Sets VMX option FollowMe 1398 * 1399 * @param $exten 1400 * Extension to set information about 1401 * @param $digit 1402 * Option number to set 1403 * @param $mode 1404 * Mode to set (unavail/busy) 1405 * @param $context 1406 * Context to set ext to (default from-findmefollow) 1407 * @param $priority 1408 * Priority to set ext to (default 1) 1409 */ 1410 function setVmxOptionFollowMe($exten, $digit, $mode, $context='ext-findmefollow', $priority='1') { 1411 1412 global $asterisk_manager_interface; 1413 1414 $value_opt = "FM$exten"; 1415 1416 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n"); 1417 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n"); 1418 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n"); 1419 } 1420 1421 /* 1422 * Gets VMX option number 1423 * 1424 * @param $exten 1425 * Extension to get information about 1426 * @param $digit 1427 * Option number to get 1428 * @param $mode 1429 * Mode to get (unavail/busy) 1430 * @return $number 1431 * Number to use or blank if disabled 1432 */ 1433 function getVmxOptionNumber($exten, $digit, $mode='unavail') { 1434 1435 global $asterisk_manager_interface; 1436 1437 $number = ''; 1438 $digit = trim($digit); 1439 1440 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n"); 1441 if (is_numeric($response)) { 1442 $number = $response; 1443 } 1444 1445 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE["ari_vmx_option_${digit}_number"]); 1446 if ($stripped==$number) { 1447 $number = $_COOKIE["ari_vmx_option_${digit}_number"]; 1448 } 1449 1450 return $number; 1451 } 1452 1453 /* 1454 * Sets VMX option number 1455 * 1456 * @param $exten 1457 * Extension to set information about 1458 * @param $digit 1459 * Option number to set 1460 * @param $mode 1461 * Mode to set (unavail/busy) 1462 * @param $number 1463 * Number to set ext to (blank will delete it) 1464 * @param $context 1465 * Context to set ext to (default from-internal) 1466 * @param $priority 1467 * Priority to set ext to (default 1) 1468 */ 1469 function setVmxOptionNumber($exten, $digit, $mode, $number, $context='from-internal', $priority='1') { 1470 1471 global $asterisk_manager_interface; 1472 1473 $value_opt = trim($number); 1474 1475 if (is_numeric($value_opt)) { 1476 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/ext $value_opt\r\n\r\n"); 1477 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/context $context\r\n\r\n"); 1478 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/$digit/pri $priority\r\n\r\n"); 1479 } else { 1480 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database deltree AMPUSER $exten/vmx/$mode/$digit\r\n\r\n"); 1481 } 1482 } 1483 1484 /* 1485 * Sets VMX State 1486 * 1487 * @param $exten 1488 * Extension to modify 1489 * @param $mode 1490 * Mode to set (unavail/busy) 1491 * @param $vmx_state 1492 * enabled/disabled state based on check box value 1493 */ 1494 function setVmxState($exten,$mode,$vmx_state) { 1495 1496 global $asterisk_manager_interface; 1497 1498 $value_opt = ($vmx_state)?'enabled':'disabled'; 1499 1500 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/state $value_opt\r\n\r\n"); 1501 } 1502 1503 /* 1504 * Gets VMX State 1505 * 1506 * @param $exten 1507 * Extension to get information about 1508 * @param $mode 1509 * Mode to get (unavail/busy) 1510 * @return $data 1511 * state of variable (checked/blank) or false if no poper value 1512 */ 1513 function getVmxState($exten, $mode='unavail') { 1514 1515 global $asterisk_manager_interface; 1516 1517 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/state\r\n\r\n"); 1518 1519 if (preg_match("/enabled/",$response)) { 1520 $response='checked'; 1521 } 1522 elseif (preg_match("/disabled/",$response)) { 1523 $response=''; 1524 } 273 function getCallForwardNumber($exten, $variable_opt = "CF") { 274 275 global $asterisk_manager_interface; 276 277 $number = ''; 278 279 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get $variable_opt $exten\r\n\r\n"); 280 if (is_numeric($response)) { 281 $number = $response; 282 } 283 284 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_number']); 285 if ($stripped==$number) { 286 $number = $_COOKIE['ari_call_forward_number']; 287 } 288 289 return $number; 290 } 291 292 293 function storeCallForwardNumber( $args, $exten, $callFwdType, $databaseCallFwdType) 294 { 295 $call_forward_enable = getArgument($args, $callFwdType . '_enable'); 296 $call_forward_number = getArgument($args, $callFwdType . '_number'); 297 298 $stripped_call_forward_number = preg_replace('/-|\(|\)|\s/','',$call_forward_number); 299 300 if ($call_forward_enable && !is_numeric($stripped_call_forward_number)) { 301 $_SESSION['ari_error'] = _("Call forward number not changed") . "<br>" . 302 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"), $call_forward_number); 303 } 1525 304 else { 1526 $response = false; 1527 } 1528 1529 //TODO: really need to check for a bogus response, see how other side does it 1530 // 1531 return $response; 1532 1533 } 1534 1535 /* 1536 * Sets VMX Play Instructions 1537 * 1538 * @param $exten 1539 * Extension to modify 1540 * @param $vmx_play_instructions 1541 * play instructions or just beep (checked, blank) 1542 * @param $mode 1543 * Mode to set (unavail/busy) 1544 */ 1545 function setVmxPlayInstructions($exten,$mode,$vmx_play_instructions) { 1546 1547 global $asterisk_manager_interface; 1548 1549 $value_opt = ($vmx_play_instructions)?'""':'s'; 1550 1551 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/vmx/$mode/vmxopts/timeout $value_opt\r\n\r\n"); 1552 } 1553 1554 /* 1555 * Get VMX Play Instructions 1556 * 1557 * @param $exten 1558 * Extension to get information about 1559 * @param $mode 1560 * Mode to get (unavail/busy) 1561 * @return $data 1562 * state of variable (checked/blank) or false if no poper value 1563 */ 1564 function getVmxPlayInstructions($exten, $mode='unavail') { 1565 1566 global $asterisk_manager_interface; 1567 1568 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/vmxopts/timeout\r\n\r\n"); 1569 1570 if (preg_match("/s/",$response)) { 1571 $response=''; 1572 } 305 $this->setCallForward( $exten, $call_forward_enable, $stripped_call_forward_number, $databaseCallFwdType); 306 307 // store cookie 308 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_' . $callFwdType]); 309 if ($call_forward_number && $stripped!=$stripped_call_forward_number) { 310 setcookie('ari_' . $callFwdType, $call_forward_number, time()+365*24*60*60); 311 } 312 } 313 } 314 315 function displayCallForwardControls( $exten, $callFwdType, $databaseCallFwdType, $title) 316 { 317 $call_forward_number = $this->getCallForwardNumber($exten, $databaseCallFwdType); 318 319 // If we have a value, we want the item checked 320 if ($call_forward_number) { 321 $call_forward_enable = 'checked'; 322 } 1573 323 else { 1574 $response='checked'; 1575 } 1576 1577 //TODO: really need to check for a bogus response, see how other side does it 1578 // 1579 return $response; 1580 1581 } 1582 1583 /* 1584 * Sets Follow Me Pre-Ring Time 1585 * 1586 * @param $exten 1587 * Extension to modify 1588 * @param $follow_me_prering_time 1589 * Pre-Ring Time to ring 1590 */ 1591 function setFollowMePreRingTime($exten,$follow_me_prering_time) { 1592 1593 global $asterisk_manager_interface; 1594 1595 $value_opt = $follow_me_prering_time; 1596 1597 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/prering $value_opt\r\n\r\n"); 1598 } 1599 1600 /* 1601 * Gets Follow Me Pre-Ring Time if set 1602 * 1603 * @param $exten 1604 * Extension to get information about 1605 * @return $number 1606 * follow me pre-ring time returned if set 1607 */ 1608 function getFollowMePreRingTime($exten) { 1609 1610 global $asterisk_manager_interface; 1611 1612 $number = ''; 1613 1614 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/prering\r\n\r\n"); 1615 if (is_numeric($response)) { 1616 $number = $response; 1617 } 1618 1619 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_prering_time']); 1620 if ($stripped==$number) { 1621 $number = $_COOKIE['ari_follow_me_prering_time']; 1622 } 1623 1624 return $number; 1625 } 1626 1627 /* 1628 * Sets Follow Me List Ring Time 1629 * 1630 * @param $exten 1631 * Extension to modify 1632 * @param $follow_me_listring_time 1633 * List Ring Time to ring 1634 */ 1635 function setFollowMeListRingTime($exten,$follow_me_listring_time) { 1636 1637 global $asterisk_manager_interface; 1638 1639 $value_opt = $follow_me_listring_time; 1640 1641 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grptime $value_opt\r\n\r\n"); 1642 } 1643 1644 /* 1645 * Gets Follow Me List-Ring Time if set 1646 * 1647 * @param $exten 1648 * Extension to get information about 1649 * @return $number 1650 * follow me list-ring time returned if set 1651 */ 1652 function getFollowMeListRingTime($exten) { 1653 1654 global $asterisk_manager_interface; 1655 1656 $number = ''; 1657 1658 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grptime\r\n\r\n"); 1659 if (is_numeric($response)) { 1660 $number = $response; 1661 } 1662 1663 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_follow_me_listring_time']); 1664 if ($stripped==$number) { 1665 $number = $_COOKIE['ari_follow_me_listring_time']; 1666 } 1667 1668 return $number; 1669 } 1670 1671 /* 1672 * Sets Follow Me List 1673 * 1674 * @param $exten 1675 * Extension to modify 1676 * @param $follow_me_list 1677 * Follow Me List 1678 */ 1679 function setFollowMeList($exten,$follow_me_list) { 1680 1681 global $asterisk_manager_interface; 1682 1683 $value_opt = $follow_me_list; 1684 1685 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grplist $value_opt\r\n\r\n"); 1686 } 1687 1688 /* 1689 * Gets Follow Me List if set 1690 * 1691 * @param $exten 1692 * Extension to get information about 1693 * @return $data 1694 * follow me list if set 1695 */ 1696 function getFollowMeList($exten) { 1697 1698 global $asterisk_manager_interface; 1699 1700 $number = ''; 1701 1702 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grplist\r\n\r\n"); 1703 1704 //TODO: really need to check for a bogus response, see how other side does it 1705 // 1706 return preg_replace("/[^0-9*\-]/", "", $response); 1707 } 1708 1709 /* 1710 * Sets Follow Confirmation Setting 1711 * 1712 * @param $exten 1713 * Extension to modify 1714 * @param $follow_me_cofirm 1715 * Follow Me Confirm Setting 1716 */ 1717 function setFollowMeConfirm($exten,$follow_me_confirm) { 1718 1719 global $asterisk_manager_interface; 1720 1721 $value_opt = ($follow_me_confirm)?'ENABLED':'DISABLED'; 1722 1723 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/grpconf $value_opt\r\n\r\n"); 1724 } 1725 1726 /* 1727 * Gets Follow Me Confirmation Setting 1728 * 1729 * @param $exten 1730 * Extension to get information about 1731 * @return $data 1732 * follow me confirm setting 1733 */ 1734 function getFollowMeConfirm($exten) { 1735 1736 global $asterisk_manager_interface; 1737 1738 $number = ''; 1739 1740 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/grpconf\r\n\r\n"); 1741 1742 if (preg_match("/ENABLED/",$response)) { 1743 $response='checked'; 1744 } 1745 else { 1746 $response=''; 1747 } 1748 1749 //TODO: really need to check for a bogus response, see how other side does it 1750 // 1751 return $response; 1752 1753 } 1754 1755 /* 1756 * Sets Follow Ddial Setting 1757 * 1758 * @param $exten 1759 * Extension to modify 1760 * @param $follow_me_ddial 1761 * Follow Me Ddial Setting 1762 */ 1763 function setFollowMeDDial($exten,$follow_me_ddial) { 1764 1765 global $asterisk_manager_interface; 1766 1767 $value_opt = ($follow_me_ddial)?'DIRECT':'EXTENSION'; 1768 1769 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/followme/ddial $value_opt\r\n\r\n"); 1770 } 1771 1772 /* 1773 * Gets Follow Me Ddial Setting 1774 * 1775 * @param $exten 1776 * Extension to get information about 1777 * @return $data 1778 * follow me ddial setting 1779 */ 1780 function getFollowMeDDial($exten) { 1781 1782 global $asterisk_manager_interface; 1783 1784 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/followme/ddial\r\n\r\n"); 1785 1786 if (preg_match("/EXTENSION/",$response)) { 1787 $response=''; 1788 } 1789 else { 1790 $response='checked'; 1791 } 1792 1793 //TODO: really need to check for a bogus response, see how other side does it 1794 // 1795 return $response; 1796 1797 } 1798 1799 1800 1801 1802 /* 1803 * Sets Asterisk call recording setting 1804 * 1805 * @param $exten 1806 * Extension to modify 1807 * @param $direction 1808 * Call direction 1809 * @param $state 1810 * State to set to 1811 */ 1812 function setRecordSettings($exten,$state_in,$state_out) { 1813 1814 global $asterisk_manager_interface; 1815 1816 if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { 1817 1818 if ($state_in=="Always") { 1819 $type_opt = "put"; 1820 $value_opt = " " . "ENABLED"; 1821 } 1822 elseif ($state_in=="Never") { 1823 $type_opt = "put"; 1824 $value_opt = " " . "DISABLED"; 1825 } 1826 else { 1827 $type_opt = "del"; 1828 $value_opt = ""; 1829 } 1830 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-IN $exten $value_opt\r\n\r\n"); 1831 1832 if ($state_out=="Always") { 1833 $type_opt = "put"; 1834 $value_opt = " " . "ENABLED"; 1835 } 1836 elseif ($state_out=="Never") { 1837 $type_opt = "put"; 1838 $value_opt = " " . "DISABLED"; 1839 } 1840 else { 1841 $type_opt = "del"; 1842 $value_opt = ""; 1843 } 1844 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-OUT $exten $value_opt\r\n\r\n"); 1845 } 1846 else { 1847 1848 $value_opt= "out=".$state_out."|in=".$state_in; 1849 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/recording $value_opt\r\n\r\n"); 1850 } 1851 } 1852 1853 /* 1854 * Gets record settings for a protocol 1855 * 1856 * @param $table 1857 * Table to pull information from 1858 * @param $exten 1859 * Extension to get information about 1860 * @return $data 1861 * call monitor record settings 1862 */ 1863 function getProtocolRecordSettings($table,$exten) { 1864 1865 global $asterisk_manager_interface; 1866 1867 $data = array(); 1868 1869 if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { 1870 1871 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-IN $exten\r\n\r\n"); 1872 if (preg_match("/ENABLED/",$response)) { 1873 $data['record_in'] = 'Always'; 1874 } 1875 elseif (preg_match("/DISABLED/",$response)) { 1876 $data['record_in'] = 'Never'; 1877 } 1878 else { 1879 $data['record_in'] = 'Adhoc'; 1880 } 1881 1882 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-OUT $exten\r\n\r\n"); 1883 if (preg_match("/ENABLED/",$response)) { 1884 $data['record_out'] = 'Always'; 1885 } 1886 elseif (preg_match("/DISABLED/",$response)) { 1887 $data['record_out'] = 'Never'; 1888 } 1889 else { 1890 $data['record_out'] = 'Adhoc'; 1891 } 1892 } 1893 else { 1894 1895 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/recording\r\n\r\n"); 1896 if (strstr($response,"in=Always")) { 1897 $data['record_in'] = 'Always'; 1898 } 1899 elseif (strstr($response,"in=Never")) { 1900 $data['record_in'] = 'Never'; 1901 } 1902 else { 1903 $data['record_in'] = 'Adhoc'; 1904 } 1905 if (strstr($response,"out=Always")) { 1906 $data['record_out'] = 'Always'; 1907 } 1908 elseif (strstr($response,"out=Never")) { 1909 $data['record_out'] = 'Never'; 1910 } 1911 else { 1912 $data['record_out'] = 'Adhoc'; 1913 } 1914 } 1915 1916 return $data; 1917 } 1918 1919 /* 1920 * Gets record settings 1921 * 1922 * @param $exten 1923 * Extension to get information about 1924 * @param $data 1925 * Reference to the variable to store the data in 1926 */ 1927 function getRecordSettings($exten) { 1928 1929 // check protocol tables first 1930 $data = $this->getProtocolRecordSettings($this->protocol_table,$exten); 1931 1932 return $data; 1933 } 1934 1935 /* 1936 * Reloads Asterisk Configuration 1937 */ 1938 function reloadAsteriskVoicemail() { 1939 1940 global $asterisk_manager_interface; 1941 1942 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: Reload app_voicemail.so\r\n\r\n"); 1943 } 1944 1945 /* 1946 * Gets FreePBX Version 1947 */ 1948 function getFreePBXVersion() { 1949 1950 if (isset($_SESSION['dbh_asterisk'])) { 1951 $sql = "SELECT * FROM admin WHERE variable = 'version'"; 1952 $results = $_SESSION['dbh_asterisk']->getAll($sql); 1953 if(DB::IsError($results)) { 1954 $_SESSION['ari_error'] = $results->getMessage(); 1955 } 1956 1957 return $results[0][1]; 1958 } 1959 } 1960 1961 /* 1962 * Sets Follow-Me Settings in FreePBX MySQL Database 1963 * 1964 * @param $exten 1965 * Extension to modify 1966 * @param $follow_me_prering_time 1967 * Pre-Ring Time to ring 1968 * @param $follow_me_listring_time 1969 * List Ring Time to ring 1970 * @param $follow_me_list 1971 * Follow Me List 1972 * @param $follow_me_list 1973 * Follow Me Confirm Setting 1974 * 1975 */ 1976 function setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm) { 1977 1978 if (isset($_SESSION['dbh_asterisk'])) { 1979 1980 //format for SQL database 1981 $follow_me_confirm = ($follow_me_confirm)?'CHECKED':''; 1982 1983 $sql = "UPDATE findmefollow SET grptime = '" . $follow_me_listring_time . "', grplist = '". 1984 str_replace("'", "''", trim($follow_me_list)) . "', pre_ring = '" . $follow_me_prering_time . 1985 "', needsconf = '" . $follow_me_confirm . "' WHERE grpnum = $exten LIMIT 1"; 1986 $results = $_SESSION['dbh_asterisk']->query($sql); 1987 1988 if(DB::IsError($results)) { 1989 $_SESSION['ari_error'] = $results->getMessage(); 1990 } 1991 1992 return 1; 1993 } 1994 } 1995 1996 function lookupSetExtensionFormat($exten) { 1997 1998 if (trim($exten) == "") return $exten; 1999 2000 $exten = preg_replace("/[^0-9*]/", "", $exten); 2001 2002 $sql = "SELECT extension FROM users WHERE extension = '".$exten."'"; 2003 $asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC); 2004 if (!is_array($asa)) { 2005 return $exten.'#'; 2006 } else { 2007 return $exten; 2008 } 2009 } 2010 2011 324 $call_forward_number = $_COOKIE['ari_' . $callFwdType ]; 325 $call_forward_text_box_options = "disabled style='background: #DDD;'"; 326 } 327 328 $ret = "\n<tr>"; 329 $ret.= "<td>" . _($title) . "</td>"; 330 $ret.= "<td>"; 331 $ret.= "<input " . $call_forward_text_box_options . " name='" . $callFwdType . "_number' type='text' size=24 value='" . $call_forward_number . "'>"; 332 $ret.= "</td>"; 333 $ret.= "<td>"; 334 $ret.= "<input " . $call_forward_enable . " type=checkbox name='" . $callFwdType . "_enable' value='checked' OnClick=\"disable_fields(); return true;\">"; 335 $ret.= "<small>" . _("Enable") . "</small>"; 336 $ret.= "</td>"; 337 $ret.= "</tr>\n"; 338 339 return $ret; 340 } 2012 341 } // class 2013 2014 342 ?> freepbx/branches/2.3/amp_conf/htdocs/recordings/modules/settings.module
r4170 r4328 19 19 function rank() { 20 20 21 $rank = 100000;21 $rank = 9; 22 22 return $rank; 23 23 } … … 58 58 if ($logout!='') { 59 59 $ret .= " 60 <br>61 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p> ";60 61 <p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p><br>"; 62 62 } 63 63 … … 78 78 global $ARI_ADMIN_USERNAME; 79 79 global $ASTERISK_VOICEMAIL_CONF; 80 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS;81 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS;82 80 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 83 81 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; 84 82 global $SETTINGS_VOICEMAIL_PASSWORD_EXACT; 85 83 global $SETTINGS_ALLOW_CALL_RECORDING_SET; 86 global $SETTINGS_ALLOW_VMX_SETTINGS;87 84 88 85 // args … … 94 91 $call_forward_enable = getArgument($args,'call_forward_enable'); 95 92 $call_forward_number = getArgument($args,'call_forward_number'); 96 97 $call_forward_busy_enable = getArgument($args,'call_forward_busy_enable');98 $call_forward_busy_number = getArgument($args,'call_forward_busy_number');99 100 $call_forward_unavailable_enable = getArgument($args,'call_forward_unavailable_enable');101 $call_forward_unavailable_number = getArgument($args,'call_forward_unavailable_number');102 103 $follow_me_prering_time = getArgument($args,'follow_me_prering_time');104 $follow_me_listring_time = getArgument($args,'follow_me_listring_time');105 $follow_me_list = getArgument($args,'follow_me_list');106 $follow_me_confirm = getArgument($args,'follow_me_confirm');107 $follow_me_ddial = getArgument($args,'follow_me_ddial');108 $follow_me_disabled = getArgument($args,'follow_me_disabled');109 110 $vmx_option_0_number = getArgument($args, 'vmx_option_0_number');111 $vmx_option_0_system_default = getArgument($args, 'vmx_option_0_system_default');112 $vmx_option_1_number = getArgument($args, 'vmx_option_1_number');113 $vmx_option_1_system_default = getArgument($args, 'vmx_option_1_system_default');114 $vmx_option_2_number = getArgument($args, 'vmx_option_2_number');115 $vmx_unavail_enabled = getArgument($args, 'vmx_unavail_enabled');116 $vmx_busy_enabled = getArgument($args, 'vmx_busy_enabled');117 $vmx_play_instructions = getArgument($args, 'vmx_play_instructions');118 $vmx_disabled = getArgument($args,'vmx_disabled');119 93 120 94 $voicemail_password = getArgument($args,'voicemail_password'); … … 144 118 145 119 // update call forward number 146 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS && !$STANDALONE['use']) { 147 148 // normal call forward 120 if (!$STANDALONE['use']) { 121 149 122 $stripped_call_forward_number = preg_replace('/-|\(|\)|\s/','',$call_forward_number); 150 123 if ($call_forward_enable && !is_numeric($stripped_call_forward_number)) { … … 164 137 } 165 138 } 166 167 // call forward busy168 $stripped_call_forward_busy_number = preg_replace('/-|\(|\)|\s/','',$call_forward_busy_number);169 if ($call_forward_busy_enable && !is_numeric($stripped_call_forward_busy_number)) {170 $_SESSION['ari_error'] =171 _("Call forward number not changed") . "<br>" .172 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_busy_number);173 }174 else {175 176 // set database177 $this->setCallForward($exten,$call_forward_busy_enable,$stripped_call_forward_busy_number, "CFB");178 179 // store cookie180 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_busy_number']);181 if ($call_forward_busy_number && $stripped!=$stripped_call_forward_busy_number) {182 setcookie("ari_call_forward_busy_number", $call_forward_busy_number, time()+365*24*60*60);183 }184 }185 186 // call forward unavailable187 $stripped_call_forward_unavailable_number = preg_replace('/-|\(|\)|\s/','',$call_forward_unavailable_number);188 if ($call_forward_unavailable_enable && !is_numeric($stripped_call_forward_unavailable_number)) {189 $_SESSION['ari_error'] =190 _("Call forward number not changed") . "<br>" .191 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$call_forward_unavailable_number);192 }193 else {194 195 // set database196 $this->setCallForward($exten,$call_forward_unavailable_enable,$stripped_call_forward_unavailable_number, "CFU");197 198 // store cookie199 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_call_forward_unavailable_number']);200 if ($call_forward_unavailable_number && $stripped!=$stripped_call_forward_unavailable_number) {201 setcookie("ari_call_forward_unavailable_number", $call_forward_unavailable_number, time()+365*24*60*60);202 }203 }204 205 139 } 206 140 207 // Make sure Follow-Me setup has not been deleted for this user since the last refresh208 $follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled'];209 210 if (! $_COOKIE['ari_follow_me_disabled']) {211 212 $follow_me_disabled = ($this->getFollowMeListRingTime($exten) > 0)?0:1;213 214 if ($follow_me_disabled) {215 216 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60);217 $follow_me_disabled_delayed = $follow_me_disabled;218 $_SESSION['ari_error'] =219 _("Your Follow-Me has been disabled, REFRESH your browser to remove this message") . "<br>" .220 sprintf(_("Check with your Telephone System Administrator if you think there is a problem"));221 }222 }223 224 $vmx_disabled_delayed = $_COOKIE['ari_vmx_disabled'];225 if (! $_COOKIE['ari_vmx_disabled']) {226 227 $vmx_disabled = $this->getVmxState($exten,'unavail');228 if ($vmx_disabled === false) {229 $vmx_disabled = true;230 $SETTINGS_ALLOW_VMX_SETTINGS=false;231 } else {232 $vmx_disabled = false;233 }234 if ($vmx_disabled) {235 236 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60);237 $vmx_disabled_delayed = $vmx_disabled;238 $_SESSION['ari_error'] =239 _("Your Premium VmX Locator service has been disabled, REFRESH your browser to remove this message") . "<br>" .240 sprintf(_("Check with your Telephone System Administrator if you think there is a problem"));241 }242 }243 244 if (! $vmx_disabled_delayed) {245 if (!$STANDALONE['use']) {246 247 // set database248 $this->setVmxState($exten,'unavail',$vmx_unavail_enabled);249 $this->setVmxState($exten,'busy',$vmx_busy_enabled);250 $this->setVmxPlayInstructions($exten,'unavail',$vmx_play_instructions);251 $this->setVmxPlayInstructions($exten,'busy',$vmx_play_instructions);252 253 // store cookie254 setcookie("ari_vmx_unavail_enabled", $vmx_unavail_enabled, time()+365*24*60*60);255 setcookie("ari_vmx_busy_enabled", $vmx_busy_enabled, time()+365*24*60*60);256 setcookie("ari_vmx_play_instructions", $vmx_play_instructions, time()+365*24*60*60);257 258 $stripped_vmx_option_0_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_0_number);259 if ($vmx_option_0_system_default) {260 $this->setVmxOptionNumber($exten,'0','unavail',"");261 $this->setVmxOptionNumber($exten,'0','busy',"");262 setcookie("ari_vmx_option_0_system_default", $vmx_option_0_system_default, time()+365*24*60*60);263 if (is_numeric($stripped_vmx_option_0_number) || !$stripped_vmx_option_0_number) {264 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']);265 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) {266 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60);267 }268 }269 } else {270 if (!is_numeric($stripped_vmx_option_0_number) && $stripped_vmx_option_0_number) {271 $_SESSION['ari_error'] =272 _("Option 0 not changed") . "<br>" .273 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_0_number);274 }275 else {276 277 // set database278 $this->setVmxOptionNumber($exten,'0','unavail',$stripped_vmx_option_0_number);279 $this->setVmxOptionNumber($exten,'0','busy',$stripped_vmx_option_0_number);280 281 // store cookie282 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_0_number']);283 if ($vmx_option_0_number && $stripped!=$stripped_vmx_option_0_number) {284 setcookie("ari_vmx_option_0_number", $call_vmx_option_0_number, time()+365*24*60*60);285 }286 }287 }288 289 $stripped_vmx_option_1_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_1_number);290 if ($vmx_option_1_system_default && !$follow_me_disabled) {291 $this->setVmxOptionFollowMe($exten,'1','unavail');292 $this->setVmxOptionFollowMe($exten,'1','busy');293 setcookie("ari_vmx_option_1_system_default", $vmx_option_1_system_default, time()+365*24*60*60);294 if (is_numeric($stripped_vmx_option_1_number) || !$stripped_vmx_option_1_number) {295 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']);296 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) {297 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60);298 }299 }300 }301 else {302 303 if (!is_numeric($stripped_vmx_option_1_number) && $stripped_vmx_option_1_number) {304 $_SESSION['ari_error'] =305 _("Option 1 not changed") . "<br>" .306 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_1_number);307 }308 else {309 310 // set database311 $this->setVmxOptionNumber($exten,'1','unavail',$stripped_vmx_option_1_number);312 $this->setVmxOptionNumber($exten,'1','busy',$stripped_vmx_option_1_number);313 314 // store cookie315 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_1_number']);316 if ($vmx_option_1_number && $stripped!=$stripped_vmx_option_1_number) {317 setcookie("ari_vmx_option_1_number", $call_vmx_option_1_number, time()+365*24*60*60);318 }319 }320 }321 322 $stripped_vmx_option_2_number = preg_replace('/-|\(|\)|\s/','',$vmx_option_2_number);323 if (!is_numeric($stripped_vmx_option_2_number) && $stripped_vmx_option_2_number) {324 $_SESSION['ari_error'] =325 _("Option 2 not changed") . "<br>" .326 sprintf(_("Number %s must contain dial numbers (characters like '(', '-', and ')' are ok)"),$vmx_option_2_number);327 }328 else {329 330 // set database331 $this->setVmxOptionNumber($exten,'2','unavail',$stripped_vmx_option_2_number);332 $this->setVmxOptionNumber($exten,'2','busy',$stripped_vmx_option_2_number);333 334 // store cookie335 $stripped = preg_replace('/-|\(|\)|\s/','',$_COOKIE['ari_vmx_option_2_number']);336 if ($vmx_option_2_number && $stripped!=$stripped_vmx_option_2_number) {337 setcookie("ari_vmx_option_2_number", $call_vmx_option_2_number, time()+365*24*60*60);338 }339 }340 }341 } // vmx_disabled_delayed false342 343 if (! $follow_me_disabled_delayed) {344 345 // assume no errors, don't update SQL if errors occured346 $follow_me_update_succeeded=1;347 348 // update follow me pre-ring time349 if (!$STANDALONE['use']) {350 351 $stripped_follow_me_prering_time = preg_replace('/-|\s/','',$follow_me_prering_time);352 if (!is_numeric($stripped_follow_me_prering_time)) {353 $_SESSION['ari_error'] =354 _("Follow-Me pre-ring time not changed") . "<br>" .355 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_prering_time);356 $follow_me_update_succeeded=0;357 }358 else {359 360 // set database361 $this->setFollowMePreRingTime($exten,$stripped_follow_me_prering_time);362 363 // store cookie364 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_prering_time']);365 if ($follow_me_prering_time && $stripped!=$stripped_follow_me_prering_time) {366 setcookie("ari_follow_me_prering_time", $follow_me_prering_time, time()+365*24*60*60);367 }368 }369 }370 371 // update follow me list ring time372 if (!$STANDALONE['use']) {373 374 $stripped_follow_me_listring_time = preg_replace('/-|\s/','',$follow_me_listring_time);375 if (!is_numeric($stripped_follow_me_listring_time)) {376 $_SESSION['ari_error'] =377 _("Follow-Me list ring time not changed") . "<br>" .378 sprintf(_("Number %s must be an interger number of seconds"),$follow_me_listring_time);379 $follow_me_update_succeeded=0;380 }381 else {382 383 // set database384 $this->setFollowMeListRingTime($exten,$stripped_follow_me_listring_time);385 386 // store cookie387 $stripped = preg_replace('/-|\s/','',$_COOKIE['ari_follow_me_listring_time']);388 if ($follow_me_listring_time && $stripped!=$stripped_follow_me_listring_time) {389 setcookie("ari_follow_me_listring_time", $follow_me_listring_time, time()+365*24*60*60);390 }391 }392 }393 394 // update follow me list395 if (!$STANDALONE['use']) {396 397 $grplist = explode("\n", $follow_me_list);398 399 if (!$grplist) {400 $grplist = null;401 }402 403 foreach (array_keys($grplist) as $key) {404 //trim it405 $grplist[$key] = trim($grplist[$key]);406 407 // Lookup the extension and append hash if not a user, and remove invalid chars408 $grplist[$key] = $this->lookupSetExtensionFormat($grplist[$key]);409 410 // remove blanks411 if ($grplist[$key] == "") unset($grplist[$key]);412 }413 414 // check for duplicates, and re-sequence415 $grplist = array_values(array_unique($grplist));416 417 $stripped_follow_me_list = implode("-",$grplist);418 419 if ($stripped_follow_me_list == "") {420 $_SESSION['ari_error'] =421 _("Follow-Me list must contain at least one valid number") . "<br>" .422 sprintf(_("The following: %s is not valid"),$follow_me_list);423 $follow_me_update_succeeded=0;424 }425 else {426 427 // set database428 $this->setFollowMeList($exten,$stripped_follow_me_list);429 430 // store cookie431 $stripped = preg_replace('/|\(|\)|\s/','',$_COOKIE['ari_follow_me_list']);432 if ($follow_me_list && $stripped!=$stripped_follow_me_list) {433 setcookie("ari_follow_me_list", $follow_me_list, time()+365*24*60*60);434 }435 }436 }437 438 // update follow me confirm439 if (!$STANDALONE['use']) {440 441 // set database442 $this->setFollowMeConfirm($exten,$follow_me_confirm);443 $this->setFollowMeDDial($exten,$follow_me_ddial);444 445 // store cookie446 setcookie("ari_follow_me_confirm", $follow_me_confirm, time()+365*24*60*60);447 setcookie("ari_follow_me_ddial", $follow_me_ddial, time()+365*24*60*60);448 }449 450 //If no errors than update the SQL table to keep in sync451 if ($follow_me_update_succeeded) {452 $this->setFollowMeMySQL($exten, $follow_me_prering_time, $follow_me_listring_time, $follow_me_list, $follow_me_confirm);453 }454 455 } //if !follow_me_disabled456 457 141 // voicemail settings 458 if ($ SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1) {142 if ($_SESSION['ari_user']['voicemail_enabled']==1) { 459 143 460 144 … … 672 356 global $STANDALONE; 673 357 global $ARI_ADMIN_USERNAME; 674 global $SETTINGS_ALLOW_CALLFORWARD_SETTINGS;675 global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS;676 358 global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; 677 359 global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; … … 679 361 global $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT; 680 362 global $SETTINGS_ALLOW_CALL_RECORDING_SET; 681 global $SETTINGS_PRERING_LOW;682 global $SETTINGS_PRERING_HIGH;683 global $SETTINGS_LISTRING_LOW;684 global $SETTINGS_LISTRING_HIGH;685 686 global $SETTINGS_FOLLOW_ME_LIST_MAX;687 global $SETTINGS_ALLOW_VMX_SETTINGS;688 363 689 364 global $loaded_modules; … … 719 394 if (!$STANDALONE['use']) { 720 395 721 722 396 $call_forward_number = $this->getCallForwardNumber($exten); 723 397 if ($call_forward_number) { … … 729 403 } 730 404 731 $call_forward_busy_number = $this->getCallForwardNumber($exten, 'CFB'); 732 if ($call_forward_busy_number) { 733 $call_forward_busy_enable = 'checked'; 734 } 735 else { 736 $call_forward_busy_number = $_COOKIE['ari_call_forward_busy_number']; 737 $call_forward_busy_text_box_options = "disabled style='background: #DDD;'"; 738 } 739 740 $call_forward_unavailable_number = $this->getCallForwardNumber($exten, 'CFU'); 741 if ($call_forward_unavailable_number) { 742 $call_forward_unavailable_enable = 'checked'; 743 } 744 else { 745 $call_forward_unavailable_number = $_COOKIE['ari_call_forward_unavailable_number']; 746 $call_forward_unavailable_text_box_options = "disabled style='background: #DDD;'"; 747 } 748 749 $follow_me_prering_time = $this->getFollowMePreRingTime($exten); 750 $follow_me_listring_time = $this->getFollowMeListRingTime($exten); 751 $follow_me_list = explode("-", $this->getFollowMeList($exten) ); 752 $follow_me_confirm = $this->getFollowMeConfirm($exten); 753 $follow_me_ddial = $this->getFollowMeDDial($exten); 754 755 $FOLLOW_ME_LIST_MAX = (count($follow_me_list) > $SETTINGS_FOLLOW_ME_LIST_MAX) ? count($follow_me_list):$SETTINGS_FOLLOW_ME_LIST_MAX; 756 757 //TODO: Set this better than this? 758 $follow_me_disabled = ($follow_me_listring_time > 0)?0:1; 759 setcookie("ari_follow_me_disabled", $follow_me_disabled, time()+365*24*60*60); 760 761 $set_call_forward_text = "<table class='settings'>"; 762 763 $set_call_forward_text .= (!$SETTINGS_ALLOW_CALLFORWARD_SETTINGS)?'':" 764 <table class='settings'> 405 $set_call_forward_text = " 406 <table class='settings'> 765 407 <tr> 766 <td><h3>" . _("Call Forwarding") . "</h3></td>408 <td><h3>" . _("Call Routing") . "</h3></td> 767 409 </tr> 768 410 <tr> 769 <td>" . _("Unconditional:") . "</td> 770 <td> 771 <input " . $call_forward_text_box_options . " name='call_forward_number' type='text' size=24 value='" . $call_forward_number . "'> 772 </td> 773 <td> 774 <input " . $call_forward_enable . " type=checkbox name='call_forward_enable' value='checked' OnClick=\"disable_fields(); return 775 true;\"> 776 <small>" . _("Enable") . "</small> 777 </td> 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> 778 443 </tr> 779 444 <tr> 780 <td>" . _("Unavailable:") . "</td> 781 <td> 782 <input " . $call_forward_unavailable_text_box_options . " name='call_forward_unavailable_number' type='text' size=24 value='" . $call_forward_unavailable_number . "'> 783 </td> 784 <td> 785 <input " . $call_forward_unavailable_enable . " type=checkbox name='call_forward_unavailable_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 786 <small>" . _("Enable") . "</small> 787 </td> 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> 788 449 </tr> 789 450 <tr> 790 <td>" . _("Busy:") . "</td> 791 <td> 792 <input " . $call_forward_busy_text_box_options . " name='call_forward_busy_number' type='text' size=24 value='" . $call_forward_busy_number . "'> 793 </td> 794 <td> 795 <input " . $call_forward_busy_enable . " type=checkbox name='call_forward_busy_enable' value='checked' OnClick=\"disable_fields(); return true;\"> 796 <small>" . _("Enable") . "</small> 797 </td> 798 </tr> 799 800 "; 801 802 $set_call_forward_text .= ($follow_me_disabled)?'':" 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 = " 803 491 <tr> 804 <td><h3><br>" . _("Follow Me") . "</h3></td> 805 </tr> 806 <tr> 807 <td><a href='#' class='info'>" . _("Enable") . "<span>". _(" 808 Dial-by-name Directory, IVR, and internal calls will ring the numbers in the FollowMe List. Any FreePBX routes that directly reference a FollowMe are unaffected by this enable/disable setting. 809 ") . "<br></span></a></td> 810 <td> 811 <input " . $follow_me_ddial . " type=checkbox name='follow_me_ddial' value='checked'> 812 <small>" . _("") . "</small> 813 </td> 814 </tr> 815 <tr> 816 <td><a href='#' class='info'>" . sprintf(_("Ring %s First For:"),$exten) . "<span>" .sprintf( _("Time to ring extension %s before ringing the %s Follow Me List %s"),"<strong>".$exten."</strong>","<strong>","</strong>") . 817 "<br></span></a></td> 818 <td> 819 <select " . $follow_me_prering_time_text_box_options . " name='follow_me_prering_time'/>"; 820 if (!$follow_me_disabled) { 821 $default_prering = $follow_me_prering_time; 822 for ($i=$SETTINGS_PRERING_LOW; $i <= $SETTINGS_PRERING_HIGH; $i++) { 823 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_prering ? 'SELECTED' : '').'>'.$i.'</option>'; 824 } 825 } 826 $set_call_forward_text .= ($follow_me_disabled)?'':" 827 </select> 828 <small>" . _("seconds") . "</small> 829 </td> 830 <tr> 831 <td valign='top'><a href='#' class='info'>" . _("Follow Me List:") . "<span>" . sprintf(_("Extensions and outside numbers to ring next.")) ."<br/><br/>". sprintf(_("Include %s to keep it ringing."),"<strong>".$exten."</strong>") . "<br></span></a></td> 832 <td> 833 <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> 834 </td> 835 <tr> 836 <td><a href='#' class='info'>" . _("List Ring Time:") . "<span>" . _("Time to ring the Follow Me List.") . "<br></span></a></td> 837 <td> 838 <select " . $follow_me_listring_time_text_box_options . " name='follow_me_listring_time'/>"; 839 if (!$follow_me_disabled) { 840 $default_listring = $follow_me_listring_time; 841 for ($i=$SETTINGS_LISTRING_LOW; $i <= $SETTINGS_LISTRING_HIGH; $i++) { 842 $set_call_forward_text .= '<option value="'.$i.'" '.($i == $default_listring ? 'SELECTED' : '').'>'.$i.'</option>'; 843 } 844 } 845 $set_call_forward_text .= ($follow_me_disabled)?'':" 846 </select> 847 <small>" . _("seconds") . "</small> 848 </td> 849 <tr> 850 <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.") . "<br></span></a></td> 851 <td> 852 <input " . $follow_me_confirm . " type=checkbox name='follow_me_confirm' value='checked'> 853 <small>" . _("Enable") . "</small> 854 </td> 855 </tr> 856 "; 857 858 $set_call_forward_text .= " 859 </tr> 860 </table> 861 "; 862 863 $vmx_unavail_enabled=$this->getVmxState($exten,'unavail'); 864 if ($vmx_unavail_enabled === false) { 865 $vmx_disabled = true; 866 setcookie("ari_vmx_disabled", $vmx_disabled, time()+365*24*60*60); 867 $SETTINGS_ALLOW_VMX_SETTINGS=false; 868 } else { 869 $vmx_disabled = false; 870 setcookie("ari_vmx_disabled", false, time()+365*24*60*60); 871 $vmx_busy_enabled=$this->getVmxState($exten,'busy'); 872 $vmx_play_instructions=$this->getVmxPlayInstructions($exten); 873 $vmx_option_0_number=$this->getVmxOptionNumber($exten,'0');; 874 $vmx_option_1_number=$this->getVmxOptionNumber($exten,'1');; 875 $vmx_option_2_number=$this->getVmxOptionNumber($exten,'2');; 876 877 if (is_numeric($vmx_option_0_number)) { 878 $vmx_option_0_system_default=''; 879 $vmx_option_0_number_text_box_options=''; 880 } else { 881 $vmx_option_0_system_default='checked'; 882 $vmx_option_0_number_text_box_options="disabled style='background: #DDD;'"; 883 } 884 885 // if follow-me is enabled then the options are a numberic value (dial a phone number) 886 // or a followme target (FMnnn) which should not be displayed but means the box is checked 887 // or otherwise blank (or garbage in which case blank it) 888 // 889 if (!$follow_me_disabled) { 890 $vmx_option_1_system_default=$this->getVmxOptionFollowMe($exten,'1'); 891 if ($vmx_option_1_system_default) { 892 $vmx_option_1_number = ''; 893 $vmx_option_1_number_text_box_options="disabled style='background: #DDD;'"; 894 } 895 } 896 } 897 $set_vmx_text .= (!$SETTINGS_ALLOW_VMX_SETTINGS)?'':" 898 <table class='settings'> 899 <tr> 900 <td><h3>" . _("Voicemail VmX Locator") . "</h3></td> 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> 901 496 </tr> 902 497 <tr> 903 <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> 904 <input " . $vmx_unavail_enabled . " type=checkbox name='vmx_unavail_enabled' value='checked'> 905 <small>" . _("unavailable") . "</small> 906 </td> 907 <td> 908 <input " . $vmx_busy_enabled . " type=checkbox name='vmx_busy_enabled' value='checked'> 909 <small>" . _("busy") . "</small> 910 </td> 911 </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'> 912 610 <tr> 913 <td><a href='#' class='info'>" . _("Voicemail Instructions:") ."<span>" . _("Uncheck to play a beep after your personal voicemail greeting.") . "<br></span></a></td> 914 <td> 915 <input " . $vmx_play_instructions . " type=checkbox name='vmx_play_instructions' value='checked'> 916 <small>" . _("Standard voicemail prompts.") . "</small> 917 </td> 918 </tr> 919 </table> 920 <table class='settings'> 921 <tr> 922 <td> </td> 923 <td><a href='#' class='info'>" . _("Press 0:") . "<span>" . _("Pressing 0 during your personal voicemail greeing goes to the Operator. 924 Uncheck to enter another destination here.") . "<br></span></a></td> 925 <td> 926 <input " . $vmx_option_0_number_text_box_options . " name='vmx_option_0_number' type='text' size=24 value='" . $vmx_option_0_number . "'> 927 </td> 928 <td> 929 <input " . $vmx_option_0_system_default . " type=checkbox name='vmx_option_0_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 930 <small>" . _("Go To Operator") . "</small> 931 </td> 932 </tr> 933 "; 934 935 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled))?'':" 936 <tr> 937 <td> </td> 938 <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> 939 <td> 940 <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 941 </td> 942 <td> 943 <input " . $vmx_option_1_system_default . " type=checkbox name='vmx_option_1_system_default' value='checked' OnClick=\"disable_fields(); return true;\"> 944 <small>" . _("Send to Follow-Me") . "</small> 945 </td> 946 </tr> 947 <tr> 948 <td> </td> 949 <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> 950 <td> 951 <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 952 </td> 953 </tr> 954 </table> 955 "; 956 957 $set_vmx_text .= (!($SETTINGS_ALLOW_VMX_SETTINGS && $follow_me_disabled))?'':" 958 <tr> 959 <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> 960 <td> 961 <input " . $vmx_option_1_number_text_box_options . " name='vmx_option_1_number' type='text' size=24 value='" . $vmx_option_1_number . "'> 962 </td> 963 </tr> 964 <tr> 965 <td>" . _("Option 2:") . "</td> 966 <td> 967 <input " . $vmx_option_2_number_text_box_options . " name='vmx_option_2_number' type='text' size=24 value='" . $vmx_option_2_number . "'> 968 </td> 969 </tr> 970 </table> 971 "; 972 973 974 } 975 976 // voicemail settings 977 if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1 && 978 in_array('voicemail',array_keys($loaded_modules))) { 979 if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { 980 981 if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) { 982 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 983 } 984 else { 985 $voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); 986 } 987 988 $set_voicemail_password_text = " 989 <tr> 990 <td>" . _("Voicemail Password:") . "</td> 991 <td> 992 <input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 993 </td> 994 </tr> 995 <tr> 996 <td>" . _("Enter again to confirm:") . "</td> 997 <td> 998 <input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> 999 </td> 1000 </tr> 1001 <tr> 1002 <td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td> 1003 </tr>"; 1004 } 1005 1006 if (isset($_SESSION['ari_user']['voicemail_email'])) { 1007 1008 if ($_SESSION['ari_user']['voicemail_email_enable']) { 1009 $voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address']; 1010 $voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address']; 1011 $voicemail_email_enable = 'checked'; 1012 1013 foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { 1014 $var = "voicemail_email_$key"; 1015 $var_enable = $var . "enable"; 1016 if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') { 1017 $$var_enable = 'checked'; 1018 } 1019 } 1020 } 1021 else { 1022 1023 $voicemail_email_address = $_COOKIE['ari_voicemail_email_address']; 1024 $voicemail_email_text_box_options = "disabled style='background: #DDD;'"; 1025 $voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address']; 1026 $voicemail_pager_text_box_options = "disabled style='background: #DDD;'"; 1027 1028 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1029 $var = "voicemail_email_$key"; 1030 $var_cookie = "ari_" . $var; 1031 $var_enable = $var . "enable"; 1032 $var_text_box_options = $var . "text_box_options"; 1033 1034 $$var_text_box_options = "disabled"; 1035 if ($_COOKIE[$var_cookie]=='yes') { 1036 $$var_enable = 'checked'; 1037 } 1038 } 1039 } 1040 1041 $set_voicemail_email_text = " 1042 1043 <tr> 1044 <td> " . _("Email Notification") . " <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\"> 1045 <small> " ._("Enable") . " </small> 1046 </td> 1047 </tr><tr> 1048 <td><a href='#' class='info'>" . _("Email Voicemail To:") . "<span>" . ("Email a notification, including audio file if indicated below.") . " </span></a></td> 1049 <td> 1050 <input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'> 1051 </td> 1052 </tr> 1053 <tr> 1054 <td><a href='#' class='info'>" . _("Pager Email Notification To:") . "<span>" . ("Email a short notification") . " </span></a></td> 1055 <td> 1056 <input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'> 1057 </td> 1058 </tr> 1059 <tr> 1060 <td></td> 1061 </tr>"; 1062 1063 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1064 1065 $var = "voicemail_email_$key"; 1066 $var_enable = $var . "enable"; 1067 $var_text_box_options = $var . "text_box_options"; 1068 if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) { 1069 $var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]; 1070 } 1071 else { 1072 $var_text = $key; 1073 } 1074 1075 if ($value != 'yes' && $value != 'no' && $value !='') { 1076 1077 $size = strlen($value) - 1; 1078 $set_voicemail_email_text .= " 1079 <tr> 1080 <td></td> 1081 <td> 1082 <input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "' OnClick=\"disable_fields(); return true;\"> 1083 <small>" . $var_text . "</small> 1084 </td> 1085 </tr>"; 1086 } 1087 else { 1088 1089 $set_voicemail_email_text .= " 1090 <tr> 1091 <td></td> 1092 <td> 1093 <input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "' value='yes' OnClick=\"disable_fields(); return true;\"> 1094 <small>" . $var_text . "</small> 1095 </td> 1096 </tr>"; 1097 } 1098 } 1099 } 1100 1101 $wav_enable = 'selected'; 1102 if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'|| 1103 ($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) { 1104 $wav_enable = ''; 1105 $gsm_enable = 'selected'; 1106 } 1107 1108 $set_voicemail_audio_format_text = " 1109 <tr> 1110 <td>" . _("Audio Format:") . "</td> 1111 <td> 1112 <select name='voicemail_audio_format'> 1113 <option value='.wav' " . $wav_enable . ">" . _("Best Quality") . " (.wav)</option> 1114 <option value='.gsm' " . $gsm_enable . ">" . _("Smallest Download") . " (.gsm)</option> 1115 </select> 1116 </td> 1117 </tr>"; 1118 1119 $set_voicemail_text = " 1120 <table class='settings'> 1121 <tr> 1122 <td><h3>" . _("Voicemail Settings") . "</h3></td> 1123 </tr> 1124 " . $set_voicemail_password_text . " 1125 " . $set_voicemail_email_text . " 1126 " . $set_voicemail_audio_format_text . " 1127 </table>"; 1128 } 1129 1130 // call monitor settings 1131 if ($this->getFreePBXVersion() && 1132 $SETTINGS_ALLOW_CALL_RECORDING_SET && 1133 in_array('callmonitor',array_keys($loaded_modules))) { 1134 1135 foreach($data as $key=>$value) { 1136 if ($key=='record_in') { 1137 if ($value=='Always') { 1138 $ri_always = 'checked=checked'; 1139 } 1140 elseif ($value=='Never') { 1141 $ri_never = 'checked=checked'; 1142 } 1143 elseif ($value=='Adhoc') { 1144 $ri_on_demand = 'checked=checked'; 1145 } 1146 } 1147 if ($key=='record_out') { 1148 if ($value=='Always') { 1149 $ro_always = 'checked=checked'; 1150 } 1151 elseif ($value=='Never') { 1152 $ro_never = 'checked=checked'; 1153 } 1154 elseif ($value=='Adhoc') { 1155 $ro_on_demand = 'checked=checked'; 1156 } 1157 } 1158 } 1159 1160 $set_callmonitor_text = " 1161 <table class='settings'> 1162 <tr> 1163 <td><h3>" . _("Call Monitor Settings") . "</h3></td> 1164 </tr> 1165 <tr> 1166 <td>" . _("Record INCOMING:") . " </td> 1167 <td> 1168 <input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . " 1169 <input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . " 1170 <input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . " 1171 </td> 1172 </tr> 1173 <tr> 1174 <td>" . _("Record OUTGOING:") . " </td> 1175 <td> 1176 <input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . " 1177 <input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . " 1178 <input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . " 1179 </td> 1180 </tr> 1181 </table>"; 1182 } 1183 } 1184 1185 // javascript enable options 1186 if (isset($_SESSION['ari_user']['voicemail_email']) && 1187 in_array('voicemail',array_keys($loaded_modules))) { 1188 foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { 1189 $var = "voicemail_email_$key"; 1190 $js_voicemail_email_disable .= " 1191 document.ari_settings.$var.disabled = false;"; 1192 $js_voicemail_email_enable .= " 1193 document.ari_settings.$var.disabled = true;"; 1194 } 1195 1196 $js_voicemail_script = " 1197 if (document.ari_settings.voicemail_email_enable.checked) { 1198 document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; 1199 document.ari_settings.voicemail_email_address.disabled = false; 1200 document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; 1201 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; 1202 document.ari_settings.voicemail_pager_address.disabled = false; 1203 document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; 1204 " . $js_voicemail_email_disable . " 1205 } 1206 else { 1207 document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; 1208 document.ari_settings.voicemail_email_address.disabled = true; 1209 document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; 1210 document.ari_settings.voicemail_pager_address.disabled = true; 1211 " . $js_voicemail_email_enable . " 1212 }"; 1213 } 1214 1215 // build page content 1216 $ret .= checkErrorMessage(); 1217 1218 if ($_SESSION['ari_user']['admin_settings']) { 1219 $headerText = _("Settings"); 1220 } else { 1221 $headerText = sprintf(_("Settings for %s (%s)"),$displayname,$exten); 1222 } 1223 1224 $ret .= $display->displayHeaderText($headerText); 1225 $ret .= $display->displayLine(); 1226 1227 $ret .= " 1228 <SCRIPT LANGUAGE='JavaScript'> 1229 <!-- Begin 1230 function rowCounter(field, maxlimit) { 1231 temp = field.value.split('\u000A',maxlimit+1) 1232 field.value = temp.join('\u000A') 1233 if (temp.length == maxlimit+1) { 1234 field.value = field.value.substring(0, field.value.length-1) 1235 } 1236 } 1237 1238 function disable_fields() {"; 1239 if ($SETTINGS_ALLOW_CALLFORWARD_SETTINGS) { 1240 $ret .= " 1241 if (document.ari_settings.call_forward_enable.checked) { 1242 document.ari_settings.call_forward_number.style.backgroundColor = '#FFF'; 1243 document.ari_settings.call_forward_number.disabled = false; 1244 } 1245 else { 1246 document.ari_settings.call_forward_number.style.backgroundColor = '#DDD'; 1247 document.ari_settings.call_forward_number.disabled = true; 1248 } 1249 1250 if (document.ari_settings.call_forward_busy_enable.checked) { 1251 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#FFF'; 1252 document.ari_settings.call_forward_busy_number.disabled = false; 1253 } 1254 else { 1255 document.ari_settings.call_forward_busy_number.style.backgroundColor = '#DDD'; 1256 document.ari_settings.call_forward_busy_number.disabled = true; 1257 } 1258 1259 if (document.ari_settings.call_forward_unavailable_enable.checked) { 1260 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#FFF'; 1261 document.ari_settings.call_forward_unavailable_number.disabled = false; 1262 } 1263 else { 1264 document.ari_settings.call_forward_unavailable_number.style.backgroundColor = '#DDD'; 1265 document.ari_settings.call_forward_unavailable_number.disabled = true; 1266 }"; 1267 } 1268 if ($SETTINGS_ALLOW_VMX_SETTINGS) { 1269 $ret .= " 1270 if (document.ari_settings.vmx_option_0_system_default.checked) { 1271 document.ari_settings.vmx_option_0_number.style.backgroundColor = '#DDD'; 1272 document.ari_settings.vmx_option_0_number.disabled = true; 1273 } 1274 else { 1275 document.ari_settings.vmx_option_0_number.style.backgroundColor = '#FFF'; 1276 document.ari_settings.vmx_option_0_number.disabled = false; 1277 }"; 1278 } 1279 if ($SETTINGS_ALLOW_VMX_SETTINGS && !$follow_me_disabled) { 1280 $ret .= " 1281 if (document.ari_settings.vmx_option_1_system_default.checked) { 1282 document.ari_settings.vmx_option_1_number.style.backgroundColor = '#DDD'; 1283 document.ari_settings.vmx_option_1_number.disabled = true; 1284 } 1285 else { 1286 document.ari_settings.vmx_option_1_number.style.backgroundColor = '#FFF'; 1287 document.ari_settings.vmx_option_1_number.disabled = false; 1288 }"; 1289 } 1290 $ret .= $js_voicemail_script . " 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 . " 1291 688 } 1292 689 // End --> … … 1299 696 <input type=hidden name=f value='action'> 1300 697 <input type=hidden name=a value='update'> 1301 <br>1302 " . $set_call_forward_text . "1303 <br>1304 " . $set_vmx_text . "1305 698 <br> 1306 699 " . $set_voicemail_text . " … … 1323 716 * @param $call_forward_number 1324 717 * Call forward number 1325 * @param $variable_opt 1326 * Call forward type (CF, CFU, CFB) 1327 */ 1328 function setCallForward($exten,$state,$call_forward_number, $variable_opt = "CF") { 718 */ 719 function setCallForward($exten,$state,$call_forward_number) { 1329 720 1330 721 global $asterisk_manager_interface; … … 1338 729 } 1339 730 1340 //$variable_opt = "CF";731 $variable_opt = "CF"; 1341 732 1342 733 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt $variable_opt $exten $value_opt\r\n\r\n"); … … 1350 741 * @return $number 1351 742 * call forward number returned if set 1352 * @param $variable_opt 1353 * Call forward type (CF, CFU, CFB) 1354 */ 1355 function getCallForwardNumber($exten, $variable_opt = "CF") { 743 */ 744 function getCallForwardNumber($exten) { 1356 745 1357 746 global $asterisk_manager_interface; … … 1359 748 $number = ''; 1360 749 1361 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get $variable_opt$exten\r\n\r\n");750 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get CF $exten\r\n\r\n"); 1362 751 if (is_numeric($response)) { 1363 752 $number = $response; … … 1371 760 return $number; 1372 761 } 1373 1374 /*1375 * Gets VMX option FollowMe1376 *1377 * @param $exten1378 * Extension to get information about1379 * @param $digit1380 * Option number to get1381 * @param $mode1382 * Mode to get (unavail/busy)1383 * @return $response1384 * checked if set to got to extesion's follow-me on this option1385 */1386 function getVmxOptionFollowMe($exten, $digit, $mode='unavail') {1387 1388 global $asterisk_manager_interface;1389 1390 $digit = trim($digit);1391 1392 $response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/vmx/$mode/$digit/ext\r\n\r\n");1393 return (($response == 'FM'.$exten) ? 'checked':'');1394 }1395 1396 /*1397 * Sets VMX option FollowMe1398 *1399 * @param $exten1400 * Extension to set information about1401 * @param $digit1402 * Option number to set1403 * @param $mode1404 * Mode to set (unavail/busy)1405 * @param $context1406 * Context to set ext to (default from-findmefollow)1407 * @param $priority1408 * Priority to set ext to (default 1)1409 */1410 &nb
