7 require_once 'Pman.php';
9 class Pman_Admin_GroupRights extends Pman
12 parent::getAuth(); // load company!
13 $au = $this->getAuthUser();
15 $this->jerr("Not authenticated", array('authFailure' => true));
18 if ($au->company_id_comptype !='OWNER') {
19 $this->jerr("Error", "only company owners can manage groups");
22 $this->authUser = $au;
26 // perms - any table that can be modified by the user should be listed here..
27 // without it, our perms manager should deny writing via the web interface...
29 // FOR PERMS - SEE THE DATAOBJECT!
33 // must recieve a group..
34 if (!isset($_GET['group_id']) || (int)$_GET['group_id'] < 0) {
35 $this->jerr("NO GROUP");
37 if (!$this->hasPerm( 'Core.Groups','S')) { // listing groups..
38 $this->jerr("PERMISSION DENIED");
41 $g = DB_DataObject::Factory('groups');
42 if (!$g->get($_GET['group_id'])) {
43 $this->jerr("group is invalid");
46 // DB_DataObject::debugLevel(1);
47 $p = DB_DataObject::factory('group_rights');
48 $p->group_id = (int)$_GET['group_id'];
53 $cur[$p->rightname] = clone($p);
57 // echo "<PRE>"; print_r($p->defaultPermData() );
58 foreach($p->defaultPermData() as $k => $defdata) {
60 if (empty($defdata[0])) { // no admin data available..
63 if (!isset($cur[$k])) {
64 // then there is no current access right for it..
65 //DB_DataObject::debugLevel(1);
66 $gr = DB_DataObject::factory('group_rights');
67 $gr->group_id = (int)$_GET['group_id'];
69 $gr->accessmask = $defdata[1]; // set to defaults..
71 $cur[$k] = clone($gr);
76 'id' => $cur[$k]->id * 1, //
78 'descript' => isset($defdata[2]) ? $defdata[2] : '' ,
79 'accessmask' => $cur[$k]->accessmask,
80 'FullMask' => $defdata[0],
81 'group_id' => (int)$_GET['group_id']
94 if (!isset($_POST['group_id']) || (int)$_POST['group_id'] < 0) {
95 $this->jerr("NO GROUP");
97 if (!$this->hasPerm( 'Core.Groups','E')) { // editing groups..
98 $this->jerr("PERMISSION DENIED");
106 if (!empty($_POST['dataUpdate'])) {
107 foreach($_POST['dataUpdate'] as $id => $ac) {
108 $p = DB_DataObject::factory('group_rights');
109 $p->group_id = (int)$_POST['group_id'];
111 continue; // errro cond.
114 $p->accessmask = $ac;
115 $p->validate(); // ensure that the basic perms can not be removed
119 if (!empty($_POST['dataAdd'])) {
120 foreach($_POST['dataAdd'] as $perm => $ac) {
121 $p = DB_DataObject::factory('group_rights');
122 $p->group_id = (int)$_POST['group_id'];
123 $p->rightname = $perm;
124 $p->accessmask = $ac;
125 $p->validate(); // ensure that the basic perms can not be removed