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!
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);
58 // echo "<PRE>"; print_r($p->defaultPermData() );
59 foreach($p->defaultPermData() as $k => $defdata) {
61 if (empty($defdata[0])) { // no admin data available..
64 if (!isset($cur[$k])) {
65 // then there is no current access right for it..
66 //DB_DataObject::debugLevel(1);
67 $gr = DB_DataObject::factory('core_group_right');
68 $gr->group_id = (int)$_GET['group_id'];
70 $gr->accessmask = $g->type == 2 ? '' : $defdata[1]; // set to defaults.. unless it's a contact group.
72 $cur[$k] = clone($gr);
77 'id' => $cur[$k]->id * 1, //
79 'descript' => isset($defdata[2]) ? $defdata[2] : '' ,
80 'accessmask' => $cur[$k]->accessmask,
81 'FullMask' => $defdata[0],
82 'group_id' => (int)$_GET['group_id']
95 if (!isset($_POST['group_id']) || (int)$_POST['group_id'] < 0) {
96 $this->jerr("NO GROUP");
98 if (!$this->hasPerm( 'Core.Groups','E')) { // editing groups..
99 $this->jerr("PERMISSION DENIED");
107 if (!empty($_POST['dataUpdate'])) {
108 foreach($_POST['dataUpdate'] as $id => $ac) {
110 $p = DB_DataObject::factory('core_group_right');
111 $p->group_id = (int)$_POST['group_id'];
113 $this->jerr("could not find gid:{$p->group_id} and $id");
114 continue; // errro cond.
117 $p->accessmask = $ac;
118 $p->validate(); // ensure that the basic perms can not be removed
122 if (!empty($_POST['dataAdd'])) {
123 foreach($_POST['dataAdd'] as $perm => $ac) {
124 $p = DB_DataObject::factory('core_group_right');
125 $p->group_id = (int)$_POST['group_id'];
126 $p->rightname = $perm;
127 $p->accessmask = $ac;
128 $p->validate(); // ensure that the basic perms can not be removed