public function getTags($usersId) { $user = new Users(); $tag = new Filfolders(); $selector = $this->select(Zend_Db_Table::SELECT_WITHOUT_FROM_PART)->setIntegrityCheck(false)->from(array('u' => $user->getTableName(true)), '')->join(array('fu' => $this->getTableName(true)), 'u.id = fu.users_id', '')->join(array('ff' => $tag->getTableName(true)), 'fu.filfolders_id = ff.id', array('label', 'parent_id', 'id'))->where('u.id = ?', $usersId)->where('ff.safinstances_id = ?', Sydney_Tools_Sydneyglobals::getSafinstancesId())->order('ff.pagorder'); return $this->fetchAll($selector); }
/** * * @param $divs * @param bool $showTitles * @param array $titleTags * @return mixed */ private function _postContentTreatment($divs, $showTitles = false, $structure = false) { $titleTags = array('<div class="breadcrumbs margin-bottom-40"><div class="container"><h1 class="color-green pull-left">', '</h1></div></div>'); if (!$showTitles) { return $divs; } else { $oldPageStructureId = ''; for ($i = 0; $i < count($divs); $i++) { $pageStructureId = $divs[$i]['pagstructure_id']; $breadCrum = $structure->getBreadCrumData(Sydney_Tools_Sydneyglobals::getSafinstancesId(), $divs[$i]['pagstructure_id']); $label = ''; foreach ($breadCrum as $elm) { $label = $elm['label']; } if ($oldPageStructureId == $pageStructureId) { $label = ''; } if ($label != '') { $label = $titleTags[0] . $label . $titleTags[1]; } $divs[$i]['content'] = $label . $divs[$i]['content']; $oldPageStructureId = $pageStructureId; } return $divs; } }
/** * Start caching * * Determine if we have a cache hit. If so, return the response; else, * start caching. * * @param Zend_Controller_Request_Abstract $request * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $request = $this->getRequest(); // $request = new Zend_Controller_Request_Http(); $moduleName = $request->getModuleName(); $params = $request->getParams(); /** * On récupère la homeId uniquement si on arrive à la racine du site * @author GDE * @project Belgium Telecom * @since 10/01/2013 */ $pagstrDB = new Pagstructure(); if (count($params) == 3 && $params['module'] == 'publicms' && $params['controller'] == 'index' && $params['action'] == 'view') { $params['page'] = $pagstrDB->getHomeId(Sydney_Tools_Sydneyglobals::getSafinstancesId()); } if ($moduleName == 'publicms' && isset($params['page'])) { $pagstr = $pagstrDB->find($params['page']); if (count($pagstr) == 1) { /** * Enregistre en session le rootid courant * Utilisé pour savoir quel index de recherche utiliser * FAR: Utile aussi pour la séparation par langue * @author GDE * @project Belgium Telecom * @since 10/01/2013 */ $breadCrumData = $pagstrDB->getBreadCrumData(Sydney_Tools_Sydneyglobals::getSafinstancesId(), $this->_treatPageData($params['page'])); $rootid = $breadCrumData[0]['id']; $lucenesearch = new Zend_Session_Namespace('current-page-rootid'); if (!empty($rootid)) { $lucenesearch->rootid = $rootid; } $struct = $pagstr[0]; $struct->hits++; $struct->save(); if (!Sydney_Auth::getInstance()->hasIdentity() && $struct->iscachable != 0 && $struct->cachetime > 0) { $this->cache->setLifetime($struct->cachetime); if (!$request->isGet()) { self::$doNotCache = true; return; } $path = $request->getPathInfo(); $this->key = $moduleName . '_' . md5($path); if (false !== ($response = $this->getCache())) { $response->sendResponse(); exit; } } } } }
public function save($label, Sydney_Content_Translator $translate, $lang, $tableId, $tableField = '') { $rowTranlationData = $this->getRowByTableName(array($translate->getTableName()), $lang, $tableId, $tableField); // If exist then update row if ($rowTranlationData) { $rowTranlationData->label = $label; $result = $this->update(array('label' => $label), 'tbl_name = "' . $translate->getTableName() . '" AND tbl_id = ' . intval($tableId) . ' AND code_language = "' . $lang . '" AND tbl_field = "' . $tableField . '" AND safinstances_id = ' . Sydney_Tools_Sydneyglobals::getSafinstancesId()); } else { // Else create row $result = $this->insert(array('label' => $label, 'tbl_name' => $translate->getTableName(), 'tbl_id' => intval($tableId), 'tbl_field' => $tableField, 'code_language' => $lang, 'safinstances_id' => Sydney_Tools_Sydneyglobals::getSafinstancesId())); } // Clear cache $cache = Zend_Registry::get('cache'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); return $result; }
/** * Standard email form for all webinstances * @since 23 aug 2013 */ public function emailAction() { $r = $this->getRequest(); $form = new PubcontactFormOp(null, $r->getParams()); $form->setMethod('post'); $purl = $this->_buildUrlFromParams($r->getParams()); if ($purl === '') { $purl = '/publicms/forms/email/'; } $currentLangCode = $this->getCurrentLangCode(); $purl .= !empty($currentLangCode) ? '?slang=' . $currentLangCode : ''; $purl .= '#pubcontact'; $form->setAction($purl); if ($r->isPost()) { $p = $this->_flattenForemailForm($r->getParams()); $form->populate($p); if ($form->isValid($p)) { $db = new Pubcontact(); $dbRow = $db->createRow(); // $dbRow->id = ''; $dbRow->safinstances_id = Sydney_Tools_Sydneyglobals::getSafinstancesId(); $dbRow->datetime = date('Y-m-d H:i:s'); // $dbRow->timestamp = ''; if (isset($p['fname'])) { $dbRow->fname = $p['fname']; } if (isset($p['lname'])) { $dbRow->lname = $p['lname']; } if (isset($p['fullname'])) { $dbRow->fullname = $p['fullname']; } if (isset($p['email'])) { $dbRow->email = $p['email']; } if (isset($p['phonenr'])) { $dbRow->phonenr = $p['phonenr']; } if (isset($p['subject'])) { $dbRow->subject = $p['subject']; } if (isset($p['message'])) { $dbRow->message = $p['message']; } if (isset($p['subsnewsletter'])) { $dbRow->subsnewsletter = $p['subsnewsletter']; } // upload the file if any $dbRow->filfiles_id = 0; if (isset($p['MAX_FILE_SIZE'])) { if ($form->uploadfile->receive()) { $filefilesDb = new FilfilesOp(); $fileData = $filefilesDb->fileToFileManager($form->uploadfile->getFileName(), date('d/m/Y H:i:s') . ' file uploaded from FORMMAIL - Author : ' . $dbRow->fname . ' ' . $dbRow->lname . ' ' . $dbRow->fullname, 'Formmail'); $dbRow->filfiles_id = $fileData; } else { Zend_Debug::dump('ERROR: The file could not be uploaded...'); } } $entId = $dbRow->save(); if ($entId !== false) { $this->view->confirmSent = true; $this->view->form = Sydney_Tools_Localization::_('Thanks, your message has been sent.'); // send the mail if ($this->_sendEmailForms($p['emails'], $dbRow)) { Sydney_Db_Trace::add('trace.event.emailsent_emailform' . ' [' . $dbRow->email . ']', 'publicms', 'pubcontact', 'email', $entId); } else { Sydney_Db_Trace::add('trace.event.emailerror_emailform' . ' [' . $dbRow->email . ']', 'publicms', 'pubcontact', 'email', $entId); } } else { $this->view->form = $form; } } else { $this->view->form = $form; } } else { $this->view->form = $form; } }
/** * Move a file from a directory to the final appdata of the webinstance * and register it to the DB * * @param string $filepath Path to the temp files * @param string $comment Comment to place in the meta description (for search purpose, for ex the name of the user) * @param string $folder The name of the folder to push the files in * @return bool|int */ public function fileToFileManager($filepath = '', $comment = '', $folder = 'temp') { if (!file_exists($filepath)) { return false; } try { $fileObj = Sydney_Medias_Filetypesfactory::createfiletype($filepath); $newName = uniqid() . '_' . Sydney_Medias_Utils::sanitizeFilename($fileObj->basename . '.' . $fileObj->extension); $newPath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $fileObj->extension . '/'; if (!is_dir($newPath)) { mkdir($newPath, 0777, true); } rename($filepath, $newPath . $newName); $fileName = $newName; $newFileObj = Sydney_Medias_Filetypesfactory::createfiletype($newPath . $newName); $fileInfo = $newFileObj->getFileinfo(); $fileWeight = $fileInfo['general.filesize']; // On récupère la taille du fichier pour pouvoir l'ajouter en DB $type = $newFileObj->extension; $usersId = Sydney_Tools_User::getUserdata('users_id'); // @todo TODO we ll have to change that, for now it uploads the file as Arnaud (user id 1) if nothing is defined. if ($usersId === false) { $usersId = 1; } $safinstancesId = Sydney_Tools_Sydneyglobals::getSafinstancesId(); // save the file to DB $fileFilesId = $this->registerFileToDb($newPath, $fileName, $fileWeight, $type, $usersId, $safinstancesId, array(), $comment); // put them in the right folder $filefoldersDb = new Filfolders(); $filefoldersId = $filefoldersDb->addSystemFolder($folder); if ($fileFilesId) { $fileCorDb = new FilfoldersFilfiles(); $fileCor = $fileCorDb->createRow(); $fileCor->filfolders_id = $filefoldersId; $fileCor->filfiles_id = $fileFilesId; $fileCor->save(); } // returns the files ids return $fileFilesId; } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); return false; } }