/** * @param string $title * @return ISecurityGroup */ public function buildSecurityGroup($title) { $g = new Group(); $g->setTitle($title); $g->setDescription($title); $g->setSlug(str_replace(' ', '-', strtolower($title))); return $g; }
function doUp() { global $database; $members = array(1368, 270, 9202); // EdgarMagana, JonProulx, ShillaSaebi $group = new Group(); $group->setTitle('User Committee'); $group->setDescription('User Committee'); $group->setSlug('user-committee'); $group->write(); $group->Members()->setByIDList($members); }
/** * Create a new group * @return void */ private function createGroup() { if (isset($_POST) && is_array($_POST) && count($_POST) > 0) { require_once FRAMEWORK_PATH . 'models/group.php'; $group = new Group($this->registry, 0); $group->setCreator($this->registry->getObject('authenticate')->getUser()->getUserID()); $group->setName($this->registry->getObject('db')->sanitizeData($_POST['name'])); $group->setDescription($this->registry->getObject('db')->sanitizeData($_POST['description'])); $group->setType($_POST['type']); $group->save(); $this->registry->errorPage('Group created', 'Thank you, your new group has been created'); } else { $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'groups/create.tpl.php', 'footer.tpl.php'); } }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = DataObject::get_one("Migration", "Name='{$this->title}'"); if (!$migration) { $g = new Group(); $g->setTitle('Community Members'); $g->setDescription('Community Members'); $g->setSlug(IFoundationMember::CommunityMemberGroupSlug); $g->write(); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); if (!$migration) { $g = new Group(); $g->setTitle('CCLA Admin'); $g->setDescription('Company CCLA Admin'); $g->setSlug(ICLAMemberDecorator::CCLAGroupSlug); $g->write(); Permission::grant($g->getIdentifier(), ICLAMemberDecorator::CCLAPermissionSlug); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
protected function body() { $inputs = array('lecture' => 'isIndex', 'name' => 'isNotEmpty', 'description' => array()); if (!$this->isInputValid($inputs)) { return false; } $lectureIndex = $this->getParams('lecture'); $groupName = $this->getParams('name'); $groupDescription = $this->getParams('description'); $public = $this->paramExists('public') ? 'public' : 'private'; $groupId = $this->getParams('id'); $editing = $groupId !== null && $groupId !== ''; $user = User::instance(); /** @var \Lecture $lecture */ $lecture = Repositories::findEntity(Repositories::Lecture, $lectureIndex); if ($editing) { /** * @var $group \Group */ $group = Repositories::findEntity(Repositories::Group, $groupId); $group->setName($groupName); $group->setDescription($groupDescription); $group->setType($public); Repositories::persistAndFlush($group); } else { if (!$this->userHasPrivileges(User::groupsAdd)) { return $this->death(StringID::InsufficientPrivileges); } $group = new \Group(); $group->setDeleted(false); $group->setDescription($groupDescription); $group->setLecture($lecture); $group->setName($groupName); $group->setOwner($user->getEntity()); $group->setType($public); Repositories::persistAndFlush($group); } return true; }
function find($criteria = null, $order = null, $limit = 1000, $from = 0) { $result = $this->database->query($this->buildFindQuery($criteria, $order, $limit, $from)); if (!is_null($result->getError())) { return $result->getError(); } $groups = array(); while ($row = $result->fetchRow()) { $group = new Group(); $value = $row[0]; $group->setId($value); $value = $row[1]; $group->setOwner($value); $value = $row[2]; $group->setName($value); $value = $row[3]; $group->setDescription($value); $value = $row[4]; $group->setPeriod_from($value); $value = $row[5]; $group->setPeriod_to($value); $value = $row[6]; $group->setProjects($value); $value = $row[7]; $group->setR_date($value); $value = $row[8]; $group->setR_user($value); if ($order != null) { array_push($groups, $group); } else { $groups[$group->getId()] = $group; } } return $groups; }
function actionSaveGroup($currentUser) { $backUrl = $this->context->getFlowScopeAttr("backUrl"); $group = new Group(); $groupErrs = array(); $group->setId($this->context->getRequestAttr("id")); $group->setName($this->context->getRequestAttr("name")); if (!is_null($group->getName())) { $group->setName(trim($group->getName())); if (strlen($group->getName()) < 1) { $group->setName(null); } } if (is_null($group->getName())) { $groupErrs["name"] = "field.error.empty"; } $group->setDescription($this->context->getRequestAttr("description")); if (!is_null($group->getDescription())) { $group->setDescription(trim($group->getDescription())); if (strlen($group->getDescription()) < 1) { $group->setDescription(null); } } $projects = $this->context->getRequestAttr("projects"); if (!is_null($projects)) { $projects = json_encode($projects); $group->setProjects($projects); } else { $group->setProjects(json_encode(array())); } $timeZone = new DateTimeZone("Europe/Vilnius"); $time = new DateTime("now", $timeZone); $group->setOwner($currentUser->getId()); $group->setR_date($time->format("Y-m-d H:i:s")); $group->setR_user($currentUser->getId()); $this->context->setFlashScopeAttr("group", $group); $this->context->setFlashScopeAttr("groupErrs", $groupErrs); if (count($groupErrs) >= 1) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $store = $this->storeGroup($group); if (!$store) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $this->context->setRequestScopeAttr("success", "groups.success.stored"); $this->context->setFlashScopeAttr("viewGroup", $group); $this->cancelGroupEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; }