public function delete(PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($this->isDefaultGroup()) { throw new sfException('Cannot remove default group (ID ' . $this->id . ')!'); return false; } /* * get default group * */ $default_group = sfGuardGroupPeer::getDefaultGroup(); //get default group /* * check if servers has this group * If servers found remove reference to group to be deleted */ $con->beginTransaction(); try { //select from... $c1 = new Criteria(); $c1->add(EtvaServerPeer::SF_GUARD_GROUP_ID, $this->getId()); //update set $c2 = new Criteria(); $c2->add(EtvaServerPeer::SF_GUARD_GROUP_ID, $default_group->getId()); BasePeer::doUpdate($c1, $c2, $con); parent::delete($con); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } }
/** *Returns all roles (groups) $user_id has, excepting current one $current_role * */ public static function retrieveForUserWithoutCurrentRole($current_role, $user_id) { $c = new Criteria(); $c->add(self::USER_ID, $user_id); $c->addJoin(self::GROUP_ID, sfGuardGroupPeer::ID); $c->add(sfGuardGroupPeer::NAME, $current_role, Criteria::NOT_EQUAL); return sfGuardGroupPeer::doSelect($c); }
public function executeDelete(sfWebRequest $request) { if (!sfGuardGroupPeer::canBeDeleted($request->getParameter('id'))) { $this->getUser()->setFlash('error', 'No se puede borrar el grupo seleccionado. Existen usuarios asociados al grupo.'); $this->redirect('@sf_guard_group'); } return parent::executeDelete($request); }
public function getsfGuardGroup($con = null) { if ($this->asfGuardGroup === null && $this->group_id !== null) { include_once 'plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroupPeer.php'; $this->asfGuardGroup = sfGuardGroupPeer::retrieveByPK($this->group_id, $con); } return $this->asfGuardGroup; }
/** * Get the associated sfGuardGroup object * * @param PropelPDO Optional Connection object. * @return sfGuardGroup The associated sfGuardGroup object. * @throws PropelException */ public function getsfGuardGroup(PropelPDO $con = null) { if ($this->asfGuardGroup === null && $this->group_id !== null) { $this->asfGuardGroup = sfGuardGroupPeer::retrieveByPk($this->group_id); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->asfGuardGroup->addsfGuardUserGroups($this); */ } return $this->asfGuardGroup; }
/** * Check if a group exists given to an id. * @param Int $group_id * @return Boolean */ public static function groupExists($id) { return sfGuardGroupPeer::retrieveByPK($id) ? true : false; }
public function executeJsonImport(sfWebRequest $request) { $nid = $request->getParameter('nid'); $import_data = json_decode($request->getParameter('import'), true); $server = $import_data; $vnc_keymap = EtvaSettingPeer::retrieveByPk('vnc_keymap'); $server['vnc_keymap'] = $vnc_keymap->getValue(); $server['uuid'] = EtvaServerPeer::generateUUID(); $server['name'] = $import_data['name']; $server['vm_type'] = $import_data['vm_type']; $server['ip'] = '000.000.000.000'; $server['boot'] = 'filesystem'; $import_data['uuid'] = $server['uuid']; $import_data['vnc_keymap'] = $server['vnc_keymap']; // import validation check $result = $this->jsonImportCheck($request); if (!$result['success']) { // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($result); } // if is browser request return text renderer $error = $this->setJsonError($result); return $this->renderText($error); } if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) { $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid)); $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n); //notify event log $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_); $message = Etva::getLogMessage(array('info' => $node_log), OvfEnvelope_VA::_ERR_IMPORT_); $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($error); } // if is browser request return text renderer $error = $this->setJsonError($error); return $this->renderText($error); } $disks = $import_data['disks']; $collVgs = array(); foreach ($disks as $id => $info) { $vg = $info['vg']; $lv = $info['lv']; if ($etva_lv = $etva_node->retrieveLogicalvolumeByLv($lv)) { $msg_type = $is_DiskFile ? EtvaLogicalvolumePeer::_ERR_DISK_EXIST_ : EtvaLogicalvolumePeer::_ERR_LV_EXIST_; $msg = Etva::getLogMessage(array('name' => $lv), $msg_type); $msg_i18n = $this->getContext()->getI18N()->__($msg_type, array('%name%' => $lv)); $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n); //notify system log $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_); $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($error); } // if is browser request return text renderer $error = $this->setJsonError($error); return $this->renderText($error); } if (!($etva_vg = $etva_node->retrieveVolumegroupByVg($vg))) { $msg = Etva::getLogMessage(array('name' => $vg), EtvaVolumegroupPeer::_ERR_NOTFOUND_); $msg_i18n = $this->getContext()->getI18N()->__(EtvaVolumegroupPeer::_ERR_NOTFOUND_, array('%name%' => $vg)); $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n); //notify system log $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_); $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($error); } // if is browser request return text renderer $error = $this->setJsonError($error); return $this->renderText($error); } // fix lv path $is_DiskFile = $vg == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0; $import_data['disks'][$id]['lv'] = $is_DiskFile ? $etva_node->getStoragedir() . '/' . $lv : $lv; $collVgs[$vg] = $etva_vg; } $networks = $import_data['networks']; $networks_va = $import_data['networks']; $collNetworks = array(); $i = 0; // check if networks are available foreach ($networks as $network) { if ($etva_vlan = EtvaVlanPeer::retrieveByPk($network['vlan_id'])) { $import_data['networks'][$i]['network'] = $etva_vlan->getName(); $import_data['networks'][$i]['macaddr'] = $network['mac']; } $etva_mac = EtvaMacPeer::retrieveByMac($network['mac']); /* * TODO improve this to add Mac Address to the pool */ if (!$etva_mac || !$etva_vlan) { $msg = Etva::getLogMessage(array(), EtvaNetworkPeer::_ERR_); $msg_i18n = $this->getContext()->getI18N()->__(EtvaNetworkPeer::_ERR_, array()); if (!$etva_mac) { $msg = Etva::getLogMessage(array('%mac%' => $network['mac']), EtvaMacPeer::_ERR_INVALID_MAC_); $msg_i18n = $this->getContext()->getI18N()->__(EtvaMacPeer::_ERR_INVALID_MAC_, array('%mac%' => $network['mac'])); } $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n); //notify event log $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_); $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($error); } // if is browser request return text renderer $error = $this->setJsonError($error); return $this->renderText($error); } if ($etva_mac->getInUse()) { $msg = Etva::getLogMessage(array('%name%' => $etva_mac->getMac()), EtvaMacPeer::_ERR_ASSIGNED_); $msg_i18n = $this->getContext()->getI18N()->__(EtvaMacPeer::_ERR_ASSIGNED_, array('%name%' => $etva_mac->getMac())); $error = array('success' => false, 'agent' => $etva_node->getName(), 'info' => $msg_i18n, 'error' => $msg_i18n); //notify event log $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_); $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($error); } // if is browser request return text renderer $error = $this->setJsonError($error); return $this->renderText($error); } $etva_network = new EtvaNetwork(); $etva_network->fromArray($network, BasePeer::TYPE_FIELDNAME); $collNetworks[] = $etva_network; $i++; } $env = new OvfEnvelope_VA(); $env->fromArray($import_data); /* get server copy VA server representation */ $params = $env->_VA(); $method = 'vm_ovf_import_may_fork'; $response = $etva_node->soapSend($method, $params); if (!$response['success']) { $error_decoded = $response['error']; $result = $response; $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_ERR_CREATE_, array('%name%' => $server['name'], '%info%' => $error_decoded)); $result['error'] = $msg_i18n; //notify event log $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $response['info']), EtvaServerPeer::_ERR_CREATE_); $this->dispatcher->notify(new sfEvent($response['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); if (sfConfig::get('sf_environment') == 'soap') { return json_encode($result); } $return = $this->setJsonError($result); return $this->renderText($return); } $response_decoded = (array) $response['response']; $returned_object = (array) $response_decoded['_obj_']; $returned_lvs = (array) $returned_object['LVS']; $collLvs = array(); foreach ($returned_lvs as $disk) { $disk_array = (array) $disk; $vg_info = (array) $disk_array[EtvaLogicalvolume::VOLUMEGROUP_MAP]; $vg = $vg_info[EtvaVolumegroup::VG_MAP]; $fake_lv_response = array('success' => true, 'response' => array('_obj_' => $disk_array)); // create logical volume $etva_lv = new EtvaLogicalvolume(); $etva_lv->setEtvaVolumegroup($collVgs[$vg]); $lv_va = new EtvaLogicalvolume_VA($etva_lv); $lv_response = $lv_va->processResponse($etva_node, $fake_lv_response, 'lvcreate'); if (!$lv_response['success']) { $return = $this->setJsonError($lv_response); return $this->renderText($return); } $collLvs[] = $etva_lv; } $etva_server = new EtvaServer(); $etva_server->fromArray($server, BasePeer::TYPE_FIELDNAME); $user_groups = $this->getUser()->getGroups(); $server_sfgroup = array_shift($user_groups); //if user has group then put one of them otherwise put DEFAULT GROUP ID if ($server_sfgroup) { $etva_server->setsfGuardGroup($server_sfgroup); } else { $etva_server->setsfGuardGroup(sfGuardGroupPeer::getDefaultGroup()); } foreach ($collNetworks as $coll) { $etva_server->addEtvaNetwork($coll); } $i = 0; foreach ($collLvs as $coll) { $server_disk = new EtvaServerLogical(); $server_disk->setEtvaLogicalvolume($coll); $server_disk->setBootDisk($i); $etva_server->addEtvaServerLogical($server_disk); $i++; } //update some data from agent response $vm = (array) $returned_object['VM']; $etva_server->initData($vm); //$etva_server->setEtvaNode($etva_node); $etva_server->setEtvaCluster($etva_node->getEtvaCluster()); try { $etva_server->save(); } catch (Exception $e) { $msg = $e->getMessage(); $result = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg, 'info' => $msg); $return = $this->setJsonError($result); return $this->renderText($return); } // assign To etva_node $etva_server->assignTo($etva_node); $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_OK_CREATE_, array('%name%' => $server['name'])); $message = Etva::getLogMessage(array('name' => $server['name']), EtvaServerPeer::_OK_CREATE_); $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message))); $result = array('success' => true, 'agent' => $response['agent'], 'insert_id' => $etva_server->getId(), 'response' => $msg_i18n); $return = json_encode($result); $this->getResponse()->setHttpHeader('Content-type', 'application/json'); // if is browser request return text renderer return $this->renderText($return); }
public function executeView(sfWebRequest $request) { // get default Group ID to mark as cannot delete $this->defaultGroupID = sfGuardGroupPeer::getDefaultGroup()->getId(); }
public function buildServer($method) { $etva_server = $this->etva_server; if ($method == self::SERVER_CREATE) { $etva_server->setUuid(EtvaServerPeer::generateUUID()); $vnc_keymap = EtvaSettingPeer::retrieveByPk('vnc_keymap'); $etva_server->setVncKeymap($vnc_keymap->getValue()); $user_groups = sfContext::getInstance()->getUser()->getGroups(); $server_sfgroup = array_shift($user_groups); //if user has group then put one of them otherwise put DEFAULT GROUP ID if ($server_sfgroup) { $etva_server->setsfGuardGroup($server_sfgroup); } else { $etva_server->setsfGuardGroup(sfGuardGroupPeer::getDefaultGroup()); } } foreach ($this->collNetworks as $coll) { $etva_server->addEtvaNetwork($coll); } foreach ($this->collDisks as $coll) { $etva_server->addEtvaServerLogical($coll); } if (isset($this->collDevices)) { $str = json_encode($this->collDevices); $etva_server->setDevices($str); } }
/** * Selects a collection of sfGuardUserGroup objects pre-filled with all related objects except sfGuardUser. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of sfGuardUserGroup objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptsfGuardUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } sfGuardUserGroupPeer::addSelectColumns($criteria); $startcol2 = sfGuardUserGroupPeer::NUM_COLUMNS - sfGuardUserGroupPeer::NUM_LAZY_LOAD_COLUMNS; sfGuardGroupPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (sfGuardGroupPeer::NUM_COLUMNS - sfGuardGroupPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(sfGuardUserGroupPeer::GROUP_ID, sfGuardGroupPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BasesfGuardUserGroupPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = sfGuardUserGroupPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = sfGuardUserGroupPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = sfGuardUserGroupPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); sfGuardUserGroupPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined sfGuardGroup rows $key2 = sfGuardGroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = sfGuardGroupPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = sfGuardGroupPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); sfGuardGroupPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (sfGuardUserGroup) to the collection in $obj2 (sfGuardGroup) $obj2->addsfGuardUserGroup($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public function executeEditWin(sfWebRequest $request) { $this->sf_guard_group = sfGuardGroupPeer::retrieveByPK($request->getParameter('id')); $this->form = $this->configuration->getForm($this->sf_guard_group); //die ('$request->getParameter(id): '.$request->getParameter('id')); }
<?php // TBB (tom@punkave.com): filters by group. $groups = sfGuardGroupPeer::doSelect(new Criteria()); $fgroups = isset($filters['groups']) ? $filters['groups'] : array(); ?> <span class="groups_filter"> <?php foreach ($groups as $group) { ?> <div class="groups_filter_group"> <?php echo checkbox_tag('filters[groups][]', $group->getId(), in_array($group->getId(), $fgroups)); ?> <span class="groups_filter_group_label"> <?php echo $group->getName(); ?> </span> </div> <?php } ?> </span>
public function executeView(sfWebRequest $request) { //used to make soap requests to node VirtAgent $this->node_id = $request->getParameter('id'); // used to get parent id component (extjs) $this->containerId = $request->getParameter('containerId'); // used to build node grid dynamic $this->node_tableMap = EtvaNodePeer::getTableMap(); //maybe deprecated //used to build form to create new server with default values $this->server_form = new EtvaServerForm(); // used to build server grid dynamic $this->server_tableMap = EtvaServerPeer::getTableMap(); $this->sfGuardGroup_tableMap = sfGuardGroupPeer::getTableMap(); }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return sfGuardGroup A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { $sql = 'SELECT `ID`, `NAME`, `DESCRIPTION` FROM `sf_guard_group` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new sfGuardGroup(); $obj->hydrate($row); sfGuardGroupPeer::addInstanceToPool($obj, (string) $row[0]); } $stmt->closeCursor(); return $obj; }
public static function doSelectJoinAllExceptsfGuardPermission(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } sfGuardGroupPermissionPeer::addSelectColumns($c); $startcol2 = sfGuardGroupPermissionPeer::NUM_COLUMNS - sfGuardGroupPermissionPeer::NUM_LAZY_LOAD_COLUMNS + 1; sfGuardGroupPeer::addSelectColumns($c); $startcol3 = $startcol2 + sfGuardGroupPeer::NUM_COLUMNS; $c->addJoin(sfGuardGroupPermissionPeer::GROUP_ID, sfGuardGroupPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = sfGuardGroupPermissionPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = sfGuardGroupPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getsfGuardGroup(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addsfGuardGroupPermission($obj1); break; } } if ($newObject) { $obj2->initsfGuardGroupPermissions(); $obj2->addsfGuardGroupPermission($obj1); } $results[] = $obj1; } return $results; }
/** * Chooses a role from the groups the user is in, right after the last one logs in. * */ public function loginRole() { $c = new Criteria(); $c->add(sfGuardUserGroupPeer::USER_ID, $this->getGuardUser()->getId(), Criteria::EQUAL); $c->addJoin(sfGuardGroupPeer::ID, sfGuardUserGroupPeer::GROUP_ID); $role = sfGuardGroupPeer::doSelectOne($c); if ($role) { if ($this->isPreceptor()) { $this->setLoginRole('Preceptor'); } else { $this->setLoginRole($role->getName()); } } }
public function addGroupByName($name, $con = null) { $group = sfGuardGroupPeer::retrieveByName($name); if (!$group) { throw new Exception(sprintf('The group "%s" does not exist.', $name)); } $ug = new sfGuardUserGroup(); $ug->setsfGuardUser($this); $ug->setGroupId($group->getId()); $ug->save($con); }
/** * Find object by primary key * Use instance pooling to avoid a database query if the object exists * <code> * $obj = $c->findPk(12, $con); * </code> * @param mixed $key Primary key to use for the query * @param PropelPDO $con an optional connection object * * @return sfGuardGroup|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if (null !== ($obj = sfGuardGroupPeer::getInstanceFromPool((string) $key)) && $this->getFormatter()->isObjectFormatter()) { // the object is alredy in the instance pool return $obj; } else { // the object has not been requested yet, or the formatter is not an object formatter $criteria = $this->isKeepQuery() ? clone $this : $this; $stmt = $criteria->filterByPrimaryKey($key)->getSelectStatement($con); return $criteria->getFormatter()->init($criteria)->formatOne($stmt); } }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = sfGuardGroupPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setName($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setDescription($arr[$keys[2]]); } }
?> <?php if ($person = PersonPeer::retrieveBySfGuardUser($sf_guard_user)) { ?> <?php echo 'Persona ' . $person; ?> <?php } ?> <table border="1"> <?php foreach ($groups as $group) { ?> <?php $group = sfGuardGroupPeer::retrieveByPk($group->getGroupId()); ?> <tr><td><strong><?php echo 'Grupo: ' . $group->getName(); ?> </strong><br><br></td></tr> <?php } ?> </table> <?php } else { ?> <?php echo __('El usuario no pertenece a ningún grupo'); ?>
protected function addSortCriteria($criteria) { if ($this->getRequestParameter('sort') == '') { return; } $column = sfGuardGroupPeer::translateFieldName(sfInflector::camelize($this->getRequestParameter('sort')), BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME); if ('asc' == strtolower($this->getRequestParameter('dir'))) { $criteria->addAscendingOrderByColumn($column); } else { $criteria->addDescendingOrderByColumn($column); } }
/** * * shows server main panel view Extjs template * */ public function executeView(sfWebRequest $request) { $this->server_tableMap = EtvaServerPeer::getTableMap(); $this->sfGuardGroup_tableMap = sfGuardGroupPeer::getTableMap(); //$this->network_tableMap = EtvaNetworkPeer::getTableMap(); }
/** * Get the associated sfGuardGroup object * * @param PropelPDO Optional Connection object. * @return sfGuardGroup The associated sfGuardGroup object. * @throws PropelException */ public function getsfGuardGroup(PropelPDO $con = null) { if ($this->asfGuardGroup === null && $this->group_id !== null) { $c = new Criteria(sfGuardGroupPeer::DATABASE_NAME); $c->add(sfGuardGroupPeer::ID, $this->group_id); $this->asfGuardGroup = sfGuardGroupPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->asfGuardGroup->addsfGuardUserGroups($this); */ } return $this->asfGuardGroup; }
public function grantProjectGroupPermission($group_name, $permission_name) { $permission = sfGuardPermissionPeer::retrieveByName($this->getUuid() . '-' . $permission_name); $group = sfGuardGroupPeer::retrieveByName($this->getUuid() . '-' . $group_name); if ($permission == null) { sfContext::getInstance()->getLogger()->info('permission not found: [' . $this->getUuid() . $permission_name . ']'); return false; } elseif ($group == null) { sfContext::getInstance()->getLogger()->info('group not found: [' . $this->getUuid() . $group_name . ']'); return false; } // TODO: make sure that the group permission name does not already exist $groupPermission = new sfGuardGroupPermission(); $groupPermission->setGroupId($group->getPrimaryKey()); $groupPermission->setPermissionId($permission->getId()); $groupPermission->save(); sfContext::getInstance()->getLogger()->info('group permission saved: [' . $this->getUuid() . $group_name . ']:[' . $this->getUuid() . $permission_name . ']'); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(sfGuardGroupPeer::DATABASE_NAME); $criteria->add(sfGuardGroupPeer::ID, $pks, Criteria::IN); $objs = sfGuardGroupPeer::doSelect($criteria, $con); } return $objs; }
public function executeChangeRole($request) { $this->form = new ChangeRoleForm(array(), array('actual_user' => $this->getUser())); $values = $request->getParameter($this->form->getName()); if (isset($values['roles']) && !empty($values['roles'])) { $this->getUser()->clearCredentials(); $new_login_role = sfGuardGroupPeer::retrieveByPK($values['roles']); $this->getUser()->setLoginRole($new_login_role->getName()); //die(var_dump($this->getUser()->getAttribute('login_role'))); $this->getUser()->addCredentials(sfGuardPermissionPeer::retrieveAllCredentialsForARole(sfGuardGroupPeer::retrieveByName($this->getUser()->getLoginRole()))); } return $this->redirect("mainBackend/index"); }