public function saveUsuarisMenusList($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (!isset($this->widgetSchema['usuaris_menus_list'])) { // somebody has unset this widget return; } if (null === $con) { $con = $this->getConnection(); } $c = new Criteria(); $c->add(UsuarisMenusPeer::SITE_ID, $this->object->getPrimaryKey()); UsuarisMenusPeer::doDelete($c, $con); $values = $this->getValue('usuaris_menus_list'); if (is_array($values)) { foreach ($values as $value) { $obj = new UsuarisMenus(); $obj->setSiteId($this->object->getPrimaryKey()); $obj->setUsuariId($value); $obj->save(); } } }
public static function initialize($idU, $idM, $idS) { $OO = UsuarisMenusPeer::retrieveByPK($idU, $idM, $idS); if (!$OO instanceof UsuarisMenus) { $OO = new UsuarisMenus(); $OO->setUsuariId($idU); $OO->setMenuId($idM); $OO->setSiteId($idS); $OO->setNivellId(NivellsPeer::REGISTRAT); $OO->setActiu(true); } return new UsuarisMenusForm($OO, array('IDS' => $idS)); }
public static function getMenusUsuarisOptions($idU, $idS) { $RET = ""; $C = new Criteria(); $C->add(GestioMenusPeer::ACTIU, true); $TOTS = GestioMenusPeer::doSelect($C); $C = new Criteria(); $C->add(self::USUARI_ID, $idU); $C->add(self::ACTIU, true); $C->add(self::SITE_ID, $idS); $PART = UsuarisMenusPeer::doSelect($C); foreach ($TOTS as $OM) { $exist = false; foreach ($PART as $OUM) { $exist = $OM->getMenuId() == $OUM->getMenuId() || $exist; } if (!$exist) { $RET .= '<option id="' . $OM->getMenuId() . '" value="' . $OM->getMenuId() . '">' . addslashes($OM->getTitol()) . '</option>'; } else { $RET .= '<option selected id="' . $OM->getMenuId() . '" value="' . $OM->getMenuId() . '">' . addslashes($OM->getTitol()) . '</option>'; } } return $RET; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = UsuarisPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related AppDocumentsPermisos objects $criteria = new Criteria(AppDocumentsPermisosPeer::DATABASE_NAME); $criteria->add(AppDocumentsPermisosPeer::IDUSUARI, $obj->getUsuariid()); $affectedRows += AppDocumentsPermisosPeer::doDelete($criteria, $con); // delete related AppDocumentsPermisosDir objects $criteria = new Criteria(AppDocumentsPermisosDirPeer::DATABASE_NAME); $criteria->add(AppDocumentsPermisosDirPeer::IDUSUARI, $obj->getUsuariid()); $affectedRows += AppDocumentsPermisosDirPeer::doDelete($criteria, $con); // delete related Cessio objects $criteria = new Criteria(CessioPeer::DATABASE_NAME); $criteria->add(CessioPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += CessioPeer::doDelete($criteria, $con); // delete related Factures objects $criteria = new Criteria(FacturesPeer::DATABASE_NAME); $criteria->add(FacturesPeer::VALIDAUSUARI, $obj->getUsuariid()); $affectedRows += FacturesPeer::doDelete($criteria, $con); // delete related Matricules objects $criteria = new Criteria(MatriculesPeer::DATABASE_NAME); $criteria->add(MatriculesPeer::USUARIS_USUARIID, $obj->getUsuariid()); $affectedRows += MatriculesPeer::doDelete($criteria, $con); // delete related Missatges objects $criteria = new Criteria(MissatgesPeer::DATABASE_NAME); $criteria->add(MissatgesPeer::USUARIS_USUARIID, $obj->getUsuariid()); $affectedRows += MissatgesPeer::doDelete($criteria, $con); // delete related Personal objects $criteria = new Criteria(PersonalPeer::DATABASE_NAME); $criteria->add(PersonalPeer::IDUSUARI, $obj->getUsuariid()); $affectedRows += PersonalPeer::doDelete($criteria, $con); // delete related Reservaespais objects $criteria = new Criteria(ReservaespaisPeer::DATABASE_NAME); $criteria->add(ReservaespaisPeer::USUARIS_USUARIID, $obj->getUsuariid()); $affectedRows += ReservaespaisPeer::doDelete($criteria, $con); // delete related UsuarisApps objects $criteria = new Criteria(UsuarisAppsPeer::DATABASE_NAME); $criteria->add(UsuarisAppsPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += UsuarisAppsPeer::doDelete($criteria, $con); // delete related UsuarisMenus objects $criteria = new Criteria(UsuarisMenusPeer::DATABASE_NAME); $criteria->add(UsuarisMenusPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += UsuarisMenusPeer::doDelete($criteria, $con); // delete related UsuarisSites objects $criteria = new Criteria(UsuarisSitesPeer::DATABASE_NAME); $criteria->add(UsuarisSitesPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += UsuarisSitesPeer::doDelete($criteria, $con); // delete related Usuarisllistes objects $criteria = new Criteria(UsuarisllistesPeer::DATABASE_NAME); $criteria->add(UsuarisllistesPeer::USUARIS_USUARISID, $obj->getUsuariid()); $affectedRows += UsuarisllistesPeer::doDelete($criteria, $con); } return $affectedRows; }
/** * Retrieve object using using composite pkey values. * @param int $usuari_id * @param int $menu_id * @param int $site_id * @param PropelPDO $con * @return UsuarisMenus */ public static function retrieveByPK($usuari_id, $menu_id, $site_id, PropelPDO $con = null) { $key = serialize(array((string) $usuari_id, (string) $menu_id, (string) $site_id)); if (null !== ($obj = UsuarisMenusPeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(UsuarisMenusPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(UsuarisMenusPeer::DATABASE_NAME); $criteria->add(UsuarisMenusPeer::USUARI_ID, $usuari_id); $criteria->add(UsuarisMenusPeer::MENU_ID, $menu_id); $criteria->add(UsuarisMenusPeer::SITE_ID, $site_id); $v = UsuarisMenusPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
/** * 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 = UsuarisMenusPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setUsuariId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setMenuId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setSiteId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setNivellId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setActiu($arr[$keys[4]]); } }
public function executeAjaxGetMenusUsuarisOptions(sfWebRequest $request) { $IDU = $request->getParameter('IDU'); $IDS = $request->getParameter('IDS'); return $this->renderText(UsuarisMenusPeer::getMenusUsuarisOptions($IDU, $IDS)); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Sites is new, it will return * an empty collection; or if this Sites has previously * been saved, it will retrieve related UsuarisMenuss from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Sites. */ public function getUsuarisMenussJoinNivells($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(SitesPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collUsuarisMenuss === null) { if ($this->isNew()) { $this->collUsuarisMenuss = array(); } else { $criteria->add(UsuarisMenusPeer::SITE_ID, $this->site_id); $this->collUsuarisMenuss = UsuarisMenusPeer::doSelectJoinNivells($criteria, $con, $join_behavior); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(UsuarisMenusPeer::SITE_ID, $this->site_id); if (!isset($this->lastUsuarisMenusCriteria) || !$this->lastUsuarisMenusCriteria->equals($criteria)) { $this->collUsuarisMenuss = UsuarisMenusPeer::doSelectJoinNivells($criteria, $con, $join_behavior); } } $this->lastUsuarisMenusCriteria = $criteria; return $this->collUsuarisMenuss; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = NivellsPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related UsuarisMenus objects $criteria = new Criteria(UsuarisMenusPeer::DATABASE_NAME); $criteria->add(UsuarisMenusPeer::NIVELL_ID, $obj->getIdnivells()); $affectedRows += UsuarisMenusPeer::doDelete($criteria, $con); // delete related UsuarisSites objects $criteria = new Criteria(UsuarisSitesPeer::DATABASE_NAME); $criteria->add(UsuarisSitesPeer::NIVELL_ID, $obj->getIdnivells()); $affectedRows += UsuarisSitesPeer::doDelete($criteria, $con); } return $affectedRows; }
public function executeGConfigSuperAdmin(sfWebRequest $request) { $this->setLayout('gestio'); $this->IDS = $this->getUser()->getSessionPar('idS'); $this->accio = $request->getParameter('accio', 'C'); $RSITES = $request->getParameter('sites', array('site_id' => 1)); $this->FSITES = SitesPeer::initialize($RSITES['site_id']); $this->SITE = $request->getParameter('SITE', ''); //Cerquem per SITE, que és més fàcil //Mirem quins usuaris hi ha a un SITE relacionats com a adminstradors //Mirem quins menús tenen els usuaris d'un SITE en general (els menús del primer usuari) $OS = SitesPeer::retrieveByPK($this->SITE); if ($OS instanceof Sites) { $this->LUSERSITES = UsuarisSitesPeer::getSitesUsers($this->SITE, true); $this->LMENUSUSUARI = GestioMenusPeer::getMenusUsuariArray($this->USUARI, $this->SITE); } else { $this->USUARI = 0; $this->LUSERSITES = array(); $this->LMENUSUSUARI = array(); } $this->FMENUUSUARI = new ConfigSuperAdminMenusForm(null, array('IDS' => $this->IDS)); $this->FMENUUSUARI->bind($request->getParameter('super_admin_menus')); if ($request->hasParameter('BSAVESITE')) { $this->accio = 'SAVE_SITE'; } if ($request->hasParameter('BDELETESITE')) { $this->accio = 'DELETE_SITE'; } if ($request->hasParameter('BSAVEUSERSITE')) { $this->accio = 'SAVE_USER_SITE'; } if ($request->hasParameter('BDELETEUSERSITE')) { $this->accio = 'DELETE_USER_SITE'; } if ($request->hasParameter('BSEARCHUSERSITES')) { $this->accio = 'SEARCH_USER_SITES'; } if ($request->hasParameter('BSAVEUSERMENU')) { $this->accio = 'SAVE_USER_MENU'; } switch ($this->accio) { case 'SAVE_SITE': $this->FSITES->bind($RSITES); if ($this->FSITES->isValid()) { $this->FSITES->save(); $this->getUser()->addLogAction($this->accio, 'gConfigSuperAdmin', $this->FSITES->getObject()); $this->FSITES = SitesPeer::initialize($this->FSITES->getObject()->getSiteId()); } break; case 'DELETE_SITE': $this->FSITES->getObject()->setActiu(false)->save(); $this->getUser()->addLogAction($this->accio, 'gConfigSuperAdmin', $this->FSITES->getObject()); $this->FESPAIS = SitesPeer::initialize(0, $this->IDS); break; case 'SAVE_USER_SITE': $RP = $request->getParameter('dades'); foreach ($RP as $RS) { if ($RS['IDU'] > 0 && $RS['IDN'] > 0 && $this->SITE > 0) { $OUS = UsuarisSitesPeer::initialize($RS['IDU'], $this->SITE, false)->getObject(); $OUS->setNivellId($RS['IDN']); $OUS->setActiu(true); $OUS->save(); } } $this->LUSERSITES = UsuarisSitesPeer::getSitesUsers($this->SITE, true); break; case 'DELETE_USER_SITE': $USUARI = $request->getParameter('USUARI'); $SITE = $request->getParameter('SITE'); $OUS = UsuarisSitesPeer::initialize($USUARI, $SITE)->getObject(); if (!$OUS->isNew()) { $OUS->setActiu(false); $OUS->save(); $this->LUSERSITES = UsuarisSitesPeer::getUserSites($this->SITE); } break; case 'SAVE_USER_MENU': $LMENUS_NOVA = $request->getParameter('dades'); $LDADES = $request->getParameter('super_admin_menus'); if (!empty($LMENUS_NOVA)) { UsuarisMenusPeer::doUpdateMy($LDADES['IDU'], $LDADES['IDS'], $LMENUS_NOVA); } $this->LMENUSUSUARI = GestioMenusPeer::getMenusUsuariArray($LDADES['IDU'], $LDADES['IDS']); $this->FMENUUSUARI->setWidgetUsers(); break; case 'SEARCH_USER_SITES': $IDS = $this->FMENUUSUARI->getValue('IDS'); $IDU = $this->FMENUUSUARI->getValue('IDU'); if (!empty($IDS)) { $this->FMENUUSUARI->setWidgetUsers(); if (!empty($IDU)) { $this->LMENUSUSUARI = GestioMenusPeer::getMenusUsuariArray($IDU, $IDS); } } break; } }