Added 'custom_fields_update' option for update_list function in the Non-Agent API

git-svn-id: svn://192.168.202.10@3415 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2021-04-01 19:54:04 +00:00
parent 0119b0af1f
commit 1d41450f28
3 changed files with 197 additions and 29 deletions
+11 -2
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-03-30 NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-04-01
This document describes the functions of an API(Application Programming This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -183,6 +183,7 @@ Changes:
210322-1218 - Added display of bad wav file formats on sounds_list function 210322-1218 - Added display of bad wav file formats on sounds_list function
210325-2042 - Added more data output fields to agent_stats_export function 210325-2042 - Added more data output fields to agent_stats_export function
210330-1633 - Added ability to use custom_fields_copy on update_list on a deleted list_id 210330-1633 - Added ability to use custom_fields_copy on update_list on a deleted list_id
210401-1058 - Added 'custom_fields_update' option for update_list function
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -1743,7 +1744,7 @@ custom_fields_add - Must be one of these: 'Y','N', will default to 'N'. The fiel
field_rerank - If there is an existing field of the same rank, move the existing ones down the list, 'YES','NO' default is 'NO' field_rerank - If there is an existing field of the same rank, move the existing ones down the list, 'YES','NO' default is 'NO'
field_max - The maximum size of data allowed in the field field_max - The maximum size of data allowed in the field
field_default - The default value of the field field_default - The default value of the field
field_options - The field options for this field field_options - The field options for this field, If not POSTing variables, to start a new line, use '%0A', for a pipe '|' use '%7C'
field_duplicate - If this is a duplicate of another existing field for this list ID: 'Y','N' default is 'N' field_duplicate - If this is a duplicate of another existing field for this list ID: 'Y','N' default is 'N'
field_description - Description of the field field_description - Description of the field
field_help - The help text for this field as it appears to the agent in the custom form field_help - The help text for this field as it appears to the agent in the custom form
@@ -1752,6 +1753,9 @@ custom_fields_add - Must be one of these: 'Y','N', will default to 'N'. The fiel
name_position - The position of the name of the field: 'TOP','LEFT' default is 'LEFT' name_position - The position of the name of the field: 'TOP','LEFT' default is 'LEFT'
field_encrypt - If this is to be an encrypted field(a VICIhost-only feature, if enabled): 'Y','N' default is 'N' field_encrypt - If this is to be an encrypted field(a VICIhost-only feature, if enabled): 'Y','N' default is 'N'
field_show_hide - If the field is to be hidden(a VICIhost-only feature, if enabled): 'DISABLED','X_OUT_ALL','LAST_1','LAST_2','LAST_3','LAST_4','FIRST_1_LAST_4' field_show_hide - If the field is to be hidden(a VICIhost-only feature, if enabled): 'DISABLED','X_OUT_ALL','LAST_1','LAST_2','LAST_3','LAST_4','FIRST_1_LAST_4'
custom_fields_update - Must be one of these: 'Y','N', will default to 'N'. The fields shown above are all optional except for 'field_label' which is required for this to work
* For 'custom_fields_update' only, you can set the following fields to '--BLANK--' to have them changed to an empty '' value:
field_description, $field_help, $field_options, $field_default
NOTES: NOTES:
- in order to set a field to empty('') set it equal to --BLANK--, i.e. "&drop_inbound_group=--BLANK--" - in order to set a field to empty('') set it equal to --BLANK--, i.e. "&drop_inbound_group=--BLANK--"
@@ -1768,6 +1772,8 @@ http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&functio
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=1102&campaign_id=ASTRICON http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=1102&campaign_id=ASTRICON
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=99883&custom_copy_method=APPEND&custom_fields_copy=9988 http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=99883&custom_copy_method=APPEND&custom_fields_copy=9988
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=9988&custom_fields_add=Y&field_label=new_api_field4&field_name=new+API+field4&field_size=20&field_type=TEXT&field_rank=16 http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=9988&custom_fields_add=Y&field_label=new_api_field4&field_name=new+API+field4&field_size=20&field_type=TEXT&field_rank=16
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=9988&custom_fields_update=Y&field_label=Utility&field_options=1,1_1_hello%0A2,2_2_hello%0A3,3_3_hello
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_list&list_id=9988&custom_fields_update=Y&field_label=bill_period3&field_options=source=%3Ebill_start_month3%0Avalue=%3ESeptember%0Aoption=%3E%7Cselect%20bill-period-1%0Aoption=%3E1_month%7C1%20Month%0Aoption=%3E2_months%7C2%20Months%0Aoption=%3E3_months%7C3%20Months%0Avalue=%3E%0Aoption=%3E%7Cno%20match
Example responses: Example responses:
ERROR: update_list USER DOES NOT HAVE PERMISSION TO UPDATE LISTS - 6666 ERROR: update_list USER DOES NOT HAVE PERMISSION TO UPDATE LISTS - 6666
@@ -1806,6 +1812,9 @@ NOTICE: update_list COPY CUSTOM FIELDS COMMAND SENT - 6666|1101|APPEND|ERROR: Fi
NOTICE: update_list COPY CUSTOM FIELDS COMMAND SENT - 6666|1101|APPEND|SUCCESS: Fields copied| NOTICE: update_list COPY CUSTOM FIELDS COMMAND SENT - 6666|1101|APPEND|SUCCESS: Fields copied|
NOTICE: update_list CUSTOM FIELDS LIST ID TO ADD TO HAS NO CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD - 6666|1101 NOTICE: update_list CUSTOM FIELDS LIST ID TO ADD TO HAS NO CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD - 6666|1101
NOTICE: update_list REQUIRED CUSTOM FIELDS VARIABLES ARE MISSING, FIELD NOT ADDED, THIS IS AN OPTIONAL FIELD - 6666|1101|||||| NOTICE: update_list REQUIRED CUSTOM FIELDS VARIABLES ARE MISSING, FIELD NOT ADDED, THIS IS AN OPTIONAL FIELD - 6666|1101||||||
NOTICE: update_list CUSTOM FIELDS LIST ID TO UPDATE TO HAS NO CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD - 6666|1101||||||
NOTICE: update_list REQUIRED CUSTOM FIELDS VARIABLES ARE MISSING, FIELD NOT UPDATED, THIS IS AN OPTIONAL FIELD - 6666|1101|||
NOTICE: update_list FIELD DOES NOT EXIST, FIELD NOT UPDATED, THIS IS AN OPTIONAL FIELD - 6666|1101|abc|||||
NOTICE: update_list ADD CUSTOM FIELD COMMAND SENT - 6666|1101|new_field|TEXT|ERROR: Field not added| NOTICE: update_list ADD CUSTOM FIELD COMMAND SENT - 6666|1101|new_field|TEXT|ERROR: Field not added|
NOTICE: update_list ADD CUSTOM FIELD COMMAND SENT - 6666|1101|new_field|TEXT|SUCCESS: Field added| NOTICE: update_list ADD CUSTOM FIELD COMMAND SENT - 6666|1101|new_field|TEXT|SUCCESS: Field added|
@@ -2423,26 +2423,26 @@ else
} }
else else
{ {
echo "<tr><td align=right>$label_title: </td><td align=left><input type=text name=title size=4 maxlength=$MAXtitle value=\"$title\"> &nbsp; \n"; echo "<tr><td align=right>$label_title: </td><td align=left><input type=text name=title id=title size=4 maxlength=$MAXtitle value=\"$title\"> &nbsp; \n";
echo "$label_first_name: <input type=text name=first_name size=15 maxlength=$MAXfirst_name value=\"".htmlparse($first_name)."\"> </td></tr>\n"; echo "$label_first_name: <input type=text name=first_name id=first_name size=15 maxlength=$MAXfirst_name value=\"".htmlparse($first_name)."\"> </td></tr>\n";
echo "<tr><td align=right>$label_middle_initial: </td><td align=left><input type=text name=middle_initial size=4 maxlength=$MAXmiddle_initial value=\"".htmlparse($middle_initial)."\"> &nbsp; \n"; echo "<tr><td align=right>$label_middle_initial: </td><td align=left><input type=text name=middle_initial id=middle_initial size=4 maxlength=$MAXmiddle_initial value=\"".htmlparse($middle_initial)."\"> &nbsp; \n";
echo " $label_last_name: <input type=text name=last_name size=15 maxlength=$MAXlast_name value=\"".htmlparse($last_name)."\"> </td></tr>\n"; echo " $label_last_name: <input type=text name=last_name id=last_name size=15 maxlength=$MAXlast_name value=\"".htmlparse($last_name)."\"> </td></tr>\n";
echo "<tr><td align=right>$label_address1 : </td><td align=left><input type=text name=address1 size=40 maxlength=$MAXaddress1 value=\"".htmlparse($address1)."\"></td></tr>\n"; echo "<tr><td align=right>$label_address1 : </td><td align=left><input type=text name=address1 id=address1 size=40 maxlength=$MAXaddress1 value=\"".htmlparse($address1)."\"></td></tr>\n";
echo "<tr><td align=right>$label_address2 : </td><td align=left><input type=text name=address2 size=40 maxlength=$MAXaddress2 value=\"".htmlparse($address2)."\"></td></tr>\n"; echo "<tr><td align=right>$label_address2 : </td><td align=left><input type=text name=address2 id=address2 size=40 maxlength=$MAXaddress2 value=\"".htmlparse($address2)."\"></td></tr>\n";
echo "<tr><td align=right>$label_address3 : </td><td align=left><input type=text name=address3 size=40 maxlength=$MAXaddress3 value=\"".htmlparse($address3)."\"></td></tr>\n"; echo "<tr><td align=right>$label_address3 : </td><td align=left><input type=text name=address3 id=address3 size=40 maxlength=$MAXaddress3 value=\"".htmlparse($address3)."\"></td></tr>\n";
echo "<tr><td align=right>$label_city : </td><td align=left><input type=text name=city size=40 maxlength=$MAXcity value=\"".htmlparse($city)."\"></td></tr>\n"; echo "<tr><td align=right>$label_city : </td><td align=left><input type=text name=city id=city size=40 maxlength=$MAXcity value=\"".htmlparse($city)."\"></td></tr>\n";
echo "<tr><td align=right>$label_state: </td><td align=left><input type=text name=state size=2 maxlength=$MAXstate value=\"".htmlparse($state)."\"> &nbsp; \n"; echo "<tr><td align=right>$label_state: </td><td align=left><input type=text name=state id=state size=2 maxlength=$MAXstate value=\"".htmlparse($state)."\"> &nbsp; \n";
echo " $label_postal_code: <input type=text name=postal_code size=10 maxlength=$MAXpostal_code value=\"".htmlparse($postal_code)."\"> </td></tr>\n"; echo " $label_postal_code: <input type=text name=postal_code id=postal_code size=10 maxlength=$MAXpostal_code value=\"".htmlparse($postal_code)."\"> </td></tr>\n";
echo "<tr><td align=right>$label_province : </td><td align=left><input type=text name=province size=40 maxlength=$MAXprovince value=\"".htmlparse($province)."\"></td></tr>\n"; echo "<tr><td align=right>$label_province : </td><td align=left><input type=text name=province id=province size=40 maxlength=$MAXprovince value=\"".htmlparse($province)."\"></td></tr>\n";
echo "<tr><td align=right>"._QXZ("Country")." : </td><td align=left><input type=text name=country_code size=3 maxlength=$MAXcountry_code value=\"".htmlparse($country_code)."\"> &nbsp; \n"; echo "<tr><td align=right>"._QXZ("Country")." : </td><td align=left><input type=text name=country_code id=country_code size=3 maxlength=$MAXcountry_code value=\"".htmlparse($country_code)."\"> &nbsp; \n";
echo " "._QXZ("Date of Birth").": <input type=text name=date_of_birth size=12 maxlength=10 value=\"".htmlparse($date_of_birth)."\"></td></tr>\n"; echo " "._QXZ("Date of Birth").": <input type=text name=date_of_birth id=date_of_birth size=12 maxlength=10 value=\"".htmlparse($date_of_birth)."\"></td></tr>\n";
if ( ($LOGmodify_leads == '1') or ($LOGmodify_leads == '3') or ($lead_id == 'NEW') ) if ( ($LOGmodify_leads == '1') or ($LOGmodify_leads == '3') or ($lead_id == 'NEW') )
{ {
echo "<tr><td align=right>$label_phone_number : </td><td align=left><input type=text name=phone_number size=18 maxlength=$MAXphone_number value=\"".htmlparse($phone_number)."\"></td></tr>\n"; echo "<tr><td align=right>$label_phone_number : </td><td align=left><input type=text name=phone_number id=phone_number size=18 maxlength=$MAXphone_number value=\"".htmlparse($phone_number)."\"></td></tr>\n";
echo "<tr><td align=right>$label_phone_code : </td><td align=left><input type=text name=phone_code size=10 maxlength=$MAXphone_code value=\"".htmlparse($phone_code)."\"></td></tr>\n"; echo "<tr><td align=right>$label_phone_code : </td><td align=left><input type=text name=phone_code id=phone_code size=10 maxlength=$MAXphone_code value=\"".htmlparse($phone_code)."\"></td></tr>\n";
echo "<tr><td align=right>$label_alt_phone : </td><td align=left><input type=text name=alt_phone size=12 maxlength=$MAXalt_phone value=\"".htmlparse($alt_phone)."\"></td></tr>\n"; echo "<tr><td align=right>$label_alt_phone : </td><td align=left><input type=text name=alt_phone id=alt_phone size=12 maxlength=$MAXalt_phone value=\"".htmlparse($alt_phone)."\"></td></tr>\n";
} }
else else
{ {
@@ -2452,13 +2452,13 @@ else
} }
echo "<tr><td align=right>$label_email : </td><td align=left><input type=text name=email size=40 maxlength=$MAXemail value=\"".htmlparse($email)."\"></td></tr>\n"; echo "<tr><td align=right>$label_email : </td><td align=left><input type=text name=email size=40 maxlength=$MAXemail value=\"".htmlparse($email)."\"></td></tr>\n";
echo "<tr><td align=right>$label_security_phrase : </td><td align=left><input type=text name=security size=30 maxlength=$MAXsecurity_phrase value=\"".htmlparse($security)."\"></td></tr>\n"; echo "<tr><td align=right>$label_security_phrase : </td><td align=left><input type=text name=security id=security_phrase size=30 maxlength=$MAXsecurity_phrase value=\"".htmlparse($security)."\"></td></tr>\n";
echo "<tr><td align=right>$label_vendor_lead_code : </td><td align=left><input type=text name=vendor_id size=30 maxlength=$MAXvendor_lead_code value=\"".htmlparse($vendor_id)."\"></td></tr>\n"; echo "<tr><td align=right>$label_vendor_lead_code : </td><td align=left><input type=text name=vendor_id id=vendor_lead_code size=30 maxlength=$MAXvendor_lead_code value=\"".htmlparse($vendor_id)."\"></td></tr>\n";
if ($SSsource_id_display > 0) if ($SSsource_id_display > 0)
{echo "<tr><td align=right>$label_source_id : </td><td align=left><input type=text name=source_id size=30 maxlength=$MAXsource_id value=\"".htmlparse($source_id)."\"></td></tr>\n";} {echo "<tr><td align=right>$label_source_id : </td><td align=left><input type=text name=source_id id=source_id size=30 maxlength=$MAXsource_id value=\"".htmlparse($source_id)."\"></td></tr>\n";}
echo "<tr><td align=right>"._QXZ("Rank")." : </td><td align=left><input type=text name=rank size=7 maxlength=5 value=\"".htmlparse($rank)."\"></td></tr>\n"; echo "<tr><td align=right>"._QXZ("Rank")." : </td><td align=left><input type=text name=rank id=rank size=7 maxlength=5 value=\"".htmlparse($rank)."\"></td></tr>\n";
echo "<tr><td align=right>"._QXZ("Owner")." : </td><td align=left><input type=text name=owner size=22 maxlength=$MAXowner value=\"".htmlparse($owner)."\"></td></tr>\n"; echo "<tr><td align=right>"._QXZ("Owner")." : </td><td align=left><input type=text name=owner id=owner size=22 maxlength=$MAXowner value=\"".htmlparse($owner)."\"></td></tr>\n";
echo "<tr><td align=right>$label_comments : </td><td align=left><TEXTAREA name=comments ROWS=3 COLS=65>".htmlparse($comments)."</TEXTAREA></td></tr>\n"; echo "<tr><td align=right>$label_comments : </td><td align=left><TEXTAREA name=comments id=comments ROWS=3 COLS=65>".htmlparse($comments)."</TEXTAREA></td></tr>\n";
} }
if ($lead_id != 'NEW') if ($lead_id != 'NEW')
@@ -3578,7 +3578,8 @@ echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\n"._QXZ("script runtime").": $RUNtime "._QXZ("seconds")."</font>"; echo "<font size=0>\n\n\n<br><br><br>\n"._QXZ("script runtime").": $RUNtime "._QXZ("seconds")."</font>";
echo "</span>\n"; echo "</span>\n";
echo "<br><span id=debugbottomspan></span>\n";
?> ?>
+162 -4
View File
@@ -173,10 +173,11 @@
# 210328-2140 - Added more variable filtering # 210328-2140 - Added more variable filtering
# 210329-2016 - Fixed for consistent custom fields values filtering # 210329-2016 - Fixed for consistent custom fields values filtering
# 210330-1633 - Added ability to use custom_fields_copy on update_list on a deleted list_id # 210330-1633 - Added ability to use custom_fields_copy on update_list on a deleted list_id
# 210401-1058 - Added 'custom_fields_update' option for update_list function
# #
$version = '2.14-150'; $version = '2.14-151';
$build = '210330-1633'; $build = '210401-1058';
$api_url_log = 0; $api_url_log = 0;
$startMS = microtime(); $startMS = microtime();
@@ -631,7 +632,8 @@ if (isset($_GET["field_rerank"])) {$field_rerank=$_GET["field_rerank"];}
elseif (isset($_POST["field_rerank"])) {$field_rerank=$_POST["field_rerank"];} elseif (isset($_POST["field_rerank"])) {$field_rerank=$_POST["field_rerank"];}
if (isset($_GET["custom_fields_add"])) {$custom_fields_add=$_GET["custom_fields_add"];} if (isset($_GET["custom_fields_add"])) {$custom_fields_add=$_GET["custom_fields_add"];}
elseif (isset($_POST["custom_fields_add"])) {$custom_fields_add=$_POST["custom_fields_add"];} elseif (isset($_POST["custom_fields_add"])) {$custom_fields_add=$_POST["custom_fields_add"];}
if (isset($_GET["custom_fields_update"])) {$custom_fields_update=$_GET["custom_fields_update"];}
elseif (isset($_POST["custom_fields_update"])) {$custom_fields_update=$_POST["custom_fields_update"];}
header ("Content-type: text/html; charset=utf-8"); header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
@@ -907,6 +909,7 @@ $list_exists_check = preg_replace('/[^0-9a-zA-Z]/','',$list_exists_check);
$use_internal_webserver = preg_replace('/[^0-9a-zA-Z]/','',$use_internal_webserver); $use_internal_webserver = preg_replace('/[^0-9a-zA-Z]/','',$use_internal_webserver);
$field_rerank = preg_replace('/[^_0-9a-zA-Z]/','',$field_rerank); $field_rerank = preg_replace('/[^_0-9a-zA-Z]/','',$field_rerank);
$custom_fields_add = preg_replace('/[^_0-9a-zA-Z]/','',$custom_fields_add); $custom_fields_add = preg_replace('/[^_0-9a-zA-Z]/','',$custom_fields_add);
$custom_fields_update = preg_replace('/[^_0-9a-zA-Z]/','',$custom_fields_update);
$USarea = substr($phone_number, 0, 3); $USarea = substr($phone_number, 0, 3);
$USprefix = substr($phone_number, 3, 3); $USprefix = substr($phone_number, 3, 3);
@@ -5247,7 +5250,7 @@ if ($function == 'update_list')
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
$list_exists=$row[0]; $list_exists=$row[0];
if ( ($list_exists < 1) and ($custom_fields_add != 'Y') and ( (strlen($custom_fields_copy) < 1) or (strlen($custom_fields_copy) > 14) ) ) if ( ($list_exists < 1) and ($custom_fields_add != 'Y') and ($custom_fields_update != 'Y') and ( (strlen($custom_fields_copy) < 1) or (strlen($custom_fields_copy) > 14) ) )
{ {
if ($insert_if_not_found == 'Y') if ($insert_if_not_found == 'Y')
{ {
@@ -5376,6 +5379,161 @@ if ($function == 'update_list')
} }
### END 'custom_fields_add' section ### END 'custom_fields_add' section
### BEGIN 'custom_fields_update' section
if ($custom_fields_update == 'Y')
{
$update_custom_fields_trigger=0;
if ($list_exists < 1)
{
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_exists=$row[0];
if ($DB>0) {echo "$list_exists|$stmt|\n";}
if ($list_exists < 1)
{
$result = 'NOTICE';
$result_reason = "update_list CUSTOM FIELDS LIST ID TO UPDATE TO HAS NO CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD";
$data = "$list_id|$list_exists";
echo "$result: $result_reason: |$user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
if ($list_exists > 0)
{
$stmt="SELECT count(*) from vicidial_users where user='$user' and custom_fields_modify='1';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$custom_fields_modify_exists=$row[0];
if ($DB>0) {echo "$custom_fields_modify_exists|$stmt|\n";}
if ($custom_fields_modify_exists < 1)
{
$result = 'NOTICE';
$result_reason = "update_list USER DOES NOT HAVE PERMISSION TO MODIFY CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD";
$data = "$list_id|$custom_fields_copy|$custom_fields_modify_exists";
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
{
if ($DB>0) {echo "Update custom field triggered|$update_custom_fields_trigger|\n";}
$update_custom_fields_trigger++;
}
}
if ( ($update_custom_fields_trigger > 0) and (strlen($list_id) > 1) )
{
if (strlen($field_label) < 1)
{
$result = 'NOTICE';
$result_reason = "update_list REQUIRED CUSTOM FIELDS VARIABLES ARE MISSING, FIELD NOT UPDATED, THIS IS AN OPTIONAL FIELD";
$data = "$list_id|$field_label|";
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
{
# Gather existing settings for this custom field
$stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order,field_encrypt,field_show_hide,field_duplicate from vicidial_lists_fields where list_id='$list_id' and field_label='$field_label';";
$rslt=mysql_to_mysqli($stmt, $link);
$fields_to_print = mysqli_num_rows($rslt);
if ($fields_to_print < 1)
{
$result = 'NOTICE';
$result_reason = "update_list FIELD DOES NOT EXIST, FIELD NOT UPDATED, THIS IS AN OPTIONAL FIELD";
$data = "$list_id|$field_label|$field_name|$field_size|$field_type|$field_rank|";
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
{
$rowx=mysqli_fetch_row($rslt);
$A_field_id = $rowx[0];
$A_field_label = $rowx[1];
$A_field_name = $rowx[2];
$A_field_description = $rowx[3];
$A_field_rank = $rowx[4];
$A_field_help = $rowx[5];
$A_field_type = $rowx[6];
$A_field_options = $rowx[7];
$A_field_size = $rowx[8];
$A_field_max = $rowx[9];
$A_field_default = $rowx[10];
$A_field_required = $rowx[12];
$A_multi_position = $rowx[13];
$A_name_position = $rowx[14];
$A_field_order = $rowx[15];
$A_field_encrypt = $rowx[16];
$A_field_show_hide = $rowx[17];
$A_field_duplicate = $rowx[18];
### BEGIN update custom fields ###
if (!preg_match("/^TOP$|^LEFT$/",$name_position)) {$name_position = $A_name_position;}
if (!preg_match("/^HORIZONTAL$|^VERTICAL$/",$multi_position)) {$multi_position = $A_multi_position;}
if (!preg_match("/^Y$|^N$/",$field_required)) {$field_required = $A_field_required;}
if (!preg_match("/^Y$|^N$/",$field_duplicate)) {$field_duplicate = $A_field_duplicate;}
if (!preg_match("/^YES$|^NO$/",$field_rerank)) {$field_rerank = 'NO';}
if (!preg_match("/^Y$|^N$/",$field_encrypt)) {$field_encrypt = $A_field_encrypt;}
if (!preg_match("/^DISABLED$|^X_OUT_ALL$|LAST_1|LAST_2|LAST_3|LAST_4|FIRST_1_LAST_4/",$field_show_hide)) {$field_show_hide = $A_field_show_hide;}
if (strlen($field_name) < 1) {$field_name = $A_field_name;}
if (strlen($field_description) < 1) {$field_description = $A_field_description;}
if (strlen($field_rank) < 1) {$field_rank = $A_field_rank;}
if (strlen($field_help) < 1) {$field_help = $A_field_help;}
if (strlen($field_type) < 1) {$field_type = $A_field_type;}
if (strlen($field_options) < 1) {$field_options = $A_field_options;}
if (strlen($field_size) < 1) {$field_size = $A_field_size;}
if (strlen($field_max) < 1) {$field_max = $A_field_max;}
if (strlen($field_default) < 1) {$field_default = $A_field_default;}
if (strlen($field_order) < 1) {$field_order = $A_field_order;}
if ($field_description == '--BLANK--') {$field_description = '';}
if ($field_help == '--BLANK--') {$field_help = '';}
if ($field_options == '--BLANK--') {$field_options = '';}
if ($field_default == '--BLANK--') {$field_default = '';}
$admin_lists_custom = 'admin_lists_custom.php';
$temp_webserver = (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]";
if ($use_internal_webserver == 'Y') {$temp_webserver = "://$SSsounds_web_server";}
$url = "http$temp_webserver/$SSadmin_web_directory/" . $admin_lists_custom;
$url_post_fields = "action=MODIFY_CUSTOM_FIELD_SUBMIT&list_id=$list_id&field_id=$A_field_id&field_label=$field_label&field_name=$field_name&field_size=$field_size&field_type=$field_type&field_rank=$field_rank&field_order=$field_order&field_rerank=$field_rerank&field_max=$field_max&field_default=$field_default&field_options=$field_options&field_duplicate=$field_duplicate&field_description=$field_description&field_help=$field_help&field_required=$field_required&multi_position=$multi_position&name_position=$name_position&field_encrypt=$field_encrypt&field_show_hide=$field_show_hide";
if ($DB>0) {echo "Update custom fields url|$url|$url_post_fields|\n";}
# use cURL to call the copy custom fields code
$curl = curl_init();
# Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_USERPWD => "$user:$pass",
CURLOPT_USERAGENT => 'non_agent_api.php',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => "$url_post_fields"
));
# Send the request & save response to $resp
$resp = curl_exec($curl);
$temp_response = 'NONE';
if (preg_match('/ERROR:/',$resp)) {$temp_response = 'ERROR: Field not updated';}
if (preg_match('/SUCCESS:/',$resp)) {$temp_response = 'SUCCESS: Field updated';}
# Close request to clear up some resources
curl_close($curl);
### END copy custom fields ###
$result = 'NOTICE';
$result_reason = "update_list UPDATE CUSTOM FIELD COMMAND SENT";
$data = "$list_id|$field_label|$field_type|$temp_response|";
echo "$result: $result_reason - $user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
}
}
### END 'custom_fields_update' section
$campaignSQL=''; $campaignSQL='';
$scriptSQL=''; $scriptSQL='';
$dropingroupSQL=''; $dropingroupSQL='';