Commit 187aea5c4e96bc4dc22e4cc6cf78369719d7d080

Authored by Brad Shuttleworth
1 parent 11d6e38e

merge in role management.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4129 c91229c3-7414-0410-bfa2-8a42b809f60b
config/siteMap.inc
@@ -114,7 +114,7 @@ $default->siteMap->addPage("doccheckoutManagement", "/presentation/lookAndFeel/k @@ -114,7 +114,7 @@ $default->siteMap->addPage("doccheckoutManagement", "/presentation/lookAndFeel/k
114 $default->siteMap->addPage("newsManagement", "/presentation/lookAndFeel/knowledgeTree/administration/news/listNewsBL.php", "Administration", SysAdmin, _("Dashboard News Management"), true, 10); 114 $default->siteMap->addPage("newsManagement", "/presentation/lookAndFeel/knowledgeTree/administration/news/listNewsBL.php", "Administration", SysAdmin, _("Dashboard News Management"), true, 10);
115 $default->siteMap->addPage("linkManagement", "/presentation/lookAndFeel/knowledgeTree/administration/linkmanagement/listLinksBL.php", "Administration", SysAdmin, _("QuickLink Management"), true, 11); 115 $default->siteMap->addPage("linkManagement", "/presentation/lookAndFeel/knowledgeTree/administration/linkmanagement/listLinksBL.php", "Administration", SysAdmin, _("QuickLink Management"), true, 11);
116 116
117 -$default->siteMap->addPage("roleManagement", "/presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/listRolesBL.php", "Administration", SysAdmin, _("Role Management"), true, 12); 117 +$default->siteMap->addPage("roleManagement", "/presentation/lookAndFeel/knowledgeTree/administration/admin.php/security/roles", "Administration", SysAdmin, _("Role Management"), true, 12);
118 $default->siteMap->addPage("websiteManagement", "/presentation/lookAndFeel/knowledgeTree/administration/websitemanagement/listWebsitesBL.php", "Administration", SysAdmin, _("Website Management"), true, 13); 118 $default->siteMap->addPage("websiteManagement", "/presentation/lookAndFeel/knowledgeTree/administration/websitemanagement/listWebsitesBL.php", "Administration", SysAdmin, _("Website Management"), true, 13);
119 119
120 $default->siteMap->addPage("systemAdministration", "/presentation/lookAndFeel/knowledgeTree/administration/systemsettings/systemSettingsBL.php", "Administration", SysAdmin, _("System Settings"), true, 14); 120 $default->siteMap->addPage("systemAdministration", "/presentation/lookAndFeel/knowledgeTree/administration/systemsettings/systemSettingsBL.php", "Administration", SysAdmin, _("System Settings"), true, 14);
lib/roles/Role.inc
@@ -47,7 +47,7 @@ class Role extends KTEntity { @@ -47,7 +47,7 @@ class Role extends KTEntity {
47 * @param boolean Role has document write permission 47 * @param boolean Role has document write permission
48 * 48 *
49 */ 49 */
50 - function Role($sNewName, $bNewCanRead, $bNewCanWrite) { 50 + function Role($sNewName = null, $bNewCanRead = false, $bNewCanWrite = false) {
51 //object not yet created in database 51 //object not yet created in database
52 $this->iId = -1; 52 $this->iId = -1;
53 $this->sName = $sNewName; 53 $this->sName = $sNewName;
@@ -114,10 +114,11 @@ class Role extends KTEntity { @@ -114,10 +114,11 @@ class Role extends KTEntity {
114 function delete() { 114 function delete() {
115 global $default, $lang_err_database, $lang_err_object_key; 115 global $default, $lang_err_database, $lang_err_object_key;
116 //only delete the object if it exists in the database 116 //only delete the object if it exists in the database
  117 + /*
117 if ($this->iId >= 0) { 118 if ($this->iId >= 0) {
118 - //check to see if role is linked to a folder 119 +
119 $sql = $default->db; 120 $sql = $default->db;
120 - $query = "SELECT role_id FROM ". $default->groups_folders_approval_table ." WHERE role_id = ?";/*ok*/ 121 + $query = "SELECT role_id FROM ". $default->groups_folders_approval_table ." WHERE role_id = ?";
121 $aParams = array($this->iId); 122 $aParams = array($this->iId);
122 $sql->query(array($query, $aParams)); 123 $sql->query(array($query, $aParams));
123 $rows = $sql->num_rows($sql); 124 $rows = $sql->num_rows($sql);
@@ -127,6 +128,7 @@ class Role extends KTEntity { @@ -127,6 +128,7 @@ class Role extends KTEntity {
127 return false; 128 return false;
128 } 129 }
129 } 130 }
  131 + */
130 return parent::delete(); 132 return parent::delete();
131 } 133 }
132 134
plugins/ktcore/KTAdminPlugins.php
@@ -29,8 +29,13 @@ $oAdminRegistry->registerCategory("misc", "Miscellaneous", "Various settings whi @@ -29,8 +29,13 @@ $oAdminRegistry->registerCategory("misc", "Miscellaneous", "Various settings whi
29 $oAdminRegistry->registerLocation("users",'KTUserAdminDispatcher',"principals", "Manage Users","Add or remove users from the system.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/usermanagement/userManagement.php', null); 29 $oAdminRegistry->registerLocation("users",'KTUserAdminDispatcher',"principals", "Manage Users","Add or remove users from the system.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/usermanagement/userManagement.php', null);
30 $oAdminRegistry->registerLocation("groups",'KTGroupAdminDispatcher',"principals", "Manage Groups","Add or remove groups from the system.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/groupManagement.php', null); 30 $oAdminRegistry->registerLocation("groups",'KTGroupAdminDispatcher',"principals", "Manage Groups","Add or remove groups from the system.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/groupManagement.php', null);
31 $oAdminRegistry->registerLocation("units",'KTUnitAdminDispatcher',"principals", "Control Units","Specify which organisation units are available.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/unitManagement.php', null); 31 $oAdminRegistry->registerLocation("units",'KTUnitAdminDispatcher',"principals", "Control Units","Specify which organisation units are available.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/unitManagement.php', null);
  32 +// disabled until it actually makes sense.
32 //$oAdminRegistry->registerLocation("orgs",'KTOrgAdminDispatcher',"principals", "Control Organisations","Specify which organisations are available.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/orgmanagement/orgManagement.php', null); 33 //$oAdminRegistry->registerLocation("orgs",'KTOrgAdminDispatcher',"principals", "Control Organisations","Specify which organisations are available.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/orgmanagement/orgManagement.php', null);
33 34
  35 +// security
  36 +$oAdminRegistry->registerLocation("permissions",'ManagePermissionsDispatcher',"security", "Permissions","Create or Delete permissions.", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/permissions/managePermissions.php', null);
  37 +$oAdminRegistry->registerLocation("roles",'RoleAdminDispatcher',"security", "Roles","Create or Delete roles (incomplete).", KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/roleManagement.php', null);
  38 +
34 // documents 39 // documents
35 $oAdminRegistry->registerLocation("typemanagement",'KTDocumentTypeDispatcher','documents', 'Document Types','Manage the different classes of document which can be added to the system.', KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/documentTypes.php', null); 40 $oAdminRegistry->registerLocation("typemanagement",'KTDocumentTypeDispatcher','documents', 'Document Types','Manage the different classes of document which can be added to the system.', KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/documentTypes.php', null);
36 $oAdminRegistry->registerLocation("fieldmanagement",'KTDocumentFieldDispatcher','documents', 'Document Fieldsets','Control which kinds of documents have which sets of information associated with them.', KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/documentFields.php', null); 41 $oAdminRegistry->registerLocation("fieldmanagement",'KTDocumentFieldDispatcher','documents', 'Document Fieldsets','Control which kinds of documents have which sets of information associated with them.', KT_DIR . '/presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/documentFields.php', null);
presentation/lookAndFeel/knowledgeTree/administration/permissions/managePermissions.php
1 <?php 1 <?php
2 -require_once("../../../../../config/dmsDefaults.php"); 2 +//require_once("../../../../../config/dmsDefaults.php");
3 3
4 require_once(KT_LIB_DIR . "/templating/templating.inc.php"); 4 require_once(KT_LIB_DIR . "/templating/templating.inc.php");
5 require_once(KT_LIB_DIR . "/permissions/permission.inc.php"); 5 require_once(KT_LIB_DIR . "/permissions/permission.inc.php");
@@ -7,12 +7,27 @@ require_once(KT_LIB_DIR . &quot;/dispatcher.inc.php&quot;); @@ -7,12 +7,27 @@ require_once(KT_LIB_DIR . &quot;/dispatcher.inc.php&quot;);
7 require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); 7 require_once(KT_LIB_DIR . "/templating/kt3template.inc.php");
8 8
9 class ManagePermissionsDispatcher extends KTAdminDispatcher { 9 class ManagePermissionsDispatcher extends KTAdminDispatcher {
  10 +
  11 + var $aBreadcrumbs = array(
  12 + array('name' => 'Administration', action => 'administration'),
  13 + );
  14 +
10 function do_main() { 15 function do_main() {
  16 +
  17 + $this->oPage->setTitle('Manage Permissions');
  18 + $this->aBreadcrumbs[] = array('action' => 'managePermissions', 'name' => 'Manage Permissions');
  19 +
  20 + $add_fields = array();
  21 + $add_fields[] = new KTStringWidget('System Name','The internal name used for the permission. This should never be changed.', 'name', null, $this->oPage, true);
  22 + $add_fields[] = new KTStringWidget('Human Name','A short name that is shown to users whenever permissions must be assigned.', 'human_name', null, $this->oPage, true);
  23 +
11 $oTemplating = new KTTemplating; 24 $oTemplating = new KTTemplating;
12 $aPermissions =& KTPermission::getList(); 25 $aPermissions =& KTPermission::getList();
13 $oTemplate = $oTemplating->loadTemplate("ktcore/manage_permissions"); 26 $oTemplate = $oTemplating->loadTemplate("ktcore/manage_permissions");
14 $aTemplateData = array( 27 $aTemplateData = array(
  28 + 'context' => $this,
15 "permissions" => $aPermissions, 29 "permissions" => $aPermissions,
  30 + 'add_fields' => $add_fields,
16 ); 31 );
17 return $oTemplate->render($aTemplateData); 32 return $oTemplate->render($aTemplateData);
18 } 33 }
@@ -30,7 +45,7 @@ class ManagePermissionsDispatcher extends KTAdminDispatcher { @@ -30,7 +45,7 @@ class ManagePermissionsDispatcher extends KTAdminDispatcher {
30 if (PEAR::isError($oPerm)) { 45 if (PEAR::isError($oPerm)) {
31 return $this->errorRedirectToMain("Error creating permission"); 46 return $this->errorRedirectToMain("Error creating permission");
32 } 47 }
33 - return $this->errorRedirectToMain("Permission created"); 48 + return $this->successRedirectToMain("Permission created");
34 } 49 }
35 50
36 function do_deletePermission() { 51 function do_deletePermission() {
@@ -49,11 +64,11 @@ class ManagePermissionsDispatcher extends KTAdminDispatcher { @@ -49,11 +64,11 @@ class ManagePermissionsDispatcher extends KTAdminDispatcher {
49 if (PEAR::isError($res)) { 64 if (PEAR::isError($res)) {
50 return $this->errorRedirectToMain("Error deleting permission"); 65 return $this->errorRedirectToMain("Error deleting permission");
51 } 66 }
52 - return $this->errorRedirectToMain("Permission deleted"); 67 + return $this->successRedirectToMain("Permission deleted");
53 } 68 }
54 } 69 }
55 70
56 -$oDispatcher = new ManagePermissionsDispatcher();  
57 -$oDispatcher->dispatch(); 71 +//$oDispatcher = new ManagePermissionsDispatcher();
  72 +//$oDispatcher->dispatch();
58 73
59 ?> 74 ?>
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/addRoleBL.php deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Add a role.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -require_once("../../../../../config/dmsDefaults.php");  
28 -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");  
29 -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");  
30 -require_once("$default->fileSystemRoot/lib/security/Permission.inc");  
31 -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");  
32 -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");  
33 -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");  
34 -require_once("$default->fileSystemRoot/presentation/Html.inc");  
35 -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/administration/adminUI.inc");  
36 -require_once("addRoleUI.inc");  
37 -  
38 -if (checkSession()) {  
39 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
40 - $oPatternCustom = & new PatternCustom();  
41 - $oPatternCustom->setHtml(getPage());  
42 - $main->setCentralPayload($oPatternCustom);  
43 - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/create.php?fRedirectURL=".urlencode("$default->rootUrl/control.php?action=editRole&fFromCreate=1&fRoleID="));  
44 - $main->setHasRequiredFields(true);  
45 - $main->render();  
46 -}  
47 -?>  
48 \ No newline at end of file 0 \ No newline at end of file
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/addRoleUI.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Add a role UI functions.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -// get add pages  
28 -function getPage() {  
29 -  
30 - global $default;  
31 -  
32 - $aDisplayRowNames = array(_("Name"), _("Read"), _("Write"));  
33 - $aParameterNumbers = array(0,1,2);  
34 - $aDisplayColumnTypes = array(1,2,2);  
35 - $aRequired = array(1,1,1);  
36 -  
37 - // create a text field that is required  
38 - $oPatternCreate = & new PatternCreate("Role", "roles/Role.inc",$aDisplayRowNames, $aParameterNumbers, $aDisplayColumnTypes, $aRequired);  
39 - $oPatternCreate->setUniqueName("role");  
40 -  
41 - $sToRender .= renderHeading(_("Add Role"));  
42 - $sToRender .= "<table>\n";  
43 - $sToRender .= "<tr></tr>\n";  
44 - $sToRender .= "<tr>\n";  
45 - $sToRender .= "<td>" . $oPatternCreate->render() . "</td>\n";  
46 - $sToRender .= "</tr>\n";  
47 - $sToRender .= "<tr>\n";  
48 - $sToRender .= "</tr>\n";  
49 - $sToRender .= "<tr>\n";  
50 - $sToRender .= "</tr>\n";  
51 - $sToRender .= "<td align = right><input type=\"image\" src =\"" . KTHtml::getAddButton() . "\" value=\"Submit\" border=\"0\"/>";  
52 - $sToRender .= getCancelButton("listRoles") . "</td>\n";  
53 - $sToRender .= "</table>\n";  
54 -  
55 - return $sToRender;  
56 -}  
57 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/editRoleBL.php deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Edit a role.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -require_once("../../../../../config/dmsDefaults.php");  
28 -  
29 -KTUtil::extractGPC('fActive', 'fForStore', 'fFromCreate', 'fReadable', 'fRoleID', 'fRoleName', 'fWriteable');  
30 -  
31 -if (checkSession()) {  
32 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");  
33 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc");  
34 - require_once("editRoleUI.inc");  
35 - require_once("$default->fileSystemRoot/lib/security/Permission.inc");  
36 - require_once("$default->fileSystemRoot/lib/roles/Role.inc");  
37 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
38 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");  
39 - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");  
40 - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");  
41 - require_once("$default->fileSystemRoot/presentation/Html.inc");  
42 -  
43 -  
44 - $oPatternCustom = & new PatternCustom();  
45 -  
46 - // if a new group has been added  
47 - if (isset($fFromCreate)) {  
48 - if($fRoleID == -1) {  
49 - $oPatternCustom->setHtml(getAddFailPage());  
50 - } else {  
51 - controllerRedirect("listRoles");  
52 - }  
53 - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true;  
54 - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=listRoles"));  
55 -  
56 - // coming from manual edit page  
57 - }  
58 - else if (isset($fForStore)) {  
59 - $oRole = Role::get($fRoleID);  
60 - $oRole->setName($fRoleName);  
61 -  
62 - //check if checkbox checked  
63 - if (isset($fActive)) {  
64 - $oRole->setActive(true);  
65 - } else {  
66 - $oRole->setActive(false);  
67 - }  
68 - //check if checkbox checked  
69 - if (isset($fReadable)) {  
70 - $oRole->setReadable(true);  
71 - } else {  
72 - $oRole->setReadable(false);  
73 - }  
74 - //check if checkbox checked  
75 - if (isset($fWriteable)) {  
76 - $oRole->setWriteable(true);  
77 - } else {  
78 - $oRole->setWriteable(false);  
79 - }  
80 - if ($oRole->update()) {  
81 - // if successfull redirec to list page  
82 - controllerRedirect("listRoles");  
83 - } else {  
84 - // if fail print out fail message  
85 - $oPatternCustom->setHtml(getEditPageFail());  
86 - }  
87 - } else if (isset($fRoleID)) {  
88 - // post back on group select from manual edit page  
89 - $oPatternCustom->setHtml(getEditPage($fRoleID));  
90 - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForStore=1");  
91 -  
92 -  
93 - } else {  
94 - // if nothing happens...just reload edit page  
95 - $oPatternCustom->setHtml(getEditPage(null));  
96 - $main->setFormAction($_SERVER["PHP_SELF"]);  
97 -  
98 - }  
99 - //render the page  
100 - $main->setCentralPayload($oPatternCustom);  
101 - $main->setHasRequiredFields(true);  
102 - $main->render();  
103 -}  
104 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/editRoleSuccess.php deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Edit a role success page.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -require_once("../../../../../config/dmsDefaults.php");  
28 -  
29 -global $default;  
30 -  
31 -if(checkSession()) {  
32 -  
33 - // include the page template (with navbar)  
34 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
35 -  
36 - $Center .= renderHeading(_("Edit Role"));  
37 - $Center .= "<TABLE BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"2\">\n";  
38 - $Center .= "<tr>\n";  
39 - $Center .= "<td>" . _("Update Successful!") . "</td>\n";  
40 - $Center .= "</tr>\n";  
41 - $Center .= "<tr></tr>\n";  
42 - $Center .= "<tr></tr>\n";  
43 - $Center .= "<tr></tr>\n";  
44 - $Center .= "<tr></tr>\n";  
45 - $Center .= "<tr>\n";  
46 - $Center .= "<td align=\"right\"><a href=\"$default->rootUrl/control.php?action=listRoles\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n";  
47 - $Center .= "</tr>\n";  
48 - $Center .= "</table>\n";  
49 -  
50 - $oPatternCustom = & new PatternCustom();  
51 - $oPatternCustom->setHtml($Center);  
52 - $main->setCentralPayload($oPatternCustom);  
53 - $main->render();  
54 -}  
55 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/editRoleUI.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Edit a role UI functions.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -// get hte edit page if it comes from the add page  
28 -function getCreatePage($iRoleID) {  
29 -  
30 - global $default;  
31 -  
32 - /*ok*/ $sQuery = array("SELECT * FROM $default->roles_table WHERE id = ?" , $iRoleID);  
33 - $aDisplayColumns = array("name", "can_read", "can_write");  
34 - $aStoreColumns = array("name", "can_read","can_write");  
35 - $aColumnNames = array(_("Name"), _("Read"), _("Write"));  
36 - $aDisplayColumnTypes = array(1,2,2);  
37 - $aDatabaseColumnTypes = array(1,2,2);  
38 -  
39 - // get list of role properties...name...text field...is_Sys_admin and is_unit_admin..checkboxes  
40 - $oPattern = & new PatternEditableListFromQuery($sQuery, $default->roles_table, $aDisplayColumns, $aStoreColumns, $aColumnNames, $aDisplayColumnTypes, $aDatabaseColumnTypes) ;  
41 - $oPattern->setUniqueName("roleEdit");  
42 - $oPattern->setColumnsRequired(array(1,0,0));  
43 -  
44 - $sToRender .= renderHeading(_("Edit Role"));  
45 - $sToRender .= "<table>\n";  
46 - $sToRender .= "<tr></tr>\n";  
47 - $sToRender .= "<tr>\n";  
48 - $sToRender .= "<td>" . $oPattern->render() . "</td>\n";  
49 - $sToRender .= "</tr>\n";  
50 - $sToRender .= "<tr>\n";  
51 - $sToRender .= "</tr>\n";  
52 - $sToRender .= "<tr>\n";  
53 - $sToRender .= "</tr>\n";  
54 -  
55 - $sToRender .= "<td align = right><input type=\"image\" src =\"" . KTHtml::getUpdateButton() . "\" value=\"Update\" border=\"0\"/><a href=\"$default->rootUrl/control.php?action=addRole\"><img src =\"" . KTHtml::getCancelButton() . "\" border = \"0\" /></a></td>\n";  
56 - $sToRender .= "</table>\n";  
57 -  
58 - return $sToRender;  
59 -}  
60 -  
61 -// if fails ..  
62 -function getAddFailPage() {  
63 -  
64 - global $default;  
65 -  
66 - $sToRender .= renderHeading(_("Edit Role"));  
67 - $sToRender .= "<table>\n";  
68 - $sToRender .= "<tr>\n";  
69 - $sToRender .= "<td>" . _("Sorry, Role Already Exists!") . "</td>\n";  
70 - $sToRender .= "</tr>\n";  
71 - $sToRender .= "<tr>\n";  
72 - $sToRender .= "</tr>\n";  
73 - $sToRender .= "<tr>\n";  
74 - $sToRender .= "<td align = right><a href=\"$default->rootUrl/control.php?action=addRole\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n";  
75 - $sToRender .= "</tr>\n";  
76 - $sToRender .= "</table>\n";  
77 -  
78 - return $sToRender;  
79 -}  
80 -  
81 -// if its the manual edit page..then display normally  
82 -function getEditPage($iRoleID) {  
83 - global $default;  
84 - $oRole = null;  
85 - if (isset($iRoleID)) {  
86 - $oRole = Role::get($iRoleID);  
87 - }  
88 -  
89 - $sToRender .= renderHeading(_("Edit Role"));  
90 - $sToRender .= "<table>\n";  
91 - $sToRender .= "<tr></tr>\n";  
92 - $sToRender .= "<tr>\n";  
93 - $sToRender .= "<td>" . _("Role Name:") . " </td><td>" . getRoleDisplay($oRole) . "</td>\n";  
94 - $sToRender .= "</tr>\n";  
95 - $sToRender .= "<tr>\n";  
96 - $sToRender .= "</tr>\n";  
97 - $sToRender .= "<tr>\n";  
98 -  
99 - // if a Role selected...show checkboxes  
100 - if (isset($iRoleID)) {  
101 - $sToRender .= "</tr>\n";  
102 - $sToRender .= "<tr>\n";  
103 - $sToRender .= "<td>" . _("Readable:") . " </td><td>" . getReadableCheckBox($oRole) . "</td>\n";  
104 - $sToRender .= "</tr>\n";  
105 - $sToRender .= "<tr>\n";  
106 - $sToRender .= "<td>" . _("Writable:") . " </td><td>" . getWriteableCheckBox($oRole) . "</td>\n";  
107 - $sToRender .= "</tr>\n";  
108 - $sToRender .= "<tr>\n";  
109 - $sToRender .= "</tr>\n";  
110 - }  
111 -  
112 - $sToRender .= "<tr>\n";  
113 - $sToRender .= "</tr>\n";  
114 - $sToRender .= "<td></td>" . getUpdateButton($oRole);  
115 - $sToRender .= getCancelButton($oRole);  
116 - $sToRender .= "</table>\n";  
117 -  
118 - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";  
119 - $sToRender .= "function validateForm(theForm) {\n";  
120 - $sToRender .= "\tif (!(validRequired(theForm.fRoleName, 'Role Name'))) {\n";  
121 - $sToRender .= "\t\treturn false;\n";  
122 - $sToRender .= "\t}\n";  
123 - $sToRender .= "return true;\n}\n";  
124 - $sToRender .= "//-->\n</script>\n\n";  
125 -  
126 - return $sToRender;  
127 -}  
128 -  
129 -// if edition is successful print otu success page  
130 -function getEditPageSuccess() {  
131 - global $default;  
132 -  
133 - $sToRender .= renderHeading(_("Edit Role"));  
134 - $sToRender .= "<b>" . _("Success") . "!</b>\n";  
135 - $sToRender .= "<table>\n";  
136 - $sToRender .= "<br></br>\n";  
137 - $sToRender .= "<tr></tr>\n";  
138 - $sToRender .= "<tr><td>" . _("The Role was successfully modified") . "</td></tr>\n";  
139 - $sToRender .= "<tr></tr>\n";  
140 - $sToRender .= "<tr></tr>\n";  
141 - $sToRender .= "<tr>\n";  
142 - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=listRoles\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n";  
143 - $sToRender .= "</tr>\n";  
144 - $sToRender .= "</table>\n";  
145 -  
146 -  
147 - return $sToRender;  
148 -}  
149 -  
150 -  
151 -// gets the page if edition fails  
152 -function getEditPageFail() {  
153 - global $default;  
154 -  
155 - $sToRender .= renderHeading(_("Edit Role"));  
156 - $sToRender .= "<b>" . _("Success") . "!</b>\n";  
157 - $sToRender .= "<table>\n";  
158 - $sToRender .= "<br></br>\n";  
159 - $sToRender .= "<tr></tr>\n";  
160 - $sToRender .= "<tr><td>" . _("The Role modification Failed!") . "</td></tr>\n";  
161 - $sToRender .= "<tr></tr>\n";  
162 - $sToRender .= "<tr></tr>\n";  
163 - $sToRender .= "<tr>\n";  
164 - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=listRole\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n";  
165 - $sToRender .= "</tr>\n";  
166 - $sToRender .= "</table>\n";  
167 -  
168 -  
169 - return $sToRender;  
170 -}  
171 -// show the list box when no Role selected  
172 -// then shows a text box with the role's name  
173 -function getRoleDisplay($oRole) {  
174 - global $default;  
175 - if (!isset($oRole)) {  
176 - $oPatternListBox = & new PatternListBox($default->roles_table, "name", "id", "fRoleID");  
177 - //$oPatternListBox->setIncludeDefaultValue(true);  
178 - $oPatternListBox->setPostBackOnChange(true);  
179 - return $oPatternListBox->render();  
180 - } else {  
181 - return "<input type=\"hidden\" name=\"fRoleID\" value=\"" . $oRole->iId . "\">\n" .  
182 - "<input size = \"40\" type=\"text\" name=\"fRoleName\" value=\"" . $oRole->getName() . "\">";  
183 - }  
184 -  
185 -}  
186 -  
187 -// returns the checkbox ticked or unticked  
188 -function getActiveCheckBox($oRole) {  
189 - if (!isset($oRole)) {  
190 - return "";  
191 - } else {  
192 - return "<input type=\"checkbox\" name=\"fActive\" " . ($oRole->getActive() ? "CHECKED " : " ") . " />";  
193 - }  
194 -}  
195 -  
196 -  
197 -// returns the checkbox ticked or unticked  
198 -function getReadableCheckBox($oRole) {  
199 - if (!isset($oRole)) {  
200 - return "";  
201 - } else {  
202 - return "<input type=\"checkbox\" name=\"fReadable\" " . ($oRole->getReadable() ? "CHECKED " : " ") . " />";  
203 - }  
204 -}  
205 -  
206 -// returns the checkbox ticked or unticked  
207 -function getWriteableCheckBox($oRole) {  
208 - if (!isset($oRole)) {  
209 - return "";  
210 - } else {  
211 - return "<input type=\"checkbox\" name=\"fWriteable\" " . ($oRole->getWriteable() ? "CHECKED " : " ") . " />";  
212 - }  
213 -  
214 -}  
215 -  
216 -// gets the updatebutton when a group is selected  
217 -function getUpdateButton($oRole) {  
218 - global $default;  
219 - if (!isset($oRole)) {  
220 - return _("Please select a Role:") . " ";  
221 - } else {  
222 - return "<td align = right><input type=\"image\" src =\"" . KTHtml::getUpdateButton() . "\" value=\"submit\" border=\"0\"/></td>\n";  
223 - }  
224 -}  
225 -  
226 -// gets the cancel button when a group is selected  
227 -function getCancelButton($oRole) {  
228 - global $default;  
229 - if (!isset($oRole)) {  
230 - //return "<td align = right><a href=\"$default->rootUrl/control.php?action=groupManagement\"><img src =\"" . KTHtml::getCancelButton() . "\" value=\"cancel\" /></a></td>\n";  
231 - } else {  
232 - return "<td align = right><a href=\"$default->rootUrl/control.php?action=listRoles\"><img src =\"" . KTHtml::getCancelButton() . "\" border = \"0\" /></a></td>\n";  
233 - }  
234 -}  
235 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/listRolesBL.php deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * List roles.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Omar Rahbeeni, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -  
28 -require_once("../../../../../config/dmsDefaults.php");  
29 -  
30 -KTUtil::extractGPC('fGroupID');  
31 -  
32 -require_once("$default->fileSystemRoot/lib/users/User.inc");  
33 -require_once("$default->fileSystemRoot/lib/security/Permission.inc");  
34 -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");  
35 -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");  
36 -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");  
37 -require_once("$default->fileSystemRoot/presentation/Html.inc");  
38 -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/administration/adminUI.inc");  
39 -require_once("listRolesUI.inc");  
40 -  
41 -if (checkSession()) {  
42 - $oPatternCustom = & new PatternCustom();  
43 - $oPatternCustom->setHtml(getPage($fGroupID));  
44 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
45 - $main->setCentralPayload($oPatternCustom);  
46 - $main->setFormAction($_SERVER['PHP_SELF']);  
47 - $main->render();  
48 -}  
49 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/listRolesUI.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * List roles UI functions.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Omar Rahbeeni, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -function getRoles() {  
28 - global $default;  
29 - /*ok*/ $sQuery = "SELECT id as roleID, name as name, can_read as reader, can_write as writer, " .  
30 - "'Edit', 'Delete' " .  
31 - "FROM roles " .  
32 - "ORDER BY name";  
33 -  
34 - $aColumns = array("name", "reader", "writer", "Edit", "Delete");  
35 - $aColumnNames = array(_("Name"), _("Read"), _("Write"), _("Edit"), _("Delete"));  
36 - $aColumnTypes = array(1,2,2,3,3);  
37 - $aDBColumnArray = array("roleID");  
38 - $aQueryStringVariableNames = array("fRoleID");  
39 -  
40 - $aHyperLinkURL = array( 3=> "$default->rootUrl/control.php?action=editRole",  
41 - 4=> "$default->rootUrl/control.php?action=removeRole"); //"$default->rootUrl/control.php?action=removeUserFromGroup");  
42 -  
43 - $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);  
44 - $oSearchResults->setDisplayColumnHeadings(true);  
45 -  
46 - return $oSearchResults->render() ;  
47 -}  
48 -  
49 -function getPage() {  
50 - global $default;  
51 - $sToRender .= renderHeading(_("Role Management"));  
52 -  
53 - // add user link  
54 - $sToRender .= getAddLink("addRole", _("Add A Role"));  
55 - $sToRender .= getRoles();  
56 - return $sToRender;  
57 -}  
58 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/removeRoleBL.php deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Remove a role.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -require_once("../../../../../config/dmsDefaults.php");  
28 -  
29 -KTUtil::extractGPC('fForDelete', 'fRoleID', 'fRoleName');  
30 -  
31 -if (checkSession()) {  
32 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");  
33 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc");  
34 - require_once("removeRoleUI.inc");  
35 - require_once("$default->fileSystemRoot/lib/security/Permission.inc");  
36 - require_once("$default->fileSystemRoot/lib/roles/Role.inc");  
37 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
38 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");  
39 - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");  
40 - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");  
41 - require_once("$default->fileSystemRoot/presentation/Html.inc");  
42 -  
43 - $oPatternCustom = & new PatternCustom();  
44 -  
45 - // get main page  
46 - if (isset($fRoleID)) {  
47 -  
48 - $oPatternCustom->setHtml(getDeletePage($fRoleID));  
49 - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForDelete=1");  
50 -  
51 - // get delete page  
52 - }  
53 - else {  
54 - $oPatternCustom->setHtml(getDeletePage(null));  
55 - $main->setFormAction($_SERVER["PHP_SELF"]);  
56 - }  
57 -  
58 - // if delete entry  
59 - if (isset($fForDelete)) {  
60 - $oRole = Role::get($fRoleID);  
61 - $oRole->setName($fRoleName);  
62 -  
63 - if ($oRole->delete()) {  
64 - controllerRedirect("listRoles");  
65 - } else {  
66 - $oPatternCustom->setHtml(getDeleteFailPage());  
67 - }  
68 - }  
69 -  
70 - $main->setCentralPayload($oPatternCustom);  
71 - $main->render();  
72 -}  
73 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/removeRoleUI.inc deleted
1 -<?php  
2 -/**  
3 - * $Id$  
4 - *  
5 - * Remove a role UI functions.  
6 - *  
7 - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com  
8 - *  
9 - * This program is free software; you can redistribute it and/or modify  
10 - * it under the terms of the GNU General Public License as published by  
11 - * the Free Software Foundation; either version 2 of the License, or  
12 - * (at your option) any later version.  
13 - *  
14 - * This program is distributed in the hope that it will be useful,  
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
17 - * GNU General Public License for more details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program; if not, write to the Free Software  
21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
22 - *  
23 - * @version $Revision$  
24 - * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa  
25 - * @package administration.rolemanagement  
26 - */  
27 -// gets the delete stuff  
28 -function getDeletePage($iRoleID) {  
29 - global $default;  
30 - $oRole = null;  
31 - if (isset($iRoleID)) {  
32 - $oRole = Role::get($iRoleID);  
33 - $sHeading .= "<b>" . _("Are you sure you wish to Remove this Role?:") . "</b>\n";  
34 - } else {  
35 - $sHeading .= _("Please select a Role:");  
36 - }  
37 -  
38 - $sToRender .= renderHeading(_("Remove Role"));  
39 - $sToRender .= "<table>\n";  
40 - $sToRender .= "<tr><td>$sHeading</td></tr>\n";  
41 - $sToRender .= "<tr>\n";  
42 - $sToRender .= "<td>" . _("Role Name:") . " </td><td>" . getRoleDisplay($oRole) . "</td>\n";  
43 - $sToRender .= "</tr>\n";  
44 - $sToRender .= "<tr>\n";  
45 - $sToRender .= "</tr>\n";  
46 - $sToRender .= "<tr>\n";  
47 - $sToRender .= getReadableCheckBox($oRole) . "</td>\n";  
48 - $sToRender .= "</tr>\n";  
49 - $sToRender .= "<tr>\n";  
50 - $sToRender .= getWriteableCheckBox($oRole) . "</td>\n";  
51 - $sToRender .= "</tr>\n";  
52 - $sToRender .= "<tr>\n";  
53 - $sToRender .= "</tr>\n";  
54 - $sToRender .= "<tr>\n";  
55 - $sToRender .= "</tr>\n";  
56 - $sToRender .= getDeleteButton($oRole);  
57 - $sToRender .= "</table>\n";  
58 -  
59 - return $sToRender;  
60 -}  
61 -  
62 -// get successfully deletion page  
63 -function getDeleteSuccessPage() {  
64 -  
65 - global $default;  
66 -  
67 - $sToRender .= renderHeading(_("Remove Role"));  
68 - $sToRender .= "<TABLE BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"2\">\n";  
69 - $sToRender .= "<tr>\n";  
70 - $sToRender .= "<td><b>" . _("Role SuccessFully Removed!") . "</b></td>\n";  
71 - $sToRender .= "</tr>\n";  
72 - $sToRender .= "<tr></tr>\n";  
73 - $sToRender .= "<tr></tr>\n";  
74 - $sToRender .= "<tr></tr>\n";  
75 - $sToRender .= "<tr></tr>\n";  
76 - $sToRender .= "<tr>\n";  
77 - $sToRender .= "<td align = right><a href=\"$default->rootUrl/control.php?action=listRoles\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n";  
78 - $sToRender .= "</tr>\n";  
79 - $sToRender .= "</table>\n";  
80 -  
81 - return $sToRender;  
82 -}  
83 -  
84 -// get deletion failed page  
85 -function getDeleteFailPage() {  
86 -  
87 - global $default;  
88 -  
89 - $sToRender .= renderHeading(_("Remove Role"));  
90 - $sToRender .= "<TABLE BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"2\">\n";  
91 - $sToRender .= "<tr>\n";  
92 - $sToRender .= "<td><b>" . _("Deletion Failed!") . "</b></td>\n";  
93 - $sToRender .= "</tr>\n";  
94 - $sToRender .= "<tr></tr>\n";  
95 - $sToRender .= "<tr></tr>\n";  
96 - $sToRender .= "<tr><td>" . _("Please Ensure that The Role has not been assigned to any Folder") . "</td></tr>\n";  
97 - $sToRender .= "<tr></tr>\n";  
98 - $sToRender .= "<tr></tr>\n";  
99 - $sToRender .= "</tr>\n";  
100 - $sToRender .= "<tr><td align = right><a href=\"$default->rootUrl/control.php?action=listRoles\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td></tr>\n";  
101 - $sToRender .= "</table>\n";  
102 -  
103 - return $sToRender;  
104 -}  
105 -  
106 -// show listbox...or the text name  
107 -function getRoleDisplay($oRole) {  
108 - global $default;  
109 - if (!isset($oRole)) {  
110 - $oPatternListBox = & new PatternListBox($default->roles_table, "name", "id", "fRoleID");  
111 - $oPatternListBox->setIncludeDefaultValue(true);  
112 - $oPatternListBox->setPostBackOnChange(true);  
113 - return $oPatternListBox->render();  
114 - } else {  
115 - return "<input type=\"hidden\" name=\"fRoleID\" value=\"" . $oRole->iId . "\">\n" .  
116 - "<b>" . $oRole->getName() . "</b>";  
117 - }  
118 -  
119 -}  
120 -  
121 -// show check box  
122 -function getActiveCheckBox($oRole) {  
123 - if (!isset($oRole)) {  
124 - return "";  
125 - } else {  
126 - return "<td>Active: </td><td><input disabled=\"true\" type=\"checkbox\" name=\"fActive\" " . ($oRole->getActive() ? "CHECKED " : " ") . " />";  
127 - }  
128 -}  
129 -  
130 -// show check box  
131 -function getReadableCheckBox($oRole) {  
132 - if (!isset($oRole)) {  
133 - return "";  
134 - } else {  
135 - return "<td>Readable: </td><td><input disabled=\"true\" type=\"checkbox\" name=\"fReadable\" " . ($oRole->getReadable() ? "CHECKED " : " ") . " />";  
136 - }  
137 -}  
138 -  
139 -// show text box  
140 -function getWriteableCheckBox($oRole) {  
141 - if (!isset($oRole)) {  
142 - return "";  
143 - } else {  
144 - return "<td>Writable: </td><td><input disabled=\"true\" type=\"checkbox\" name=\"fWritable\" " . ($oRole->getWriteable() ? "CHECKED " : " ") . " />";  
145 - }  
146 -  
147 -}  
148 -  
149 -// show delete button  
150 -function getDeleteButton($oRole) {  
151 - global $default;  
152 - if (isset($oRole)) {  
153 - return "<td></td><td><td align = right><input type=\"image\" src =\"" . KTHtml::getDeleteButton() . "\" value=\"submit\" border=\"0\"/></td>\n".  
154 - "<td align = right><a href=\"$default->rootUrl/control.php?action=listRoles\"><img src =\"" . KTHtml::getCancelButton() . "\" border = \"0\" /></a></td>\n";  
155 - }  
156 -}  
157 -?>  
presentation/lookAndFeel/knowledgeTree/administration/rolemanagement/roleManagement.php 0 → 100644
  1 +<?php
  2 +
  3 +/*
  4 + * Document Link Type management
  5 + *
  6 + * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
  7 + *
  8 + * This program is free software; you can redistribute it and/or modify
  9 + * it under the terms of the GNU General Public License as published by
  10 + * the Free Software Foundation; either version 2 of the License, or
  11 + * (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21 + *
  22 + * @version $Revision$
  23 + * @author Brad Shuttleworth <brad@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  24 + * @package documentmanagement
  25 + */
  26 +
  27 +/* boilerplate */
  28 +//require_once('../../../../../config/dmsDefaults.php');
  29 +
  30 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  31 +require_once(KT_LIB_DIR . '/templating/kt3template.inc.php');
  32 +
  33 +require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
  34 +require_once(KT_LIB_DIR . "/roles/Role.inc");
  35 +
  36 +class RoleAdminDispatcher extends KTAdminDispatcher {
  37 +
  38 + // Breadcrumbs base - added to in methods
  39 + var $aBreadcrumbs = array(
  40 + array('action' => 'administration', 'name' => 'Administration'),
  41 + );
  42 +
  43 + function check() {
  44 + return true;
  45 + }
  46 +
  47 + function do_main() {
  48 + $this->aBreadcrumbs[] = array('action' => 'roleManagement', 'name' => 'Role Management');
  49 +
  50 + $this->oPage->setTitle('Role Management');
  51 +
  52 + $edit_fields = array();
  53 + $role_id = KTUtil::arrayGet($_REQUEST, 'role_id', null);
  54 + $oRole = Role::get($role_id);
  55 + if (PEAR::isError($oRole) || ($oRole == false)) { $for_edit = false; }
  56 + else {
  57 + $for_edit = true;
  58 + $edit_fields[] = new KTStringWidget('Name','A short, human-readable name for the role.', 'name', $oRole->getName(), $this->oPage, true);
  59 + }
  60 +
  61 + $aRoles =& Role::getList('id > 0');
  62 +
  63 + $add_fields = array();
  64 + $add_fields[] = new KTStringWidget('Name','A short, human-readable name for the role.', 'name', null, $this->oPage, true);
  65 +
  66 + $oTemplating =& KTTemplating::getSingleton();
  67 + $oTemplate = $oTemplating->loadTemplate('ktcore/principals/roleadmin');
  68 + $oTemplate->setData(array(
  69 + "context" => $this,
  70 + "add_fields" => $add_fields,
  71 + "for_edit" => $for_edit,
  72 + 'edit_role' => $oRole,
  73 + 'edit_fields' => $edit_fields,
  74 + 'roles' => $aRoles,
  75 + ));
  76 + return $oTemplate;
  77 + }
  78 +
  79 + function do_createRole() {
  80 + $name = KTUtil::arrayGet($_REQUEST, 'name', null);
  81 + if ($name === null) {
  82 + $this->errorRedirectToMain('Please give the role a name.');
  83 + }
  84 +
  85 + $this->startTransaction();
  86 + $oRole = new Role($name);
  87 + $res = $oRole->create();
  88 + if (PEAR::isError($res) || ($res == false)) {
  89 + $this->errorRedirectToMain('Unable to create role.');
  90 + }
  91 +
  92 + $this->successRedirectToMain('Role "' . $name . '" created.');
  93 + }
  94 +
  95 + function do_updateRole() {
  96 + $role_id = KTUtil::arrayGet($_REQUEST, 'role_id');
  97 + $oRole = Role::get($role_id);
  98 + if (PEAR::isError($oRole) || ($oRole == false)) {
  99 + $this->errorRedirectToMain('Please select a valid role first.');
  100 + }
  101 +
  102 + $name = KTUtil::arrayGet($_REQUEST, 'name', null);
  103 + if ($name === null) {
  104 + $this->errorRedirectToMain('Please give the role a name.');
  105 + }
  106 +
  107 + $this->startTransaction();
  108 + $oRole->setName($name);
  109 + $res = $oRole->update();
  110 + if (PEAR::isError($res) || ($res == false)) {
  111 + $this->errorRedirectToMain('Unable to update role.');
  112 + }
  113 +
  114 + $this->successRedirectToMain('Role "' . $name . '" updated.');
  115 + }
  116 +
  117 + function do_deleteRole() {
  118 + $role_id = KTUtil::arrayGet($_REQUEST, 'role_id');
  119 + $oRole = Role::get($role_id);
  120 + if (PEAR::isError($oRole) || ($oRole == false)) {
  121 + $this->errorRedirectToMain('Please select a valid role first.');
  122 + }
  123 + $name = $oRole->getName();
  124 +
  125 + $this->startTransaction();
  126 + $res = $oRole->delete();
  127 + if (PEAR::isError($res) || ($res == false)) {
  128 + $this->errorRedirectToMain('Unable to delete the role. Possible cause: ' . $_SESSION['errorMessage']);
  129 + }
  130 +
  131 + $this->successRedirectToMain('Role "' . $name . '" deleted. ');
  132 + }
  133 +
  134 +}
  135 +
templates/ktcore/manage_permissions.smarty
1 <h2>Existing permissions</h2> 1 <h2>Existing permissions</h2>
2 -<table class="pretty" cellspacing="0" cellpadding="0" border="0">  
3 -<thead>  
4 -<tr>  
5 -<th>Permission</th>  
6 -<th>Human Name</th>  
7 -<th colspan="2">Manage</th>  
8 -</tr>  
9 -</thead>  
10 -{ foreach item=oPerm from=$permissions }  
11 -<tr class="{cycle values="odd,even"}">  
12 -<td>  
13 -{ $oPerm->sName }  
14 -</td>  
15 -<td>  
16 -{ $oPerm->sHumanName }  
17 -</td>  
18 -{ if $oPerm->bBuiltIn == true }  
19 -<td colspan="2">  
20 -Built-in  
21 -</td>  
22 -{ else }  
23 -<td>  
24 -Edit  
25 -</td>  
26 -<td>  
27 -<a  
28 -href="{$smarty.server.PHP_SELF}?action=deletePermission&id={$oPerm->getId()}">Delete</a>  
29 -</td>  
30 -{ /if }  
31 -</tr>  
32 -{ /foreach }  
33 -</table>  
34 2
35 -<h2>Create a new permission</h2> 3 +<p class="descriptiveText"><strong>FIXME</strong> add a useful explanation about permissions.</p>
36 4
37 <form> 5 <form>
  6 +<fieldset>
  7 +<legend>Create a new permission</legend>
38 <input type="hidden" name="action" value="newPermission"> 8 <input type="hidden" name="action" value="newPermission">
39 -<table>  
40 -<tr>  
41 -<td>Name:</td>  
42 -<td><input type="text" name="name" value="custom."></td>  
43 -</tr>  
44 -<tr>  
45 -<td>Human name:</td>  
46 -<td><input type="text" name="human_name" value="Custom: "></td>  
47 -</tr>  
48 -<tr>  
49 -<td colspan="2" align="right"> 9 +
  10 +
  11 +
  12 +{foreach item=oWidget from=$add_fields}
  13 + {$oWidget->render()}
  14 +{/foreach}
  15 +
  16 +<div class="form_actions">
50 <input type="submit" name="submit" value="Create"> 17 <input type="submit" name="submit" value="Create">
51 -</td>  
52 -</tr>  
53 -</table> 18 +</div>
  19 +</fieldset>
  20 +
54 </form> 21 </form>
  22 +
  23 +
  24 +<table class="listing">
  25 + <thead>
  26 + <tr>
  27 + <th>Permission</th>
  28 + <th>Human Name</th>
  29 + <th>Delete</th>
  30 + </tr>
  31 + </thead>
  32 + { foreach item=oPerm from=$permissions }
  33 + <tr class="{cycle values="odd,even"}">
  34 + <td>
  35 + { $oPerm->sName }
  36 + </td>
  37 + <td>
  38 + { $oPerm->sHumanName }
  39 + </td>
  40 + { if $oPerm->bBuiltIn == true }
  41 + <td>
  42 + Built-in
  43 + </td>
  44 + { else }
  45 + <!-- <td>
  46 + Edit
  47 + </td> -->
  48 + <td>
  49 + <a href="{$smarty.server.PHP_SELF}?action=deletePermission&id={$oPerm->getId()}" class="ktAction ktDelete">Delete Permission</a>
  50 + </td>
  51 + { /if }
  52 + </tr>
  53 + { /foreach }
  54 +</table>
  55 +
templates/ktcore/principals/roleadmin.smarty 0 → 100644
  1 +<h2>Role Administration</h2>
  2 +
  3 +<p class="descriptiveText"><strong>FIXME</strong> Overview of roles.</p>
  4 +
  5 +<div class="ktInfo"><p><strong>Note:</strong> Roles are not yet fully functional within
  6 +<strong>KnowledgeTree&trade;</strong> 3.0</p></div>
  7 +
  8 +{if ($for_edit === false)}
  9 +
  10 +<form action="{$smarty.server.PHP_SELF}" method="GET">
  11 +<fieldset>
  12 + <legend>Add a Role</legend>
  13 +
  14 + <input type="hidden" name="action" value="createRole" />
  15 +
  16 + {foreach item=oWidget from=$add_fields}
  17 + {$oWidget->render()}
  18 + {/foreach}
  19 +
  20 + <div class="form_actions">
  21 + <input type="submit" value="create new role" />
  22 + </div class="form_actions">
  23 +</fieldset>
  24 +</form>
  25 +
  26 +{else}
  27 +
  28 +<form action="{$smarty.server.PHP_SELF}" method="GET">
  29 +<fieldset>
  30 + <legend>Change a role's details</legend>
  31 +
  32 + <input type="hidden" name="action" value="updateRole" />
  33 + <input type="hidden" name="role_id" value="{$edit_role->getId()}" />
  34 +
  35 + {foreach item=oWidget from=$edit_fields}
  36 + {$oWidget->render()}
  37 + {/foreach}
  38 +
  39 + <div class="form_actions">
  40 + <input type="submit" value="update role information" />
  41 + <a href="?action=main" class="ktAction ktCancel">Cancel</a>
  42 + <a href="?action=main">Cancel</a>
  43 + </div class="form_actions">
  44 +</fieldset>
  45 +</form>
  46 +
  47 +{/if}
  48 +
  49 +<table class="listing">
  50 +<thead>
  51 + <tr>
  52 + <th>Role Name</th>
  53 + <th>Edit</th>
  54 + <th>Delete</th>
  55 + </tr>
  56 +</thead>
  57 +<tbody>
  58 + {if (count($roles) !== 0)}
  59 + {foreach item=oRole from=$roles}
  60 + <tr>
  61 + <td>{$oRole->getName()}</td>
  62 + <td><a href="?action=editRole&role_id={$oRole->getId()}" class="ktAction ktEdit">Edit</a></td>
  63 + <td><a href="?action=deleteRole&role_id={$oRole->getId()}" class="ktAction ktDelete">Delete</a></td>
  64 + </tr>
  65 + {/foreach}
  66 + {else}
  67 + <tr>
  68 + <td class="ktInfo" colspan="3"><p>There are currently no roles created within the system.</td>
  69 + </tr>
  70 + {/if}
  71 +</tbody>
  72 +</table>
0 \ No newline at end of file 73 \ No newline at end of file