Esempio n. 1
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 = MissatgesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setMissatgeid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUsuarisUsuariid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setTitol($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setText($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDate($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPublicacio($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setSiteId($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setActiu($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setIsglobal($arr[$keys[8]]);
     }
 }
Esempio n. 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;
 }
Esempio n. 3
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(MissatgesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(MissatgesPeer::DATABASE_NAME);
         $criteria->add(MissatgesPeer::MISSATGEID, $pks, Criteria::IN);
         $objs = MissatgesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 4
0
 public function executeGMissatges(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     $this->IDU = $this->getUser()->getSessionPar('idU');
     $this->IDM = $request->getParameter('IDM');
     //Netegem cerca
     if ($request->getParameter('accio') == 'I') {
         $this->CERCA = $this->getUser()->setSessionPar('cerca', array('text' => ''));
         $this->PAGINA = $this->getUser()->setSessionPar('p', 1);
         $this->accio = $this->getUser()->setSessionPar('accio', "");
     }
     //Actualitzem el requadre de cerca
     $this->FCerca = new CercaForm();
     $this->FCerca->bind($request->getParameter('cerca'));
     $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => ""));
     $this->PAGINA = $this->getUser()->ParReqSesForm($request, 'p', 1);
     $this->accio = $request->getParameter('accio', '');
     $this->MODE = array();
     if ($request->isMethod('POST') || $request->isMethod('GET')) {
         $accio = $request->getParameter('accio');
         if ($request->hasParameter('BNOU')) {
             $this->accio = 'N';
         }
         if ($request->hasParameter('BSAVE')) {
             $this->accio = 'S';
         }
         if ($request->hasParameter('BDELETE')) {
             $this->accio = 'D';
         }
     }
     switch ($this->accio) {
         //Entrem per primer cop a aquest apartat
         case 'I':
             $this->MISSATGES = MissatgesPeer::doSearch($this->CERCA['text'], $this->PAGINA, false, $this->IDS);
             $this->getUser()->addLogAction('inside', 'gMissatges');
             break;
         case 'N':
             $this->MODE = "NOU";
             $this->FMissatge = MissatgesPeer::inicialitza(0, $this->IDU, $this->IDS);
             $this->OM = $this->FMissatge->getObject();
             break;
             //Consultem un missatge.
         //Consultem un missatge.
         case 'C':
             $this->MODE = "CONSULTA";
             $this->OM = MissatgesPeer::retrieveByPK($this->IDM);
             $this->FMissatge = new MissatgesForm($this->OM);
             break;
         case 'AJAX_RESPOSTA_SAVE':
             $TEXT = $request->getParameter('FORMULARI');
             $OR = new Respostes();
             $OR->setIdpare($this->IDM);
             $OR->setIdusuari($this->IDU);
             $OR->setTipus(RespostesPeer::TIPUS_MISSATGE);
             $OR->setData(date('Y-m-d H:i', time()));
             $OR->setText($TEXT);
             $OR->setIdsite($this->IDS);
             $OR->setActiu(true);
             $OR->save();
             //Carreguem dades pel partial
             $OM = MissatgesPeer::retrieveByPK($this->IDM);
             $FMissatge = new MissatgesForm($OM);
             $MODE = 'CONSULTA';
             $IDU = $this->IDU;
             return $this->renderPartial('formMissatge', array('FMISSATGE' => $FMissatge, 'IDU' => $IDU, 'OM' => $OM, 'MODE' => $MODE));
             break;
         case 'AJAX_RESPOSTA_DELETE':
             $ERRORS = array();
             $ID = $request->getParameter('FORMULARI');
             $OR = RespostesPeer::retrieveByPK($ID);
             if ($OR instanceof Respostes) {
                 $OR->setActiu(false);
                 $OR->save();
             } else {
                 $ERRORS[] = "No s'ha trobat cap resposta amb aquest codi: {$ID}.";
             }
             //Carreguem dades pel partial
             $OM = MissatgesPeer::retrieveByPK($this->IDM);
             $FMissatge = new MissatgesForm($OM);
             $MODE = 'CONSULTA';
             $IDU = $this->IDU;
             return $this->renderPartial('formMissatge', array('ERRORS' => $ERRORS, 'FMISSATGE' => $FMissatge, 'IDU' => $IDU, 'OM' => $OM, 'MODE' => $MODE));
             break;
         case 'AJAX_MISSATGE_SAVE':
             parse_str($request->getParameter('FORMULARI'), $RP);
             $RP = $RP['missatges'];
             $this->FMissatge = MissatgesPeer::inicialitza($RP['MissatgeID'], $this->IDU, $this->IDS);
             $this->FMissatge->bind($RP);
             if ($this->FMissatge->isValid()) {
                 $this->FMissatge->save();
                 $OM = $this->FMissatge->getObject();
                 $OM->save();
                 $this->getUser()->addLogAction($accio, 'gMisatges', $OM);
                 myUser::addLogTimeline($this->FMissatge->isNew() ? 'alta' : 'modificació', 'taulell', $this->getUser()->getSessionPar('idU'), $this->IDS, $OM->getMissatgeid());
                 if ($OM->getIsglobal()) {
                     $OM->EnviaMissatgeGlobalHospici();
                 }
                 $MODE = 'CONSULTA';
             } else {
                 //Retornem els errors que apareguin.
                 $ERRORS[] = "Hi ha hagut algun error inesperat...";
                 $OM = MissatgesPeer::retrieveByPK($RP['MissatgeID']);
                 $MODE = 'NOU';
             }
             //Carreguem dades pel partial
             $FMissatge = MissatgesPeer::inicialitza($OM->getMissatgeid(), $this->IDU, $this->IDS);
             return $this->renderPartial('formMissatge', array('ERRORS' => $ERRORS, 'FMISSATGE' => $FMissatge, 'IDU' => $this->IDU, 'OM' => $OM, 'MODE' => $MODE));
             break;
         case 'AJAX_MISSATGE_DELETE':
             parse_str($request->getParameter('FORMULARI'), $RP);
             $RP = $RP['missatges'];
             $OM = MissatgesPeer::retrieveByPK($this->IDM);
             if ($OM instanceof Missatges) {
                 $OM->setActiu(false);
                 $OM->save();
                 $this->getUser()->addLogAction($accio, 'gMisatges', $OM);
                 myUser::addLogTimeline('baixa', 'taulell', $this->getUser()->getSessionPar('idU'), $this->IDS, $this->IDM);
             }
             return $this->renderText('');
             break;
         case 'SF':
             $this->MISSATGES = MissatgesPeer::doSearch($this->CERCA['text'], $this->PAGINA, true, $this->IDS);
             break;
         default:
             $this->MISSATGE = new Missatges();
             $this->getUser()->setSessionPar('IDM', 0);
             $this->MISSATGES = MissatgesPeer::doSearch($this->CERCA['text'], $this->PAGINA, false, $this->IDS);
             break;
     }
 }
Esempio n. 5
0
 static function getMissatgesAvui($idS = 1)
 {
     $C = new Criteria();
     $C = self::getCriteriaActiu($C, $idS);
     $avui = date('Y-m-d', time());
     $C->add(self::PUBLICACIO, $avui);
     $C->addDescendingOrderByColumn(self::PUBLICACIO);
     $C->addDescendingOrderByColumn(self::MISSATGEID);
     return MissatgesPeer::doSelect($C);
 }
Esempio n. 6
0
 /**
  * Returns the number of related Missatges objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Missatges objects.
  * @throws     PropelException
  */
 public function countMissatgess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UsuarisPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collMissatgess === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(MissatgesPeer::USUARIS_USUARIID, $this->usuariid);
             $count = MissatgesPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // 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 count of the collection.
             $criteria->add(MissatgesPeer::USUARIS_USUARIID, $this->usuariid);
             if (!isset($this->lastMissatgesCriteria) || !$this->lastMissatgesCriteria->equals($criteria)) {
                 $count = MissatgesPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collMissatgess);
             }
         } else {
             $count = count($this->collMissatgess);
         }
     }
     return $count;
 }
		
	      
      
  <?php 
} else {
    ?>
  
  	<div class="REQUADRE">
  	<div class="TITOL">Llistat de missatges (<a href="<?php 
    echo url_for('gestio/gMissatges?accio=SF');
    ?>
">Veure missatges futurs</a>)</div>
        <div class="DADES" style="width:650px;">
         <?php 
    if ($MISSATGES->getNbResults() == 0) {
        echo '<div>No s\'ha trobat cap resultat d\'entre ' . MissatgesPeer::doCount(MissatgesPeer::getCriteriaActiu(new Criteria(), $IDS)) . ' disponibles.</div>';
    } else {
        $dif = "";
        foreach ($MISSATGES->getResults() as $M) {
            if ($dif != $M->getPublicacio('d/m/Y')) {
                echo '<div style="height:20px; clear:both;"></div>';
                echo '<div class="gray" style="padding:4px; border-bottom:1px solid #CCCCCC;"><b>' . diaSetmanaText($M->getPublicacio('Y-m-d')) . ' </b></div>';
            }
            $SPAN = '<span>' . $M->getText() . '</span>';
            $R = $M->getRespostesCount();
            $RESP = $R > 0 ? ' <span style="font-size:8px; color: gray;">(' . $R . ' resposts/es )</span>' : "";
            if ($M->getIsglobal()) {
                echo '<div style="border-bottom:1px solid #CCCCCC; background-color:#E4F7D9;">                      				
                      				<div style="float:left; width:500px;"><div style="padding:4px">' . link_to(image_tag('intranet/Submenu2.png') . ' ' . $M->getTitol() . $SPAN, 'gestio/gMissatges?accio=C&IDM=' . $M->getMissatgeid(), array('class' => 'tt2')) . $RESP . '</div></div>
                      				<div style="float:left; width:150px;">
                                        <div style="padding:4px"><b>' . $M->getUsuaris()->getNom() . ' ' . $M->getUsuaris()->getCog1() . '</b> de 
Esempio n. 8
0
 public function executeGMissatges(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     $this->IDU = $this->getUser()->getSessionPar('idU');
     //Netegem cerca
     if ($request->getParameter('accio') == 'I') {
         $this->CERCA = $this->getUser()->setSessionPar('cerca', array('text' => ''));
         $this->PAGINA = $this->getUser()->setSessionPar('p', 1);
         $this->accio = $this->getUser()->setSessionPar('accio', "");
     }
     //Actualitzem el requadre de cerca
     $this->FCerca = new CercaForm();
     $this->FCerca->bind($request->getParameter('cerca'));
     $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => ""));
     $this->PAGINA = $this->getUser()->ParReqSesForm($request, 'p', 1);
     $this->accio = $this->getUser()->ParReqSesForm($request, 'accio', "");
     $this->MODE = array();
     if ($request->isMethod('POST') || $request->isMethod('GET')) {
         $accio = $request->getParameter('accio');
         if ($request->hasParameter('BCERCA')) {
             $this->accio = 'C';
         }
         if ($request->hasParameter('BNOU')) {
             $this->accio = 'N';
         }
         if ($request->hasParameter('BSAVE')) {
             $this->accio = 'S';
         }
         if ($request->hasParameter('BDELETE')) {
             $this->accio = 'D';
         }
     }
     $this->getUser()->setSessionPar('accio', $this->accio);
     switch ($this->accio) {
         //Entrem per primer cop a aquest apartat
         case 'I':
             $this->MISSATGES = MissatgesPeer::doSearch($this->CERCA['text'], $this->PAGINA, false, $this->IDS);
             $this->getUser()->addLogAction('inside', 'gMissatges');
             break;
         case 'N':
             $this->MODE['NOU'] = true;
             $this->FMissatge = MissatgesPeer::inicialitza(0, $this->IDU, $this->IDS);
             $this->getUser()->setSessionPar('IDM', 0);
             $this->IDU = $this->getUser()->getSessionPar('idU');
             break;
         case 'E':
             $this->MODE['EDICIO'] = true;
             $IDM = $request->getParameter('IDM');
             $this->getUser()->setSessionPar('IDM', $IDM);
             $this->FMissatge = MissatgesPeer::inicialitza($IDM, $this->IDU, $this->IDS);
             $this->IDU = $this->getUser()->getSessionPar('idU');
             break;
         case 'S':
             $IDM = $this->getUser()->getSessionPar('IDM');
             $this->FMissatge = MissatgesPeer::inicialitza($IDM, $this->IDU, $this->IDS);
             $this->FMissatge->bind($request->getParameter('missatges'));
             if ($this->FMissatge->isValid()) {
                 $this->FMissatge->save();
                 $this->getUser()->addLogAction($accio, 'gMisatges', $this->FMissatge->getObject());
                 //Si el missatge és global, enviarem un mail a tothom.
                 if ($this->FMissatge->getObject()->getIsglobal()) {
                     $ADMIN = OptionsPeer::getString('MAIL_ADMIN', $this->IDS);
                     //Carreguem el correu de l'administrador
                     $OM = $this->FMissatge->getObject();
                     //Carreguem el missatge que hem entrat
                     $MAILS = UsuarisPeer::getAdminMails();
                     //Carreguem els mails dels administradors
                     $BODY = OptionsPeer::getString('BODY_MAIL_MISSATGE_GLOBAL', $this->IDS);
                     $BODY = str_replace('{NOM}', $OM->getUsuaris()->getNomComplet(), $BODY);
                     $BODY = str_replace('{SITE}', $OM->getSiteNom(), $BODY);
                     $BODY = str_replace('{ENLLAC}', $this->getController()->genUrl('gestio/gMissatges?accio=E&IDM=' . $OM->getMissatgeid(), true), $BODY);
                     $SUBJECT = 'Hospici : Nou missatge global';
                     self::sendMail($ADMIN, $MAILS, $SUBJECT, $BODY);
                     //Enviem el missatge.
                 }
                 $this->redirect('gestio/gMissatges?accio=I');
             }
             $this->MODE['EDICIO'] = true;
             break;
         case 'D':
             $this->IDM = $this->getUser()->getSessionPar('IDM');
             $M = MissatgesPeer::retrieveByPK($this->IDM);
             if ($M instanceof Missatges) {
                 $M->setActiu(false);
                 $M->save();
                 $this->getUser()->addLogAction($accio, 'gMisatges', $M);
             }
             $this->redirect('gestio/gMissatges?accio=I');
             break;
         case 'SF':
             $this->MISSATGES = MissatgesPeer::doSearch($this->CERCA['text'], $this->PAGINA, true, $this->IDS);
             break;
         default:
             $this->MISSATGE = new Missatges();
             $this->getUser()->setSessionPar('IDM', 0);
             $this->MISSATGES = MissatgesPeer::doSearch($this->CERCA['text'], $this->PAGINA, false, $this->IDS);
             break;
     }
 }
Esempio n. 9
0
 /**
  * Carrega els missatges que han de ser publicats avui i tamb� aquells que tenen respostes associades.
  * @return array(idM => array( 'OM' => Missatges , 'RESPOSTES' = array( Respostes ) ) ) ))
  * */
 static function getMissatgesAvui($idS = 1)
 {
     $RET = array();
     $C = new Criteria();
     $C = self::getCriteriaActiu($C, $idS);
     $avui = date('Y-m-d', time());
     $C->add(self::PUBLICACIO, $avui);
     $C->addDescendingOrderByColumn(self::PUBLICACIO);
     $C->addDescendingOrderByColumn(self::MISSATGEID);
     foreach (MissatgesPeer::doSelect($C) as $OM) {
         $RET[$OM->getMissatgeid()]['OM'] = $OM;
         $RET[$OM->getMissatgeid()]['RESPOSTES'] = array();
     }
     foreach (RespostesPeer::getRespostesAvui($idS) as $OR) {
         //Si la resposta és d'un missatge que avui ja s'ensenya... la guardem.
         if (isset($RET[$OR->getIdpare()])) {
             $RET[$OR->getIdpare()]['RESPOSTES'][] = $OR;
             //Si la resposta és d'un missatge antic, el carreguem i mostrem
         } else {
             $OM = MissatgesPeer::retrieveByPK($OR->getIdpare());
             if ($OM instanceof Missatges) {
                 $RET[$OM->getMissatgeid()]['OM'] = $OM;
                 $RET[$OM->getMissatgeid()]['RESPOSTES'][] = $OR;
             }
         }
     }
     return $RET;
 }