function setUpGroups($lang) { if (!file_exists(GROUP_FILE_LOCATION)) { $aGroupDB = new Groups(); $aGroupDB->setFileName(GROUP_FILE_LOCATION); $names = ImageTypes::getMenuNames(); foreach ($names as $name) { $aGroup = new Group(); $aGroup->setType($lang[$name]); $aGroup->setGroupImage($name); $aGroup->rebuildElementLine(); $aGroupDB->addElement($aGroup); } $aGroupDB->save(); } else { // validate we have all the default groups $addedElement = false; $aGroupDB = new Groups(GROUP_FILE_LOCATION); $names = ImageTypes::getMenuNames(); foreach ($names as $name) { if ($aGroupDB->getAGroup($name) == "") { $aGroup = new Group(); $aGroup->setType($lang[$name]); $aGroup->setGroupImage($name); $aGroup->rebuildElementLine(); $aGroupDB->addElement($aGroup); $addedElement = true; } } if ($addedElement) { $aGroupDB->save(); } } }
/** * 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 getSessionVar() { $sessionVar = []; $sql_select = "SELECT sessionName, varName, varValue, LastUpdate\n FROM sessionvar"; $stmt = $conn->query($sql_select); $returnedList = $stmt->fetchAll(); if (count($returnedList) > 0) { foreach ($returnedList as $group) { $curGroup = new Group($group['group_name']); $curGroup->setID($group['groupid']); $curGroup->setType($group['group_type']); $curGroup->setWeb($group['group_web']); $listOfGroups[] = $curGroup; } } return $listOfGroups; }
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 &getTypedGroups($reload = false) { if (isset($this->typedGroups) && !$reload) { if ($this->typedGroups->hasFileChanged()) { $reload = true; } } if (!isset($this->typedGroups) || $reload) { $_SESSION['load_count'] += 1; $groupsinstance = new Groups(); $names = ImageTypes::getModuleNames(); foreach ($names as $name) { $aGroup = new Group(); $aGroup->setType($this->lang[$name]); $aGroup->setGroupImage($name); $aGroup->rebuildElementLine(); $groupsinstance->addElement($aGroup); } $this->typedGroups =& $groupsinstance; } return $this->typedGroups; }
/** * @param $type */ private function createImplicitGroup($type) { $group = new Group(); $group->setType($type); $group->addItem(array_pop($this->items)); $group->fromString(substr($this->expression, $this->parsePos), $this->value, $this->expressionClass); $this->items[] = $group; $this->parsePos = strlen($this->expression); }
case "show": $groupings[$_GET['line']]->setVisible(true); $groupings[$_GET["line"]]->rebuildElementLine(); $mustSave = true; break; case "edit": $tpl_edit = new Template(TPL_FILE_LOCATION . 'groups_edit.tpl'); $tpl_edit->set('lang', $lang); $tpl_edit->set('theGroup', $groupings[$_GET['line']]); $tpl_edit->set('imagenames', $thenamelist); $tpl_edit->set('config', $config); $tpl_body->set('form', $tpl_edit); break; case "add": $aGroup = new Group(); $aGroup->setType(trim($_POST["groupname"])); $aGroup->setGroupImage(trim($_POST["imagename"])); $aGroup->setVisible(true); $aGroup->rebuildElementLine(); $groups->addElement($aGroup); $mustSave = true; break; case "save": $groupings[$_POST["line"]]->setType(trim($_POST["groupname"])); $groupings[$_POST["line"]]->setGroupImage(trim($_POST["imagename"])); $groupings[$_POST["line"]]->rebuildElementLine(); $mustSave = true; break; case "del": $groups->deleteElement($_GET["line"]); $mustSave = true;
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! }
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Add Group</title> </head> <body> <form class="" action="add-group.php" method="post"> Group Name: <input type="text" name="group_name" value=""><br> Group Type: <input type="text" name="group_type" value=""><br> Website: <input type="text" name="group_web" value=""><br> <input type="submit" name="name" value="submit"> </form> </body> </html> <?php require 'conntodb.php'; include 'group-class.php'; if (!empty($_POST)) { $group = new Group($_POST['group_name']); $group->setType($_POST['group_type']); $group->setWeb($_POST['group_web']); $group->addToGroupTbl($conn); }
public static function retrieveGroupList($conn) { $listOfGroups; $sql_select = "SELECT groupid, group_name, group_type, group_web, marked_for_deletion\n FROM group_tbl\n ORDER BY group_type"; $stmt = $conn->query($sql_select); $returnedList = $stmt->fetchAll(); if (count($returnedList) > 0) { foreach ($returnedList as $group) { if ($group['marked_for_deletion'] == true) { continue; } $curGroup = new Group($group['group_name']); $curGroup->setID($group['groupid']); $curGroup->setType($group['group_type']); $curGroup->setWeb($group['group_web']); $listOfGroups[] = $curGroup; } } return $listOfGroups; }