public function saveMissatgesllistesList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['missatgesllistes_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(MissatgesllistesPeer::IDMISSATGESLLISTES, $this->object->getPrimaryKey());
     MissatgesllistesPeer::doDelete($c, $con);
     $values = $this->getValue('missatgesllistes_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new Missatgesllistes();
             $obj->setIdmissatgesllistes($this->object->getPrimaryKey());
             $obj->setLlistesIdllistes($value);
             $obj->save();
         }
     }
 }
Exemplo n.º 2
0
 public function getDataEnviament($idl)
 {
     $OMISSATGE = MissatgesllistesPeer::retrieveByPK($this->getIdmissatge(), $idl);
     if ($OMISSATGE instanceof Missatgesllistes) {
         return $OMISSATGE->getEnviat('d-m-Y');
     } else {
         return null;
     }
 }
Exemplo n.º 3
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Missatgesmailing is new, it will return
  * an empty collection; or if this Missatgesmailing has previously
  * been saved, it will retrieve related Missatgesllistess 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 Missatgesmailing.
  */
 public function getMissatgesllistessJoinLlistes($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(MissatgesmailingPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collMissatgesllistess === null) {
         if ($this->isNew()) {
             $this->collMissatgesllistess = array();
         } else {
             $criteria->add(MissatgesllistesPeer::IDMISSATGESLLISTES, $this->idmissatge);
             $this->collMissatgesllistess = MissatgesllistesPeer::doSelectJoinLlistes($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(MissatgesllistesPeer::IDMISSATGESLLISTES, $this->idmissatge);
         if (!isset($this->lastMissatgesllistesCriteria) || !$this->lastMissatgesllistesCriteria->equals($criteria)) {
             $this->collMissatgesllistess = MissatgesllistesPeer::doSelectJoinLlistes($criteria, $con, $join_behavior);
         }
     }
     $this->lastMissatgesllistesCriteria = $criteria;
     return $this->collMissatgesllistess;
 }
Exemplo n.º 4
0
 public function saveMissatges()
 {
     $M = new Missatgesllistes();
     if ($this->getRequestParameter('IDM') > 0) {
         $M = MissatgesllistesPeer::retrieveByPK($this->getRequestParameter('IDM'));
         $M->setNew(false);
     }
     $M->setTitol($this->getRequestParameter('TITOL'));
     $M->setText($this->getRequestParameter('TEXT'));
     $M->setDate(time());
     $M->setLlistesIdllistes($this->getRequestParameter('IDL'));
     $M->save();
     $RET['ERRORS'] = array();
     $RET['MISSATGE'] = $M;
     return $RET;
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 /**
  * Retrieve object using using composite pkey values.
  * @param      int $idmissatgesllistes
  * @param      int $llistes_idllistes
  * @param      PropelPDO $con
  * @return     Missatgesllistes
  */
 public static function retrieveByPK($idmissatgesllistes, $llistes_idllistes, PropelPDO $con = null)
 {
     $key = serialize(array((string) $idmissatgesllistes, (string) $llistes_idllistes));
     if (null !== ($obj = MissatgesllistesPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(MissatgesllistesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(MissatgesllistesPeer::DATABASE_NAME);
     $criteria->add(MissatgesllistesPeer::IDMISSATGESLLISTES, $idmissatgesllistes);
     $criteria->add(MissatgesllistesPeer::LLISTES_IDLLISTES, $llistes_idllistes);
     $v = MissatgesllistesPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Exemplo n.º 8
0
 /**
  * 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 = MissatgesllistesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setIdmissatgesllistes($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setLlistesIdllistes($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEnviat($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]]);
     }
 }