Exemplo n.º 1
0
 /**
  * add default users and groups
  * @return void
  */
 protected function setupUsersGroups()
 {
     $groups = array('Administrators', 'Lawyers');
     foreach ($groups as $group) {
         echo "creating group '{$group}' .. ";
         $id = DM\Group::getIdByName($group);
         if (empty($id)) {
             DM\Group::create(array('name' => $group));
         }
         echo "ok\n";
     }
 }
Exemplo n.º 2
0
 /**
  * Create a security group
  *
  * @returns group properties
  */
 public function createUserGroup($p)
 {
     $p['success'] = true;
     if (!Security::canAddGroup()) {
         throw new \Exception(L\get('Access_denied'));
     }
     $p['data']['name'] = trim(strip_tags($p['data']['name']));
     // check if group with that name already exists
     $id = DM\Group::getIdByName($p['data']['name']);
     if (!empty($id)) {
         trigger_error(L\get('Group_exists') . ' "' . $p['data']['name'] . '"', E_USER_ERROR);
     }
     //create group
     $name = $p['data']['name'];
     $p['data']['id'] = DM\Group::create(array('name' => $name, 'cid' => User::getId()));
     return $p;
 }