From ce2ceae9530e33935d955e96a88533eac7d4538b Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 2 Jul 2021 02:11:48 +0000 Subject: [PATCH] Added ingroup_rank/ingroup_grade options to the update_user Non-Agent API function git-svn-id: svn://192.168.202.10@3469 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/docs/NON-AGENT_API.txt | 14 ++- agc_2-X/trunk/www/vicidial/non_agent_api.php | 90 ++++++++++++++++++-- 2 files changed, 96 insertions(+), 8 deletions(-) diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index c2001e70..d908e164 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-06-25 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-07-01 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -190,6 +190,7 @@ Changes: 210611-1610 - Added more variables for add_did/update_did functions 210618-1000 - Added CORS support 210625-1421 - Added BARGESWAP option to blind_monitor function +210701-2050 - Added ingroup_rank/ingroup_grade options to the update_user function API Functions use the 'function' variable @@ -1325,14 +1326,19 @@ active - 'Y' or 'N' wrapup_seconds_override - number from -1 to 9999 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 +ingroup_rank - from -9 to 9, this will change the in-group rank for this user on all in-groups +ingroup_grade - from 1 to 10, this will change the in-group grade for this user on all in-groups 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 +ingrp_rg_only - 0 or 1, this will set only one inbound group rank/grade for this user, requires group_id to be set +group_id - only required for use with ingrp_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 http://server/vicidial/non_agent_api.php?source=test&function=update_user&user=6666&pass=1234&agent_user=2424&agent_user_level=3 http://server/vicidial/non_agent_api.php?source=test&function=update_user&user=6666&pass=1234&agent_user=2424&agent_full_name=Testing&hotkeys_active=1&active=Y http://server/vicidial/non_agent_api.php?source=test&function=update_user&user=6666&pass=1234&agent_user=2424&campaign_rank=3&campaign_grade=4 +http://server/vicidial/non_agent_api.php?source=test&function=update_user&user=6666&pass=1234&agent_user=2424&ingroup_rank=3&ingroup_grade=4&ingrp_rg_only=1&group_id=TEST_IN Example responses: ERROR: update_user USER DOES NOT HAVE PERMISSION TO UPDATE USERS - 6666|0 @@ -1357,9 +1363,11 @@ ERROR: update_user ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666 ERROR: update_user wrapup_seconds_override MUST BE A VALID DIGIT BETWEEN -1 AND 9999, THIS IS AN OPTIONAL FIELD - 6666|-2 ERROR: update_user YOU MUST USE A VALID CAMPAIGN RANK, THIS IS AN OPTIONAL FIELD - 6666|0 ERROR: update_user YOU MUST USE A VALID CAMPAIGN GRADE, THIS IS AN OPTIONAL FIELD - 6666|0 +ERROR: update_user YOU MUST USE A VALID IN-GROUP RANK, THIS IS AN OPTIONAL FIELD - 6666|0 +ERROR: update_user YOU MUST USE A VALID IN-GROUP 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 +NOTICE: update_user USER CAMPAIGN RANKS/GRADES HAVE BEEN UPDATED - 6666|9|10|TESTCAMP|1 +NOTICE: update_user USER IN-GROUP RANKS/GRADES HAVE BEEN UPDATED - 6666|9|10|TEST_IN|1 SUCCESS: update_user USER HAS BEEN UPDATED - 6666|7878 SUCCESS: update_user USER HAS BEEN DELETED - 6666|7878 diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index e88dfc6a..548ee957 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -180,10 +180,11 @@ # 210611-1610 - Added more variables for add_did/update_did functions # 210618-1000 - Added CORS support # 210625-1421 - Added BARGESWAP option to blind_monitor function +# 210701-2050 - Added ingroup_rank/ingroup_grade options to the update_user function # -$version = '2.14-157'; -$build = '210625-1421'; +$version = '2.14-158'; +$build = '210701-2050'; $php_script='non_agent_api.php'; $api_url_log = 0; @@ -560,7 +561,7 @@ if (isset($_GET["remove_from_hopper"])) {$remove_from_hopper=$_GET["remove_fr if (isset($_GET["dedupe_statuses"])) {$dedupe_statuses=$_GET["dedupe_statuses"];} elseif (isset($_POST["dedupe_statuses"])) {$dedupe_statuses=$_POST["dedupe_statuses"];} if (isset($_GET["status_mismatch_action"])) {$status_mismatch_action=$_GET["status_mismatch_action"];} - elseif (isset($_POST["status_mismatch_action"])) {$status_mismatch_action=$_POST["status_mismatch_action"];} + elseif (isset($_POST["status_mismatch_action"])) {$status_mismatch_action=$_POST["status_mismatch_action"];} if (isset($_GET["custom_order"])) {$custom_order=$_GET["custom_order"];} elseif (isset($_POST["custom_order"])) {$custom_order=$_POST["custom_order"];} if (isset($_GET["custom_copy_method"])) {$custom_copy_method=$_GET["custom_copy_method"];} @@ -649,6 +650,14 @@ if (isset($_GET["call_handle_method"])) {$call_handle_method=$_GET["call_hand elseif (isset($_POST["call_handle_method"])) {$call_handle_method=$_POST["call_handle_method"];} if (isset($_GET["agent_search_method"])) {$agent_search_method=$_GET["agent_search_method"];} elseif (isset($_POST["agent_search_method"])) {$agent_search_method=$_POST["agent_search_method"];} +if (isset($_GET["ingroup_rank"])) {$ingroup_rank=$_GET["ingroup_rank"];} + elseif (isset($_POST["ingroup_rank"])) {$ingroup_rank=$_POST["ingroup_rank"];} +if (isset($_GET["ingroup_grade"])) {$ingroup_grade=$_GET["ingroup_grade"];} + elseif (isset($_POST["ingroup_grade"])) {$ingroup_grade=$_POST["ingroup_grade"];} +if (isset($_GET["ingrp_rg_only"])) {$ingrp_rg_only=$_GET["ingrp_rg_only"];} + elseif (isset($_POST["ingrp_rg_only"])) {$ingrp_rg_only=$_POST["ingrp_rg_only"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} if (file_exists('options.php')) {require('options.php');} @@ -911,6 +920,10 @@ if ($non_latin < 1) {$field_options = preg_replace('/[^ \.\n\|\,-\_0-9a-zA-Z]/', '',$field_options);} $field_help = preg_replace('/[^ \'\&\.\n\|\,-\_0-9a-zA-Z]/', '',$field_help); $field_default = preg_replace('/[^ \.\n\,-\_0-9a-zA-Z]/', '',$field_default); + $ingroup_rank = preg_replace('/[^-_0-9]/','',$ingroup_rank); + $ingroup_grade = preg_replace('/[^0-9]/','',$ingroup_grade); + $group_id = preg_replace('/[^_0-9a-zA-Z]/','',$group_id); + $ingrp_rg_only = preg_replace('/[^0-9]/','',$ingrp_rg_only); } else { @@ -3736,7 +3749,7 @@ if ($function == 'update_user') } $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); + $affected_rows = mysqli_affected_rows($link); if ($DB) {echo "|$stmt|$affected_rows|\n";} ### LOG INSERTION Admin Log Table ### @@ -3748,12 +3761,79 @@ if ($function == 'update_user') $rslt=mysql_to_mysqli($stmt, $link); $result = 'NOTICE'; - $result_reason = "update_user USER CAMPAIGN RANKS HAVE BEEN UPDATED"; + $result_reason = "update_user USER CAMPAIGN RANKS/GRADES HAVE BEEN UPDATED"; $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); } + if ( (strlen($ingroup_rank) > 0) or (strlen($ingroup_grade) > 0) ) + { + $rank_BEGIN_SQL=''; + $rank_MID_SQL=''; + $rank_END_SQL=''; + $grade_BEGIN_SQL=''; + $grade_MID_SQL=''; + $grade_END_SQL=''; + if (strlen($ingroup_rank) > 0) + { + if ( ($ingroup_rank > 9) or ($ingroup_rank < -9) ) + { + $result = 'ERROR'; + $result_reason = "update_user YOU MUST USE A VALID IN-GROUP RANK, THIS IS AN OPTIONAL FIELD"; + $data = "$ingroup_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); + exit; + } + $rank_BEGIN_SQL=',group_rank,group_weight'; + $rank_MID_SQL=",'$ingroup_rank','$ingroup_rank'"; + $rank_END_SQL="group_rank='$ingroup_rank',group_weight='$ingroup_rank'"; + } + if (strlen($ingroup_grade) > 0) + { + if ( ($ingroup_grade > 10) or ($ingroup_grade < 1) ) + { + $result = 'ERROR'; + $result_reason = "update_user YOU MUST USE A VALID IN-GROUP GRADE, THIS IS AN OPTIONAL FIELD"; + $data = "$ingroup_grade"; + 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; + } + if (strlen($rank_END_SQL)>0) + {$grade_END_SQL .= ",";} + $grade_BEGIN_SQL=',group_grade'; + $grade_MID_SQL=",'$ingroup_grade'"; + $grade_END_SQL.="group_grade='$ingroup_grade'"; + } + $ingrp_rg_onlySQL=''; + $ingrp_rg_onlyNOTE=''; + if ($ingrp_rg_only=='1') + { + $ingrp_rg_onlySQL = "where group_id='$group_id'"; + $ingrp_rg_onlyNOTE = "|$group_id|$ingrp_rg_only"; + } + $stmt="INSERT INTO vicidial_inbound_group_agents(user,group_id $rank_BEGIN_SQL $grade_BEGIN_SQL) SELECT '$agent_user',group_id $rank_MID_SQL $grade_MID_SQL from vicidial_inbound_groups $ingrp_rg_onlySQL ON DUPLICATE KEY UPDATE $rank_END_SQL $grade_END_SQL;"; + $rslt=mysql_to_mysqli($stmt, $link); + $affected_rows = mysqli_affected_rows($link); + if ($DB) {echo "|$stmt|$affected_rows|\n";} + + ### LOG INSERTION Admin Log Table ### + $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: $ingroup_rank|grade: $ingroup_grade|rows: $affected_rows$ingrp_rg_onlyNOTE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + $result = 'NOTICE'; + $result_reason = "update_user USER IN-GROUP RANKS/GRADES HAVE BEEN UPDATED"; + $data = "$agent_user|$ingroup_rank|$ingroup_grade$ingrp_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); + } + $updateSQL = "$passSQL$pass_hashSQL$full_nameSQL$user_levelSQL$user_groupSQL$phone_loginSQL$phone_passSQL$hotkeys_activeSQL$voicemail_idSQL$emailSQL$custom_oneSQL$custom_twoSQL$custom_threeSQL$custom_fourSQL$custom_fiveSQL$activeSQL$wrapup_seconds_overrideSQL"; if (strlen($updateSQL)< 3)