Added update_phone, add_phone_alias, update_phone_alias functions to the non-agent API
several small bug fixes git-svn-id: svn://192.168.202.10@1713 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -683,6 +683,9 @@ OTHER CHANGES:
|
||||
155. Added the Campaign Status List Report which shows calls broken down by
|
||||
status within each list_id for a campaign.
|
||||
|
||||
156. Added update_phone, add_phone_alias, update_phone_alias functions to the
|
||||
Non-Agent API.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2948,7 +2948,7 @@ while($one_day_interval > 0)
|
||||
{
|
||||
if ($MLnoanswer =~ /\|$MLstatus[$vle_count]\|/i)
|
||||
{
|
||||
if ( ($tables_use_alt_log_db =~ /vicidial_log_noanswer/i) && (length($alt_log_server_ip)>4) && (length($alt_log_dbname)>0) )
|
||||
if ( ($tables_use_alt_log_db =~ /log_noanswer/i) && (length($alt_log_server_ip)>4) && (length($alt_log_dbname)>0) )
|
||||
{
|
||||
$stmtA = "SELECT uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial FROM vicidial_log where uniqueid='$MLuniqueid[$vle_count]' and lead_id='$MLleadid[$vle_count]' and call_date > \"$RMSQLdate\";";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2011-07-05
|
||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2011-08-21
|
||||
|
||||
This document describes the functions of an API(Application Programming
|
||||
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
|
||||
@@ -24,6 +24,9 @@ recording_lookup - looks up recordings based upon user and date or lead_id
|
||||
did_log_export - exports all calls inbound to a DID for one day
|
||||
add_user - adds a user to the system
|
||||
add_phone - adds a phone to the system
|
||||
update_phone - updates or deletes an existing phone record in the system
|
||||
add_phone_alias - adds a phone alias record to the system
|
||||
update_phone_alias - updates or deletes an existing phone alias record in the system
|
||||
add_list - adds a list to the system
|
||||
update_list - updates list settings in the system, reset leads in list, delete list
|
||||
|
||||
@@ -60,6 +63,8 @@ Changes:
|
||||
110529-1220 - Added time zone information output to version function
|
||||
110614-0726 - Added reset_lead option to update_lead function(issue #502)
|
||||
110705-1928 - Added options for USACAN 4th digit prefix(no 0 or 1) and valid areacode filtering to add_lead
|
||||
110821-2318 - Added update_phone, add_phone_alias, update_phone_alias functions
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -187,6 +192,7 @@ ERROR: NO FUNCTION SPECIFIED
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
agent_ingroup_info - shows in-group and outbound auto-dial info for logged-in agent
|
||||
|
||||
@@ -207,6 +213,7 @@ ERROR: agent_ingroup_info INVALID USER ID - 1255|6666
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
recording_lookup - looks up recordings based upon user and date or lead_id
|
||||
|
||||
@@ -392,6 +399,7 @@ ERROR: add_lead DUPLICATE NAME PHONE IN SYSTEM - Bob|Smith|7275551113|101|876544
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
update_lead - updates lead information in the vicidial_list and custom_ tables
|
||||
|
||||
@@ -585,6 +593,106 @@ SUCCESS: add_phone PHONE HAS BEEN ADDED - 6666|cc100|10.0.9.8|SIP|100
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
update_phone - updates or deletes a phone entry already in the system
|
||||
|
||||
REQUIRED FIELDS-
|
||||
extension - 2-100 characters
|
||||
server_ip - 7-15 characters, must be a valid server_ip
|
||||
|
||||
SETTINGS FIELDS-
|
||||
delete_phone - Y or N, Setting this to Y will delete the phone from the system, default is N.
|
||||
|
||||
EDITABLE FIELDS-
|
||||
dialplan_number - 1-20 digits
|
||||
voicemail_id - 1-10 digits
|
||||
phone_login - 1-20 characters
|
||||
phone_pass - 1-20 characters
|
||||
protocol - Must be one of these: 'IAX2','SIP','Zap','EXTERNAL'
|
||||
registration_password - 1-20 characters
|
||||
phone_full_name - 1-50 characters
|
||||
local_gmt - timezone setting, not adjusting for DST, default: '-5.00'
|
||||
outbound_cid - 1-20 digits
|
||||
phone_context - a phone context, default is 'default'
|
||||
email - 1-100 characters
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=update_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP®istration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=update_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP®istration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212&phone_context=default&email=test@test.com
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=update_phone&user=6666&pass=1234&extension=55000&server_ip=192.168.198.5&delete_phone=Y
|
||||
|
||||
Example responses:
|
||||
ERROR: update_phone USER DOES NOT HAVE PERMISSION TO UPDATE PHONES - 6666|0
|
||||
ERROR: update_phone YOU MUST USE ALL REQUIRED FIELDS - 6666||
|
||||
ERROR: update_phone SERVER DOES NOT EXIST - 6666|10.0.9.9
|
||||
ERROR: update_phone PHONE DOES NOT EXIST ON THIS SERVER - 6666|10.0.9.8|cc101
|
||||
ERROR: update_phone LOGIN ALREADY EXISTS - 6666|x101
|
||||
ERROR: update_phone YOU MUST USE A VALID TIMEZONE - 6666|-99
|
||||
ERROR: update_phone YOU MUST USE A VALID DIALPLAN NUMBER - 6666|0
|
||||
ERROR: update_phone YOU MUST USE A VALID VOICEMAIL NUMBER - 6666|0
|
||||
ERROR: update_phone YOU MUST USE A VALID PHONE PASSWORD - 6666|0
|
||||
ERROR: update_phone YOU MUST USE A VALID REGISTRATION PASSWORD - 6666|0
|
||||
ERROR: update_phone YOU MUST USE A VALID PROTOCOL - 6666|0
|
||||
ERROR: update_phone YOU MUST USE A VALID PHONE NAME - 6666|0
|
||||
ERROR: update_phone YOU MUST USE A VALID PHONE CONTEXT - 6666|0
|
||||
ERROR: update_phone NO UPDATES DEFINED - 6666|0
|
||||
SUCCESS: update_phone PHONE HAS BEEN UPDATED - 6666|cc100|10.0.9.8|SIP|100
|
||||
SUCCESS: update_phone PHONE HAS BEEN DELETED - 6666|cc100|10.0.9.8|
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
add_phone_alias - adds a phone alias entry to the system
|
||||
|
||||
REQUIRED FIELDS-
|
||||
alias_id - 2-20 characters
|
||||
phone_logins - 2-255 characters (phone logins separated by commas)
|
||||
alias_name - 1-50 characters
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=add_phone_alias&user=6666&pass=1234&alias_id=xyz100&alias_name=XYZ+testing&phone_logins=100a,100b
|
||||
|
||||
Example responses:
|
||||
ERROR: add_phone_alias USER DOES NOT HAVE PERMISSION TO ADD PHONE ALIASES - 6666|0
|
||||
ERROR: add_phone_alias YOU MUST USE ALL REQUIRED FIELDS - 6666||||
|
||||
ERROR: add_phone_alias PHONE ALIAS ALREADY EXISTS - 6666|x101
|
||||
ERROR: add_phone_alias PHONE DOES NOT EXIST - 6666|cc100
|
||||
SUCCESS: add_phone_alias PHONE ALIAS HAS BEEN ADDED - 6666|x100|testing_x100|cc100,bb100
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
update_phone_alias - updates or deletes a phone alias entry already in the system
|
||||
|
||||
REQUIRED FIELDS-
|
||||
alias_id - 2-20 characters
|
||||
phone_logins - 2-255 characters (phone logins separated by commas)
|
||||
alias_name - 1-50 characters
|
||||
|
||||
SETTINGS FIELDS-
|
||||
delete_alias - Y or N, Setting this to Y will delete the phone alias from the system, default is N.
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=update_phone_alias&user=6666&pass=1234&alias_id=xyz100&alias_name=XYZ+testing+X&phone_logins=100a,100b
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=update_phone_alias&user=6666&pass=1234&alias_id=xyz100&delete_alias=Y
|
||||
|
||||
Example responses:
|
||||
ERROR: update_phone_alias USER DOES NOT HAVE PERMISSION TO UPDATE PHONE ALIASES - 6666|0
|
||||
ERROR: update_phone_alias YOU MUST USE ALL REQUIRED FIELDS - 6666||||
|
||||
ERROR: update_phone_alias PHONE ALIAS DOES NOT EXIST - 6666|x101
|
||||
ERROR: update_phone_alias YOU MUST USE A VALID ALIAS NAME - 6666|x
|
||||
ERROR: update_phone_alias PHONE DOES NOT EXIST - 6666|cc100
|
||||
SUCCESS: update_phone_alias PHONE ALIAS HAS BEEN UPDATED - 6666|x100|
|
||||
SUCCESS: update_phone_alias PHONE ALIAS HAS BEEN DELETED - 6666|x100|
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
add_list - adds a list to the system
|
||||
|
||||
@@ -622,7 +730,6 @@ SUCCESS: add_list LIST HAS BEEN ADDED - 6666|1101|TESTCAMP
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
update_list - updates list information in the vicidial_lists table
|
||||
|
||||
@@ -684,4 +791,3 @@ NOTICE: update_list LEADS IN LIST HAVE BEEN DELETED - 6666|1101|324
|
||||
|
||||
ERROR: NO FUNCTION SPECIFIED
|
||||
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ VID Enter Filename||
|
||||
VID ID Number Filename||
|
||||
VID Confirm Filename||
|
||||
VID Digits||
|
||||
Search Method defines how the queue will find the next agent, recommend leave this on LB. List ID is the list that the new lead is inserted into, also if the Method is not a LOOKUP method and the lead is not found. Campaign ID is the campaign to search lists through if one of the RC methods is used. Phone Code is the phone_code field entry for the lead that is inserted with. VID Enter Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to ask the customer to enter their ID. VID ID Number Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played after customer enters their ID, something like YOU HAVE ENTERED. VID Confirm Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to confirm their ID, something like PRESS 1 TO CONFIRM AND 2 TO REENTER. VID Digits is used if the Method is set to one of the VIDPROMPT methods, if it is set to a number it is the number of digits that must be ebtered by the customer when prompted for their ID, if set to empty or X then the customer will have to press pound or hash to finish their entry of their ID||
|
||||
Search Method defines how the queue will find the next agent, recommend leave this on LB. List ID is the list that the new lead is inserted into, also if the Method is not a LOOKUP method and the lead is not found. Campaign ID is the campaign to search lists through if one of the RC methods is used. Phone Code is the phone_code field entry for the lead that is inserted with. VID Enter Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to ask the customer to enter their ID. VID ID Number Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played after customer enters their ID, something like YOU HAVE ENTERED. VID Confirm Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to confirm their ID, something like PRESS 1 TO CONFIRM AND 2 TO REENTER. VID Digits is used if the Method is set to one of the VIDPROMPT methods, if it is set to a number it is the number of digits that must be entered by the customer when prompted for their ID, if set to empty or X then the customer will have to press pound or hash to finish their entry of their ID||
|
||||
Admin Web Directory||
|
||||
This is the directory that your administation web content, like admin.php, are in. Default is vicidial. To figure out your Admin web directory, it is everything that is between the domain name and the admin.php in the URL on this page, without the beginning and ending slashes||
|
||||
TTS Voice||
|
||||
|
||||
@@ -102,7 +102,7 @@ $Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary , Inbound R
|
||||
|
||||
$UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary , Inbound Report, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound DID Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Campaign Status List Report, Export Calls Report , Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily , User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report , Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Custom Reports Links, CallCard Search';
|
||||
|
||||
$Vtables = 'NONE,vicidial_log_noanswer';
|
||||
$Vtables = 'NONE,log_noanswer';
|
||||
|
||||
######################################################################################################
|
||||
######################################################################################################
|
||||
@@ -6053,7 +6053,7 @@ if ($ADD==99999)
|
||||
<BR>
|
||||
<A NAME="vicidial_call_menu-ingroup_settings">
|
||||
<BR>
|
||||
<B>Call Menu In-Group Settings -</B> If the route is set to INGROUP then there are many options that you can set to define how the call is sent to into the queue. In-Group is the inbound group that you want the call to go to. Handle Method is the way you want the call to be handled, <a href="#vicidial_inbound_dids-call_handle_method">Click here to see a list of the available handle methods</a>. Search Method defines how the queue will find the next agent, recommend leave this on LB. List ID is the list that the new lead is inserted into, also if the Method is not a LOOKUP method and the lead is not found. Campaign ID is the campaign to search lists through if one of the RC methods is used. Phone Code is the phone_code field entry for the lead that is inserted with. VID Enter Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to ask the customer to enter their ID. VID ID Number Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played after customer enters their ID, something like YOU HAVE ENTERED. VID Confirm Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to confirm their ID, something like PRESS 1 TO CONFIRM AND 2 TO REENTER. VID Digits is used if the Method is set to one of the VIDPROMPT methods, if it is set to a number it is the number of digits that must be ebtered by the customer when prompted for their ID, if set to empty or X then the customer will have to press pound or hash to finish their entry of their ID.
|
||||
<B>Call Menu In-Group Settings -</B> If the route is set to INGROUP then there are many options that you can set to define how the call is sent to into the queue. In-Group is the inbound group that you want the call to go to. Handle Method is the way you want the call to be handled, <a href="#vicidial_inbound_dids-call_handle_method">Click here to see a list of the available handle methods</a>. Search Method defines how the queue will find the next agent, recommend leave this on LB. List ID is the list that the new lead is inserted into, also if the Method is not a LOOKUP method and the lead is not found. Campaign ID is the campaign to search lists through if one of the RC methods is used. Phone Code is the phone_code field entry for the lead that is inserted with. VID Enter Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to ask the customer to enter their ID. VID ID Number Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played after customer enters their ID, something like YOU HAVE ENTERED. VID Confirm Filename is used if the Method is set to one of the VIDPROMPT methods, it is the audio prompt played to confirm their ID, something like PRESS 1 TO CONFIRM AND 2 TO REENTER. VID Digits is used if the Method is set to one of the VIDPROMPT methods, if it is set to a number it is the number of digits that must be entered by the customer when prompted for their ID, if set to empty or X then the customer will have to press pound or hash to finish their entry of their ID.
|
||||
|
||||
<BR>
|
||||
<A NAME="vicidial_call_menu-custom_dialplan_entry">
|
||||
@@ -29679,7 +29679,7 @@ if ($ADD==720000000000000)
|
||||
|
||||
$sectionSQL = "event_section='$category'";
|
||||
if (preg_match("/CAMPAIGNS/",$category))
|
||||
{$sectionSQL = "event_section IN('CAMPAIGNS','CAMPAIGN_SURVEY','CAMPAIGN_LISTMIX','CAMPAIGN_PRESET','CAMPAIGN_QC','CAMPAIGN_PAUSECODE','CAMPAIGN_RECYCLE','CAMPAIGN_HOTKEY','CAMPAIGN_STATUS')";}
|
||||
{$sectionSQL = "event_section IN('CAMPAIGNS','CAMPAIGN_SURVEY','CAMPAIGN_LISTMIX','CAMPAIGN_PRESET','CAMPAIGN_QC','CAMPAIGN_PAUSECODE','CAMPAIGN_RECYCLE','CAMPAIGN_HOTKEY','CAMPAIGN_STATUS','CAMPAIGN_DIALSTATUSES','CAMPAIGN_DIALSTATUS')";}
|
||||
|
||||
$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code from vicidial_admin_log where $sectionSQL and record_id='$stage' order by event_date desc limit 10000;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
@@ -50,10 +50,11 @@
|
||||
# 110529-1220 - Added time zone information output to version function
|
||||
# 110614-0726 - Added reset_lead option to update_lead function(issue #502)
|
||||
# 110705-1928 - Added options for USACAN 4th digit prefix(no 0 or 1) and valid areacode filtering to add_lead
|
||||
# 110821-2318 - Added update_phone, add_phone_alias, update_phone_alias functions
|
||||
#
|
||||
|
||||
$version = '2.4-36';
|
||||
$build = '110705-1928';
|
||||
$version = '2.4-37';
|
||||
$build = '110821-2318';
|
||||
|
||||
$startMS = microtime();
|
||||
|
||||
@@ -252,6 +253,16 @@ if (isset($_GET["usacan_areacode_check"])) {$usacan_areacode_check=$_GET["usac
|
||||
elseif (isset($_POST["usacan_areacode_check"])) {$usacan_areacode_check=$_POST["usacan_areacode_check"];}
|
||||
if (isset($_GET["usacan_prefix_check"])) {$usacan_prefix_check=$_GET["usacan_prefix_check"];}
|
||||
elseif (isset($_POST["usacan_prefix_check"])) {$usacan_prefix_check=$_POST["usacan_prefix_check"];}
|
||||
if (isset($_GET["delete_phone"])) {$delete_phone=$_GET["delete_phone"];}
|
||||
elseif (isset($_POST["delete_phone"])) {$delete_phone=$_POST["delete_phone"];}
|
||||
if (isset($_GET["alias_id"])) {$alias_id=$_GET["alias_id"];}
|
||||
elseif (isset($_POST["alias_id"])) {$alias_id=$_POST["alias_id"];}
|
||||
if (isset($_GET["phone_logins"])) {$phone_logins=$_GET["phone_logins"];}
|
||||
elseif (isset($_POST["phone_logins"])) {$phone_logins=$_POST["phone_logins"];}
|
||||
if (isset($_GET["alias_name"])) {$alias_name=$_GET["alias_name"];}
|
||||
elseif (isset($_POST["alias_name"])) {$alias_name=$_POST["alias_name"];}
|
||||
if (isset($_GET["delete_alias"])) {$delete_alias=$_GET["delete_alias"];}
|
||||
elseif (isset($_POST["delete_alias"])) {$delete_alias=$_POST["delete_alias"];}
|
||||
|
||||
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
@@ -381,6 +392,11 @@ if ($non_latin < 1)
|
||||
$reset_lead = ereg_replace("[^A-Z]","",$reset_lead);
|
||||
$usacan_areacode_check = ereg_replace("[^A-Z]","",$usacan_areacode_check);
|
||||
$usacan_prefix_check = ereg_replace("[^A-Z]","",$usacan_prefix_check);
|
||||
$delete_phone = ereg_replace("[^A-Z]","",$delete_phone);
|
||||
$alias_id = ereg_replace("[^-\_0-9a-zA-Z]","",$alias_id);
|
||||
$phone_logins = ereg_replace("[^-\,\_0-9a-zA-Z]","",$phone_logins);
|
||||
$alias_name = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$alias_name);
|
||||
$delete_alias = ereg_replace("[^A-Z]","",$delete_alias);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1475,6 +1491,676 @@ if ($function == 'add_phone')
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### update_phone - updates phone entry already in the system
|
||||
################################################################################
|
||||
if ($function == 'update_phone')
|
||||
{
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "Invalid Source";
|
||||
echo "$result: $result_reason - $source\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
echo "ERROR: Invalid Source: |$source|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and ast_admin_access='1' and user_level >= 8;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone USER DOES NOT HAVE PERMISSION TO ADD PHONES";
|
||||
$data = "$allowed_user";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (strlen($extension)<2) or (strlen($server_ip)<1) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE ALL REQUIRED FIELDS";
|
||||
$data = "$extension|$server_ip";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from servers where server_ip='$server_ip';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$server_exists=$row[0];
|
||||
if ($server_exists < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone SERVER DOES NOT EXIST";
|
||||
$data = "$server_ip";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$phone_exists=$row[0];
|
||||
if ($phone_exists < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone PHONE DOES NOT EXIST ON THIS SERVER";
|
||||
$data = "$server_ip|$extension";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($delete_phone == 'Y')
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and ast_delete_phones='1' and user_level >= 8;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_phone USER DOES NOT HAVE PERMISSION TO DELETE PHONES";
|
||||
$data = "$allowed_user";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="DELETE FROM phones WHERE extension='$extension' and server_ip='$server_ip';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$affected_rows = mysql_affected_rows($link);
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = ereg_replace(';','',$SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='PHONES', event_type='DELETE', record_id='$extension', event_code='ADMIN API DELETE PHONE', event_sql=\"$SQL_log\", event_notes='phone: $extension|$server_ip';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
|
||||
$rslt=mysql_query($stmtA, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_phone PHONE HAS BEEN DELETED";
|
||||
$data = "$extension|$server_ip|";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$dialplan_numberSQL='';
|
||||
$activeSQL='';
|
||||
$outboundcidSQL='';
|
||||
$voicemail_idSQL='';
|
||||
$phone_loginSQL='';
|
||||
$phone_passSQL='';
|
||||
$protocolSQL='';
|
||||
$registration_passwordSQL='';
|
||||
$phone_full_nameSQL='';
|
||||
$phone_contextSQL='';
|
||||
$emailSQL='';
|
||||
$local_gmtSQL='';
|
||||
|
||||
if (strlen($local_gmt) > 0)
|
||||
{
|
||||
if ( ($local_gmt != '12.75') and ($local_gmt != '12.00') and ($local_gmt != '11.00') and ($local_gmt != '10.00') and ($local_gmt != '9.50') and ($local_gmt != '9.00') and ($local_gmt != '8.00') and ($local_gmt != '7.00') and ($local_gmt != '6.50') and ($local_gmt != '6.00') and ($local_gmt != '5.75') and ($local_gmt != '5.50') and ($local_gmt != '5.00') and ($local_gmt != '4.50') and ($local_gmt != '4.00') and ($local_gmt != '3.50') and ($local_gmt != '3.00') and ($local_gmt != '2.00') and ($local_gmt != '1.00') and ($local_gmt != '0.00') and ($local_gmt != '-1.00') and ($local_gmt != '-2.00') and ($local_gmt != '-3.00') and ($local_gmt != '-3.50') and ($local_gmt != '-4.00') and ($local_gmt != '-5.00') and ($local_gmt != '-6.00') and ($local_gmt != '-7.00') and ($local_gmt != '-8.00') and ($local_gmt != '-9.00') and ($local_gmt != '-10.00') and ($local_gmt != '-11.00') and ($local_gmt != '-12.00') )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID TIMEZONE";
|
||||
$data = "$local_gmt";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$local_gmtSQL = " ,local_gmt='$local_gmt'";}
|
||||
}
|
||||
if (strlen($email) > 0)
|
||||
{
|
||||
if ($email == '--BLANK--')
|
||||
{$emailSQL = " ,email=''";}
|
||||
else
|
||||
{
|
||||
if ( (strlen($email) > 300) or (strlen($email) < 4) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID EMAIL";
|
||||
$data = "$email";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$emailSQL = " ,email='$email'";}
|
||||
}
|
||||
}
|
||||
if (strlen($phone_context) > 0)
|
||||
{
|
||||
if ($phone_context == '--BLANK--')
|
||||
{$phone_contextSQL = " ,phone_context=''";}
|
||||
else
|
||||
{
|
||||
if ( (strlen($phone_context) > 30) or (strlen($phone_context) < 2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID PHONE CONTEXT";
|
||||
$data = "$phone_context";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$phone_contextSQL = " ,phone_context='$phone_context'";}
|
||||
}
|
||||
}
|
||||
if (strlen($phone_full_name) > 0)
|
||||
{
|
||||
if ($phone_full_name == '--BLANK--')
|
||||
{$phone_full_nameSQL = " ,fullname=''";}
|
||||
else
|
||||
{
|
||||
if ( (strlen($phone_full_name) > 30) or (strlen($phone_full_name) < 2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID PHONE NAME";
|
||||
$data = "$phone_full_name";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$phone_full_nameSQL = " ,fullname='$phone_full_name'";}
|
||||
}
|
||||
}
|
||||
if (strlen($registration_password) > 0)
|
||||
{
|
||||
if ($registration_password == '--BLANK--')
|
||||
{$registration_passwordSQL = " ,conf_secret=''";}
|
||||
else
|
||||
{
|
||||
if ( (strlen($registration_password) > 30) or (strlen($registration_password) < 2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID REGISTRATION PASSWORD";
|
||||
$data = "$registration_password";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$registration_passwordSQL = " ,conf_secret='$registration_password'";}
|
||||
}
|
||||
}
|
||||
if (strlen($protocol) > 0)
|
||||
{
|
||||
if ( ($protocol != 'IAX2') and ($protocol != 'SIP') and ($protocol != 'Zap') and ($protocol != 'EXTERNAL') )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID PROTOCOL";
|
||||
$data = "$protocol";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$protocolSQL = " ,protocol='$protocol'";}
|
||||
}
|
||||
if (strlen($phone_pass) > 0)
|
||||
{
|
||||
if ( (strlen($phone_pass) > 30) or (strlen($phone_pass) < 2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID PHONE PASSWORD";
|
||||
$data = "$phone_pass";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$phone_passSQL = " ,pass='$phone_pass'";}
|
||||
}
|
||||
if (strlen($phone_login) > 0)
|
||||
{
|
||||
$stmt="SELECT count(*) from phones where login='$phone_login' and extension != '$extension' and server_ip != '$server_ip';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$login_exists=$row[0];
|
||||
if ($login_exists > 0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone LOGIN ALREADY EXISTS";
|
||||
$data = "$phone_login";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$phone_loginSQL = " ,login='$phone_login'";}
|
||||
}
|
||||
if (strlen($voicemail_id) > 0)
|
||||
{
|
||||
if ($voicemail_id == '--BLANK--')
|
||||
{$voicemail_idSQL = " ,voicemail_id=''";}
|
||||
else
|
||||
{
|
||||
if ( (strlen($voicemail_id) > 30) or (strlen($voicemail_id) < 2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID VOICEMAIL NUMBER";
|
||||
$data = "$voicemail_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$voicemail_idSQL = " ,voicemail_id='$voicemail_id'";}
|
||||
}
|
||||
}
|
||||
if (strlen($dialplan_number) > 0)
|
||||
{
|
||||
if ( (strlen($dialplan_number) > 30) or (strlen($dialplan_number) < 3) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone YOU MUST USE A VALID DIALPLAN NUMBER";
|
||||
$data = "$dialplan_number";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$dialplan_numberSQL = " ,dialplan_number='$dialplan_number'";}
|
||||
}
|
||||
if (strlen($active) > 0)
|
||||
{
|
||||
if ( ($active != 'Y') and ($active != 'N') )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD";
|
||||
$data = "$active";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$activeSQL = " ,active='$active'";}
|
||||
}
|
||||
if (strlen($outbound_cid) > 0)
|
||||
{
|
||||
if ( (strlen($outbound_cid) > 18) or (strlen($outbound_cid) < 6) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone OUTBOUND CID MUST BE FROM 6 TO 18 DIGITS, THIS IS AN OPTIONAL FIELD";
|
||||
$data = "$outbound_cid";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$outboundcidSQL = " ,outbound_cid='$outbound_cid'";}
|
||||
}
|
||||
|
||||
|
||||
$updateSQL = "$dialplan_numberSQL$activeSQL$outboundcidSQL$voicemail_idSQL$phone_loginSQL$phone_passSQL$protocolSQL$registration_passwordSQL$phone_full_nameSQL$phone_contextSQL$emailSQL$local_gmtSQL";
|
||||
|
||||
|
||||
if (strlen($updateSQL)< 3)
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_phone NO UPDATES DEFINED";
|
||||
$data = "$updateSQL";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="UPDATE phones SET install_directory='' $updateSQL WHERE extension='$extension' and server_ip='$server_ip';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = ereg_replace(';','',$SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='PHONES', event_type='MODIFY', record_id='$extension', event_code='ADMIN API UPDATE PHONE', event_sql=\"$SQL_log\", event_notes='phone: $extension|$server_ip';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
|
||||
$rslt=mysql_query($stmtA, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_phone PHONE HAS BEEN UPDATED";
|
||||
$data = "$extension|$server_ip|";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END update_phone
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### add_phone_alias - adds phone alias to the system
|
||||
################################################################################
|
||||
if ($function == 'add_phone_alias')
|
||||
{
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "Invalid Source";
|
||||
echo "$result: $result_reason - $source\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
echo "ERROR: Invalid Source: |$source|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and ast_admin_access='1' and user_level >= 8;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_phone_alias USER DOES NOT HAVE PERMISSION TO ADD PHONE ALIASES";
|
||||
$data = "$allowed_user";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (strlen($alias_id)<2) or (strlen($phone_logins)<2) or (strlen($alias_name)<1) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_phone_alias YOU MUST USE ALL REQUIRED FIELDS";
|
||||
$data = "$alias_id|$alias_name|$phone_logins";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from phones_alias where alias_id='$alias_id';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$alias_exists=$row[0];
|
||||
if ($alias_exists > 0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_phone_alias PHONE ALIAS ALREADY EXISTS";
|
||||
$data = "$alias_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$phone_loginsX = explode(",",$phone_logins);
|
||||
$phone_logins_ct = count($phone_loginsX);
|
||||
$k=0;
|
||||
while ($k < $phone_logins_ct)
|
||||
{
|
||||
$phone_check = $phone_loginsX[$k];
|
||||
$stmt="SELECT count(*) from phones where login='$phone_check';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$phone_exists=$row[0];
|
||||
if ($phone_exists < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_phone_alias PHONE DOES NOT EXIST";
|
||||
$data = "$phone_check";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
$k++;
|
||||
}
|
||||
|
||||
$stmt="INSERT INTO phones_alias (alias_id,alias_name,logins_list) values('$alias_id','$alias_name','$phone_logins');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = ereg_replace(';','',$SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='PHONEALIASES', event_type='ADD', record_id='$alias_id', event_code='ADMIN API ADD PHONE ALIAS', event_sql=\"$SQL_log\", event_notes='phones: $phone_logins';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "add_phone_alias PHONE ALIAS HAS BEEN ADDED";
|
||||
$data = "$alias_id|$alias_name|$phone_logins";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END add_phone_alias
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### update_phone_alias - updates phone entry already in the system
|
||||
################################################################################
|
||||
if ($function == 'update_phone_alias')
|
||||
{
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "Invalid Source";
|
||||
echo "$result: $result_reason - $source\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
echo "ERROR: Invalid Source: |$source|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and ast_admin_access='1' and user_level >= 8;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone_alias USER DOES NOT HAVE PERMISSION TO UPDATE PHONE ALIASES";
|
||||
$data = "$allowed_user";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (strlen($alias_id)<2) or ( (strlen($phone_logins)<2) and (strlen($alias_name)<1) and (strlen($delete_alias)<1) ) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone_alias YOU MUST USE ALL REQUIRED FIELDS";
|
||||
$data = "$alias_id|$alias_name|$phone_logins";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from phones_alias where alias_id='$alias_id';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$alias_exists=$row[0];
|
||||
if ($alias_exists < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone_alias PHONE ALIAS DOES NOT EXIST";
|
||||
$data = "$alias_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($delete_alias == 'Y')
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and ast_delete_phones='1' and user_level >= 8;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_phone_alias USER DOES NOT HAVE PERMISSION TO DELETE PHONE ALIASES";
|
||||
$data = "$allowed_user";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="DELETE FROM phones_alias where alias_id='$alias_id';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$affected_rows = mysql_affected_rows($link);
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = ereg_replace(';','',$SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='PHONEALIASES', event_type='DELETE', record_id='$alias_id', event_code='ADMIN API DELETE PHONE ALIAS', event_sql=\"$SQL_log\", event_notes='';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_phone_alias PHONE ALIAS HAS BEEN DELETED";
|
||||
$data = "$alias_id";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$phone_loginsSQL='';
|
||||
$alias_nameSQL='';
|
||||
|
||||
if (strlen($alias_name) > 0)
|
||||
{
|
||||
if ( (strlen($alias_name) > 50) or (strlen($alias_name) < 2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone_alias YOU MUST USE A VALID ALIAS NAME";
|
||||
$data = "$alias_name";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{$alias_nameSQL = "alias_name='$alias_name',";}
|
||||
}
|
||||
if (strlen($phone_logins) > 1)
|
||||
{
|
||||
$phone_loginsX = explode(",",$phone_logins);
|
||||
$phone_logins_ct = count($phone_loginsX);
|
||||
$k=0;
|
||||
while ($k < $phone_logins_ct)
|
||||
{
|
||||
$phone_check = $phone_loginsX[$k];
|
||||
$stmt="SELECT count(*) from phones where login='$phone_check';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$phone_exists=$row[0];
|
||||
if ($phone_exists < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_phone_alias PHONE DOES NOT EXIST";
|
||||
$data = "$phone_check";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
$k++;
|
||||
}
|
||||
$phone_loginsSQL = "logins_list='$phone_logins',";
|
||||
}
|
||||
|
||||
|
||||
$updateSQL = "$phone_loginsSQL$alias_nameSQL";
|
||||
$updateSQL = preg_replace("/\,$/","",$updateSQL);
|
||||
|
||||
|
||||
if (strlen($updateSQL)< 3)
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "update_phone_alias NO UPDATES DEFINED";
|
||||
$data = "$updateSQL";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="UPDATE phones_alias SET $updateSQL WHERE alias_id='$alias_id';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = ereg_replace(';','',$SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='PHONEALIASES', event_type='MODIFY', record_id='$alias_id', event_code='ADMIN API UPDATE PHONE', event_sql=\"$SQL_log\", event_notes='phones: $phone_logins';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_phone_alias PHONE ALIAS HAS BEEN UPDATED";
|
||||
$data = "$alias_id|";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END update_phone_alias
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### update_list - updates list information in the vicidial_lists table and other functions
|
||||
################################################################################
|
||||
|
||||
Reference in New Issue
Block a user