function initAll() { global $facade, $objects, $perms, $USERS, $GROUPS; initUsers(); foreach (qw2('1,1 3,1 3,2 4,2') as $r) { list($u, $g) = explode(',', $r); M('Account')->loadGroupById($GROUPS[$g])->addUserToGroup(M('Account')->loadUserById($USERS[$u])); } # init accesses $facade->changePermission($objects[1], array(qw2("grant " . PERM_TARGET_OWNER . " ALL"), qw2("grant {$GROUPS['1']} READ|WRITE"), qw2("grant {$GROUPS['1']} GRANT"), qw2("grant {$GROUPS['2']} READ"), qw2("grant {$GROUPS['2']} WRITE|GRANT"), qw2("password {$GROUPS['2']} pass2"), qw2('revoke ' . PERM_TARGET_OTHER . ' ALL'))); return; }
if (!$newTabSet) { $errMsg[] = "Error: Problem creating table 'settings' in calendar {$calID}"; break; } } else { $tabExist++; $newTabSet = ''; } //insert initial data in cat, user and settings tables $catSaved = initCats(); if (!$catSaved) { $errMsg[] = "Error: Problem writing to database table 'categories' in calendar {$calID}."; break; } $adPwMd5 = md5($adPwrd); $usrSaved = initUsers($adName, $adMail, $adPwMd5); if (!$usrSaved) { $errMsg[] = "Error: Problem writing to database table 'users' in calendar {$calID}."; break; } $grpSaved = initGroups(); if (!$grpSaved) { $errMsg[] = "Error: Problem writing to database table 'groups' in calendar {$calID}."; break; } $setSaved = true; //init if ($newTabSet) { //insert default settings $dbSet = array(); $dbSet['calendarTitle'] = $calTitle;
# ok, ok. It must be placed in mapper, but we don't have one... M('Db')->exec("UPDATE t_myobject SET access_id = ?, access_inherit = ? WHERE id = ?", $this->access_id, $this->access_inherit, $this->id); } public function getParent() { return $this->_storage->loadObjectById($this->parent_id); } public function getChildren() { return $this->_storage->getObjectList()->filter('parent_id = ?', $this->id); } public function _getOwnerId() { global $USERS; return $USERS[2]; # owner always is user "2" } } $storage = M('Store')->storage(array('table' => 't_myobject', 'props' => qw2('id parent_id val access_id access_inherit'), 'keys' => qw2('id'), 'auto-id-prop' => 'id', 'class' => 'MyObject')); initUsers(); $objects = array(NULL); foreach (array(qw2('val>a'), qw2('val>b parent_id>1 access_inherit>1'), qw2('val>c parent_id>1 access_inherit>1'), qw2('val>d parent_id>3 access_inherit>1'), qw2('val>e parent_id>3 access_inherit>1'), qw2('val>f parent_id>5 access_inherit>1'), qw2('val>g parent_id>5 access_inherit>1')) as $i) { M('Permission')->initObject($objects[] = $storage->createObject($i))->save(); } # Load ALL $perms = array(NULL); foreach ($objects as $o) { if ($o) { $perms[] = M('Permission')->getPermission($o); } }