From 5af37d56164445295b423c3d590ee39e71074e0d Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 11 Jun 2015 22:03:33 -0400 Subject: [PATCH 01/25] #196 Some boilerplate stuff --- admin/manage_permission_templates.php | 96 ++++++++++++++++++++++++ install/mods-for-hesk/sql/installSql.php | 5 ++ 2 files changed, 101 insertions(+) create mode 100644 admin/manage_permission_templates.php diff --git a/admin/manage_permission_templates.php b/admin/manage_permission_templates.php new file mode 100644 index 00000000..e0cb8f29 --- /dev/null +++ b/admin/manage_permission_templates.php @@ -0,0 +1,96 @@ + + + + +'.$mycat['name'].''; + } +?> +
+
+
+
+ + diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 38427c96..b533922f 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -453,6 +453,11 @@ function execute230Scripts() { executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0"); + executeQuery("CREATE TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`id` INT NOT NULL AUTO_INCREMENT, + `name` VARCHAR(255) NOT NULL, + `heskprivileges` VARCHAR(1000), + `categories` VARCHAR(500))"); + executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'"); } From ff3ebc50672cd582aa5bf3d48d495f4e50ec9418 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 12 Jun 2015 22:14:09 -0400 Subject: [PATCH 02/25] #196 fix create sql, add default permission templates --- install/mods-for-hesk/sql/installSql.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index b533922f..c15159ac 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -453,10 +453,14 @@ function execute230Scripts() { executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0"); - executeQuery("CREATE TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`id` INT NOT NULL AUTO_INCREMENT, + executeQuery("CREATE TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `heskprivileges` VARCHAR(1000), `categories` VARCHAR(500))"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`name`, `heskprivileges`, `categories`) + VALUES ('Administrator', 'ALL', 'ALL')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`name`, `heskprivileges`, `categories`) + VALUES ('Staff', 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online', '1')"); executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'"); } From 7f4b1036a7dfe9450255065248fd6a3a70473208 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 12 Jun 2015 22:14:26 -0400 Subject: [PATCH 03/25] #196 Change query --- admin/manage_permission_templates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/manage_permission_templates.php b/admin/manage_permission_templates.php index e0cb8f29..785cd2e6 100644 --- a/admin/manage_permission_templates.php +++ b/admin/manage_permission_templates.php @@ -72,7 +72,7 @@ else {return false;} Date: Sat, 13 Jun 2015 01:20:06 -0400 Subject: [PATCH 04/25] #196 Move feature list into common --- admin/manage_users.php | 32 +------------------------------- inc/common.inc.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/admin/manage_users.php b/admin/manage_users.php index ed8ec1eb..456e093a 100644 --- a/admin/manage_users.php +++ b/admin/manage_users.php @@ -50,37 +50,7 @@ hesk_isLoggedIn(); hesk_checkPermission('can_man_users'); /* Possible user features */ -$hesk_settings['features'] = array( -'can_view_tickets', /* User can read tickets */ -'can_reply_tickets', /* User can reply to tickets */ -'can_del_tickets', /* User can delete tickets */ -'can_edit_tickets', /* User can edit tickets */ -'can_merge_tickets', /* User can merge tickets */ -'can_del_notes', /* User can delete ticket notes posted by other staff members */ -'can_change_cat', /* User can move ticke to a new category/department */ -'can_man_kb', /* User can manage knowledgebase articles and categories */ -'can_man_users', /* User can create and edit staff accounts */ -'can_man_cat', /* User can manage categories/departments */ -'can_man_canned', /* User can manage canned responses */ -'can_man_ticket_tpl', /* User can manage ticket templates */ -'can_add_archive', /* User can mark tickets as "Tagged" */ -'can_assign_self', /* User can assign tickets to himself/herself */ -'can_assign_others', /* User can assign tickets to other staff members */ -'can_view_unassigned', /* User can view unassigned tickets */ -'can_view_ass_others', /* User can view tickets that are assigned to other staff */ -'can_run_reports', /* User can run reports and see statistics (only allowed categories and self) */ -'can_run_reports_full', /* User can run reports and see statistics (unrestricted) */ -'can_export', /* User can export own tickets to Excel */ -'can_view_online', /* User can view what staff members are currently online */ -'can_ban_emails', /* User can ban email addresses */ -'can_unban_emails', /* User can delete email address bans. Also enables "can_ban_emails" */ -'can_ban_ips', /* User can ban IP addresses */ -'can_unban_ips', /* User can delete IP bans. Also enables "can_ban_ips" */ -'can_service_msg', /* User can manage service messages shown in customer interface */ -'can_man_email_tpl', /* User can manage email templates */ -'can_man_ticket_statuses', /* User can manage ticket statuses */ -'can_set_manager', /* User can set category managers */ -); +$hesk_settings['features'] = hesk_getFeatureArray(); /* Set default values */ $default_userdata = array( diff --git a/inc/common.inc.php b/inc/common.inc.php index 7f2c5ce3..6b13588c 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -1911,3 +1911,37 @@ function hesk_dateToString($dt, $returnName=1, $returnTime=0, $returnMonth=0, $f return "$m $n, $y"; } // End hesk_dateToString() + +function hesk_getFeatureArray() { + return array( + 'can_view_tickets', /* User can read tickets */ + 'can_reply_tickets', /* User can reply to tickets */ + 'can_del_tickets', /* User can delete tickets */ + 'can_edit_tickets', /* User can edit tickets */ + 'can_merge_tickets', /* User can merge tickets */ + 'can_del_notes', /* User can delete ticket notes posted by other staff members */ + 'can_change_cat', /* User can move ticke to a new category/department */ + 'can_man_kb', /* User can manage knowledgebase articles and categories */ + 'can_man_users', /* User can create and edit staff accounts */ + 'can_man_cat', /* User can manage categories/departments */ + 'can_man_canned', /* User can manage canned responses */ + 'can_man_ticket_tpl', /* User can manage ticket templates */ + 'can_add_archive', /* User can mark tickets as "Tagged" */ + 'can_assign_self', /* User can assign tickets to himself/herself */ + 'can_assign_others', /* User can assign tickets to other staff members */ + 'can_view_unassigned', /* User can view unassigned tickets */ + 'can_view_ass_others', /* User can view tickets that are assigned to other staff */ + 'can_run_reports', /* User can run reports and see statistics (only allowed categories and self) */ + 'can_run_reports_full', /* User can run reports and see statistics (unrestricted) */ + 'can_export', /* User can export own tickets to Excel */ + 'can_view_online', /* User can view what staff members are currently online */ + 'can_ban_emails', /* User can ban email addresses */ + 'can_unban_emails', /* User can delete email address bans. Also enables "can_ban_emails" */ + 'can_ban_ips', /* User can ban IP addresses */ + 'can_unban_ips', /* User can delete IP bans. Also enables "can_ban_ips" */ + 'can_service_msg', /* User can manage service messages shown in customer interface */ + 'can_man_email_tpl', /* User can manage email templates */ + 'can_man_ticket_statuses', /* User can manage ticket statuses */ + 'can_set_manager', /* User can set category managers */ + ); +} \ No newline at end of file From 4a2862e433e644e7db9c9ab800d9516caadc1ad2 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sat, 13 Jun 2015 01:20:28 -0400 Subject: [PATCH 05/25] #196 Add permission template id to user --- install/mods-for-hesk/sql/installSql.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index c15159ac..c588de99 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -453,6 +453,7 @@ function execute230Scripts() { executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ADD COLUMN `permission_template` INT"); executeQuery("CREATE TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `heskprivileges` VARCHAR(1000), @@ -461,6 +462,7 @@ function execute230Scripts() { VALUES ('Administrator', 'ALL', 'ALL')"); executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` (`name`, `heskprivileges`, `categories`) VALUES ('Staff', 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online', '1')"); + executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` SET `permission_template` = 1 WHERE `isadmin` = '1'"); executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.3.0' WHERE `Key` = 'modsForHeskVersion'"); } From e095534648125ac535b910046b97780265ad086e Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sat, 13 Jun 2015 01:20:45 -0400 Subject: [PATCH 06/25] #196 Can now output permission groups --- admin/manage_permission_templates.php | 40 ++++++++++++++++++++++----- css/hesk_newStyle.php | 12 ++++++++ css/hesk_newStyleRTL.php | 12 ++++++++ language/en/text.php | 4 +++ 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/admin/manage_permission_templates.php b/admin/manage_permission_templates.php index 785cd2e6..d50a5471 100644 --- a/admin/manage_permission_templates.php +++ b/admin/manage_permission_templates.php @@ -46,6 +46,7 @@ hesk_dbConnect(); hesk_isLoggedIn(); /* Check permissions for this feature */ +//TODO Create and use new permission here hesk_checkPermission('can_man_cat'); /* What should we do? */ @@ -73,16 +74,36 @@ else {return false;} '.$mycat['name'].''; - } + $featureArray = hesk_getFeatureArray(); ?>
+

+
+ + + + + + + + + + + + + + + +
+ + + +
+
@@ -92,5 +113,10 @@ exit(); /*** START FUNCTIONS ***/ +function getNumberOfUsersWithPermissionGroup($templateId) { + global $hesk_settings; + $res = hesk_dbQuery("SELECT 1 FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `permission_template` = ".intval($templateId)); + return hesk_dbNumRows($res); +} ?> diff --git a/css/hesk_newStyle.php b/css/hesk_newStyle.php index 236d8b28..b99c14f2 100644 --- a/css/hesk_newStyle.php +++ b/css/hesk_newStyle.php @@ -383,4 +383,16 @@ button.dropdown-submit { .default-row-margins { margin: 0 -15px; +} + +.icon-link { + font-size: 16px !important; +} + +.orange { + color: orange; +} + +.red { + color: #FF0000; } \ No newline at end of file diff --git a/css/hesk_newStyleRTL.php b/css/hesk_newStyleRTL.php index 5355d765..b1951159 100644 --- a/css/hesk_newStyleRTL.php +++ b/css/hesk_newStyleRTL.php @@ -377,4 +377,16 @@ button.dropdown-submit { .default-row-margins { margin: 0 -15px; +} + +.icon-link { + font-size: 16px; +} + +.orange { + color: orange; +} + +.red { + color: #FF0000; } \ No newline at end of file diff --git a/language/en/text.php b/language/en/text.php index 9614ffd2..08b1581a 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -70,6 +70,10 @@ $hesklang['manager'] = 'Manager'; $hesklang['manager_updated'] = 'Category manager has been updated.'; $hesklang['can_set_manager'] = 'Can set category managers'; $hesklang['no_manager'] = 'No manager'; +$hesklang['manage_permission_templates'] = 'Manage Permission Templates'; +$hesklang['number_of_users'] = 'Number of Users'; +$hesklang['actions'] = 'Actions'; +$hesklang['view_permissions_for_this_template'] = 'View permissions for this template'; // ADDED OR MODIFIED IN Mods for HESK 2.2.1 $hesklang['popart_no_colon']='Top Knowledgebase Articles'; // same as $hesklang['popart'] but without a colon (:) From 723674fab1a152e22a71e8882733558d9fc60c6c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sat, 13 Jun 2015 16:44:52 -0400 Subject: [PATCH 07/25] #196 More progress on permission templates --- admin/manage_permission_templates.php | 65 ++++++++++++++++++++++++--- language/en/text.php | 4 +- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/admin/manage_permission_templates.php b/admin/manage_permission_templates.php index d50a5471..43222628 100644 --- a/admin/manage_permission_templates.php +++ b/admin/manage_permission_templates.php @@ -74,7 +74,16 @@ else {return false;}
@@ -87,27 +96,29 @@ else {return false;} - + - - + + - +
- + + diff --git a/language/en/text.php b/language/en/text.php index 08b1581a..bdd1f30c 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -73,7 +73,9 @@ $hesklang['no_manager'] = 'No manager'; $hesklang['manage_permission_templates'] = 'Manage Permission Templates'; $hesklang['number_of_users'] = 'Number of Users'; $hesklang['actions'] = 'Actions'; -$hesklang['view_permissions_for_this_template'] = 'View permissions for this template'; +$hesklang['view_permissions_for_this_template'] = 'View/edit permissions for this template'; +$hesklang['permission'] = 'Permission'; +$hesklang['permissions_for_template'] = 'Permissions for template %s'; // %s template name // ADDED OR MODIFIED IN Mods for HESK 2.2.1 $hesklang['popart_no_colon']='Top Knowledgebase Articles'; // same as $hesklang['popart'] but without a colon (:) From 8328d206fc9b6b7e7a718eef70dceedd4191d7ff Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 14 Jun 2015 11:56:49 -0400 Subject: [PATCH 08/25] #196 Add icon for designating permission template as admin template --- admin/manage_permission_templates.php | 89 +++++++++++++++++++-------- css/hesk_newStyle.php | 4 ++ css/hesk_newStyleRTL.php | 4 ++ language/en/text.php | 3 + 4 files changed, 75 insertions(+), 25 deletions(-) diff --git a/admin/manage_permission_templates.php b/admin/manage_permission_templates.php index 43222628..d82f36b9 100644 --- a/admin/manage_permission_templates.php +++ b/admin/manage_permission_templates.php @@ -104,6 +104,13 @@ else {return false;} + + + + + @@ -133,38 +140,70 @@ function getNumberOfUsersWithPermissionGroup($templateId) { function createModal($template, $features, $categories) { global $hesklang; + + $showNotice = true; + $disabled = 'checked="checked" disabled'; + $enabledFeatures = array(); + $enabledCategories = array(); + if ($template['heskprivileges'] != 'ALL') { + $showNotice = false; + $disabled = ''; + $enabledFeatures = explode(',', $template['heskprivileges']); + $enabledCategories = explode(',', $template['categories']); + } ?>