diff --git a/include/ajax.kbase.php b/include/ajax.kbase.php index a6b9a388a91df635bddf02542ae42aac47282dce..3909fd831598a3a23c3a4182cf5a3fb9f469a478 100644 --- a/include/ajax.kbase.php +++ b/include/ajax.kbase.php @@ -55,7 +55,7 @@ class KbaseAjaxAPI extends AjaxController { $faq->getId(), $faq->getNumAttachments()); if($thisstaff - && $thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) { + && $thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) { $resp.=sprintf(' | <a href="faq.php?id=%d&a=edit">'.__('Edit').'</a>',$faq->getId()); } diff --git a/include/class.canned.php b/include/class.canned.php index a7154b974ef56d877c1bead681c8cb9fd4e081f2..ca1354332107d391b4f55a512fd5a3a149d8a117 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -15,6 +15,25 @@ **********************************************************************/ include_once(INCLUDE_DIR.'class.file.php'); +class CannedModel { + + const PERM_MANAGE = 'canned.manage'; + + static protected $perms = array( + self::PERM_MANAGE => array( + 'title' => + /* @trans */ 'Premade', + 'desc' => + /* @trans */ 'Ability to add/update/disable/delete canned responses') + ); + + static function getPermissions() { + return self::$perms; + } +} + +RolePermission::register( /* @trans */ 'Knowledgebase', CannedModel::getPermissions()); + class Canned { var $id; var $ht; diff --git a/include/class.email.php b/include/class.email.php index 438f033fabf39276f20334de0ffa1e20fec0ba52..ab0727f7cbf4c5cf941ebbf1893fc6873f6eb79f 100644 --- a/include/class.email.php +++ b/include/class.email.php @@ -39,7 +39,9 @@ class EmailModel extends VerySimpleModel { static protected $perms = array( self::PERM_BANLIST => array( + 'title' => /* @trans */ 'Banlist', + 'desc' => /* @trans */ 'Ability to add/remove emails from banlist via ticket interface'), ); diff --git a/include/class.faq.php b/include/class.faq.php index 4e0fe8f456d10bb198636f87afe1ed4d546e307a..055da0c2797b119e9c73f225cff23212c89b181c 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -46,6 +46,16 @@ class FAQ extends VerySimpleModel { ), ); + const PERM_MANAGE = 'faq.manage'; + static protected $perms = array( + self::PERM_MANAGE => array( + 'title' => + /* @trans */ 'FAQ', + 'desc' => + /* @trans */ 'Ability to add/update/disable/delete knowledgebase categories and FAQs'), + ); + + var $attachments; var $topics; var $_local; @@ -481,8 +491,14 @@ class FAQ extends VerySimpleModel { $this->updated = SqlFunction::NOW(); return parent::save($refetch || $this->dirty); } + + static function getPermissions() { + return self::$perms; + } } -FAQ::_inspect(); + +RolePermission::register( /* @trans */ 'Knowledgebase', + FAQ::getPermissions()); class FaqTopic extends VerySimpleModel { diff --git a/include/class.knowledgebase.php b/include/class.knowledgebase.php index 8dbbbbd4a3ec6440be58ddd1af395c2f6fb30d4c..33b214d6a1cbc21d293cfa0cfffd4ff20c735b9f 100644 --- a/include/class.knowledgebase.php +++ b/include/class.knowledgebase.php @@ -15,27 +15,6 @@ **********************************************************************/ require_once("class.file.php"); -class KnowledgebaseModel { - - const PERM_PREMADE = 'kb.premade'; - const PERM_FAQ = 'kb.faq'; - - static protected $perms = array( - self::PERM_PREMADE => array( - /* @trans */ 'Premade', - /* @trans */ 'Ability to add/update/disable/delete canned responses'), - self::PERM_FAQ => array( - /* @trans */ 'FAQ', - /* @trans */ 'Ability to add/update/disable/delete knowledgebase categories and FAQs'), - ); - - static function getPermissions() { - return self::$perms; - } -} - -RolePermission::register( /* @trans */ 'Knowledgebase', KnowledgebaseModel::getPermissions()); - class Knowledgebase { function Knowledgebase($id) { diff --git a/include/class.nav.php b/include/class.nav.php index 53df0df3d01c8685ccb03cef204611a1b97dd622..e8359e00d44eddd282488283ab6f1c524fda6006 100644 --- a/include/class.nav.php +++ b/include/class.nav.php @@ -161,9 +161,9 @@ class StaffNav { case 'kbase': $subnav[]=array('desc'=>__('FAQs'),'href'=>'kb.php', 'urls'=>array('faq.php'), 'iconclass'=>'kb'); if($staff) { - if ($staff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) + if ($staff->getRole()->hasPerm(FAQ::PERM_MANAGE)) $subnav[]=array('desc'=>__('Categories'),'href'=>'categories.php','iconclass'=>'faq-categories'); - if ($staff->getRole()->hasPerm(KnowledgebaseModel::PERM_PREMADE)) + if ($staff->getRole()->hasPerm(CannedModel::PERM_MANAGE)) $subnav[]=array('desc'=>__('Canned Responses'),'href'=>'canned.php','iconclass'=>'canned'); } break; diff --git a/include/class.organization.php b/include/class.organization.php index 0c6bb5212d2cd734091ad26c9c473d5deeda4b9f..fa0ffc9cf568bc85ee20eb8e6e2726bba8f1ac81 100644 --- a/include/class.organization.php +++ b/include/class.organization.php @@ -466,5 +466,4 @@ Filter::addSupportedMatches(/*@trans*/ 'Organization Data', function() { } return $matches; },40); -Organization::_inspect(); ?> diff --git a/include/class.report.php b/include/class.report.php index 257b1236c85703da9a45a220562bff0350480d47..0e8bae980f7af555cd743551655df3fbdb89e7e5 100644 --- a/include/class.report.php +++ b/include/class.report.php @@ -6,7 +6,9 @@ class ReportModel { static protected $perms = array( self::PERM_AGENTS => array( + 'title' => /* @trans */ 'Stats', + 'desc' => /* @trans */ 'Ability to view stats of other agents in allowed departments'), ); diff --git a/include/class.role.php b/include/class.role.php index 48e99a7849dd17025c6b7a4d378a2ce9930b68f9..476bd9a72b89721f1235a9f3b1dfdf65a2d89587 100644 --- a/include/class.role.php +++ b/include/class.role.php @@ -313,10 +313,4 @@ class RolePermission { static::$_permissions[$group] ?: array(), $perms); } } - -// Classes that might need to register roles permissions -include_once INCLUDE_DIR.'class.knowledgebase.php'; -include_once INCLUDE_DIR.'class.email.php'; -include_once INCLUDE_DIR.'class.report.php'; - ?> diff --git a/include/class.task.php b/include/class.task.php index 8a381adf48154b7a5565cdca33373e868227a135..54da8170f882a43bc4d4935835be8ee505f051b6 100644 --- a/include/class.task.php +++ b/include/class.task.php @@ -41,22 +41,34 @@ class TaskModel extends VerySimpleModel { static protected $perms = array( self::PERM_CREATE => array( + 'title' => /* @trans */ 'Create', + 'desc' => /* @trans */ 'Ability to create tasks'), self::PERM_EDIT => array( + 'title' => /* @trans */ 'Edit', + 'desc' => /* @trans */ 'Ability to edit tasks'), self::PERM_ASSIGN => array( + 'title' => /* @trans */ 'Assign', + 'desc' => /* @trans */ 'Ability to assign tasks to agents or teams'), self::PERM_TRANSFER => array( + 'title' => /* @trans */ 'Transfer', + 'desc' => /* @trans */ 'Ability to transfer tasks between departments'), self::PERM_CLOSE => array( + 'title' => /* @trans */ 'Close', + 'desc' => /* @trans */ 'Ability to close tasks'), self::PERM_DELETE => array( + 'title' => /* @trans */ 'Delete', + 'desc' => /* @trans */ 'Ability to delete tasks'), ); diff --git a/include/class.ticket.php b/include/class.ticket.php index 5931c7b303c84c7ddea0752f4256cd8339a37d0f..b1b3ea30cddb714508d9cca00235dd7c4225eda1 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -97,25 +97,40 @@ class TicketModel extends VerySimpleModel { static protected $perms = array( self::PERM_CREATE => array( + 'title' => /* @trans */ 'Create', + 'desc' => /* @trans */ 'Ability to open tickets on behalf of users'), self::PERM_EDIT => array( + 'title' => /* @trans */ 'Edit', + 'desc' => /* @trans */ 'Ability to edit tickets'), self::PERM_ASSIGN => array( + 'title' => /* @trans */ 'Assign', + 'desc' => /* @trans */ 'Ability to assign tickets to agents or teams'), self::PERM_TRANSFER => array( + + 'title' => /* @trans */ 'Transfer', + 'desc' => /* @trans */ 'Ability to transfer tickets between departments'), self::PERM_REPLY => array( + 'title' => /* @trans */ 'Post Reply', + 'desc' => /* @trans */ 'Ability to post a ticket reply'), self::PERM_CLOSE => array( + 'title' => /* @trans */ 'Close', + 'desc' => /* @trans */ 'Ability to close tickets'), self::PERM_DELETE => array( + 'title' => /* @trans */ 'Delete', + 'desc' => /* @trans */ 'Ability to delete tickets'), ); diff --git a/include/staff/category.inc.php b/include/staff/category.inc.php index b8942cc6b05666c5972ec14fce97a08fa7a1df7d..55926a0aaef1cf2a716cad851466a93da2f58c11 100644 --- a/include/staff/category.inc.php +++ b/include/staff/category.inc.php @@ -1,6 +1,6 @@ <?php if (!defined('OSTSCPINC') || !$thisstaff - || !$thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) + || !$thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) die('Access Denied'); $info=array(); diff --git a/include/staff/faq-category.inc.php b/include/staff/faq-category.inc.php index 721cd9de2a03151a9c12c0284a20b22b2dd63aec..afc5194bb7c08ebfe4ea4caeed74072a5b434db4 100644 --- a/include/staff/faq-category.inc.php +++ b/include/staff/faq-category.inc.php @@ -17,7 +17,7 @@ if(!defined('OSTSTAFFINC') || !$category || !$thisstaff) die('Access Denied'); <?php echo Format::display($category->getDescription()); ?> </div> <?php -if ($thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) { +if ($thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) { echo sprintf('<div class="cat-manage-bar"><a href="categories.php?id=%d" class="Icon editCategory">'.__('Edit Category').'</a> <a href="categories.php" class="Icon deleteCategory">'.__('Delete Category').'</a> <a href="faq.php?cid=%d&a=add" class="Icon newFAQ">'.__('Add New FAQ').'</a></div>', diff --git a/include/staff/faq-view.inc.php b/include/staff/faq-view.inc.php index a18e340c7c04f2ad4eaed1d6532443162f39f42a..8afda9a67e320f6636f9fe4119c011561ea35a58 100644 --- a/include/staff/faq-view.inc.php +++ b/include/staff/faq-view.inc.php @@ -79,7 +79,7 @@ $query = http_build_query($query); ?> echo __('Print'); ?> </a></button> <?php -if ($thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) { ?> +if ($thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) { ?> <button> <i class="icon-edit"></i> <a href="faq.php?id=<?php echo $faq->getId(); ?>&a=edit"><?php @@ -104,7 +104,7 @@ if ($thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) { ?> <hr> <?php -if ($thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) { ?> +if ($thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) { ?> <form action="faq.php?id=<?php echo $faq->getId(); ?>" method="post"> <?php csrf_token(); ?> <input type="hidden" name="do" value="manage-faq"> diff --git a/include/staff/faq.inc.php b/include/staff/faq.inc.php index 29f3dbe7d0640dcb5e30be81b225e20cda203f58..a1bdfcc7ac36558974060b1bb7cb902dd7311e6f 100644 --- a/include/staff/faq.inc.php +++ b/include/staff/faq.inc.php @@ -1,6 +1,6 @@ <?php if (!defined('OSTSCPINC') || !$thisstaff - || !$thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) + || !$thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) die('Access Denied'); $info=array(); diff --git a/include/staff/role.inc.php b/include/staff/role.inc.php index e36b87073bd0132507967d1b11a822f931ac12d4..25384cd39977d15950297605ec05bc11b3308db8 100644 --- a/include/staff/role.inc.php +++ b/include/staff/role.inc.php @@ -98,8 +98,8 @@ $info = Format::htmlchars(($errors && $_POST) ? array_merge($info, $_POST) : $in <?php echo sprintf('%s - <em>%s</em>', - Format::htmlchars(__($v[0])), - Format::htmlchars(__($v[1]))); + Format::htmlchars(__($v['title'])), + Format::htmlchars(__($v['desc']))); ?> </label> </td> diff --git a/include/upgrader/streams/core/1ee831c8-36f6b328.task.php b/include/upgrader/streams/core/1ee831c8-36f6b328.task.php index 3b8ff65b41343cff6852899844942b3ed63b04ce..ef8cd369069ee874343ebf3083a3d4c2c688a17c 100644 --- a/include/upgrader/streams/core/1ee831c8-36f6b328.task.php +++ b/include/upgrader/streams/core/1ee831c8-36f6b328.task.php @@ -11,8 +11,8 @@ class GroupRoles extends MigrationTask { 'can_assign_tickets' => 'ticket.assign', 'can_transfer_tickets' => 'ticket.transfer', 'can_ban_emails' => 'emails.banlist', - 'can_manage_premade' => 'kb.premade', - 'can_manage_faq' => 'kb.faq', + 'can_manage_premade' => 'canned.manage', + 'can_manage_faq' => 'faq.manage', 'can_view_staff_stats' => 'stats.agents', ); diff --git a/scp/canned.php b/scp/canned.php index d6e66a7799b9ffa6ef234325321e2f3bc658be4d..c8290c39f58b9f87494bb11f6ad436f329d598b6 100644 --- a/scp/canned.php +++ b/scp/canned.php @@ -19,7 +19,7 @@ include_once(INCLUDE_DIR.'class.canned.php'); /* check permission */ if(!$thisstaff || - !$thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_PREMADE)) { + !$thisstaff->getRole()->hasPerm(CannedModel::PERM_MANAGE)) { header('Location: kb.php'); exit; } diff --git a/scp/categories.php b/scp/categories.php index 00e93620a8142bef7b453109d36ff6a1b09dfab4..d4e6125b4bca4d3fee6d40544d1ec173c408ff17 100644 --- a/scp/categories.php +++ b/scp/categories.php @@ -18,7 +18,7 @@ include_once(INCLUDE_DIR.'class.category.php'); /* check permission */ if(!$thisstaff || - !$thisstaff->getRole()->hasPerm(KnowledgebaseModel::PERM_FAQ)) { + !$thisstaff->getRole()->hasPerm(FAQ::PERM_MANAGE)) { header('Location: kb.php'); exit; } diff --git a/scp/emailsettings.php b/scp/emailsettings.php index 175fa4575b2dfc2ac79246782b91adf11e97d2d5..6f871b4bf7b62e072689f4672b9df64f15bb5e06 100644 --- a/scp/emailsettings.php +++ b/scp/emailsettings.php @@ -35,5 +35,5 @@ $nav->setTabActive('emails', 'emailsettings.php'); require_once(STAFFINC_DIR.'header.inc.php'); include_once(STAFFINC_DIR.$inc); include_once(STAFFINC_DIR.'footer.inc.php'); -?> +?> diff --git a/scp/faq.php b/scp/faq.php index 7ea28c4076d10c248d2ccf26ce3d818e9dd12b8d..03c5f160118ba06081f1e53b33afc867a84d9b10 100644 --- a/scp/faq.php +++ b/scp/faq.php @@ -155,12 +155,12 @@ $inc='faq-categories.inc.php'; //FAQs landing page. if($faq) { $inc='faq-view.inc.php'; if ($_REQUEST['a']=='edit' - && $role->hasPerm(KnowledgebaseModel::PERM_FAQ)) + && $role->hasPerm(FAQ::PERM_MANAGE)) $inc='faq.inc.php'; elseif ($_REQUEST['a'] == 'print') return $faq->printPdf(); }elseif($_REQUEST['a']=='add' - && $role->hasPerm(KnowledgebaseModel::PERM_FAQ)) { + && $role->hasPerm(FAQ::PERM_MANAGE)) { $inc='faq.inc.php'; } elseif($category && $_REQUEST['a']!='search') { $inc='faq-category.inc.php'; diff --git a/scp/roles.php b/scp/roles.php index 02bb0fec0c8d663c2e5e014e03a24c72cbffcbb0..2c9476e29b8cb7499b01f7d5e7d171fe980af980 100644 --- a/scp/roles.php +++ b/scp/roles.php @@ -14,7 +14,11 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ -require('admin.inc.php'); +require 'admin.inc.php'; +include_once INCLUDE_DIR . 'class.canned.php'; +include_once INCLUDE_DIR . 'class.faq.php'; +include_once INCLUDE_DIR . 'class.email.php'; +include_once INCLUDE_DIR . 'class.report.php'; $errors = array(); $role=null;