Added camp_rg_only option to update_user function of the Non-Agent-API

git-svn-id: svn://192.168.202.10@2098 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2014-04-04 00:39:44 +00:00
parent a834b8101f
commit aa642a73d5
2 changed files with 22 additions and 6 deletions
+6 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2014-02-14
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2014-04-03
This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -92,6 +92,8 @@ Changes:
140206-1205 - Added update_user function
140211-1056 - Added server_refresh function
140214-1540 - Added check_phone_number function
140331-2119 - Converted division calculations to use MathZDC function
140403-2024 - Added camp_rg_only option to update_user function
API Functions use the 'function' variable
@@ -839,6 +841,8 @@ custom_five - 1-100 characters
active - 'Y' or 'N'
campaign_rank - from -9 to 9, this will change the campaign rank for this user on all campaigns
campaign_grade - from 1 to 10, this will change the campaign grade for this user on all campaigns
camp_rg_only - 0 or 1, this will set only one campaign rank/grade for this user, requires campaign_id to be set
campaign_id - only required for use with camp_rg_only
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&function=update_user&user=6666&pass=1234&agent_user=2424&agent_pass=9876
@@ -870,6 +874,7 @@ ERROR: update_user YOU MUST USE A VALID CAMPAIGN RANK, THIS IS AN OPTIONAL FIELD
ERROR: update_user YOU MUST USE A VALID CAMPAIGN GRADE, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_user NO UPDATES DEFINED - 6666|0
NOTICE: update_user USER CAMPAIGN RANKS HAVE BEEN UPDATED - 6666|9|10
NOTICE: update_user USER CAMPAIGN RANKS HAVE BEEN UPDATED - 6666|9|10|TESTCAMP|1
SUCCESS: update_user USER HAS BEEN UPDATED - 6666|7878
SUCCESS: update_user USER HAS BEEN DELETED - 6666|7878
+16 -5
View File
@@ -87,10 +87,11 @@
# 140211-1056 - Added server_refresh function
# 140214-1540 - Added check_phone_number function
# 140331-2119 - Converted division calculations to use MathZDC function
# 140403-2024 - Added camp_rg_only option to update_user function
#
$version = '2.8-63';
$build = '140331-2119';
$version = '2.8-64';
$build = '140403-2024';
$api_url_log = 0;
$startMS = microtime();
@@ -353,6 +354,8 @@ if (isset($_GET["campaign_grade"])) {$campaign_grade=$_GET["campaign_grade"];
elseif (isset($_POST["campaign_grade"])) {$campaign_grade=$_POST["campaign_grade"];}
if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];}
elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];}
if (isset($_GET["camp_rg_only"])) {$camp_rg_only=$_GET["camp_rg_only"];}
elseif (isset($_POST["camp_rg_only"])) {$camp_rg_only=$_POST["camp_rg_only"];}
header ("Content-type: text/html; charset=utf-8");
@@ -513,6 +516,7 @@ if ($non_latin < 1)
$campaign_rank = preg_replace('/[^-_0-9]/','',$campaign_rank);
$campaign_grade = preg_replace('/[^0-9]/','',$campaign_grade);
$local_call_time = preg_replace('/[^-_0-9a-zA-Z]/','',$local_call_time);
$camp_rg_only = preg_replace('/[^0-9]/','',$camp_rg_only);
}
else
{
@@ -2261,7 +2265,14 @@ if ($function == 'update_user')
$grade_MID_SQL=",'$campaign_grade'";
$grade_END_SQL.="campaign_grade='$campaign_grade'";
}
$stmt="INSERT INTO vicidial_campaign_agents(user,campaign_id $rank_BEGIN_SQL $grade_BEGIN_SQL) SELECT '$agent_user',campaign_id $rank_MID_SQL $grade_MID_SQL from vicidial_campaigns ON DUPLICATE KEY UPDATE $rank_END_SQL $grade_END_SQL;";
$camp_rg_onlySQL='';
$camp_rg_onlyNOTE='';
if ($camp_rg_only=='1')
{
$camp_rg_onlySQL = "where campaign_id='$campaign_id'";
$camp_rg_onlyNOTE = "|$campaign_id|$camp_rg_only";
}
$stmt="INSERT INTO vicidial_campaign_agents(user,campaign_id $rank_BEGIN_SQL $grade_BEGIN_SQL) SELECT '$agent_user',campaign_id $rank_MID_SQL $grade_MID_SQL from vicidial_campaigns $camp_rg_onlySQL ON DUPLICATE KEY UPDATE $rank_END_SQL $grade_END_SQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($linkB);
if ($DB) {echo "|$stmt|$affected_rows|\n";}
@@ -2270,13 +2281,13 @@ if ($function == 'update_user')
$SQL_log = "$stmt|";
$SQL_log = preg_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='USERS', event_type='MODIFY', record_id='$agent_user', event_code='ADMIN API UPDATE USER RANK', event_sql=\"$SQL_log\", event_notes='user: $agent_user|rank: $campaign_rank|grade: $campaign_grade|rows: $affected_rows';";
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='USERS', event_type='MODIFY', record_id='$agent_user', event_code='ADMIN API UPDATE USER RANK', event_sql=\"$SQL_log\", event_notes='user: $agent_user|rank: $campaign_rank|grade: $campaign_grade|rows: $affected_rows$camp_rg_onlyNOTE';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$result = 'NOTICE';
$result_reason = "update_user USER CAMPAIGN RANKS HAVE BEEN UPDATED";
$data = "$agent_user|$campaign_rank|$campaign_grade";
$data = "$agent_user|$campaign_rank|$campaign_grade$camp_rg_onlyNOTE";
echo "$result: $result_reason - $user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}