public function saveUsuaris()
 {
     $USUARIS = $this->getRequestParameter('USUARIS');
     $IDL = $this->getRequestParameter('IDL');
     $ERRORS = array();
     if (isset($USUARIS)) {
         foreach ($USUARIS as $U) {
             $C = new Criteria();
             $C->add(UsuarisllistesPeer::USUARIS_USUARISID, $U);
             $C->add(UsuarisllistesPeer::LLISTES_IDLLISTES, $IDL);
             $UL = UsuarisllistesPeer::doSelectOne($C);
             $UL->delete();
         }
     }
     if ($this->getRequestParameter('DNI') != '') {
         $DNIs = explode(",", $this->getRequestParameter('DNI'));
         foreach ($DNIs as $D) {
             if ($this->ValidaDNI(trim($D), false)) {
                 $C = new Criteria();
                 $C->add(UsuarisPeer::DNI, trim($D));
                 $U = UsuarisPeer::doSelectOne($C);
                 $C = new Criteria();
                 $C->add(UsuarisllistesPeer::LLISTES_IDLLISTES, $IDL);
                 $C->add(UsuarisllistesPeer::USUARIS_USUARISID, $U->getUsuariid());
                 $COUNT = UsuarisllistesPeer::doCount($C);
                 if ($COUNT == 0) {
                     $UL = new Usuarisllistes();
                     $UL->setLlistesIdllistes($IDL);
                     $UL->setUsuarisUsuarisid($U->getUsuariid());
                     $UL->save();
                 }
             } else {
                 $ERRORS[] = 'El DNI ' . $D . ' és incorrecte.';
             }
         }
     }
     $RET['ERRORS'] = $ERRORS;
     return $RET;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 public static function getUsuarisLlistaEmail($idL)
 {
     $C = new Criteria();
     $RET = array();
     $C->add(UsuarisllistesPeer::LLISTES_IDLLISTES, $idL);
     foreach (UsuarisllistesPeer::doSelect($C) as $UL) {
         $email = $UL->getUsuaris()->getEmail();
         if (self::comprobar_email($email)) {
             $RET[] = $email;
         }
     }
     return $RET;
 }
Example #4
0
 public static function EnviaMissatge($IDM, $idS)
 {
     $M = MissatgesllistesPeer::retrieveByPK($IDM);
     require_once 'lib/vendor/swift/swift_init.php';
     # needed due to symfony autoloader
     $mailer = Swift_Mailer::newInstance(Swift_MailTransport::newInstance());
     $MAILS = UsuarisllistesPeer::getUsuarisLlistaEmail($M->getLlistesIdllistes());
     foreach ($MAILS as $Email) {
         $message = Swift_Message::newInstance($M->getTitol())->setFrom(OptionsPeer::getString('MAIL_FROM', $idS))->setTo($Email)->setBody($M->getText(), 'text/html');
         $mailer->send($message);
     }
     $M->setEnviat(date('Y-m-d', time()));
     $M->save();
     return sizeof($MAILS);
 }
Example #5
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Llistes is new, it will return
  * an empty collection; or if this Llistes has previously
  * been saved, it will retrieve related Usuarisllistess 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 Llistes.
  */
 public function getUsuarisllistessJoinUsuaris($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(LlistesPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUsuarisllistess === null) {
         if ($this->isNew()) {
             $this->collUsuarisllistess = array();
         } else {
             $criteria->add(UsuarisllistesPeer::LLISTES_IDLLISTES, $this->idllistes);
             $this->collUsuarisllistess = UsuarisllistesPeer::doSelectJoinUsuaris($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(UsuarisllistesPeer::LLISTES_IDLLISTES, $this->idllistes);
         if (!isset($this->lastUsuarisllistesCriteria) || !$this->lastUsuarisllistesCriteria->equals($criteria)) {
             $this->collUsuarisllistess = UsuarisllistesPeer::doSelectJoinUsuaris($criteria, $con, $join_behavior);
         }
     }
     $this->lastUsuarisllistesCriteria = $criteria;
     return $this->collUsuarisllistess;
 }
Example #6
0
 /**
  * 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(UsuarisllistesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(UsuarisllistesPeer::DATABASE_NAME);
         $criteria->add(UsuarisllistesPeer::IDUSUARISLLISTES, $pks, Criteria::IN);
         $objs = UsuarisllistesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #7
0
 static function getLlistesUsuari($idU)
 {
     $C = new Criteria();
     $C->add(UsuarisllistesPeer::IDUSUARISLLISTES, $idU);
     return UsuarisllistesPeer::doSelect($C);
 }
 /**
  * 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 = UsuarisllistesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setIdusuarisllistes($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setLlistesIdllistes($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUsuarisUsuarisid($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setSiteId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setActiu($arr[$keys[4]]);
     }
 }
Example #9
0
 /**
  * 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 = LlistesPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related MissatgesEmails objects
         $criteria = new Criteria(MissatgesEmailsPeer::DATABASE_NAME);
         $criteria->add(MissatgesEmailsPeer::IDLLISTA, $obj->getIdllistes());
         $affectedRows += MissatgesEmailsPeer::doDelete($criteria, $con);
         // delete related MissatgesUsuaris objects
         $criteria = new Criteria(MissatgesUsuarisPeer::DATABASE_NAME);
         $criteria->add(MissatgesUsuarisPeer::IDLLISTA, $obj->getIdllistes());
         $affectedRows += MissatgesUsuarisPeer::doDelete($criteria, $con);
         // delete related Missatgesllistes objects
         $criteria = new Criteria(MissatgesllistesPeer::DATABASE_NAME);
         $criteria->add(MissatgesllistesPeer::LLISTES_IDLLISTES, $obj->getIdllistes());
         $affectedRows += MissatgesllistesPeer::doDelete($criteria, $con);
         // delete related Usuarisllistes objects
         $criteria = new Criteria(UsuarisllistesPeer::DATABASE_NAME);
         $criteria->add(UsuarisllistesPeer::LLISTES_IDLLISTES, $obj->getIdllistes());
         $affectedRows += UsuarisllistesPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }