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()->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!
31 function get($v, $opts = Array())
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('core_group');
42 if (!$g->get($_GET['group_id'])) {
43 $this->jerr("group is invalid");
46 // DB_DataObject::debugLevel(1);
47 $p = DB_DataObject::factory('core_group_right');
48 $p->group_id = (int)$_GET['group_id'];
53 $cur[$p->rightname] = clone($p);
56 // print_r($cur);exit;
60 // echo "<PRE>"; print_r($p->defaultPermData() );
61 foreach($p->defaultPermData() as $k => $defdata) {
63 if (empty($defdata[0])) { // no admin data available..
66 if (!isset($cur[$k])) {
67 // then there is no current access right for it..
68 //DB_DataObject::debugLevel(1);
69 $gr = DB_DataObject::factory('core_group_right');
70 $gr->group_id = (int)$_GET['group_id'];
72 $gr->accessmask = $g->type == 2 ? '' : $defdata[1]; // set to defaults.. unless it's a contact group.
74 $cur[$k] = clone($gr);
79 'id' => $cur[$k]->id * 1, //
81 'descript' => isset($defdata[2]) ? $defdata[2] : '' ,
82 'accessmask' => $cur[$k]->accessmask,
83 'FullMask' => $defdata[0],
84 'group_id' => (int)$_GET['group_id']
97 if (!isset($_POST['group_id']) || (int)$_POST['group_id'] < 0) {
98 $this->jerr("NO GROUP");
100 if (!$this->hasPerm( 'Core.Groups','E')) { // editing groups..
101 $this->jerr("PERMISSION DENIED");
109 if (!empty($_POST['dataUpdate'])) {
110 foreach($_POST['dataUpdate'] as $id => $ac) {
112 $p = DB_DataObject::factory('core_group_right');
113 $p->group_id = (int)$_POST['group_id'];
115 $this->jerr("could not find gid:{$p->group_id} and $id");
116 continue; // errro cond.
119 $p->accessmask = $ac;
120 $p->validate(); // ensure that the basic perms can not be removed
124 if (!empty($_POST['dataAdd'])) {
125 foreach($_POST['dataAdd'] as $perm => $ac) {
126 $p = DB_DataObject::factory('core_group_right');
127 $p->group_id = (int)$_POST['group_id'];
128 $p->rightname = $perm;
129 $p->accessmask = $ac;
130 $p->validate(); // ensure that the basic perms can not be removed