public function setup() { $this->setWidgets(array('usuari_id' => new sfWidgetFormInputHidden(), 'app_id' => new sfWidgetFormChoice(array('choices' => AppsPeer::select())), 'nivell_id' => new sfWidgetFormChoice(array('choices' => NivellsPeer::getSelect())))); $this->setValidators(array('usuari_id' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID', 'required' => false)), 'app_id' => new sfValidatorPropelChoice(array('model' => 'Apps', 'column' => 'app_id', 'required' => false)), 'nivell_id' => new sfValidatorPropelChoice(array('model' => 'Nivells', 'column' => 'idNivells', 'required' => false)))); $this->widgetSchema->setNameFormat('usuaris_apps[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); parent::setup(); }
public function setup() { $Users = UsuarisPeer::selectAllUsers(); $idU = $this->getObject()->getUsuariid(); $this->setWidgets(array('DNI' => new sfWidgetFormInput(array(), array()), 'usuari_id' => new sfWidgetFormChoice(array('choices' => $Users), array()), 'site_id' => new sfWidgetFormChoice(array('choices' => UsuarisSitesPeer::getSites($idU, $this->getOption('NEW')))), 'nivell_id' => new sfWidgetFormChoice(array('choices' => NivellsPeer::getSelect())), 'actiu' => new sfWidgetFormInputHidden())); $this->setValidators(array('DNI' => new sfValidatorString(array('required' => true), array()), 'usuari_id' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID', 'required' => false)), 'site_id' => new sfValidatorPropelChoice(array('model' => 'Sites', 'column' => 'site_id', 'required' => false)), 'nivell_id' => new sfValidatorPropelChoice(array('model' => 'Nivells', 'column' => 'idNivells')), 'actiu' => new sfValidatorInteger(array('min' => -128, 'max' => 127)))); $this->widgetSchema->setNameFormat('usuaris_sites[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); }
public function setup() { $this->setWidgets(array('idUsuari' => new sfWidgetFormSelect(array('choices' => UsuarisAppsPeer::getSelectUsuarisPermis($this->getOption('app'), $this->getOption('IDS')))), 'idDirectori' => new sfWidgetFormSelect(array('choices' => AppDocumentsDirectorisPeer::getSelectDirectoris($this->getOption('IDS')))), 'idNivell' => new sfWidgetFormSelect(array('choices' => NivellsPeer::getSelectPermisos($this->getOption('IDS')))))); $this->setValidators(array('idUsuari' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID', 'required' => false)), 'idDirectori' => new sfValidatorPropelChoice(array('model' => 'AppDocumentsDirectoris', 'column' => 'idDirectori', 'required' => false)), 'idNivell' => new sfValidatorPropelChoice(array('model' => 'Nivells', 'column' => 'idNivells', 'required' => false)))); $this->widgetSchema->setNameFormat('app_documents_permisos_dir[%s]'); $this->setDefault('idDirectori', $this->getOption('IDD')); $this->setDefault('idNivell', 6); $this->widgetSchema->setLabels(array('idUsuari' => 'Usuari: ', 'idDirectori' => 'Directori: ', 'idNivell' => 'Permisos: ')); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); }
public function setup() { //Carrego el nivell de l'usuari a la taula,. Si l'estic veient per força n'he de tenir. $OUS = UsuarisSitesPeer::initialize($this->getObject()->getUsuariId(), $this->getObject()->getSiteId(), false)->getObject(); if ($OUS->isNew()) { $NIVELL = NivellsPeer::REGISTRAT; } else { $NIVELL = $OUS->getNivellId(); } $this->setWidgets(array('UsuariID' => new sfWidgetFormInputHidden(), 'Nivells_idNivells' => new sfWidgetFormChoice(array('choices' => NivellsPeer::getSelect()), array()), 'DNI' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Passwd' => new sfWidgetFormInputPassword(array('always_render_empty' => false), array('always_render_empty' => false, 'style' => 'width:200px')), 'Nom' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Cog1' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Cog2' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Email' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Adreca' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'CodiPostal' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Poblacio' => new sfWidgetFormPropelChoice(array('model' => 'Poblacions', 'add_empty' => true)), 'Poblaciotext' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Telefon' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Mobil' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Entitat' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Habilitat' => new sfWidgetFormChoice(array('choices' => array(1 => 'SÃ', 0 => 'No')), array()), 'Actualitzacio' => new sfWidgetFormInputHidden(array(), array()), 'site_id' => new sfWidgetFormInputHidden(array(), array()))); $this->setDefault('Nivells_idNivells', $NIVELL); $C = new Criteria(); $C->addAscendingOrderByColumn(PoblacionsPeer::NOM); $this->setValidators(array('UsuariID' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID', 'required' => false)), 'Nivells_idNivells' => new sfValidatorPropelChoice(array('model' => 'Nivells', 'column' => 'idNivells')), 'Passwd' => new sfValidatorString(array('max_length' => 20, 'required' => true)), 'Nom' => new sfValidatorString(array('required' => true)), 'Cog1' => new sfValidatorString(array('required' => true)), 'Cog2' => new sfValidatorString(array('required' => false)), 'Email' => new sfValidatorEmail(array('required' => true)), 'Adreca' => new sfValidatorString(array('required' => false)), 'CodiPostal' => new sfValidatorInteger(array('required' => false)), 'Poblacio' => new sfValidatorPropelChoice(array('model' => 'Poblacions', 'criteria' => $C, 'column' => 'idPoblacio', 'required' => false)), 'Poblaciotext' => new sfValidatorString(array('required' => false)), 'Telefon' => new sfValidatorString(array('required' => false)), 'Mobil' => new sfValidatorString(array('required' => false)), 'Entitat' => new sfValidatorString(array('required' => false)), 'Habilitat' => new sfValidatorBoolean(array('required' => false)), 'Actualitzacio' => new sfValidatorDate(array('required' => false), array()), 'site_id' => new sfValidatorPass(array(), array()))); $this->setValidator('DNI', new sfValidatorCallback(array('callback' => array('UsuarisForm', 'ComprovaDNI'), 'arguments' => array('idU' => $this->getObject()->getUsuariId()), 'required' => true))); $this->widgetSchema->setLabels(array('Nivells_idNivells' => 'Nivell: ', 'DNI' => 'DNI: ', 'Passwd' => 'Contrasenya: ', 'Nom' => 'Nom: ', 'Cog1' => 'Primer cognom: ', 'Cog2' => 'Segon cognom: ', 'Email' => 'Correu electrònic: ', 'Adreca' => 'Adreça postal: ', 'CodiPostal' => 'Codi postal: ', 'Poblacio' => 'Població: ', 'Poblaciotext' => 'Població: ', 'Telefon' => 'Telèfon: ', 'Mobil' => 'Mòbil: ', 'Entitat' => 'Entitat: ', 'Habilitat' => 'Habilitat: ')); $this->widgetSchema->setNameFormat('usuaris[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); }
/** * Selects a collection of UsuarisSites objects pre-filled with all related objects except Sites. * * @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 UsuarisSites objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptSites(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); } UsuarisSitesPeer::addSelectColumns($criteria); $startcol2 = UsuarisSitesPeer::NUM_COLUMNS - UsuarisSitesPeer::NUM_LAZY_LOAD_COLUMNS; UsuarisPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (UsuarisPeer::NUM_COLUMNS - UsuarisPeer::NUM_LAZY_LOAD_COLUMNS); NivellsPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + (NivellsPeer::NUM_COLUMNS - NivellsPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(UsuarisSitesPeer::USUARI_ID, UsuarisPeer::USUARIID, $join_behavior); $criteria->addJoin(UsuarisSitesPeer::NIVELL_ID, NivellsPeer::IDNIVELLS, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseUsuarisSitesPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UsuarisSitesPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UsuarisSitesPeer::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 = UsuarisSitesPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); UsuarisSitesPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Usuaris rows $key2 = UsuarisPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = UsuarisPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = UsuarisPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); UsuarisPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (UsuarisSites) to the collection in $obj2 (Usuaris) $obj2->addUsuarisSites($obj1); } // if joined row is not null // Add objects for joined Nivells rows $key3 = NivellsPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = NivellsPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = NivellsPeer::getOMClass(false); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); NivellsPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (UsuarisSites) to the collection in $obj3 (Nivells) $obj3->addUsuarisSites($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Get the associated Nivells object * * @param PropelPDO Optional Connection object. * @return Nivells The associated Nivells object. * @throws PropelException */ public function getNivells(PropelPDO $con = null) { if ($this->aNivells === null && $this->nivell_id !== null) { $this->aNivells = NivellsPeer::retrieveByPk($this->nivell_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->aNivells->addUsuarisSitess($this); */ } return $this->aNivells; }
/** * 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(NivellsPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(NivellsPeer::DATABASE_NAME); $criteria->add(NivellsPeer::IDNIVELLS, $pks, Criteria::IN); $objs = NivellsPeer::doSelect($criteria, $con); } return $objs; }
/** * 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 = NivellsPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdnivells($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNom($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setSiteId($arr[$keys[2]]); } }
<?php echo input_hidden_tag('IDD', $IDD); ?> <DIV class="REQUADRE"> <DIV class="TITOL">Llitat d'usuaris i permisos</DIV> <TABLE class="DADES"> <?php if (sizeof($LLISTAT_PERMISOS) == 0) { echo '<TR><TD colspan="3">Ningú hi té accés.</TD></TR>'; } else { echo '<TR><th>DNI</th><th>Nom</th><th>Permís</th></TR>'; foreach ($LLISTAT_PERMISOS as $P) { echo '<TR> <TD>' . $P['DNI'] . '</TD> <TD>' . $P['nomUsuari'] . '</TD> <TD>' . select_tag('nivell[' . $P['idUsuari'] . ']', options_for_select(NivellsPeer::getSelectPermisos(), $P['idNivell'])) . '</TD> </TR>'; } } ?> <td colspan="3" class="dreta"><br> <button name="B_NEW_USER" class="BOTO_ACTIVITAT">Afegir usuari</button> <button name="B_UPDATE_PERMISOS" class="BOTO_ACTIVITAT"> Actualitza els permisos</button> </td> </TABLE> </DIV> </form> <?php
" method="post"> <DIV class="REQUADRE"> <?php include_partial('botonera', array('tipus' => 'Tancar', 'url' => 'gestio/gUsuaris?accio=FC')); echo input_hidden_tag('id_usuari', $USUARI->getUsuariId()); ?> <DIV class="TITOL">Gestió de permisos d'aplicacions de l'usuari <?php echo $USUARI->getNomComplet(); ?> </DIV> <TABLE class="DADES"> <?php foreach (AppsPeer::select() as $IDAPP => $APP) { $SELECT = isset($LLISTAT_PERMISOS[$IDAPP]) ? $LLISTAT_PERMISOS[$IDAPP] : NivellsPeer::CAP; echo '<tr><td>' . AppsPeer::getNom($IDAPP) . '</td> <td>' . select_tag('PERMIS[' . $IDAPP . ']', options_for_select(NivellsPeer::getSelect(), $SELECT, array('include_blank' => true))) . '</td> </tr>'; } echo '<TR><TD colspan="2"><button name="BACTUALITZA_PERMISOS" class="BOTO_ACTIVITAT">ACTUALITZA</TD></TR>'; ?> </TABLE> </DIV> </form> <?php } ?> <?php if (isset($MODE['CONSULTA']) && $MODE['CONSULTA']) { ?>
/** * Permisos Tab * */ function PermisosTab($SITE, $LUSERSITES = "") { $RET = ' <form id="FPERMISOS" action="' . url_for('gestio/gConfigSuperAdmin') . '" method="POST" enctype="multipart/form-data"> Site : ' . select_tag('SITE', options_for_select(SitesPeer::getSelect(), $SITE)); $RET .= '<br /><br /><table>'; $RET .= '<tr><td class="titol">User</td><td class="titol">Nivell</td><td class="titol"></td></tr>'; foreach ($LUSERSITES as $OUS) { $USUARI = $OUS->getUsuariId(); $OU = UsuarisPeer::retrieveByPK($USUARI); $nom = "n/d"; if ($OU instanceof Usuaris) { $nom = $OU->getNomComplet(); } $RET .= '<tr><td>' . input_tag('dades[' . $USUARI . '][IDU]', $USUARI, array('class' => 'autocomplete', 'style' => 'width:60px;')) . ' - ' . $nom . '</td>'; $RET .= '<td>' . select_tag('dades[' . $USUARI . '][IDN]', options_for_select(NivellsPeer::getSelect(), $OUS->getNivellId())) . '</td>'; $RET .= '<td>' . link_to('esborra', 'gestio/gConfigSuperAdmin?accio=DELETE_USER_SITE&USUARI=' . $USUARI . '&SITE=' . $SITE) . '</td></tr>'; } $RET .= '<tr><td>' . input_tag('dades[0][IDU]', 0, array('class' => 'autocomplete', 'style' => 'width:60px;')) . '</td>'; $RET .= '<td>' . select_tag('dades[0][IDN]', options_for_select(NivellsPeer::getSelect(), 0)) . '</td></tr>'; $RET .= '</table>'; $RET .= ' <div style="text-align:right"> <button style="margin-top:10px;" name="BSEARCHUSERSITES" class="BOTO_ACTIVITAT"> ' . image_tag('template/find.png') . ' Consulta </BUTTON> <button type="submit" name="BSAVEUSERSITE" class="BOTO_ACTIVITAT" onClick="return confirm(\'Segur que vols guardar els canvis?\')"> ' . image_tag('template/disk.png') . ' Guardar i sortir </button> </div> </form>'; return $RET; }