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));
17 $this->authUser = $au;
21 // perms - any table that can be modified by the user should be listed here..
22 // without it, our perms manager should deny writing via the web interface...
24 // FOR PERMS - SEE THE DATAOBJECT!
28 // must recieve a group..
29 if (!isset($_GET['group_id']) || (int)$_GET['group_id'] < 0) {
30 $this->jerr("NO GROUP");
32 if (!$this->hasPerm( 'Core.Groups','S')) { // listing groups..
33 $this->jerr("PERMISSION DENIED");
36 $g = DB_DataObject::Factory('groups');
37 if (!$g->get($_GET['group_id'])) {
38 $this->jerr("group is invalid");
41 // DB_DataObject::debugLevel(1);
42 $p = DB_DataObject::factory('group_rights');
43 $p->group_id = (int)$_GET['group_id'];
48 $cur[$p->rightname] = clone($p);
52 // echo "<PRE>"; print_r($p->defaultPermData() );
53 foreach($p->defaultPermData() as $k => $defdata) {
55 if (empty($defdata[0])) { // no admin data available..
58 if (!isset($cur[$k])) {
59 // then there is no current access right for it..
60 //DB_DataObject::debugLevel(1);
61 $gr = DB_DataObject::factory('group_rights');
62 $gr->group_id = (int)$_GET['group_id'];
64 $gr->accessmask = $defdata[1]; // set to defaults..
66 $cur[$k] = clone($gr);
71 'id' => $cur[$k]->id * 1, //
73 'descript' => isset($defdata[2]) ? $defdata[2] : '' ,
74 'accessmask' => $cur[$k]->accessmask,
75 'FullMask' => $defdata[0],
76 'group_id' => (int)$_GET['group_id']
89 if (!isset($_POST['group_id']) || (int)$_POST['group_id'] < 0) {
90 $this->jerr("NO GROUP");
92 if (!$this->hasPerm( 'Core.Groups','E')) { // editing groups..
93 $this->jerr("PERMISSION DENIED");
101 if (!empty($_POST['dataUpdate'])) {
102 foreach($_POST['dataUpdate'] as $id => $ac) {
103 $p = DB_DataObject::factory('group_rights');
104 $p->group_id = (int)$_POST['group_id'];
106 continue; // errro cond.
109 $p->accessmask = $ac;
110 $p->validate(); // ensure that the basic perms can not be removed
114 if (!empty($_POST['dataAdd'])) {
115 foreach($_POST['dataAdd'] as $perm => $ac) {
116 $p = DB_DataObject::factory('group_rights');
117 $p->group_id = (int)$_POST['group_id'];
118 $p->rightname = $perm;
119 $p->accessmask = $ac;
120 $p->validate(); // ensure that the basic perms can not be removed