function Aastra_is_daynight_notify_allowed_Asterisk($user, $index = 'ALL') { global $array_config_daynight; # No by default $return = False; # One or all index? if ($index == 'ALL') { # Retrieve status for all configured indexes $array_night = Aastra_manage_daynight_Asterisk('get_all', ''); # Test all indexes foreach ($array_night as $index => $value) { # Depending on the configuration switch ($array_config_daynight[$index]['notify']) { case 'ALL': $return = True; break; case '': break; default: $array = explode(',', $array_config_daynight[$index]['notify']); if (in_array($user, $array)) { $return = True; } else { if (Aastra_is_daynight_appli_allowed_Asterisk($user, $index)) { $return = True; } } break; } if ($return) { break; } } } else { # Depending on the configuration switch ($array_config_daynight[$index]['notify']) { case 'ALL': $return = True; break; case '': break; default: $array = explode(',', $array_config_daynight[$index]['notify']); if (in_array($user, $array)) { $return = True; } else { if (Aastra_is_daynight_appli_allowed_Asterisk($user, $index)) { $return = True; } } break; } } # Return result return $return; }
# Retrieve all status $array_night = Aastra_manage_daynight_Asterisk('get_all', ''); # Next actions require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); # Force day or night foreach ($array_night as $i => $value) { $update = False; if ($value['night'] == '1' and $action == 'day') { $update = True; } if ($value['night'] == '0' and $action == 'night') { $update = True; } if ($update) { $night = Aastra_manage_daynight_Asterisk('change', $i); if (!$AA_FREEPBX_USEDEVSTATE or !Aastra_is_sip_notify_supported()) { # Send a SIP Notification to everybody allowd Aastra_propagate_daynight_Asterisk($user, $i); } } } # Update via the "check" mechanism $object->addEntry($XML_SERVER . '&action=check'); # Back to the list $object->addEntry($XML_SERVER . '&action=list&index=' . $index); break; # Default # Default default: # Unexpected action