From 2b0e82aa9d09fef04ac01698a249f88fa48c7a27 Mon Sep 17 00:00:00 2001 From: mattf Date: Sun, 6 Nov 2011 16:25:10 +0000 Subject: [PATCH] Added ability to block customer information and hide portions of customer phone numbers within the admin interface on a per admin-user basis. Many fixes for user group restrictions in admin pages git-svn-id: svn://192.168.202.10@1753 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 7 +- docs/NON-AGENT_API.txt | 5 +- www/vicidial/AST_CLOSER_service_level.php | 38 +- www/vicidial/AST_CLOSERstats.php | 49 +- www/vicidial/AST_CLOSERsummary_hourly.php | 47 +- www/vicidial/AST_DIDstats.php | 45 +- www/vicidial/AST_IVRstats.php | 34 +- www/vicidial/AST_OUTBOUNDsummary_interval.php | 16 +- www/vicidial/AST_VICIDIAL_hopperlist.php | 32 + www/vicidial/AST_agent_days_detail.php | 35 +- www/vicidial/AST_agent_performance_detail.php | 31 +- www/vicidial/AST_agent_status_detail.php | 38 +- www/vicidial/AST_agent_time_detail.php | 33 +- www/vicidial/AST_agent_time_sheet.php | 33 +- www/vicidial/AST_agent_timeclock_detail.php | 48 +- www/vicidial/AST_team_performance_detail.php | 32 +- www/vicidial/AST_timeonVDADall.php | 41 +- www/vicidial/admin.php | 155 +++-- www/vicidial/admin_header.php | 11 +- www/vicidial/admin_modify_lead.php | 141 +++- www/vicidial/admin_search_lead.php | 110 ++- www/vicidial/call_report_export.php | 32 +- www/vicidial/fcstats.php | 50 +- www/vicidial/lead_report_export.php | 33 +- www/vicidial/non_agent_api.php | 644 ++++++++++++------ www/vicidial/timeclock_report.php | 31 +- www/vicidial/timeclock_status.php | 35 +- www/vicidial/user_stats.php | 126 +++- 28 files changed, 1501 insertions(+), 431 deletions(-) diff --git a/UPGRADE b/UPGRADE index c0bf3368..d8899181 100644 --- a/UPGRADE +++ b/UPGRADE @@ -754,12 +754,15 @@ OTHER CHANGES: selected call time. 171. Added "Admin User Group" setting to just about every section of the admin - web interface, allowing for more complete administrative access - segmentation for different divisions within the same company. + web interface and reports, allowing for more complete administrative + access segmentation for different divisions within the same company. 172. Added Max Calls settings to in-groups, allowing for a cap on concurrent calls being handled by each in-group, either in total or in queue. +173. Added ability to block customer information and hide portions of customer + phone numbers within the admin interface on a per admin-user basis. + diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 8118522b..8a19fafd 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -65,6 +65,8 @@ Changes: 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 110928-2110 - Added callback options to add_lead and update_lead +111106-0959 - Added user_group restrictions to some functions + @@ -600,7 +602,7 @@ outbound_cid - 1-20 digits OPTIONAL FIELDS- phone_context - a phone context, default is 'default' email - 1-100 characters - +admin_user_group - a valid user group or '---ALL---' Example URL strings for API calls: http://server/vicidial/non_agent_api.php?source=test&function=add_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 @@ -641,6 +643,7 @@ 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 +admin_user_group - a valid user group or '---ALL---' 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 diff --git a/www/vicidial/AST_CLOSER_service_level.php b/www/vicidial/AST_CLOSER_service_level.php index 39da9f40..20f5bce2 100644 --- a/www/vicidial/AST_CLOSER_service_level.php +++ b/www/vicidial/AST_CLOSER_service_level.php @@ -18,6 +18,7 @@ # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1756 - Added download option +# 111103-2300 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -101,12 +102,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -116,6 +119,26 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -123,16 +146,18 @@ if (!isset($group)) {$group = '';} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($end_date)) {$end_date = $NOW_DATE;} -$stmt="select group_id,group_name from vicidial_inbound_groups order by group_id;"; +$stmt="select group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $groups_to_print = mysql_num_rows($rslt); $i=0; +$groups_string='|'; while ($i < $groups_to_print) { $row=mysql_fetch_row($rslt); $groups[$i] = $row[0]; $group_names[$i] = $row[1]; + $groups_string .= "$groups[$i]|"; $i++; } @@ -146,6 +171,11 @@ $HEADER.=" .orange {color: black; background-color: #FFCC99}\n"; $HEADER.="-->\n"; $HEADER.=" \n"; +if (!preg_match("/\|$group\|/i",$groups_string)) + { + $HEADER.="\n"; + $group=''; + } $HEADER.="\n"; $HEADER.="\n"; diff --git a/www/vicidial/AST_CLOSERstats.php b/www/vicidial/AST_CLOSERstats.php index 6e3d86fb..626508f2 100644 --- a/www/vicidial/AST_CLOSERstats.php +++ b/www/vicidial/AST_CLOSERstats.php @@ -33,6 +33,7 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1759 - Added download option # 111103-0632 - Added MAXCAL as a drop status +# 111103-2003 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -135,12 +136,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -150,6 +153,26 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -157,9 +180,9 @@ if (!isset($group)) {$group = '';} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($end_date)) {$end_date = $NOW_DATE;} -$stmt="select group_id,group_name,8 from vicidial_inbound_groups order by group_id;"; +$stmt="select group_id,group_name,8 from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; if ($DID=='Y') - {$stmt="select did_pattern,did_description,did_id from vicidial_inbound_dids order by did_pattern;";} + {$stmt="select did_pattern,did_description,did_id from vicidial_inbound_dids $whereLOGadmin_viewable_groupsSQL order by did_pattern;";} $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $groups_to_print = mysql_num_rows($rslt); @@ -167,12 +190,14 @@ $i=0; $LISTgroups[$i]='---NONE---'; $i++; $groups_to_print++; +$groups_string='|'; while ($i < $groups_to_print) { $row=mysql_fetch_row($rslt); $LISTgroups[$i] = $row[0]; $LISTgroup_names[$i] = $row[1]; $LISTgroup_ids[$i] = $row[2]; + $groups_string .= "$LISTgroups[$i]|"; $i++; } @@ -181,9 +206,12 @@ $group_string='|'; $group_ct = count($group); while($i < $group_ct) { - $group_string .= "$group[$i]|"; - $group_SQL .= "'$group[$i]',"; - $groupQS .= "&group[]=$group[$i]"; + if ( (strlen($group[$i]) > 0) and (preg_match("/\|$group[$i]\|/",$groups_string)) ) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + } $i++; } if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) @@ -196,6 +224,7 @@ else $group_SQL = eregi_replace(",$",'',$group_SQL); # $group_SQL = "group_id IN($group_SQL)"; } +if (strlen($group_SQL)<3) {$group_SQL="''";} $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; @@ -245,7 +274,7 @@ if ($DB > 0) $MAIN.="
\n"; } -$MAIN.="
\n"; +$MAIN.="\n"; $MAIN.="
\n"; $MAIN.="\n"; $MAIN.="\n"; @@ -371,7 +400,7 @@ $CSV_text1.="\"Inbound Call Stats:\",\"$group_string\",\"$NOW_TIME\"\n"; if ($DID=='Y') { - $stmt="select did_id from vicidial_inbound_dids where did_pattern IN($group_SQL);"; + $stmt="select did_id from vicidial_inbound_dids where did_pattern IN($group_SQL) $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $dids_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_CLOSERsummary_hourly.php b/www/vicidial/AST_CLOSERsummary_hourly.php index 8c09b55b..bce912e6 100644 --- a/www/vicidial/AST_CLOSERsummary_hourly.php +++ b/www/vicidial/AST_CLOSERsummary_hourly.php @@ -13,6 +13,7 @@ # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1806 - Added download option +# 111103-2315 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -126,12 +127,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -141,6 +144,26 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -148,14 +171,15 @@ if (!isset($group)) {$group = '';} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($end_date)) {$end_date = $NOW_DATE;} -$exclude_rolloverSQL=''; +$exclude_rolloverSQL="$whereLOGadmin_viewable_groupsSQL"; if (eregi("YES",$exclude_rollover)) - {$exclude_rolloverSQL = " where group_id NOT IN(SELECT drop_inbound_group from vicidial_campaigns)";} + {$exclude_rolloverSQL = " where group_id NOT IN(SELECT drop_inbound_group from vicidial_campaigns) $LOGadmin_viewable_groupsSQL";} $stmt="select group_id,group_name from vicidial_inbound_groups $exclude_rolloverSQL order by group_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $groups_to_print = mysql_num_rows($rslt); $i=0; +$groups_string='|'; #$LISTgroups[$i]='---NONE---'; #$i++; #$groups_to_print++; @@ -164,6 +188,7 @@ while ($i < $groups_to_print) $row=mysql_fetch_row($rslt); $LISTgroups[$i] = $row[0]; $LISTgroup_names[$i] = $row[1]; + $groups_string .= "$LISTgroups[$i]|"; $i++; } @@ -172,9 +197,12 @@ $group_string='|'; $group_ct = count($group); while($i < $group_ct) { - $group_string .= "$group[$i]|"; - $group_SQL .= "'$group[$i]',"; - $groupQS .= "&group[]=$group[$i]"; + if ( (strlen($group[$i]) > 0) and (preg_match("/\|$group[$i]\|/",$groups_string)) ) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + } $i++; } if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) @@ -187,6 +215,7 @@ else $group_SQL = eregi_replace(",$",'',$group_SQL); # $group_SQL = "group_id IN($group_SQL)"; } +if (strlen($group_SQL)<3) {$group_SQL="''";} $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; @@ -203,7 +232,7 @@ while ($i < $statcats_to_print) $i++; } -$stmt="select call_time_id,call_time_name from vicidial_call_times order by call_time_id;"; +$stmt="select call_time_id,call_time_name from vicidial_call_times $whereLOGadmin_viewable_call_timesSQL order by call_time_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $times_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_DIDstats.php b/www/vicidial/AST_DIDstats.php index 2c801e5f..ea448fb8 100644 --- a/www/vicidial/AST_DIDstats.php +++ b/www/vicidial/AST_DIDstats.php @@ -13,6 +13,7 @@ # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1809 - Added download option +# 111104-1133 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -99,12 +100,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -114,6 +117,26 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -121,10 +144,11 @@ if (!isset($group)) {$group = '';} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($end_date)) {$end_date = $NOW_DATE;} -$stmt="select did_id,did_pattern,did_description from vicidial_inbound_dids order by did_pattern;"; +$stmt="select did_id,did_pattern,did_description from vicidial_inbound_dids $whereLOGadmin_viewable_groupsSQL order by did_pattern;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $groups_to_print = mysql_num_rows($rslt); +$groups_string='|'; $i=0; while ($i < $groups_to_print) { @@ -132,6 +156,7 @@ while ($i < $groups_to_print) $groups[$i] = $row[0]; $group_patterns[$i] = $row[1]; $group_names[$i] = $row[2]; + $groups_string .= "$groups[$i]|"; $i++; } @@ -140,9 +165,12 @@ $group_string='|'; $group_ct = count($group); while($i < $group_ct) { - $group_string .= "$group[$i]|"; - $group_SQL .= "'$group[$i]',"; - $groupQS .= "&group[]=$group[$i]"; + if ( (strlen($group[$i]) > 0) and (preg_match("/\|$group[$i]\|/",$groups_string)) ) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + } $i++; } if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) @@ -155,6 +183,7 @@ else $group_SQL = eregi_replace(",$",'',$group_SQL); # $group_SQL = "group_id IN($group_SQL)"; } +if (strlen($group_SQL)<3) {$group_SQL="''";} @@ -187,7 +216,7 @@ if ($DB > 0) $MAIN.="
"; -$MAIN.="\n"; +$MAIN.="\n"; $MAIN.="\n"; echo "\n"; echo "\n"; echo "\n"; echo "$NWB#vicidial_users-user_group$NWE\n"; @@ -11338,6 +11341,21 @@ if ($ADD==21) { echo "
CAMPAIGN ADDED: $campaign_id\n"; + # if admin user's user group does not have -ALL-CAMPAIGNS- then add this new campaign to their user group's allowable campaigns + if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) + { + $UPDATEallowed_campaigns = $LOGallowed_campaigns; + $UPDATEallowed_campaigns = preg_replace("/ -$/"," $campaign_id -",$UPDATEallowed_campaigns); + $LOGallowed_campaigns = $UPDATEallowed_campaigns; + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + $stmt="UPDATE vicidial_user_groups SET allowed_campaigns='$UPDATEallowed_campaigns' where user_group='$LOGuser_group';"; + $rslt=mysql_query($stmt, $link); + } + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,campaign_description,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch,campaign_changedate,campaign_stats_refresh,list_order_mix,web_form_address_two,start_call_url,dispo_call_url,na_call_url,user_group) values('$campaign_id','$campaign_name','$campaign_description','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch','$SQLdate','Y','DISABLED','','','','','$user_group');"; $rslt=mysql_query($stmt, $link); @@ -11405,6 +11423,21 @@ if ($ADD==20) { echo "
CAMPAIGN COPIED: $campaign_id copied from $source_campaign_id\n"; + # if admin user's user group does not have -ALL-CAMPAIGNS- then add this new campaign to their user group's allowable campaigns + if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) + { + $UPDATEallowed_campaigns = $LOGallowed_campaigns; + $UPDATEallowed_campaigns = preg_replace("/ -$/"," $campaign_id -",$UPDATEallowed_campaigns); + $LOGallowed_campaigns = $UPDATEallowed_campaigns; + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + $stmt="UPDATE vicidial_user_groups SET allowed_campaigns='$UPDATEallowed_campaigns' where user_group='$LOGuser_group';"; + $rslt=mysql_query($stmt, $link); + } + $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number,use_custom_cid,scheduled_callbacks_alert,queuemetrics_callstatus_override,extension_appended_cidname,scheduled_callbacks_count,manual_dial_override,blind_monitor_warning,blind_monitor_message,blind_monitor_filename,inbound_queue_no_dial,timer_action_destination,enable_xfer_presets,hide_xfer_number_to_dial,manual_dial_prefix,customer_3way_hangup_logging,customer_3way_hangup_seconds,customer_3way_hangup_action,ivr_park_call,ivr_park_call_agi,manual_preview_dial,realtime_agent_time_stats,use_auto_hopper,auto_hopper_multi,auto_trim_hopper,api_manual_dial,manual_dial_call_time_check,display_leads_count,lead_order_randomize,lead_order_secondary,per_call_notes,my_callback_option,agent_lead_search,agent_lead_search_method,queuemetrics_phone_environment,auto_pause_precall,auto_resume_precall,auto_pause_precall_code,manual_dial_cid,post_phone_time_diff_alert,custom_3way_button_transfer,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,safe_harbor_audio,safe_harbor_menu_id,survey_menu_id,callback_days_limit,dl_diff_target_method,disable_dispo_screen,disable_dispo_status,screen_labels,status_display_fields,na_call_url,survey_recording,pllb_grouping,pllb_grouping_limit,call_count_limit,call_count_target,callback_hours_block,callback_list_calltime,user_group from vicidial_campaigns where campaign_id='$source_campaign_id';"; $rslt=mysql_query($stmt, $link); @@ -12495,11 +12528,17 @@ if ($ADD==211111) { $UPDATEadmin_viewable_groups = $LOGadmin_viewable_groups; $UPDATEadmin_viewable_groups = preg_replace("/ $/"," $user_group ",$UPDATEadmin_viewable_groups); + $LOGadmin_viewable_groups = $UPDATEadmin_viewable_groups; $stmt="UPDATE vicidial_user_groups SET admin_viewable_groups='$UPDATEadmin_viewable_groups' where user_group='$LOGuser_group';"; $rslt=mysql_query($stmt, $link); $allowed_user_group_insert_SQL = " $user_group -"; + + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; } if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) { @@ -18019,53 +18058,53 @@ if ($ADD==61) } else { - $stmtA="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $stmtA="DELETE from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL limit 1;"; $rslt=mysql_query($stmtA, $link); - $stmt="DELETE from vicidial_campaign_agents where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaign_agents where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_campaign_statuses where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaign_statuses where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_campaign_hotkeys where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaign_hotkeys where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_callbacks where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_callbacks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_campaign_stats where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaign_stats where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_campaign_stats_debug where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaign_stats_debug where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_lead_recycle where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_lead_recycle where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_campaign_server_stats where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaign_server_stats where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_server_trunks where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_server_trunks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_pause_codes where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_pause_codes where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_campaigns_list_mix where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_campaigns_list_mix where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_xfer_presets where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_xfer_presets where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_xfer_stats where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_xfer_stats where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($campaign_id)\n"; - $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18103,7 +18142,7 @@ if ($ADD==62) { $now_date_epoch = date('U'); $inactive_epoch = ($now_date_epoch - 60); - $stmt = "SELECT user,campaign_id,UNIX_TIMESTAMP(last_update_time),extension from vicidial_live_agents where campaign_id='$campaign_id';"; + $stmt = "SELECT user,campaign_id,UNIX_TIMESTAMP(last_update_time),extension from vicidial_live_agents where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "
$stmt\n";} $vla_ct = mysql_num_rows($rslt); @@ -18395,7 +18434,7 @@ if ($ADD==63) } else { - $stmt="DELETE from vicidial_auto_calls where status='LIVE' and campaign_id='$campaign_id' order by call_time limit 1;"; + $stmt="DELETE from vicidial_auto_calls where status='LIVE' and campaign_id='$campaign_id' $LOGallowed_campaignsSQL order by call_time limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18444,7 +18483,7 @@ if ($ADD==65) { echo "
CAMPAIGN LEAD RECYCLE DELETED: $campaign_id - $status - $attempt_delay\n"; - $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18496,7 +18535,7 @@ if ($ADD==66) $row=mysql_fetch_row($rslt); $auto_alt_dial_statuses = eregi_replace(" $status "," ",$row[0]); - $stmt="UPDATE vicidial_campaigns set auto_alt_dial_statuses='$auto_alt_dial_statuses' where campaign_id='$campaign_id';"; + $stmt="UPDATE vicidial_campaigns set auto_alt_dial_statuses='$auto_alt_dial_statuses' where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18538,7 +18577,7 @@ if ($ADD==67) { echo "
CAMPAIGN PAUSE CODE DELETED: $campaign_id - $pause_code\n"; - $stmt="DELETE FROM vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code';"; + $stmt="DELETE FROM vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18590,7 +18629,7 @@ if ($ADD==68) $row=mysql_fetch_row($rslt); $dial_statuses = eregi_replace(" $status "," ",$row[0]); - $stmt="UPDATE vicidial_campaigns set dial_statuses='$dial_statuses' where campaign_id='$campaign_id';"; + $stmt="UPDATE vicidial_campaigns set dial_statuses='$dial_statuses' where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18632,10 +18671,10 @@ if ($ADD==601) { echo "
CAMPAIGN PRESET DELETED: $campaign_id - $preset_name\n"; - $stmt="DELETE FROM vicidial_xfer_presets where campaign_id='$campaign_id' and preset_name='$preset_name';"; + $stmt="DELETE FROM vicidial_xfer_presets where campaign_id='$campaign_id' and preset_name='$preset_name' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE FROM vicidial_xfer_stats where campaign_id='$campaign_id' and preset_name='$preset_name';"; + $stmt="DELETE FROM vicidial_xfer_stats where campaign_id='$campaign_id' and preset_name='$preset_name' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18672,11 +18711,11 @@ if ($ADD==611) } else { - $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $stmt="DELETE from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL limit 1;"; $rslt=mysql_query($stmt, $link); echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($list_id)\n"; - $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); echo "
REMOVING LIST LEADS FROM VICIDIAL_LIST TABLE\n"; @@ -18713,7 +18752,7 @@ if ($ADD==6111) } else { - $stmtA="DELETE from vicidial_inbound_groups where group_id='$group_id' and group_id NOT IN('AGENTDIRECT') limit 1;"; + $stmtA="DELETE from vicidial_inbound_groups where group_id='$group_id' and group_id NOT IN('AGENTDIRECT') $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmtA, $link); $stmt="DELETE from vicidial_inbound_group_agents where group_id='$group_id';"; @@ -18759,7 +18798,7 @@ if ($ADD==6311) } else { - $stmt="DELETE from vicidial_inbound_dids where did_id='$did_id' limit 1;"; + $stmt="DELETE from vicidial_inbound_dids where did_id='$did_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -18792,7 +18831,7 @@ if ($ADD==6511) } else { - $stmt="DELETE from vicidial_call_menu where menu_id='$menu_id' limit 1;"; + $stmt="DELETE from vicidial_call_menu where menu_id='$menu_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); $stmtA="DELETE from vicidial_call_menu_options where menu_id='$menu_id' limit 17;"; @@ -18828,7 +18867,7 @@ if ($ADD==6711) } else { - $stmt="DELETE from vicidial_filter_phone_groups where filter_phone_group_id='$filter_phone_group_id' limit 1;"; + $stmt="DELETE from vicidial_filter_phone_groups where filter_phone_group_id='$filter_phone_group_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); $stmtA="DELETE from vicidial_filter_phone_numbers where filter_phone_group_id='$filter_phone_group_id';"; @@ -18972,7 +19011,7 @@ if ($ADD==6111111) } else { - $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $stmt="DELETE from vicidial_scripts where script_id='$script_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19006,7 +19045,7 @@ if ($ADD==61111111) } else { - $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19040,7 +19079,7 @@ if ($ADD==611111111) } else { - $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19074,7 +19113,7 @@ if ($ADD==6111111111) } else { - $stmtA="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $stmtA="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmtA, $link); $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; @@ -19132,7 +19171,7 @@ if ($ADD==631111111) } else { - $stmt="DELETE from vicidial_shifts where shift_id='$shift_id' limit 1;"; + $stmt="DELETE from vicidial_shifts where shift_id='$shift_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19167,7 +19206,7 @@ if ($ADD==61111111111) } else { - $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL limit 1;"; $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';"; @@ -19203,7 +19242,7 @@ if ($ADD==62111111111) } else { - $stmt="DELETE from phones_alias where alias_id='$alias_id' limit 1;"; + $stmt="DELETE from phones_alias where alias_id='$alias_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19236,7 +19275,7 @@ if ($ADD==63111111111) } else { - $stmt="DELETE from groups_alias where group_alias_id='$group_alias_id' limit 1;"; + $stmt="DELETE from groups_alias where group_alias_id='$group_alias_id' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19270,7 +19309,7 @@ if ($ADD==611111111111) } else { - $stmt="DELETE from servers where server_id='$server_id' and server_ip='$server_ip' limit 1;"; + $stmt="DELETE from servers where server_id='$server_id' and server_ip='$server_ip' $LOGadmin_viewable_groupsSQL limit 1;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19353,7 +19392,7 @@ if ($ADD==631111111111) $stmt="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; $rslt=mysql_query($stmt, $link); - $stmt="DELETE from vicidial_conf_templates where template_id='$template_id';"; + $stmt="DELETE from vicidial_conf_templates where template_id='$template_id' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19427,7 +19466,7 @@ if ($ADD==651111111111) } else { - $stmt="DELETE from vicidial_tts_prompts where tts_id='$tts_id';"; + $stmt="DELETE from vicidial_tts_prompts where tts_id='$tts_id' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -19463,7 +19502,7 @@ if ($ADD==661111111111) $stmt="UPDATE vicidial_music_on_hold SET remove='Y' where moh_id='$moh_id';"; $rslt=mysql_query($stmt, $link); - $stmtA="DELETE from vicidial_music_on_hold_files where moh_id='$moh_id';"; + $stmtA="DELETE from vicidial_music_on_hold_files where moh_id='$moh_id' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmtA, $link); ### LOG INSERTION Admin Log Table ### @@ -19496,7 +19535,7 @@ if ($ADD==671111111111) } else { - $stmt="DELETE from vicidial_voicemail where voicemail_id='$voicemail_id';"; + $stmt="DELETE from vicidial_voicemail where voicemail_id='$voicemail_id' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); $stmt="SELECT active_voicemail_server from system_settings;"; @@ -19537,7 +19576,7 @@ if ($ADD==681111111111) } else { - $stmt="DELETE from vicidial_screen_labels where label_id='$label_id';"; + $stmt="DELETE from vicidial_screen_labels where label_id='$label_id' $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -20446,9 +20485,11 @@ if ($ADD==31) else {$Dgroups_menu .= "\n";} - + $nxLOGadmin_viewable_groupsSQL = $LOGadmin_viewable_groupsSQL; + if (strlen($xfer_groupsSQL) < 6) + {$nxLOGadmin_viewable_groupsSQL = $whereLOGadmin_viewable_groupsSQL;} ##### get in-groups listings for dynamic transfer group pulldown list menu - $stmt="SELECT group_id,group_name from vicidial_inbound_groups $xfer_groupsSQL $LOGadmin_viewable_groupsSQL order by group_id;"; + $stmt="SELECT group_id,group_name from vicidial_inbound_groups $xfer_groupsSQL $nxLOGadmin_viewable_groupsSQL order by group_id;"; $rslt=mysql_query($stmt, $link); $Xgroups_to_print = mysql_num_rows($rslt); $Xgroups_menu=''; @@ -20490,7 +20531,7 @@ if ($ADD==31) $row=mysql_fetch_row($rslt); $agent_servers_count=$row[0]; - $stmt="SELECT count(*) from phones_alias $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT count(*) from phones_alias $whereLOGadmin_viewable_groupsSQL;"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); @@ -20999,7 +21040,7 @@ if ($ADD==31) echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($lead_id == 'NEW') {$list_id='';} - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + if ($LOGadmin_hide_lead_data != '0') + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } if ($lead_id != 'NEW') { @@ -848,7 +932,10 @@ else echo "\n"; } - echo "\n"; + if ( ($LOGadmin_hide_lead_data == '0') or ($lead_id == 'NEW') ) + { + echo "\n"; + } echo "
\n"; $MAIN.=""; diff --git a/www/vicidial/AST_IVRstats.php b/www/vicidial/AST_IVRstats.php index 7c4242c4..d9e3ca7c 100644 --- a/www/vicidial/AST_IVRstats.php +++ b/www/vicidial/AST_IVRstats.php @@ -18,6 +18,7 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110525-1907 - Added support for outbound log analysis # 110703-1850 - Added download option +# 111103-2315 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -109,12 +110,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; $LOGallowed_campaignsSQL=''; $whereLOGallowed_campaignsSQL=''; @@ -126,6 +129,26 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; } +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); @@ -142,9 +165,9 @@ if (!isset($query_date)) {$query_date = "$NOW_DATE 00:00:00";} if (!isset($end_date)) {$end_date = "$NOW_DATE 23:23:59";} if ($type == 'inbound') - {$stmt="select group_id,group_name from vicidial_inbound_groups order by group_id;";} + {$stmt="select group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;";} else - {$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id $whereLOGallowed_campaignsSQL;";} + {$stmt="select campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";} $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $groups_to_print = mysql_num_rows($rslt); @@ -188,6 +211,7 @@ else $group_SQL = eregi_replace(",$",'',$group_SQL); # $group_SQL = "group_id IN($group_SQL)"; } +if (strlen($group_SQL)<3) {$group_SQL="''";} $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; diff --git a/www/vicidial/AST_OUTBOUNDsummary_interval.php b/www/vicidial/AST_OUTBOUNDsummary_interval.php index ab301107..3df3755e 100644 --- a/www/vicidial/AST_OUTBOUNDsummary_interval.php +++ b/www/vicidial/AST_OUTBOUNDsummary_interval.php @@ -13,6 +13,7 @@ # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1825 - Added download option +# 111104-1205 - Added user_group and calltime restrictions # require("dbconnect.php"); @@ -128,13 +129,14 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) $LOGallowed_campaignsSQL=''; $whereLOGallowed_campaignsSQL=''; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$user_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_call_times from vicidial_user_groups where user_group='$user_group';"; $rslt=mysql_query($stmt, $link); $records_to_print = mysql_num_rows($rslt); if ($records_to_print > 0) { $row=mysql_fetch_row($rslt); $LOGallowed_reports = $row[1]; + $LOGadmin_viewable_call_times = $row[2]; if ( (!eregi("ALL-CAMPAIGNS",$row[0])) ) { $rawLOGallowed_campaignsSQL = eregi_replace(' -','',$row[0]); @@ -154,6 +156,16 @@ else exit; } +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -253,7 +265,7 @@ while ($i < $statcats_to_print) $i++; } -$stmt="select call_time_id,call_time_name from vicidial_call_times order by call_time_id;"; +$stmt="select call_time_id,call_time_name from vicidial_call_times $whereLOGadmin_viewable_call_timesSQL order by call_time_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $times_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_VICIDIAL_hopperlist.php b/www/vicidial/AST_VICIDIAL_hopperlist.php index fc0bffc4..fd39990a 100644 --- a/www/vicidial/AST_VICIDIAL_hopperlist.php +++ b/www/vicidial/AST_VICIDIAL_hopperlist.php @@ -13,6 +13,7 @@ # 90508-0644 - Changed to PHP long tags # 91023-1540 - Changed to only show hopper status of READY # 101111-1253 - Added source field +# 111103-1207 - Added admin_hide_phone_data and admin_hide_lead_data options # require("dbconnect.php"); @@ -46,6 +47,14 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) exit; } +$stmt="SELECT full_name,user_group,admin_hide_lead_data,admin_hide_phone_data from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGfullname = $row[0]; +$LOGuser_group = $row[1]; +$LOGadmin_hide_lead_data = $row[2]; +$LOGadmin_hide_phone_data = $row[3]; + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -145,6 +154,29 @@ else { $row=mysql_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } + if ($LOGadmin_hide_lead_data != '0') + { + if ($DB > 0) {echo "HIDELEADDATA|$row[2]|$LOGadmin_hide_lead_data|\n";} + if (strlen($row[2]) > 0) + {$state_temp = $row[2]; $row[2] = preg_replace("/./",'X',$state_temp);} + } + $FMT_i = sprintf("%-4s", $i); $lead_id = sprintf("%-9s", $row[0]); $phone_number = sprintf("%-10s", $row[1]); diff --git a/www/vicidial/AST_agent_days_detail.php b/www/vicidial/AST_agent_days_detail.php index 17c17ebc..2d9cf716 100644 --- a/www/vicidial/AST_agent_days_detail.php +++ b/www/vicidial/AST_agent_days_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -14,6 +14,7 @@ # 100712-1324 - Added system setting slave server option # 100802-2347 - Added User Group Allowed Reports option validation and allowed campaigns restrictions # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links +# 111104-1302 - Added user_group restrictions for selecting in-groups # @@ -104,12 +105,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -130,6 +133,28 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$LOGadmin_viewable_groupsSQL=''; +$vuLOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vuLOGadmin_viewable_groupsSQL = "and vicidial_users.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $MT[0]=''; $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); @@ -305,7 +330,7 @@ else $date_namesARY[0]=''; $k=0; - $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL group by date,status order by date,status desc limit 500000;"; + $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date,status order by date,status desc limit 500000;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $rows_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_agent_performance_detail.php b/www/vicidial/AST_agent_performance_detail.php index d99228ab..8ec0caa9 100644 --- a/www/vicidial/AST_agent_performance_detail.php +++ b/www/vicidial/AST_agent_performance_detail.php @@ -28,6 +28,7 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1739 - Added file download option # 111007-0709 - Changed user and fullname to use non-truncated for output file +# 111104-1256 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -119,12 +120,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -145,6 +148,26 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $MT[0]=''; $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); @@ -176,7 +199,7 @@ while ($i < $campaigns_to_print) {$group[$i] = $groups[$i];} $i++; } -$stmt="select user_group from vicidial_user_groups order by user_group;"; +$stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_query($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} $user_groups_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_agent_status_detail.php b/www/vicidial/AST_agent_status_detail.php index 7a589c51..35b9461c 100644 --- a/www/vicidial/AST_agent_status_detail.php +++ b/www/vicidial/AST_agent_status_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -15,6 +15,7 @@ # 100712-1324 - Added system setting slave server option # 100802-2347 - Added User Group Allowed Reports option validation and allowed campaigns restrictions # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links +# 111104-1249 - Added user_group restrictions for selecting in-groups # @@ -105,12 +106,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -131,6 +134,25 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } $MT[0]=''; $NOW_DATE = date("Y-m-d"); @@ -163,7 +185,7 @@ while ($i < $campaigns_to_print) {$group[$i] = $groups[$i];} $i++; } -$stmt="select user_group from vicidial_user_groups order by user_group;"; +$stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysql_num_rows($rslt); @@ -242,7 +264,7 @@ while ($i < $statha_to_print) $customer_interactive_statuses .= "|$row[0]"; $i++; } -$stmt="select status from vicidial_campaign_statuses where human_answered='Y';"; +$stmt="select status from vicidial_campaign_statuses where human_answered='Y' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $statha_to_print = mysql_num_rows($rslt); @@ -606,7 +628,9 @@ else $TOTcalls = sprintf("%7s", $TOTcalls); $CIScountTOT = sprintf("%7s", $CIScountTOT); - $DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100); + $DNCcountPCT = 0; + if ( ($DNCcountTOT > 0) and ($CIScountTOT > 0) ) + {$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);} $DNCcountPCT = round($DNCcountPCT,2); $DNCcountPCT = sprintf("%3.2f", $DNCcountPCT); if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) ) diff --git a/www/vicidial/AST_agent_time_detail.php b/www/vicidial/AST_agent_time_detail.php index 3adba291..c267497c 100644 --- a/www/vicidial/AST_agent_time_detail.php +++ b/www/vicidial/AST_agent_time_detail.php @@ -21,6 +21,7 @@ # 110307-1057 - Added user_case setting in options.php # 110623-0728 - Fixed user group selection bug # 110708-1727 - Added options.php setting for time precision +# 111104-1248 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -127,12 +128,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -153,6 +156,26 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $MT[0]=''; $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); @@ -207,7 +230,7 @@ else $group_SQL = "and campaign_id IN($group_SQL)"; } -$stmt="select user_group from vicidial_user_groups order by user_group;"; +$stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysql_num_rows($rslt); @@ -347,7 +370,7 @@ else ############################################################################ ### BEGIN gather user IDs and names for matching up later - $stmt="select full_name,$userSQL from vicidial_users order by user limit 100000;"; + $stmt="select full_name,$userSQL from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user limit 100000;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $users_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_agent_time_sheet.php b/www/vicidial/AST_agent_time_sheet.php index b34a8644..6ae2274e 100644 --- a/www/vicidial/AST_agent_time_sheet.php +++ b/www/vicidial/AST_agent_time_sheet.php @@ -15,6 +15,7 @@ # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1848 - Added download option +# 111104-1308 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -98,12 +99,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -113,6 +116,28 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGadmin_viewable_groupsSQL=''; +$vuLOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vuLOGadmin_viewable_groupsSQL = "and vicidial_users.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -181,7 +206,7 @@ $query_date_END = "$query_date 23:59:59"; $time_BEGIN = "00:00:00"; $time_END = "23:59:59"; -$stmt="select full_name from vicidial_users where user='$agent';"; +$stmt="select full_name from vicidial_users where user='$agent' $vuLOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $row=mysql_fetch_row($rslt); diff --git a/www/vicidial/AST_agent_timeclock_detail.php b/www/vicidial/AST_agent_timeclock_detail.php index b31dfd7d..2773862c 100644 --- a/www/vicidial/AST_agent_timeclock_detail.php +++ b/www/vicidial/AST_agent_timeclock_detail.php @@ -3,7 +3,7 @@ # # Pulls all timeclock records for an agent # -# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # CHANGES # 90602-2244 - First build @@ -11,6 +11,7 @@ # 100712-1324 - Added system setting slave server option and added user stats link dates # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links +# 111104-1315 - Added user_group restrictions for selecting in-groups # @@ -103,12 +104,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -118,6 +121,37 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } +$regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $MT[0]=''; $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); @@ -135,7 +169,7 @@ $end_dateARRAY = explode(" ",$end_date); $end_date_D = $end_dateARRAY[0]; $end_date_T = $end_dateARRAY[1]; -$stmt="select campaign_id from vicidial_campaigns;"; +$stmt="select campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $campaigns_to_print = mysql_num_rows($rslt); @@ -146,7 +180,7 @@ while ($i < $campaigns_to_print) $groups[$i] =$row[0]; $i++; } -$stmt="select user_group from vicidial_user_groups;"; +$stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysql_num_rows($rslt); @@ -304,7 +338,7 @@ else ############################################################################ ### BEGIN gather user IDs and names for matching up later - $stmt="select full_name,user,user_group from vicidial_users order by user limit 100000;"; + $stmt="select full_name,user,user_group from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user limit 100000;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $users_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/AST_team_performance_detail.php b/www/vicidial/AST_team_performance_detail.php index 56601f2a..a9ec1119 100644 --- a/www/vicidial/AST_team_performance_detail.php +++ b/www/vicidial/AST_team_performance_detail.php @@ -12,6 +12,7 @@ # # 110802-2041 - First build # 110804-0049 - Added First Call Resolution +# 111104-1259 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -101,12 +102,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -126,6 +129,27 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + ###################################### $MT[0]=''; @@ -168,7 +192,7 @@ for ($i=0; $i 0) {echo "HIDEPHONEDATA|$row[2]|$LOGadmin_hide_phone_data|\n";} + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[2] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[2] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[2] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[2] = preg_replace("/./",'X',$phone_temp);} + } + } if (eregi("LIVE",$row[0])) { @@ -2241,6 +2260,22 @@ $talking_to_print = mysql_num_rows($rslt); while ($i < $calls_to_list) { $row=mysql_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[2]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[2]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[2] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[2] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[2] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[2] = preg_replace("/./",'X',$phone_temp);} + } + } $callerids .= "$row[0]|"; $VAClead_ids[$i] = $row[1]; $VACphones[$i] = $row[2]; diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 344bce06..b194a185 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -3015,12 +3015,13 @@ else # 111024-1234 - Added callback_list_calltime option # 111025-0728 - Added user group to all sections, more user settings # 111102-1930 - Added in-group max_calls_ options +# 111106-1116 - Many fixes for user_group restrictions # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.4-346a'; -$build = '111102-1930'; +$admin_version = '2.4-347a'; +$build = '111106-1116'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -3863,7 +3864,7 @@ if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($AD $groups = explode(" ", $closer_campaigns); } - $stmt="SELECT group_id,group_name from vicidial_inbound_groups $LOGadmin_viewable_groupsSQL order by group_id;"; + $stmt="SELECT group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; # $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id"; $rslt=mysql_query($stmt, $link); $groups_to_print = mysql_num_rows($rslt); @@ -8753,7 +8754,10 @@ if ($ADD=="1") echo "
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group:
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
Omit Phone Code: $NWB#vicidial_campaigns-omit_phone_code$NWE
Campaign CallerID: $NWB#vicidial_campaigns-campaign_cid$NWE\n"; - $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and campaign_cid_override != '' and active='Y' $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and campaign_cid_override != '' and active='Y' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); $rowx=mysql_fetch_row($rslt); if ($rowx[0] > 0) @@ -21030,7 +21071,7 @@ if ($ADD==31) echo "$scripts_list"; echo "\n"; echo "$NWB#vicidial_campaigns-campaign_script$NWE\n"; - $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and agent_script_override != '' and active='Y' $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and agent_script_override != '' and active='Y' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); $rowx=mysql_fetch_row($rslt); if ($rowx[0] > 0) @@ -21045,7 +21086,7 @@ if ($ADD==31) echo "
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
Answering Machine Message: audio chooser $NWB#vicidial_campaigns-am_message_exten$NWE\n"; - $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and am_message_exten_override != '' and active='Y' $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and am_message_exten_override != '' and active='Y' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); $rowx=mysql_fetch_row($rslt); if ($rowx[0] > 0) @@ -21131,7 +21172,7 @@ if ($ADD==31) echo "
Drop Transfer Group: $NWB#vicidial_campaigns-drop_inbound_group$NWE\n"; - $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and drop_inbound_group_override != '' and active='Y' $LOGadmin_viewable_groupsSQL;"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and drop_inbound_group_override != '' and active='Y' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); $rowx=mysql_fetch_row($rslt); if ($rowx[0] > 0) @@ -28494,7 +28535,7 @@ if ($ADD==341111111111) echo "
Registration String: $NWB#vicidial_server_carriers-registration_string$NWE
Template ID: '; - while ($lists_to_print > $Lc) + while ($lists_to_print > $Lc) { $row=mysql_fetch_row($rslt); $select_list .= ""; @@ -737,28 +793,56 @@ else echo "
Fronter: $tsr     Called Count: $called_count
$label_title:   \n"; - echo "$label_first_name:
$label_middle_initial:   \n"; - echo " $label_last_name:
$label_address1 :
$label_address2 :
$label_address3 :
$label_city :
$label_state:   \n"; - echo " $label_postal_code:
$label_title: $title   \n"; + echo "$label_first_name: $first_name
$label_middle_initial: $middle_initial   \n"; + echo " $label_last_name: $last_name
$label_address1 : $address1
$label_address2 : $address2
$label_address3 : $address3
$label_city : $city
$label_state: $state   \n"; + echo " $label_postal_code: $postal_code
$label_province :
Country :
$label_phone_number :
$label_phone_code :
$label_alt_phone :
$label_email :
$label_security_phrase :
$label_vendor_lead_code :
Rank :
Owner :
$label_comments :
$label_province : $province
Country : $country_code
$label_phone_number : $phone_number
$label_phone_code : $phone_code
$label_alt_phone : $alt_phone
$label_email : $email
$label_security_phrase : $security
$label_vendor_lead_code : $vendor_id>
Rank : $rank
Owner : $owner
$label_comments : $comments
$label_title:   \n"; + echo "$label_first_name:
$label_middle_initial:   \n"; + echo " $label_last_name:
$label_address1 :
$label_address2 :
$label_address3 :
$label_city :
$label_state:   \n"; + echo " $label_postal_code:
$label_province :
Country :
$label_phone_number :
$label_phone_code :
$label_alt_phone :
$label_email :
$label_security_phrase :
$label_vendor_lead_code :
Rank :
Owner :
$label_comments :
\n"; echo "


\n"; diff --git a/www/vicidial/admin_search_lead.php b/www/vicidial/admin_search_lead.php index c490a958..1fb8ea1a 100644 --- a/www/vicidial/admin_search_lead.php +++ b/www/vicidial/admin_search_lead.php @@ -25,6 +25,7 @@ # 100405-1331 - Added log search ability # 100622-0928 - Added field labels # 110218-1237 - Added vicidial_lead_search_log logging +# 111103-1239 - Added admin_hide_phone_data and admin_hide_lead_data options # require("dbconnect.php"); @@ -98,11 +99,13 @@ else { $office_no=strtoupper($PHP_AUTH_USER); $password=strtoupper($PHP_AUTH_PW); - $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $stmt="SELECT full_name,modify_leads,admin_hide_lead_data,admin_hide_phone_data from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); - $LOGfullname = $row[0]; - $LOGmodify_leads = $row[1]; + $LOGfullname = $row[0]; + $LOGmodify_leads = $row[1]; + $LOGadmin_hide_lead_data = $row[2]; + $LOGadmin_hide_phone_data = $row[3]; if ($WeBRooTWritablE > 0) { @@ -316,6 +319,22 @@ else while ($results_to_print > $o) { $row=mysql_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } $o++; $search_lead = $row[0]; if (eregi("1$|3$|5$|7$|9$", $o)) @@ -365,6 +384,22 @@ else while ($results_to_print > $o) { $row=mysql_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } $o++; $search_lead = $row[0]; if (eregi("1$|3$|5$|7$|9$", $o)) @@ -411,6 +446,22 @@ else while ($results_to_print > $o) { $row=mysql_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } $o++; $search_lead = $row[0]; if (eregi("1$|3$|5$|7$|9$", $o)) @@ -600,6 +651,59 @@ else while ($results_to_print > $o) { $row=mysql_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[11]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[11]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[11] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[11] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[11] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[11] = preg_replace("/./",'X',$phone_temp);} + } + } + if ($LOGadmin_hide_lead_data != '0') + { + if ($DB > 0) {echo "HIDELEADDATA|$row[5]|$row[6]|$row[12]|$row[13]|$row[14]|$row[15]|$row[16]|$row[17]|$row[18]|$row[19]|$row[20]|$row[21]|$row[22]|$row[26]|$row[27]|$row[28]|$LOGadmin_hide_lead_data|\n";} + if (strlen($row[5]) > 0) + {$data_temp = $row[5]; $row[5] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[6]) > 0) + {$data_temp = $row[6]; $row[6] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[12]) > 0) + {$data_temp = $row[12]; $row[12] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[13]) > 0) + {$data_temp = $row[13]; $row[13] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[14]) > 0) + {$data_temp = $row[14]; $row[14] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[15]) > 0) + {$data_temp = $row[15]; $row[15] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[16]) > 0) + {$data_temp = $row[16]; $row[16] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[17]) > 0) + {$data_temp = $row[17]; $row[17] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[18]) > 0) + {$data_temp = $row[18]; $row[18] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[19]) > 0) + {$data_temp = $row[19]; $row[19] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[20]) > 0) + {$data_temp = $row[20]; $row[20] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[21]) > 0) + {$data_temp = $row[21]; $row[21] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[22]) > 0) + {$data_temp = $row[22]; $row[22] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[26]) > 0) + {$data_temp = $row[26]; $row[26] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[27]) > 0) + {$data_temp = $row[27]; $row[27] = preg_replace("/./",'X',$data_temp);} + if (strlen($row[28]) > 0) + {$data_temp = $row[28]; $row[28] = preg_replace("/./",'X',$data_temp);} + } + $o++; $search_lead = $row[0]; if (eregi("1$|3$|5$|7$|9$", $o)) diff --git a/www/vicidial/call_report_export.php b/www/vicidial/call_report_export.php index 29fe28e5..6c2ee790 100644 --- a/www/vicidial/call_report_export.php +++ b/www/vicidial/call_report_export.php @@ -32,6 +32,7 @@ # 110721-2027 - Added IVR export options # 110911-1445 - Added did fields to the EXTENDED format # 111010-1930 - Added ALTERNATE_1 format +# 111104-1240 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -136,12 +137,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -162,6 +165,25 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } ##### START RUN THE EXPORT AND OUTPUT FLAT DATA FILE ##### if ($run_export > 0) @@ -780,7 +802,7 @@ else $i++; } - $stmt="select group_id from vicidial_inbound_groups order by group_id;"; + $stmt="select group_id from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $groups_to_print = mysql_num_rows($rslt); @@ -795,7 +817,7 @@ else $i++; } - $stmt="select user_group from vicidial_user_groups order by user_group;"; + $stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/fcstats.php b/www/vicidial/fcstats.php index fdc24d02..fe1de355 100644 --- a/www/vicidial/fcstats.php +++ b/www/vicidial/fcstats.php @@ -18,6 +18,7 @@ # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1828 - Added download option +# 111104-1213 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -101,12 +102,14 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -116,21 +119,43 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); if (!isset($group)) {$group = 'CL_TEST_L';} if (!isset($query_date)) {$query_date = $NOW_DATE;} -$stmt="select group_id from vicidial_inbound_groups order by group_id;"; +$stmt="select group_id from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} $groups_to_print = mysql_num_rows($rslt); $i=0; +$groups_string='|'; while ($i < $groups_to_print) { $row=mysql_fetch_row($rslt); $groups[$i] =$row[0]; + $groups_string .= "$groups[$i]|"; $i++; } @@ -148,6 +173,19 @@ $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; +#if (strlen($group) > 0) +# { +# if (preg_match("/\|$group\|/i",$groups_string)) +# { +# # $HTML_head.="\n"; +# } +# else +# { +# # $HTML_head.="\n"; +# $group=''; +# } +# } + $HTML_head.="\n"; $HTML_head.="$report_name\n"; @@ -313,7 +351,7 @@ while ($i < $users_to_print) $i=0; while ($i < $users_to_print) { - $stmt="select full_name from vicidial_users where user='$userRAW[$i]';"; + $stmt="select full_name from vicidial_users where user='$userRAW[$i]' $LOGadmin_viewable_groupsSQL;"; if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} $rslt=mysql_query($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} @@ -502,7 +540,7 @@ while ($i < $users_to_print) $i=0; while ($i < $users_to_print) { - $stmt="select full_name from vicidial_users where user='$userRAW[$i]';"; + $stmt="select full_name from vicidial_users where user='$userRAW[$i]' $LOGadmin_viewable_groupsSQL;"; if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} $rslt=mysql_query($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} diff --git a/www/vicidial/lead_report_export.php b/www/vicidial/lead_report_export.php index f6d855cb..6a1ef5e5 100644 --- a/www/vicidial/lead_report_export.php +++ b/www/vicidial/lead_report_export.php @@ -10,6 +10,7 @@ # CHANGES # # 110624-0834 - First build, based upon calls_report_export.php +# 111104-1245 - Added user_group restrictions for selecting in-groups # require("dbconnect.php"); @@ -112,12 +113,15 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGuser_group = $row[0]; -$stmt="SELECT allowed_campaigns,allowed_reports from vicidial_user_groups where user_group='$LOGuser_group';"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$LOGallowed_campaigns = $row[0]; -$LOGallowed_reports = $row[1]; +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -138,6 +142,25 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$LOGadmin_viewable_call_timesSQL=''; +$whereLOGadmin_viewable_call_timesSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) ) + { + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times); + $rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL); + $LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; + } ##### START RUN THE EXPORT AND OUTPUT FLAT DATA FILE ##### if ($run_export > 0) @@ -661,7 +684,7 @@ else $i++; } - $stmt="select group_id from vicidial_inbound_groups order by group_id;"; + $stmt="select group_id from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $groups_to_print = mysql_num_rows($rslt); @@ -676,7 +699,7 @@ else $i++; } - $stmt="select user_group from vicidial_user_groups order by user_group;"; + $stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysql_num_rows($rslt); diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index d824b6d1..64f3cfc2 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -59,10 +59,11 @@ # 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 # 110928-2110 - Added callback options to add_lead and update_lead +# 111106-0959 - Added user_group restrictions to some functions # -$version = '2.4-38'; -$build = '110928-2110'; +$version = '2.4-39'; +$build = '111106-0959'; $startMS = microtime(); @@ -283,6 +284,8 @@ if (isset($_GET["callback_user"])) {$callback_user=$_GET["callback_user"];} elseif (isset($_POST["callback_user"])) {$callback_user=$_POST["callback_user"];} if (isset($_GET["callback_comments"])) {$callback_comments=$_GET["callback_comments"];} elseif (isset($_POST["callback_comments"])) {$callback_comments=$_POST["callback_comments"];} +if (isset($_GET["admin_user_group"])) {$admin_user_group=$_GET["admin_user_group"];} + elseif (isset($_POST["admin_user_group"])) {$admin_user_group=$_POST["admin_user_group"];} header ("Content-type: text/html; charset=utf-8"); @@ -423,6 +426,7 @@ if ($non_latin < 1) $callback_type = ereg_replace("[^A-Z]","",$callback_type); $callback_user = ereg_replace("[^-\_0-9a-zA-Z]","",$callback_user); $callback_comments = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$callback_comments); + $admin_user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$admin_user_group); } else { @@ -729,6 +733,29 @@ if ($function == 'moh_list') } else { + $stmt="SELECT user_group from vicidial_users where user='$user' and pass='$pass' and user_level > 6;"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGuser_group = $row[0]; + + $stmt="SELECT allowed_campaigns,admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + $LOGadmin_viewable_groups = $row[1]; + + $LOGadmin_viewable_groupsSQL=''; + $whereLOGadmin_viewable_groupsSQL=''; + if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + echo "\n"; echo "NON-AGENT API\n"; echo "