Exemplo n.º 1
0
 public function setInactiu()
 {
     $this->setActiu(false);
     $C = new Criteria();
     $C = AppBlogsFormsEntriesPeer::getCriteriaActiu($C, $this->getSiteId());
     foreach ($this->getAppBlogsFormsEntriess($C) as $OFE) {
         $OFE->setInactiu();
     }
     $this->save();
 }
Exemplo n.º 2
0
 public static function initialize($idFE, $idS, $idF = 0)
 {
     $OO = AppBlogsFormsEntriesPeer::retrieveByPK($idFE);
     if (!$OO instanceof AppBlogsFormsEntries) {
         $OO = new AppBlogsFormsEntries();
         $OO->setDate(date('Y-m-d H:i:s', time()));
         $OO->setFormId($idF);
         $OO->setSiteId($idS);
         $OO->setActiu(true);
     }
     return new AppBlogsFormsEntriesForm($OO, array('IDS' => $idS));
 }
Exemplo n.º 3
0
 public static function save($form_id, $dades, $arxius, $idS)
 {
     try {
         //Creem una nova entrada al formulari
         $OO2 = AppBlogsFormsEntriesPeer::initialize(0, $idS, $form_id)->getObject();
         $OO2->save();
         //Passem totes les dades a un array
         $RET = array();
         foreach ($dades as $K => $V) {
             $RET[$K] = $V;
         }
         //Si hi ha arxius, els guardem.
         if (isset($arxius['arxius'])) {
             foreach ($arxius['arxius'] as $K => $V) {
                 if ($V['error'] == 0) {
                     $file_ext = substr($V['name'], strripos($V['name'], '.'));
                     $file_name = $OO2->getId() . '-' . $K . $file_ext;
                     $url = OptionsPeer::getString('SF_WEBSYSROOT', $idS) . 'uploads/formularis/' . $file_name;
                     move_uploaded_file($V['tmp_name'], $url);
                     $RET['file'][] = $file_name;
                 }
             }
         }
         //Guardem els camps del formulari en el format de formulari
         $SOL = "@@@";
         foreach ($RET as $K => $V) {
             if ($K == 'file') {
                 foreach ($V as $V2) {
                     $SOL .= 'file###' . $V2 . '@@@';
                 }
             } else {
                 $SOL .= $K . "###" . $V . '@@@';
             }
         }
         $OO2->setDades($SOL);
         $OO2->save();
     } catch (Exception $e) {
         mail('*****@*****.**', 'Error Formulari Noticies culturals', $form_id . $e->getMessage() . serialize($SOL));
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
 public function executeGBlogs(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     //Add,Edit,Delete Multimedia
     //Add,Edit,Delete Page
     //Add,Edit,Delete Entry
     //Principal view -> Blogs
     //You Select a blog -> Choice Menus - Pages
     //Edit Page - Menu
     $this->APP_BLOG = $request->getParameter('APP_BLOG', -1);
     $this->APP_PAGE = $request->getParameter('APP_PAGE', -1);
     $this->APP_ENTRY = $request->getParameter('APP_ENTRY', -1);
     $this->APP_MENU = $request->getParameter('APP_MENU', -1);
     $this->APP_MULTIMEDIA = $request->getParameter('APP_MULTIMEDIA', -1);
     $this->APP_FORM = $request->getParameter('APP_FORM', 1);
     $this->APP_FORM_ENTRY = $request->getParameter('APP_FORM_ENTRY', 0);
     $this->accio = $request->getParameter('accio', 'VB');
     //    $this->APP_BLOG			= $this->getUser()->ParReqSesForm($request,'APP_BLOG',-1);
     //    $this->APP_PAGE			= $this->getUser()->ParReqSesForm($request,'APP_PAGE',-1);
     //    $this->APP_ENTRY		= $this->getUser()->ParReqSesForm($request,'APP_ENTRY',-1);
     //    $this->APP_MENU			= $this->getUser()->ParReqSesForm($request,'APP_MENU',-1);
     //    $this->APP_MULTIMEDIA	= $this->getUser()->ParReqSesForm($request,'APP_MULTIMEDIA',-1);
     //    $this->APP_FORM			= $this->getUser()->ParReqSesForm($request,'APP_FORM',1);
     //    $this->APP_FORM_ENTRY   = $this->getUser()->ParReqSesForm($request,'APP_FORM_ENTRY',0);
     $accio = $request->getParameter('accio', 'GP');
     $this->MODE = 'CERCA';
     if ($request->isMethod('POST')) {
         if ($request->hasParameter('B_NEW_MENU')) {
             $accio = 'NEW_MENU';
         } elseif ($request->hasParameter('B_EDIT_MENU')) {
             $accio = 'EDIT_MENU';
         } elseif ($request->hasParameter('B_DELETE_MENU')) {
             $accio = 'DELETE_MENU';
         } elseif ($request->hasParameter('B_SAVE_MENU')) {
             $accio = 'SAVE_MENU';
         } elseif ($request->hasParameter('B_NEW_PAGE')) {
             $accio = 'NEW_PAGE';
         } elseif ($request->hasParameter('B_EDIT_PAGE')) {
             $accio = 'EDIT_PAGE';
         } elseif ($request->hasParameter('B_DELETE_PAGE')) {
             $accio = 'DELETE_PAGE';
         } elseif ($request->hasParameter('B_SAVE_PAGE')) {
             $accio = 'SAVE_PAGE';
         } elseif ($request->hasParameter('B_NEW_ENTRY')) {
             $accio = 'NEW_ENTRY';
         } elseif ($request->hasParameter('B_EDIT_ENTRY')) {
             $accio = 'EDIT_ENTRY';
         } elseif ($request->hasParameter('B_DELETE_ENTRY')) {
             $accio = 'DELETE_ENTRY';
         } elseif ($request->hasParameter('B_SAVE_ENTRY')) {
             $accio = 'SAVE_ENTRY';
         } elseif ($request->hasParameter('B_NEW_BLOG')) {
             $accio = 'NEW_BLOG';
         } elseif ($request->hasParameter('B_EDIT_BLOG')) {
             $accio = 'EDIT_BLOG';
         } elseif ($request->hasParameter('B_DELETE_BLOG')) {
             $accio = 'DELETE_BLOG';
         } elseif ($request->hasParameter('B_SAVE_BLOG')) {
             $accio = 'SAVE_BLOG';
         } elseif ($request->hasParameter('B_VIEW_CONTENT')) {
             $accio = 'VIEW_CONTENT';
         } elseif ($request->hasParameter('B_VIEW_STADISTICS')) {
             $accio = 'VIEW_STADISTICS';
         } elseif ($request->hasParameter('B_VIEW_FORM')) {
             $accio = 'VIEW_FORM';
         }
     }
     switch ($accio) {
         case 'NEW_MENU':
             $this->FORM_MENU = AppBlogsMenuPeer::initialize(0, $this->APP_BLOG, $this->IDS);
             break;
         case 'EDIT_MENU':
             $this->FORM_MENU = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS);
             break;
         case 'DELETE_MENU':
             $this->FORM_MENU = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS);
             $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_MENU->getObject());
             $this->FORM_MENU->getObject()->setInactiu();
             $this->redirect('gestio/gBlogs?accio=VIEW_CONTENT');
             break;
         case 'SAVE_MENU':
             $RP = $request->getParameter('app_blogs_menu');
             $this->APP_MENU = $RP['id'];
             $this->APP_BLOG = $RP['blog_id'];
             $this->FORM_MENU = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS);
             $this->FORM_MENU->bind($RP);
             if ($this->FORM_MENU->isValid()) {
                 try {
                     $this->FORM_MENU->save();
                     $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_MENU->getObject());
                     $this->APP_MENU = $this->FORM_MENU->getObject()->getId();
                     unset($this->APP_MENU);
                     $this->reloadBlog();
                 } catch (Exception $e) {
                     echo $e->getMessage();
                 }
             }
             break;
         case 'NEW_PAGE':
             $this->FORM_PAGE = AppBlogsPagesPeer::initialize(0, $this->APP_BLOG, $this->IDS);
             break;
         case 'EDIT_PAGE':
             $this->FORM_PAGE = AppBlogsPagesPeer::initialize($this->APP_PAGE, $this->APP_BLOG, $this->IDS);
             break;
         case 'DELETE_PAGE':
             try {
                 $RP = $request->getParameter('app_blogs_pages');
                 $this->APP_PAGE = $RP['id'];
                 $this->APP_BLOG = $RP['blog_id'];
                 $this->FORM_PAGE = AppBlogsPagesPeer::initialize($this->APP_PAGE, $this->APP_BLOG, $this->IDS);
                 $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_PAGE->getObject());
                 $this->FORM_PAGE->getObject()->setInactiu();
                 unset($this->FORM_PAGE);
                 $this->reloadBlog();
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
             break;
         case 'SAVE_PAGE':
             $RP = $request->getParameter('app_blogs_pages');
             $this->APP_PAGE = $RP['id'];
             $this->APP_BLOG = $RP['blog_id'];
             $this->FORM_PAGE = AppBlogsPagesPeer::initialize($this->APP_PAGE, $this->APP_BLOG, $this->IDS);
             $this->FORM_PAGE->bind($RP);
             if ($this->FORM_PAGE->isValid()) {
                 try {
                     $this->FORM_PAGE->save();
                     $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_PAGE->getObject());
                     $this->APP_PAGE = $this->FORM_PAGE->getObject()->getId();
                     //Ara assignem també aquesta pàgina al menú que tenim seleccionat. Si no n'hi ha cap, no fem res.
                     if ($this->APP_MENU > 0) {
                         $FM = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS);
                         $FM->getObject()->setPageId($this->APP_PAGE)->save();
                     }
                     unset($this->FORM_PAGE);
                     $this->reloadBlog();
                 } catch (Exception $e) {
                     echo $e->getMessage();
                 }
             }
             break;
         case 'NEW_ENTRY':
             $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS);
             $this->GALLERY = array();
             break;
         case 'EDIT_ENTRY':
             $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS);
             $this->GALLERY = AppBlogsEntriesPeer::getFiles($this->APP_ENTRY, 'CA');
             break;
         case 'DELETE_ENTRY':
             $RS = $request->getParameter('app_blogs_entries');
             $this->APP_ENTRY = $RS['id'];
             $this->APP_PAGE = $RS['page_id'];
             $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS);
             $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_ENTRY->getObject());
             $this->FORM_ENTRY->getObject()->setInactiu();
             $this->reloadBlog();
             break;
         case 'SAVE_ENTRY':
             $RS = $request->getParameter('app_blogs_entries');
             $this->APP_ENTRY = $RS['id'];
             $this->APP_PAGE = $RS['page_id'];
             $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS);
             $this->FORM_ENTRY->bind($RS);
             if ($this->FORM_ENTRY->isValid()) {
                 try {
                     $this->FORM_ENTRY->save();
                     $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_ENTRY->getObject());
                     $this->APP_ENTRY = $this->FORM_ENTRY->getObject()->getId();
                     $this->GUARDA_IMATGES($request->getFiles('arxiu'), $request->getParameter('desc'), $this->APP_ENTRY);
                     unset($this->FORM_ENTRY);
                     $this->reloadBlog();
                 } catch (Exception $e) {
                     echo $e->getMessage();
                 }
             }
             $this->GALLERY = AppBlogsEntriesPeer::getFiles($this->APP_ENTRY, 'CA');
             break;
         case 'NEW_BLOG':
             $this->FORM_BLOG = AppBlogsBlogsPeer::initialize(0, $this->IDS);
             break;
         case 'EDIT_BLOG':
             $this->FORM_BLOG = AppBlogsBlogsPeer::initialize($this->APP_BLOG, $this->IDS);
             break;
         case 'DELETE_BLOG':
             $RS = $request->getParameter('app_blogs_blogs');
             $this->APP_BLOG = $RS['id'];
             $this->FORM_BLOG = AppBlogsBlogsPeer::initialize($this->APP_BLOG, $this->IDS);
             $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_BLOG->getObject());
             $this->FORM_BLOG->getObject()->setInactiu();
             unset($this->FORM_BLOG);
             break;
         case 'DELETE_IMAGE':
             AppBlogsMultimediaPeer::initialize($this->APP_MULTIMEDIA, $this->IDS)->getObject()->setInactiu();
             $this->getUser()->addLogAction($accio, 'gBlogs', $this->APP_MULTIMEDIA);
             break;
         case 'SAVE_BLOG':
             $RS = $request->getParameter('app_blogs_blogs');
             $this->APP_BLOG = $RS['id'];
             $this->FORM_BLOG = AppBlogsBlogsPeer::initialize($this->APP_BLOG, $this->IDS);
             $this->FORM_BLOG->bind($RS);
             if ($this->FORM_BLOG->isValid()) {
                 try {
                     $this->FORM_BLOG->save();
                     $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_BLOG->getObject());
                     $this->APP_BLOG = $this->FORM_BLOG->getObject()->getId();
                     unset($this->FORM_BLOG);
                     $this->reloadBlog();
                 } catch (Exception $e) {
                     echo $e->getMessage();
                 }
             }
             break;
         case 'VIEW_CONTENT':
             $this->reloadBlog($this->APP_BLOG);
             break;
         case 'AJAX_PAGE':
             $APP_PAGE = $request->getParameter('APP_PAGE');
             $APP_ENTRY = $request->getParameter('APP_ENTRY');
             $HTML = AppBlogsEntriesPeer::getOptionsEntries($APP_PAGE, $APP_ENTRY, $this->IDS);
             return $this->renderText($HTML);
             break;
         case 'AJAX_MENU':
             $APP_BLOG = $request->getParameter('APP_BLOG');
             $APP_MENU = $request->getParameter('APP_MENU') > 0 ? $request->getParameter('APP_MENU') : 0;
             $APP_PAGE = $request->getParameter('APP_PAGE') > 0 ? $request->getParameter('APP_PAGE') : 0;
             $HTML = AppBlogsPagesPeer::getOptionsPages($APP_BLOG, $APP_MENU, $APP_PAGE, $this->IDS);
             return $this->renderText($HTML);
             break;
         case 'AJAX_ESTAT_FORM':
             $APP_FORM_ENTRY = $request->getParameter('APP_FORM_ENTRY');
             $ESTAT = $request->getParameter('ESTAT');
             $OO = AppBlogsFormsEntriesPeer::initialize($APP_FORM_ENTRY, $this->IDS)->getObject();
             $OO->setEstat($ESTAT);
             $OO->save();
             return $this->renderText('Canvi fet correctament');
             break;
         case 'AJAX_SAVE_OBJECCIONS':
             $APP_FORM_ENTRY = $request->getParameter('APP_FORM_ENTRY');
             $OO = AppBlogsFormsEntriesPeer::initialize($APP_FORM_ENTRY, $this->IDS);
             $OO->setObjeccions($request->getParameter('OBJECCIONS'));
             $OO->save();
             return $this->renderText('Canvi fet correctament');
             break;
         case 'VB':
             $this->APP_BLOG = -1;
             $this->APP_PAGE = -1;
             $this->APP_ENTRY = -1;
             $this->APP_MENU = -1;
             $this->APP_MULTIMEDIA = -1;
             $this->APP_FORM = -1;
             $this->getUser()->addLogAction('inside', 'gBlogs');
             break;
         case 'VIEW_STADISTICS':
             //Veure estructura d'arbre
             $this->PAGES_WITHOUT_CONTENT = AppBlogsPagesPeer::getPagesWithoutContent($this->APP_BLOG, $this->IDS);
             $this->MENUS_WITHOUT_PAGES = AppBlogsMenuPeer::getMenusWithoutPages($this->APP_BLOG, $this->IDS);
             $this->TREE = AppBlogsMenuPeer::getOptionsMenus($this->APP_BLOG, null, false, $this->IDS);
             break;
         case 'VIEW_FORM':
             $datai = mktime(0, 0, 0, date('m', time()) - 2, date('d', time()), date('Y', time()));
             $this->VIEW_FORM_ENTRIES = AppBlogsFormsEntriesPeer::getEntries($this->APP_FORM, date('Y-m-d', $datai), $this->IDS);
             $this->VIEW_FIELDS = AppBlogsFormsEntriesPeer::getFields($this->APP_FORM, $this->IDS);
             break;
     }
     $this->BLOGS_ARRAY = AppBlogsBlogsPeer::getOptionsBlogs($this->APP_BLOG, $this->IDS);
 }
 /**
  * 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 = AppBlogsFormsEntriesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setDades($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDate($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setFormId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEstat($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setObjeccions($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]]);
     }
 }
Exemplo n.º 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(AppBlogsFormsEntriesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(AppBlogsFormsEntriesPeer::DATABASE_NAME);
         $criteria->add(AppBlogsFormsEntriesPeer::ID, $pks, Criteria::IN);
         $objs = AppBlogsFormsEntriesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 7
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeNoticiesculturals(sfWebRequest $request)
 {
     $this->IDS = 1;
     $this->PAGE_ID_QUE_ESTA_PASSANT = 1;
     $this->PAGE_ID_QUE_PASSARA = 2;
     $this->PAGE_ID_QUE_HA_PASSAT = 3;
     $this->FORM_ID = 2;
     $this->BLOG_ID = 4;
     $this->setLayout('blank');
     $this->PAGE_ID = $this->ParReqSesForm($request, 'PAGE_ID', $this->PAGE_ID_QUE_ESTA_PASSANT);
     $this->NOTICIA_ID = $this->ParReqSesForm($request, 'NOTICIA_ID', -1);
     $this->PAGINA = $request->getParameter('PAGINA', 1);
     $this->MODE = $this->ParReqSesForm($request, 'MODE', 'CONTINGUT');
     $this->ERRORS = "";
     if ($this->MODE == 'CONTINGUT' && $request->hasParameter('NOTICIA_ID')) {
         $this->NOTICIA = AppBlogsEntriesPeer::retrieveByPK($request->getParameter('NOTICIA_ID'));
         $this->MODE = 'CONTINGUT';
     } elseif ($this->MODE == 'CONTINGUT') {
         $order = $this->PAGE_ID == $this->PAGE_ID_QUE_HA_PASSAT ? false : true;
         $this->NOTICIES = AppBlogsEntriesPeer::getEntries($this->PAGE_ID, $this->PAGINA, $order, $this->IDS);
         $this->MODE = 'CONTINGUT';
     } elseif ($this->MODE == 'FORM1') {
         $this->FORM1 = array('nom_entitat' => '', 'nom_cognoms' => '', 'lloc_ocupa' => '', 'nom_cognoms_contacte' => '', 'adreca' => '', 'codi_postal' => '', 'municipi' => '', 'comarca' => '', 'telefons' => '', 'email' => '');
     } elseif ($this->MODE == 'FORM2') {
         $this->DADES = $request->getParameter('dades');
         $this->getUser()->setAttribute('dades', $this->DADES);
         $this->FORM2 = array('titol' => '', 'subtitol1' => '', 'ciutat_acte' => '', 'dia_acte' => '', 'web' => '', 'imatge' => '', 'tipus' => '', 'resum' => '');
     } elseif ($this->MODE == 'ENVIA_FINALITZA') {
         if (!$this->getUser()->hasAttribute('dades')) {
             $this->redirect('@noticies_culturals?MODE=FORM1');
         }
         $this->getUser()->setAttribute('dades2', $request->getParameter('dades'));
         $this->DADES = $this->getUser()->getAttribute('dades');
         $this->DADES2 = $this->getUser()->getAttribute('dades2');
         foreach ($this->DADES2 as $K => $E) {
             $this->DADES[$K] = $E;
         }
         AppBlogsFormsPeer::save($this->FORM_ID, $this->DADES, $request->getFiles(), $this->IDS);
         $this->MODE = 'FORM_OK';
     } elseif ($this->MODE == 'ACTUALITZA') {
         $next_two_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) + 2, date('d', time()), date('Y', time())));
         $next_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) + 1, date('d', time()), date('Y', time())));
         $today = date('Y-m-d', time());
         $previous_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) - 1, date('d', time()), date('Y', time())));
         $previous_two_month = date('Y-m-d', mktime(0, 0, 0, date('m', time()) - 2, date('d', time()), date('Y', time())));
         //Captem els que s'han de migrar del formulari
         $C = new Criteria();
         $C = AppBlogsFormsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsFormsEntriesPeer::FORM_ID, $this->FORM_ID);
         $C->add(AppBlogsFormsEntriesPeer::ESTAT, AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_MIGRAT_WAIT);
         //Treballem i migrem els camps que hem marcat com "Per publicar"
         foreach (AppBlogsFormsEntriesPeer::doSelect($C) as $OO) {
             $RET = array();
             foreach (explode("@@@", $OO->getDades()) as $E) {
                 $EX = explode("###", $E);
                 if (isset($EX[0]) && isset($EX[1])) {
                     list($EXCAMP, $TEXT) = explode("###", $E);
                     $RET[$EX[0]] = $EX[1];
                 }
             }
             try {
                 $ON = AppBlogsEntriesPeer::initialize(0, 'CA', 1, 1, $this->IDS)->getObject();
                 $ON->setTitle($RET['titol']);
                 $ON->setSubtitle1($RET['subtitol1']);
                 $ON->setSubtitle2($RET['ciutat_acte'] . ', ' . $this->dataText($RET['dia_acte']));
                 $ON->setBody($RET['text']);
                 $ON->setTags($RET['tipus']);
                 echo stripos($RET['web'], 'http://');
                 if (!stripos($RET['web'], 'http://')) {
                     $ON->setUrl('http://' . $RET['web']);
                 } else {
                     $ON->setUrl($RET['web']);
                 }
                 $ON->setDate($RET['dia_acte']);
                 $dia = $RET['dia_acte'];
                 if ($dia >= $today && $dia < $next_month) {
                     $ON->setPageId($this->PAGE_ID_QUE_ESTA_PASSANT);
                 } elseif ($dia < $today) {
                     $ON->setPageId($this->PAGE_ID_QUE_HA_PASSAT);
                 } elseif ($dia > $next_month) {
                     $ON->setPageId($this->PAGE_ID_QUE_PASSARA);
                 }
                 $ON->save();
                 //Guardem la notícia
                 //Guardem les imatges
                 if (isset($RET['file'])) {
                     $WEBSYSROOT = OptionsPeer::getString('SF_WEBSYSROOT', $this->IDS);
                     //Mirem l'extensió de l'arxiu
                     $path_info = pathinfo($WEBSYSROOT . 'uploads/formularis/' . $RET['file']);
                     //Si l'arxiu és una imatge, el tractem i el posem com a imatge
                     if (strtolower($path_info['extension']) == 'jpg' || strtolower($path_info['extension']) == 'png') {
                         try {
                             $img = new sfImage($WEBSYSROOT . 'uploads/formularis/' . $RET['file'], 'image/jpeg');
                             $img->resize(200, null);
                             $img->saveAs($WEBSYSROOT . 'images/blogs/' . $RET['file']);
                             $OM = AppBlogsMultimediaPeer::initialize(0, $this->IDS)->getObject();
                             $OM->setName($RET['file']);
                             $OM->setUrl($RET['file']);
                             $OM->save();
                             echo 'ONID:' . $ON->getId();
                             $OME = AppBlogMultimediaEntriesPeer::initialize($ON->getId(), $OM->getId(), $this->IDS)->getObject()->save();
                         } catch (Exception $e) {
                             echo 'hail';
                             echo $e->getMessage();
                             echo $e->getCode();
                         }
                     }
                 }
                 $OO->setEstat(AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_MIGRAT);
                 $OO->save();
             } catch (Exception $e) {
                 echo 'fiodaf';
                 echo $e->getMessage();
                 echo $e->getCode();
             }
         }
         /**
          * Captem els valors que han estat marcats com "Per arxivar" i els passem a "arxivats"
          */
         $C = new Criteria();
         $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsFormsEntriesPeer::FORM_ID, $this->FORM_ID);
         $C->add(AppBlogsFormsEntriesPeer::ESTAT, AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_EMMAGATZEMAT_WAIT);
         foreach (AppBlogsFormsEntriesPeer::doSelect($C) as $OO) {
             $OO->setEstat(AppBlogsFormsEntriesPeer::ESTAT_TRACTAT_EMMAGATZEMAT);
             $OO->save();
         }
         /**
          * Procès de canvi de lloc les notícies que ja han passat a una altra pàgina
          */
         //Captem les notícies que han de canviar de pàgina... (Actual->Passades)
         $C = new Criteria();
         $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsEntriesPeer::PAGE_ID, $this->PAGE_ID_QUE_ESTA_PASSANT);
         $C->add(AppBlogsEntriesPeer::DATE, $today, CRITERIA::LESS_THAN);
         foreach (AppBlogsEntriesPeer::doSelect($C) as $OO) {
             $OO->setPageid($this->PAGE_ID_QUE_HA_PASSAT);
             $OO->save();
         }
         //Captem les notícies que han de canviar de pàgina... (Futures->actual)
         $C = new Criteria();
         $C = AppBlogsEntriesPeer::getCriteriaActiu($C, $this->IDS);
         $C->add(AppBlogsEntriesPeer::PAGE_ID, $this->PAGE_ID_QUE_PASSARA);
         $C->add(AppBlogsEntriesPeer::DATE, $today, CRITERIA::GREATER_THAN);
         $C->add(AppBlogsEntriesPeer::DATE, $next_month, CRITERIA::LESS_THAN);
         foreach (AppBlogsEntriesPeer::doSelect($C) as $OO) {
             $OO->setPageid($this->PAGE_ID_QUE_ESTA_PASSANT);
             $OO->save();
         }
         //  		$this->redirect('blogs/noticiesculturals?MODE=CONTINGUT&PAGE_ID='.$this->PAGE_ID_QUE_ESTA_PASSANT);
     }
 }
Exemplo n.º 8
0
 /**
  * Returns the number of related AppBlogsFormsEntries objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related AppBlogsFormsEntries objects.
  * @throws     PropelException
  */
 public function countAppBlogsFormsEntriess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(AppBlogsFormsPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collAppBlogsFormsEntriess === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(AppBlogsFormsEntriesPeer::FORM_ID, $this->id);
             $count = AppBlogsFormsEntriesPeer::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(AppBlogsFormsEntriesPeer::FORM_ID, $this->id);
             if (!isset($this->lastAppBlogsFormsEntriesCriteria) || !$this->lastAppBlogsFormsEntriesCriteria->equals($criteria)) {
                 $count = AppBlogsFormsEntriesPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collAppBlogsFormsEntriess);
             }
         } else {
             $count = count($this->collAppBlogsFormsEntriess);
         }
     }
     return $count;
 }
Exemplo n.º 9
0
    ?>
"><?php 
    echo image_tag('icons/Grey/PNG/action_delete.png');
    ?>
</a>
		 	</div>            
		 	<div class="titol">
		 		Entrades del formulari  
		 	</div>
	    	<table>
	    	<?php 
    $WEBROOT = OptionsPeer::getString('SF_WEBROOT', $IDS);
    foreach ($VIEW_FORM_ENTRIES as $F) {
        echo '<tr>';
        echo '<td>
	    					<select name="estat" onChange="SubmitEstat(this,' . $F->getId() . ')">' . options_for_select(AppBlogsFormsEntriesPeer::selectEstats(), $F->getEstat()) . '</select>
	    				  </td>';
        echo '<td>';
        echo '<div class="hidden1" id="hidden1_' . $F->getId() . '">';
        echo $F->getId() . ' | ';
        foreach ($F->getArrayElements() as $K => $V) {
            if (in_array($K, $VIEW_FIELDS)) {
                echo '<b>' . $V . '</b> | ';
            }
        }
        echo '<a onClick="Activa(' . $F->getId() . ')"><img src="' . $WEBROOT . 'images/template/add.png' . '" /></a>';
        $O = $F->getObjeccions();
        if (!empty($O)) {
            echo ' <a onClick="Activa(' . $F->getId() . ')"><img src="' . $WEBROOT . 'images/template/buildings.png' . '" /></a>';
        }
        echo '</div>';
Exemplo n.º 10
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 = AppBlogsFormsPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related AppBlogsFormsEntries objects
         $criteria = new Criteria(AppBlogsFormsEntriesPeer::DATABASE_NAME);
         $criteria->add(AppBlogsFormsEntriesPeer::FORM_ID, $obj->getId());
         $affectedRows += AppBlogsFormsEntriesPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }