public function testName() { $testName = "TEST_GROUP_2"; $this->assertEquals($this::TEST_GROUP, $this->group->getName()); $this->group->setName($testName); $this->assertEquals($testName, $this->group->getName()); }
protected function setUp() { $this->entityManager = getEntityManager(); $this->groupRepository = $this->entityManager->getRepository('AppBundle\\Entity\\Group'); $this->userRepository = $this->entityManager->getRepository('AppBundle\\Entity\\User'); $this->group = new Group(); $this->group->setName("EXAMPLE__TEST_GROUP"); $this->user = new User(); $this->user->setUsername("Mario Perez")->setUsernameCanonical(strtolower("Mario Perez"))->setEmail("*****@*****.**")->setEmailCanonical(strtolower("*****@*****.**"))->setPassword(password_hash('WowSoSecretPassword', PASSWORD_DEFAULT))->setRoles(['ROLE_MANAGER', 'ROLE_PLAYER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN'])->setEnabled(true)->setSalt("AnRandomlyGeneratedSalt")->setLocked(false)->setExpired(false)->setCredentialsExpired(false); $this->tearDown(); // Clean database (this exercise is sharing DB for all environments) }
/** * @todo Implement testDelete(). */ public function testDelete() { $this->object->setName('testgroup'); $this->object->save(); $this->object->delete(); $this->assertEquals(new Group(), new Group($this->object->getId())); }
public function createOrFindByName($sGroupName) { $oGroup = $this->filterByName($sGroupName)->findOne(); if ($oGroup === null) { $oGroup = new Group(); $oGroup->setName($sGroupName); $oGroup->save(); } return $oGroup; }
/** * 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'); } }
public function testSerialize() { $group = new Group(); $group->setName('Developers'); $user = new User(); $user->setEmail('*****@*****.**'); $user->setPassword('123456'); $user->addGroup($group); $user->save(); $userId = $user->getId(); $this->assertInternalType('int', $userId); $serialized = serialize($user); UserPeer::clearInstancePool(); $this->assertCount(0, UserPeer::$instances); $unserialized = unserialize($serialized); $fetchedUser = UserQuery::create()->findOneById($userId); $this->assertInstanceOf('FOS\\UserBundle\\Propel\\User', $unserialized); $this->assertCount(1, UserPeer::$instances); $this->assertTrue($fetchedUser->equals($unserialized)); $this->assertCount(1, $unserialized->getGroups()); }
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; }
function isArray($size) { if ($size > 0) { return 1; } return 0; } function convertRouting() { $query = "select meid as seid, rules from " . $this->sourcetable . "_module where syid=" . $this->syid . " order by meid"; if ($res = $this->importdb->selectQuery($query)) { if ($this->importdb->getNumberOfRows($res) > 0) { global $db; while ($row = $this->importdb->getRow($res)) { $rules = explode("\r\n", $row["rules"]); $cnt = 1; foreach ($rules as $rule) { $query = "replace into " . $this->targettable . "_routing (suid, seid, rgid, rule) values ("; $query .= prepareDatabaseString($this->suid) . ","; $query .= prepareDatabaseString($row["seid"]) . ","; $query .= prepareDatabaseString($cnt) . ","; $query .= "'" . prepareDatabaseString($rule) . "')"; $this->db->executeQuery($query); $cnt++; } } $query = "select * from " . $this->targettable . "_routing where suid=" . $this->suid . " and trim(rule) like 'begincombine%' order by rgid asc"; if ($res = $this->db->selectQuery($query)) { $survey = new Survey($this->suid); if ($this->db->getNumberOfRows($res) > 0) { while ($row = $this->db->getRow($res)) { $rule = trim($row["rule"]); if (contains($rule, "(")) { $line = trim(str_replace(")", "", substr($rule, strpos($rule, "(") + 1))); } if ($line == "") { $line = "shortcombinegroup"; } $query = "update " . $this->targettable . "_routing set rule='group." . $line . "' where suid=" . $this->suid . " and seid=" . $row["seid"] . " and rgid=" . $row["rgid"]; //echo $query; $this->db->executeQuery($query); /* add group */ if ($line != "") { $exgr = $survey->getGroupByName($line); if ($exgr->getGid() == "") { $group = new Group(); $group->setSuid($this->suid); $group->setName($line); $group->save(); } } } } } $query = "select * from " . $this->targettable . "_routing where suid=" . $this->suid . " and rule like 'jumpback(%' order by rgid asc"; if ($res = $this->db->selectQuery($query)) { if ($this->db->getNumberOfRows($res) > 0) { //echo 'jjjj'; while ($row = $db->getRow($res)) { $line = str_replace(")", "", substr($row["rule"], strpos($row["rule"], "(") + 1)); $query = "update " . $this->targettable . "_routing set rule='moveBackward." . $line . "' where suid=" . $this->suid . " and seid=" . $row["seid"] . " and rgid=" . $row["rgid"]; //echo $query; $this->db->executeQuery($query); } } } $query = "select * from " . $this->targettable . "_routing where suid=" . $this->suid . " and rule like 'jump(%' order by rgid asc"; if ($res = $this->db->selectQuery($query)) { if ($this->db->getNumberOfRows($res) > 0) { //echo 'aaaaj'; while ($row = $this->importdb->getRow($res)) { $line = str_replace(")", "", substr($row["rule"], strpos($row["rule"], "(") + 1)); $query = "update " . $this->targettable . "_routing set rule='moveForward." . $line . "' where suid=" . $this->suid . " and seid=" . $row["seid"] . " and rgid=" . $row["rgid"]; //echo $query; $this->db->executeQuery($query); }
/** * Finish the installation - create owner company and administrator * * @param void * @return null */ function complete_installation() { if (Companies::getOwnerCompany() instanceof Company) { die('Owner company already exists'); // Somebody is trying to access this method even if the user already exists } // if $form_data = array_var($_POST, 'form'); tpl_assign('form_data', $form_data); if (array_var($form_data, 'submited') == 'submited') { try { $admin_password = trim(array_var($form_data, 'admin_password')); $admin_password_a = trim(array_var($form_data, 'admin_password_a')); if (trim($admin_password) == '') { throw new Error(lang('password value required')); } // if if ($admin_password != $admin_password_a) { throw new Error(lang('passwords dont match')); } // if DB::beginWork(); Users::delete(); // clear users table Companies::delete(); // clear companies table // Create the administrator user $administrator = new User(); $administrator->setId(1); $administrator->setCompanyId(1); $administrator->setUsername(array_var($form_data, 'admin_username')); $administrator->setEmail(array_var($form_data, 'admin_email')); $administrator->setPassword($admin_password); $administrator->setCanEditCompanyData(true); $administrator->setCanManageConfiguration(true); $administrator->setCanManageSecurity(true); $administrator->setCanManageWorkspaces(true); $administrator->setCanManageContacts(true); $administrator->setCanManageTemplates(true); $administrator->setCanManageReports(true); $administrator->setCanManageTime(true); $administrator->setCanAddMailAccounts(true); $administrator->setAutoAssign(false); $administrator->setPersonalProjectId(1); $administrator->setType('admin'); $administrator->save(); $group = new Group(); $group->setName('administrators'); $group->setAllPermissions(true); $group->setId(Group::CONST_ADMIN_GROUP_ID); $group->save(); $group_user = new GroupUser(); $group_user->setGroupId(Group::CONST_ADMIN_GROUP_ID); $group_user->setUserId($administrator->getId()); $group_user->save(); $project = new Project(); $project->setId(1); $project->setP1(1); $project->setName(new_personal_project_name($administrator->getUsername())); $project->setDescription(lang('files')); $project->setCreatedById($administrator->getId()); $project->save(); $project_user = new ProjectUser(); $project_user->setProjectId($project->getId()); $project_user->setUserId($administrator->getId()); $project_user->setCreatedById($administrator->getId()); $project_user->setAllPermissions(true); $project_user->save(); // Create a company $company = new Company(); $company->setId(1); $company->setClientOfId(0); $company->setName(array_var($form_data, 'company_name')); $company->setCreatedById(1); $company->save(); DB::commit(); $this->redirectTo('access', 'login'); } catch (Exception $e) { tpl_assign('error', $e); DB::rollback(); } // try } // if }
require_once "lib/lworm/ModelGenerator.class.php"; require_once "lib/lworm/mysql/MySQLDataStoreFactory.class.php"; $mg = new ModelGenerator(); $mg->generateModel('test.yaml', 'model'); require_once "model/User.class.php"; require_once "model/Role.class.php"; require_once "model/Group.class.php"; $ds = MySQLDataStoreFactory::getDataStore('localhost', 'lworm', 'root', ''); $ds->createSchema('test.yaml'); // many-to-many $user = new User(); $user->setName('Test User'); $ds->save($user); /* $role = new Role; $role->setName('Test Role'); $ds->save($role); $roles = $user->getRolesRelation($ds); $roles->addEntity($role); //$roles->removeEntity($role); var_dump($roles->getEntities()); */ // many-to-one $group = new Group(); $group->setName("Test group"); $ds->save($group); $user->getGroupRelation($ds)->setEntity($group); var_dump($user->getGroupRelation($ds)->getEntity()); // one-to-many var_dump($group->getUsersRelation($ds)->getEntities());
/** * Get array of all own groups. * * @return array of \Newsletter2Go\Group */ public function getGroups() { $groupsarray = array(); $groups = $this->handleGetRequest('/de/api/get/groups/', null); foreach ($groups as $key => $val) { $grp = new Group(); $grp->setId($key); $grp->setName($val); $groupsarray[] = $grp; } return $groupsarray; }
function showEditGroupGeneralRes() { $displaySysAdmin = new DisplaySysAdmin(); $survey = new Survey($_SESSION['SUID']); $gid = getFromSessionParams('gid'); $_SESSION['GID'] = $gid; $content = ""; if ($gid != '') { //edit $group = $survey->getGroup($gid); $content = $displaySysAdmin->displaySuccess(Language::messageGroupChanged(loadvar(SETTING_GROUP_NAME))); } else { //add group! if (loadvar(SETTING_GROUP_NAME) != "") { $group = new Group(); $group->setSuid($_SESSION['SUID']); $_SESSION['GID'] = $group->getGid(); $content = $displaySysAdmin->displaySuccess(Language::messageGroupAdded(loadvar(SETTING_GROUP_NAME))); } } $checker = new Checker($_SESSION['SUID']); if ($gid == '') { $checks = $checker->checkName(loadvar(SETTING_GROUP_NAME)); if (sizeof($checks) > 0) { $content = implode("<br/>", $checks); return $this->showAddGroup($content); } } /* ADD ALL SORTS OF CHECKS!! */ if ($gid != '' || loadvar(SETTING_GROUP_NAME) != "") { $group->setName(trim(loadvar(SETTING_GROUP_NAME))); $group->setTemplate(loadvar(SETTING_GROUP_TEMPLATE)); if (loadvar(SETTING_GROUP_TEMPLATE) == TABLE_TEMPLATE_CUSTOM) { $group->setCustomTemplate(loadvarAllowHTML(SETTING_GROUP_CUSTOM_TEMPLATE)); } else { $group->setCustomTemplate(""); } if (Config::xiExtension()) { $group->setXiTemplate(loadvar(SETTING_GROUP_XI_TEMPLATE)); } $group->save(); $checker = new Checker($_SESSION['SUID']); $checks = $checker->checkGroup($group); if (sizeof($checks) > 0) { $content .= $displaySysAdmin->displayError(implode("<br/>", $checks)); } } /* compile */ $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey)); $mess = $compiler->generateGroups(array($group)); if (loadvar(SETTING_GROUP_TEMPLATE) == TABLE_TEMPLATE_CUSTOM) { $mess = $compiler->generateGetFillsGroups(array($group)); $mess = $compiler->generateInlineFieldsGroups(array($group)); } /* update last page */ $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res")); if ($gid != '') { return $displaySysAdmin->showEditGroup($_SESSION['GID'], $content); } else { return $this->showSection($content); } }
/** * @brief Creates a group, which will by filled bei actions * * @param $name The name of that group * @return Cmsable\Action\Group **/ public function createGroup($name = 'default') { $group = new Group(); $group->setName($name); return $group; }
function addSubGroup($function, &$node, $instruction) { if ($this->fillclass == true) { return; } if ($this->checkclass == true) { return; } $rule = trim($instruction->getRule()); $rgid = trim($instruction->getRgid()); $endrgid = $this->findEndSubGroup($rgid); if ($endrgid == "") { //$this->addErrorMessage(Language::errorGroupMissingEndSubGroup()); return; } $group = explode(".", $rule); if (sizeof($group) < 2 || trim($group[1]) == "") { $this->addErrorMessage(Language::errorGroupTemplateNotFound()); return; } $this->groups[] = $rgid; $this->groupsend[] = $endrgid; $groupactions = $this->findStatementsInSubGroup($rgid); //print_r($groupactions); /* add these sub group actions to the top group, so we know they are part of the group structure! */ $current = $this->groupactions[end($this->realgroups)]; $this->groupactions[end($this->realgroups)] = array_merge($current, $groupactions); $this->groupactions[$this->groups[sizeof($this->groups) - 1]] = $groupactions; // add sub group function $subgroupfunctionnode = $this->factory->method($function); $subgroupfunctionnode->makePrivate(); // determine group $groupnode = new PHPParser_Node_Scalar_String(trim($group[1])); // get group actions and add statement $args[] = new PHPParser_Node_Arg(new PHPParser_Node_Scalar_String(implode("~", $groupactions))); $args[] = new PHPParser_Node_Arg($groupnode); $stmt = new PHPParser_Node_Stmt_Return(new PHPParser_Node_Expr_MethodCall(new PHPParser_Node_Expr_Variable(VARIABLE_THIS), new PHPParser_Node_Name(array(FUNCTION_DO_SUBGROUP)), $args)); $subgroupfunctionnode->addStmt($stmt); /* add subgroup doAction */ $node->addStmt($subgroupfunctionnode); // add group to db if not exists yet if (substr(trim($group[1]), 0, 1) != INDICATOR_FILL) { $gr = $this->survey->getGroupByName(trim($group[1])); if ($gr->getName() == "") { $gr = new Group(); $gr->setSuid($this->suid); $gr->setName(trim($group[1])); $gr->setType(GROUP_SUB); $gr->save(); } } // update overall counter $this->cnt = $rgid; // back to beginning of subgroup so we add any subquestions! }
/** * Edite le nom d'un groupe * @return int $state * @param int $id_group * @param String $name */ public function editGroupName($id_group, $name_group) { $Group = new Group($id_group); if ($Group->getState() == 1) { $Group->setName(html_entity_decode($name_group)); } return $Group->getState(); }
require_once "model/Role.class.php"; $ds = GAEDataStoreFactory::getDataStore(); // insert $user = new User(); $user->setName("test"); $ds->save($user); // update $user->setPassword("test"); $ds->save($user); //var_dump($user); // read $user2 = $ds->getEntity(User, $user->getId()); //var_dump($user2); // many to one $group = new Group(); $group->setName("test"); $ds->save($group); $user->getGroupRelation($ds)->setEntity($group); $user = new User(); $user->setName("test 2"); $ds->save($user); $user->getGroupRelation($ds)->setEntity($group); //var_dump($user->getGroupRelation($ds)->getEntity($group)); // one to many //var_dump($group->getUsersRelation($ds)->getEntities()); // many to many $role = new Role(); $role->setName('Test Role 1'); $ds->save($role); $user->getRolesRelation($ds)->addEntity($role); $role = new Role();
public static function getAddEditForm($target = '/admin/User') { $form = new Form('group_addedit', 'POST', $target, '', array('class' => 'admin')); if (@$_REQUEST['id']) { $group = new Group($_REQUEST['id']); $form->setConstants(array('id' => $_REQUEST['id'])); $form->addElement('hidden', 'id'); } else { $group = new Group(); } $form->setConstants(array('section' => 'groupsaddedit')); $form->addElement('hidden', 'section'); $form->addElement('text', 'name', 'Group Name'); $form->addElement('submit', 'submit', 'Save'); $form->addElement('reset', 'cancel', 'Cancel'); $defaultValues['name'] = $group->getName(); $form->setDefaults($defaultValues); if ($form->validate() && isset($_REQUEST['submit'])) { $group->setName($_REQUEST['name']); $group->save(); } return $form; }
/** * @covers AppBundle\Entity\Group::setName * Implement testSetName(). */ public function testSetName() { $this->group->setName("Group2"); $this->assertEquals("Group2", $this->group->getName()); }