/** * * @param unknown_type $content * @param unknown_type $word */ public static function highlightWord($content, $word) { // list of separator $separator = array(' ', ' + ', ' - ', '~', '^', ' and ', ' or ', ' not ', '*', '"'); // explode content $mycontent = explode(" ", $content); // group 1 $group1 = explode(' ', $word); // group 2 $group2 = str_ireplace($separator, ' ', $word); $group2 = explode(' ', $group2); // parse content foreach ($mycontent as $key => &$currentWord) { foreach ($group1 as $wordpart) { if ($wordpart == $currentWord || $wordpart == Sydney_Tools::stripAccents($currentWord)) { $currentWord = '<strong>' . $currentWord . '</strong>'; continue 2; } else { $currentWord = str_ireplace($wordpart, '<strong>' . $wordpart . '</strong>', $currentWord); } } foreach ($group2 as $wordpart) { if ($wordpart == $currentWord || $wordpart == Sydney_Tools::stripAccents($currentWord)) { $currentWord = '<strong>' . $currentWord . '</strong>'; continue 2; } else { $currentWord = str_ireplace($wordpart, '<strong>' . $wordpart . '</strong>', $currentWord); } } } // create string $content = implode(' ', $mycontent); return $content; }
/** * Helper main function * @return String HTML to be inserted in the view */ public function EditorText() { $pathToConfigStyles = Sydney_Tools::getLocalPath() . '/config/ckeditor.styles.ini'; $pathToConfigJsTemplate = Sydney_Tools::getLocalPath() . '/config/ckeditor.jstemplate.ini'; $toReturn = '<script> var publicCss = "' . Zend_Registry::get("config")->ckeditor->css . '";' . '</script><!-- ' . $pathToConfigStyles . ' -->'; if (file_exists($pathToConfigStyles) && ($contentStyles = file_get_contents($pathToConfigStyles))) { $addStyleCss = '<script> var addStyleCss = ' . $contentStyles . ';</script>'; } else { $addStyleCss = '<script> var addStyleCss = false;</script>'; } if (file_exists($pathToConfigJsTemplate) && ($contentTemplate = file_get_contents($pathToConfigJsTemplate))) { $toReturn .= '<script type="text/javascript">' . $contentTemplate . '</script>'; } $toReturn .= $addStyleCss . '<div class="editor text-block sydneyeditor" data-content-type="text-block"> <textarea class="texteditor"> </textarea> <p class="buttons sydney_editor_p"> <a class="button sydney_editor_a" href="save">' . Sydney_Tools_Localization::_('Save as actual content') . '</a> <a class="button sydney_editor_a" href="save-draft">' . Sydney_Tools_Localization::_('Save as draft') . '</a> <a class="button muted sydney_editor_a" href="cancel">' . Sydney_Tools_Localization::_('Cancel') . '</a> </p> </div>'; return $toReturn; }
public function init() { //parent::init(); $usersData = Sydney_Tools::getUserdata(); $this->view->cdn = Sydney_Tools::getRootUrlCdn(); $this->view->allowPermission = in_array(7, $usersData['member_of_groups']); }
/** * * @return void */ function __construct() { $this->cache = Zend_Registry::get('cache'); $this->config = Zend_Registry::get('config'); $this->cachePath = Sydney_Tools::getCachePath(); // clean the old cache $this->cache->clean(Zend_Cache::CLEANING_MODE_OLD); }
/** * Helper main function * @param $actionsHtml String HTML code showing the action buttons * @param $content String The content of this element * @param $dbId Int DB id of the object * @param $order Int order of this item in the DB * @param $params Array parameters (if any) * @return String HTML to be inserted in the view */ public function contentViewembeder($actionsHtml = '', $content = '', $dbId = 0, $order = 0, $params = array(), $moduleName = 'adminpages', $pageStructureId = 0, $sharedInIds = '') { $toReturn = ''; if (!empty($content)) { switch (Sydney_Tools::getConf('helpers')->content->viewembedder->method) { case 'ajax': $toReturn = Sydney_View_Embedder_Content::ajaxContents($content); break; case 'filegetcontents': $toReturn = file_get_contents(Sydney_Tools::getRootUrl() . '/' . $content . '/sydneylayout/no/'); break; case 'curlgetcontents': $toReturn = Sydney_View_Embedder_Content::curlGetContents(Sydney_Tools::getRootUrl() . $content . '/sydneylayout/no/'); break; case 'action': default: $i = 0; $module = null; $controller = null; $action = null; $oldv = null; $params2 = array(); foreach (preg_split("/\\//", $content) as $v) { if ($i == 1) { $module = $v; } elseif ($i == 2) { $controller = $v; } elseif ($i == 3) { $action = $v; } elseif ($i > 3) { if ($i % 2 == 0) { $params2[$v] = null; $oldv = $v; } if ($i % 2 == 1) { $params2[$oldv] = $v; $oldv = null; } } $i++; } $toReturn = $this->view->action($action, $controller, $module, $params2); break; } } // END - if content return ' <li class="' . $params['addClass'] . ' sydney_editor_li" type="" dbparams="' . $content . '" editclass="viewembeder" dbid="' . $dbId . '" dborder="' . $order . '" data-content-type="view-embedder-block" pagstructureid="' . $pageStructureId . '" sharedinids="' . $sharedInIds . '">' . $actionsHtml . '<div class="content">' . $toReturn . '</div></li>'; }
/** * * @param unknown_type $object */ public static function getTableName($object) { if (is_object($object)) { if (get_class($object) == 'Zend_Db_Table_Row') { return $object->getTable()->info('name'); } elseif (method_exists($object, 'info')) { $info = $object->info(); return $info['name']; } } return Sydney_Tools::_('unknow_table'); }
/** * Returns an array with webinstance dir as keys and full config files path as value * @return Array */ public function getAllConfigFilesLocation() { $e = array(); $p1 = $this->rootPath . $this->rootInstancesPath; foreach (Sydney_Tools::getDirList($p1, true) as $d) { if (!preg_match('/^\\./', $d)) { $fp = $p1 . '/' . $d . '/config/' . $this->configFileName; if (file_exists($fp)) { $e[$d] = $fp; } } } return $e; }
/** * @todo Change the $dbAdapter for making it automatic according to the config, here we are stuck with MySQL * @param Zend_Controller_Request_Http $request * @param bool $encryptedPass * @return bool|Sydney_Auth_Adaptater_DbTable */ public static function getAuthAdapter(Zend_Controller_Request_Http $request, $encryptedPass = false) { // Load cookie informations $identity = Sydney_Http_Cookie::getIdentity($request); $credential = Sydney_Http_Cookie::getCredential($request); // Load params $params = $request->getParams(); // Auth with identity and credential loaded from cookie if (empty($identity) && empty($credential) && empty($params['username']) && empty($params['password'])) { // IF no username and no password then return false return false; } elseif (!empty($identity) && !empty($credential) && empty($params['username']) && empty($params['password'])) { // IF identity loaded from cookie then set as params $params['username'] = $identity; $params['password'] = $credential; } $where2 = " 1 = 2 "; $username = strtolower(addslashes($params['username'])); $password = addslashes($params['password']); // get the user if any $uDB = new Users(); $users = $uDB->fetchAll(" LOWER(login) LIKE '" . $username . "' "); // one user found if (count($users) == 1) { if ($users[0]->safinstances_id == Sydney_Tools::getSafinstancesId()) { $where2 = " 1 = 1 "; } else { $corDB = new SafinstancesUsers(); $cors = $corDB->fetchAll(" safinstances_id = " . Sydney_Tools::getSafinstancesId() . " AND users_id = " . $users[0]->id . " "); if (count($cors) > 0) { $where2 = " 1 = 1 "; } } $username = $users[0]->login; } $config = Zend_Registry::get('config'); $dbAdapter = new Zend_Db_Adapter_Pdo_Mysql($config->db->params); if ($encryptedPass === false) { $authAdapter = new Sydney_Auth_Adaptater_DbTable($dbAdapter, 'users', 'login', 'password', 'MD5(?) AND valid = 1 AND active = 1 AND (TIMESTAMPADD(SECOND,timeValidityPassword,lastpwdchanges) > now() OR timeValidityPassword = 0) AND ' . $where2); } else { $authAdapter = new Sydney_Auth_Adaptater_DbTable($dbAdapter, 'users', 'login', 'password', '? AND valid = 1 AND active = 1 AND (TIMESTAMPADD(SECOND,timeValidityPassword,lastpwdchanges) > now() OR timeValidityPassword = 0) AND ' . $where2); } // Store username and pass to cookie if ($params['rememberme'] == "1") { Sydney_Http_Cookie::setAuthCookie($username, $password, 7); } $authAdapter->setIdentity($username)->setCredential($password); return $authAdapter; }
/** * @param $fullpath * @param null $cachpath */ public function setPath($fullpath, $cachpath = null) { $pi = pathinfo($fullpath); $this->dirname = $pi['dirname']; $this->basename = $pi['basename']; $this->extension = strtoupper($pi['extension']); $this->filename = $pi['filename']; // set the cache dir path if we have one in the config if ($cachpath == null) { //$t = Sydney_Tools::getCachePath(); //if (isset($t)) $this->cachepath = Sydney_Tools::getCachePath(); } else { $this->cachepath = $cachpath; } }
/** * Helper main function * @param $actionsHtml String HTML code showing the action buttons * @param $content String The content of this element * @param $dbId Int DB id of the object * @param $order Int order of this item in the DB * @param $params Array parameters (if any) * @return String HTML to be inserted in the view */ public function contentViewembeder($actionsHtml = '', $content = '', $dbId = 0, $order = 0, $params = array(), $pagstructureId = 0) { if (!empty($content)) { switch (Sydney_Tools_Sydneyglobals::getConf('helpers')->content->viewembedder->method) { case 'ajax': return Sydney_View_Embedder_Content::ajaxContents($content); break; case 'filegetcontents': return file_get_contents(Sydney_Tools::getRootUrl() . '/' . $content . '/sydneylayout/no/'); break; case 'curlgetcontents': return Sydney_View_Embedder_Content::curlGetContents(Sydney_Tools::getRootUrl() . $content . '/sydneylayout/no/'); break; case 'action': default: $i = 0; $module = null; $controller = null; $action = null; $oldv = null; $params2 = array(); foreach (preg_split("/\\//", $content) as $v) { if ($i == 1) { $module = $v; } elseif ($i == 2) { $controller = $v; } elseif ($i == 3) { $action = $v; } elseif ($i > 3) { if ($i % 2 == 0) { $params2[$v] = null; $oldv = $v; } if ($i % 2 == 1) { $params2[$oldv] = $v; $oldv = null; } } $i++; } return $this->view->action($action, $controller, $module, array_merge($params2, $params)); break; } } // END - if content return ''; }
/** * Helper main function * @return String HTML to be inserted in the view * @param Array $structureArray [optional] Structure in an array form */ public function Dashboard($listactivities) { $html = ''; foreach ($listactivities['time'] as $datetime => $activityListId) { $html .= '<div xmlns="http://www.w3.org/1999/xhtml" class="whitebox"> <h2>' . $datetime . '</h2><ul class="journal">'; foreach ($activityListId as $activityId) { $html .= '<li> ' . Sydney_Tools::getTime($listactivities['datas'][$activityId]->timestamp) . ': '; switch ($listactivities['datas'][$activityId]->module . '-' . $listactivities['datas'][$activityId]->module_table . '-' . $listactivities['datas'][$activityId]->action) { case 'adminfiles-filfiles-insert': case 'adminfiles-filfiles-update': $html .= '<a href="/adminfiles/index/index/id/' . $listactivities['datas'][$activityId]->module_ids . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminpages-pagstructure-restore': case 'adminpages-pagstructure-insert': case 'adminpages-pagstructure-update': $html .= '<a href="/' . $listactivities['datas'][$activityId]->module . '/index/edit/id/' . $listactivities['datas'][$activityId]->module_ids . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminpages-pagdivs-insert': case 'adminpages-pagdivs-update': $html .= '<a href="/' . $listactivities['datas'][$activityId]->module . '/pages/edit/id/' . $listactivities['datas'][$activityId]->parent_id . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminnews-nwsnews-insert': case 'adminnews-nwsnews-update': $html .= '<a href="/' . $listactivities['datas'][$activityId]->module . '/index/properties/id/' . $listactivities['datas'][$activityId]->module_ids . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminnews-pagdivs-insert': case 'adminnews-pagdivs-update': $html .= '<a href="/adminpages/pages/edit/id/' . $listactivities['datas'][$activityId]->parent_id . '/emodule/news">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; default: $html .= $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action); break; } $html .= ' <strong>by</strong> ' . $listactivities['datas'][$activityId]->fname . ' ' . $listactivities['datas'][$activityId]->lname . '. </li>'; } $html .= '</ul></div>'; } return $html; }
/** * displays the page content in edition mode */ public function editAction() { // [AS] add CKEditor (moved from the global as it was using a lot of ressource) $this->view->headScript()->appendFile(Sydney_Tools::getRootUrlCdn() . '/sydneyassets/jslibs/ckeditor/ckeditor.js', 'text/javascript'); $this->view->headScript()->appendFile(Sydney_Tools::getRootUrlCdn() . '/sydneyassets/jslibs/ckeditor/adapters/jquery.js', 'text/javascript'); $r = $this->getRequest(); $elid = isset($r->id) && preg_match('/^[0-9]{1,50}$/', $r->id) ? $r->id : 0; $emodule = isset($r->emodule) ? $r->emodule : 'pages'; $this->view->emodule = $emodule; $this->view->pagstructure_id = $elid; $this->view->customHelpers = $this->_registry->get('customhelpers'); switch ($emodule) { case 'pages': $nodes = new Pagstructure(); $where = 'id = ' . $elid . ' AND safinstances_id = ' . $this->safinstancesId; $this->view->node = $nodes->fetchRow($where); $this->view->pagid = $elid; $this->view->moduleName = 'adminpages'; // set layout and titles properties $this->setSubtitle2($this->view->node->label); $this->setSubtitle('Edit page'); $this->setSideBar('edit', 'pages'); $this->layout->langswitch = true; $this->layout->search = true; // get the div content $cnt = new Pagdivspage(); $this->view->contentDivs = $cnt->getDivs($this->view->node->id, false); // Affichage d'un design spécifique $layout = new Sydney_Layout_Layout(); /* If layout if empty we will take the one in the config */ if (!$this->view->node->layout) { $this->view->node->layout = $this->_config->general->layout; } $layout->setName($this->view->node->layout); if ($layout->loadZones()->hasZones()) { $this->view->layout = $layout; $this->view->preview = $layout->calculatePreview()->getPreview(); $this->view->zones = $layout->getZones(); $this->render('editzones'); } break; } }
/** * * @param String $message * @param String $module * @param String $moduleTable * @param String $action * @param Integer $id * @param Integer $parentId */ public static function add($message, $module, $moduleTable, $action, $id = 0, $parentId = 0) { $udata = new Zend_Session_Namespace('userdata'); if (is_object($udata) && !empty($udata->user['users_id'])) { self::getLogger()->setEventItem('users_id', $udata->user['users_id']); self::getLogger()->setEventItem('login', $udata->user['login']); self::getLogger()->setEventItem('fname', $udata->user['fname']); self::getLogger()->setEventItem('lname', $udata->user['lname']); } else { self::getLogger()->setEventItem('users_id', 0); self::getLogger()->setEventItem('login', "guest"); self::getLogger()->setEventItem('fname', "guest"); self::getLogger()->setEventItem('lname', "anonymous"); } self::getLogger()->setEventItem('module', $module); self::getLogger()->setEventItem('action', $action); self::getLogger()->setEventItem('module_table', $moduleTable); self::getLogger()->setEventItem('module_ids', $id); self::getLogger()->setEventItem('parent_id', $parentId); self::getLogger()->setEventItem('safinstances_id', Sydney_Tools::getSafinstancesId()); self::getLogger()->log($message, Zend_Log::INFO); }
public function processuserAction() { $data = $this->getRequest()->getPost(); $objectUser = new Users(); if (!($this->view->status = $objectUser->save($data, true))) { $msg = Sydney_Messages::getInstance()->getMessages(); $this->view->message = 'Validation errors found...'; if (!is_array($msg)) { $this->view->message .= ' (' . $msg . ')'; } $this->view->ResultSet = array('errors' => Sydney_Messages::getInstance()->getMessages(), 'entry' => array()); } else { // send email if (!$objectUser->isEditMode($data)) { $data['id'] = $objectUser->get()->id; $mailSubject = str_replace('[SITE_TITLE]', Sydney_Tools::getConf('general')->siteTitle, Sydney_Tools::_('subjectMailSubscribe')); $objectUser->registermail($objectUser->get()->login, $mailSubject, $data, $confirmationAction = '/publicms/profile/confirm/init/2', false, array('management/partialmailconfirm.phtml', 'publictimedex')); } $this->view->message = Sydney_Messages::getInstance()->getMessages(); $this->view->ResultSet = array('errors' => Sydney_Messages::getInstance()->getMessages(), 'entry' => $objectUser->get()->toArray()); } $this->view->showtime = 3; $this->view->modal = false; }
public function restoreAction() { $this->view->ResultSet = array('message' => 'Node not restored !', 'status' => 0, 'modal' => true); $data = Zend_Json::decode($this->getRequest()->jsondata); try { if ($data['dbId'] > 0) { // restore node $pgsd = new Pagstructure(); $node = $pgsd->get($data['dbId']); $pgsd->restoreNode($data['dbId']); /* * GDE : 27/08/2010 * Add trace of current action */ Sydney_Db_Trace::add('trace.event.restore_page' . ' [' . $node->label . ']', 'adminpages', Sydney_Tools::getTableName($pgsd), 'restorepage', $data['dbId']); // */ $this->view->ResultSet = array('message' => 'Node restored !', 'status' => 1, 'modal' => false); } else { $this->view->ResultSet = array('message' => 'Node not found !', 'status' => 0, 'modal' => true); } } catch (Exception $e) { $this->view->ResultSet = array('message' => 'error! ' . $e->getMessage(), 'status' => 0, 'modal' => true); } }
/** * Displays the upload screen * @return void */ public function uploadAction() { //$this->_helper->layout->disableLayout(); $params = $this->getRequest()->getParams(); // gets the categories for upload + tagging $catDB = new Filfolders(); $this->view->categories = $catDB->getFoldersStructure(); if ($params['calledBy'] != 'adminpeople') { $this->setSubtitle('Upload files'); $this->setSideBar('upload', 'files'); } if (count($_FILES['file']) > 0) { switch ($_FILES['file']['error']) { case UPLOAD_ERR_OK: $fullpath = Sydney_Tools::getAppdataPath() . '/adminfiles/'; $filename = $_FILES['file']['name']; $ndirn = substr($filename, -3); $ndirn = preg_replace('/\\./', '', $ndirn); $nnd = $fullpath . '/' . strtoupper($ndirn); $type = strtoupper($ndirn); if (!is_dir($nnd)) { mkdir($nnd); } if (!empty($_POST['fileupload-new-filename'])) { $filename = $_POST['fileupload-new-filename']; } if (move_uploaded_file($_FILES['file']['tmp_name'], $nnd . '/' . $filename)) { $fil = new Filfiles(); $fil->registerFileToDb($nnd, $filename, filesize($nnd . '/' . $filename), $type, $this->usersId, $this->safinstancesId, $this->getRequest()); $returnmsg = '"' . $filename . '", ' . Sydney_Tools::_('UPLOAD_ERR_OK'); } else { $returnmsg = Sydney_Tools::_('UPLOAD_UNKNOW_ERROR'); } break; case UPLOAD_ERR_INI_SIZE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_INI_SIZE'); break; case UPLOAD_ERR_FORM_SIZE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_FORM_SIZE'); break; case UPLOAD_ERR_PARTIAL: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_PARTIAL'); break; case UPLOAD_ERR_NO_FILE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_NO_FILE'); break; case UPLOAD_ERR_NO_TMP_DIR: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_NO_TMP_DIR'); break; case UPLOAD_ERR_CANT_WRITE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_CANT_WRITE'); break; case UPLOAD_ERR_EXTENSION: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_EXTENSION'); break; } if (!empty($returnmsg)) { echo '<span class="warning">', $returnmsg, '</span>'; } } }
/** * Returns the group of the user and put the user's data in the session * @param $login * @return string */ private function getGroupName($login) { if (!isset($this->userNamespace->user)) { $users = new Users(); $select = $users->select()->setIntegrityCheck(false)->from($users, array('users_id' => 'users.id', 'login' => 'users.login', 'usersgroups_name' => 'usersgroups.name', 'usersgroups_id' => 'usersgroups.id', 'fname' => 'users.fname', 'lname' => 'users.lname', 'email' => 'users.email', 'usersgroups_id' => 'users.usersgroups_id'))->where(' users.login LIKE ?', $login)->join('usersgroups', 'users.usersgroups_id = usersgroups.id'); $rows = $users->fetchAll($select); $row = $rows->current(); // save the last login time $usrDB = new Users(); $urow = $usrDB->fetchRow("id = '" . $row->users_id . "'"); $urow->lastlogindate = Sydney_Tools::getMySQLFormatedDate(); $urow->save(); $this->userNamespace->user = $row->toArray(); // define all the groups this user is part of $groupsDB = new Usersgroups(); $this->userNamespace->user['member_of_groups'] = $groupsDB->getParentsIds($this->userNamespace->user['usersgroups_id']); $this->userNamespace->lock(); return $row->usersgroups_name; } else { return $this->userNamespace->user['usersgroups_name']; } }
public static function ajaxContents($url) { self::setUrl($url); $divId = uniqid(); return "<div id='" . $divId . "'></div><script>\n\t\t\t\$.get('" . Sydney_Tools::getRootUrl() . "/" . self::$url . "/sydneylayout/no', function(data) {\n\t\t\t \$('#" . $divId . "').html(data);\n\t\t\t});\n\t\t</script>"; }
/** * * Enter description here ... * @param unknown_type $nodeId * @param unknown_type $published */ public function saveLastupdateContent($nodeId, $published = true) { $who = Sydney_Tools::who(); $row = $this->get($nodeId); if ($published) { $row->datemodified = new Zend_Db_Expr("NOW()"); $row->who_modified = $who; } $row->date_lastupdate_content = new Zend_Db_Expr("NOW()"); $row->who_lastupdate_content = $who; $row->save(); }
/** * * @return void */ public function editindexAction() { // call upload action from adminfiles //$this->view->action('upload', 'index', 'adminfiles', array('calledBy' => 'adminpeople','peopleId' => $this->view->id)); $this->layout->currentModule = $this->_request->getModuleName(); $modeEdit = false; if (isset($this->getRequest()->id)) { $this->setSubtitle2('Edit'); } else { $this->setSubtitle2('Create'); } $this->setSideBar('edit', 'people'); // request id if (isset($this->view->id)) { // search user $sql = $this->_getQuery('people', 'AND users.id = ' . $this->view->id); $u = $this->_db->fetchAll($sql); // if user exist if (count($u) == 1) { $d = array(); $modeEdit = true; // get the user $uDB = new Users(); $usr = $uDB->find($u[0]['id']); $user = $usr[0]; //$this->view->usersForm->populate($user->toArray()); $this->view->avatar = $user->avatar; } // END - if user exist } // Set a custom form user on publicms if exist for the current instance $formclass = 'UsersFormOp'; if ($this->view->moduleName == 'publicms' && !empty(Sydney_Tools::getConf('general')->form->profile) && @class_exists(Sydney_Tools::getConf('general')->form->profile)) { $formclass = Sydney_Tools::getConf('general')->form->profile; } Sydney_Form::setParams(array('request' => $this->r)); $this->view->usersForm = new $formclass(null, $this->usersData['member_of_groups'], $modeEdit); if (isset($this->view->id)) { $usera = $user->toArray(); } if ($modeEdit) { $this->view->usersForm->populate($usera); } }
/** * * delete all contents of page $pageid * @param $pageId id of the pagstructure * @param $rollback determine if the content are deleted or restored */ public function deleteContentFromPage($pageId, $rollback = false) { // search all content from page $PageDiv = new PagstructurePagdivs(); $selector = $PageDiv->select()->from(Sydney_Tools::getTableName($PageDiv), 'pagdivs_id')->where('pagstructure_id = ' . $pageId); $rowset = $PageDiv->fetchAll($selector)->toArray(); $listContentId = Sydney_Tools::implode(',', $rowset); // delete content if (!empty($listContentId)) { if ($this->isLogicalDelete()) { return $this->update(array('isDeleted' => !$rollback), 'id IN (' . $listContentId . ')'); } else { return $this->delete('id IN (' . $listContentId . ')'); } } return false; }
/** * */ public function toHtmlLastEditor() { $event = $this->toObject(); if ($event->current() != null) { return $html = '<strong>Last update:</strong> ' . substr(Sydney_Tools::getDate($event->current()->timestamp), 0, -3) . ' by ' . $event->current()->fname . ' ' . $event->current()->lname . ''; } }
private static function getCredentialCookieName() { return self::getPrefixCookieName() . sha1(Sydney_Tools::getSafinstancesId() . 'sydney_credential'); }
/** * Translation object setup */ public function setTranslationObject() { // set language if (isset($this->requestLang)) { $lg = $this->requestLang; } else { $lg = $this->config->general->lang; } if ($lg == '' || !$lg) { $lg = 'en'; } $this->registry->set('language', $lg); $translate = new Zend_Translate('csv', $this->corePath . '/application/language/en.csv', $this->config->general->lang); $translate->setLocale($this->config->general->locale); Zend_Validate_Abstract::setDefaultTranslator($translate); Zend_Form::setDefaultTranslator($translate); $this->registry->set('Zend_Translate', $translate); $path1 = $this->corePath . '/application/language/'; $path2 = Sydney_Tools::getLocalPath() . '/application/language/'; // general global translations if (is_dir($path1) && file_exists($path1 . $lg . '.csv')) { $translate->addTranslation($path1 . $lg . '.csv', $lg); } if (is_dir($path2) && file_exists($path2 . $lg . '.csv')) { $translate->addTranslation($path2 . $lg . '.csv', $lg); } // Create a log instance if ($this->debugTranslationsNotFound) { $writer = new Zend_Log_Writer_Stream(Sydney_Tools_Paths::getLogPath() . '/' . $lg . '-translation-notfound.log'); $log = new Zend_Log($writer); // Attach it to the translation instance $translate->setOptions(array('log' => $log, 'logUntranslated' => $this->config->general->env != 'PROD')); } }
/** * */ public function editadvancedprocessAction() { $r = $this->getRequest(); $eid = 0; if ($r->id > 0) { $nodeDB = new Pagstructure(); $node = $nodeDB->fetchRow('id = ' . $r->id . ' AND safinstances_id = ' . $this->safinstancesId); $node->metakeywords = $r->metakeywords; $node->metadesc = $r->metadesc; $node->iscachable = $r->iscachable; $node->cachetime = $r->cachetime; $node->redirecttoid = $r->redirecttoid; $node->shortdesc = $r->shortdesc; $node->colorcode = $r->colorcode; $node->layout = $r->layout; $node->save(); $eid = $r->id; // GDE : 27/08/2010 - Add trace of current action Sydney_Db_Trace::add('trace.event.update_advanced_properties' . ' [' . $node->label . ']', 'adminpages', Sydney_Tools::getTableName($nodeDB), 'editadvancedproperties', $eid); } // update the linked menu $mns = new PagstructurePagmenus(); $mns->delete('pagstructure_id = ' . $eid); //Zend_Debug::dump($r->menus); if (is_array($r->menus)) { foreach ($r->menus as $mid) { $crow = $mns->createRow(); $crow->pagstructure_id = $eid; $crow->pagmenus_id = $mid; $crow->save(); } } PagstructureOp::cleanCache($this->safinstancesId); $this->redirect('/adminpages/pages/edit/id/' . $eid); }
/** * Saves the files properties. * This is called from jquery.fileproperties method save() * @return void */ public function savefilepropsAction() { $message = 'No action taken'; $fltr = new Zend_Filter_Digits(); $r = $this->getRequest(); $fid = 0; if (isset($r->fid)) { $fid = $fltr->filter($r->fid); } if ($fid > 0) { $fildb = new Filfiles(); $where = "id = {$fid} AND safinstances_id = '" . $this->safinstancesId . "'"; $rows = $fildb->fetchAll($where); if (count($rows) == 1) { if (isset($r->filename)) { $rows[0]->label = $r->filename; } if (isset($r->desc)) { $rows[0]->desc = $r->desc; } $rows[0]->istagged = 0; /** if (isset($r->istagged)) { * if ($r->istagged == 'true' )$rows[0]->istagged = 1; * } **/ $rows[0]->save(); $message = 'File params saved'; /** * GDE : 27/08/2010 * Add trace of current action */ Sydney_Db_Trace::add('trace.event.update_file' . ' [' . $r->filename . ']', 'adminfiles', Sydney_Tools::getTableName($fildb), 'updatefile', $fid); // */ // save the folders if (isset($r->filfolders) && $r->filfolders != '') { $ffdata = array(); foreach (Zend_Json::decode($r->filfolders) as $fel) { $ffdata[] = $fel['val']; } $fileFilesDb = new FilfoldersFilfiles(); $fileFilesDb->setFilfilesLinkedTo($fid, $ffdata); } } } $this->view->ResultSet = array('message' => $message); }
/** * * @return void */ public function lostpasswordAction() { $form = $this->getLostpassForm(); $request = $this->getRequest(); $this->view->showform = true; // Check if we have a POST request if ($request->isPost() && !$form->isValid($request->getPost())) { // Invalid entries $this->view->form = $form; } if ($request->isPost() && $form->isValid($request->getPost())) { $this->view->showform = false; $usrDB = new Users(); $user = $usrDB->fetchRow("login LIKE '" . addslashes($request->username) . "' AND safinstances_id = '" . $this->safinstancesId . "' "); if ($user) { $strl = 'qwertyuiopasdfghjklzxcvbnm12345678902@#$!'; $strll = strlen($strl); $npwd = ''; for ($i = 0; $i <= 8; $i++) { $rdd = rand(0, $strll - 1); $npwd .= $strl[$rdd]; } $user->password = md5($npwd); $user->lastpwdchanges = Sydney_Tools::getMySQLFormatedDate(); $user->save(); // send the email $tmsg = "Dear user,\n\nYour password has been modified as requested.\nYou will now be able to use the following credentials:\n\nlogin: "******"\npassword: "******"\n\nWe suggest you change your password as soon as possible for security reason.\nIf you did not request a password change, please contact our support.\n\nRegards,\n" . $this->_config->general->siteTitle . " team.\n\n"; $mail = new Zend_Mail(); $mail->setBodyText($tmsg); $mail->setFrom($this->_config->general->siteEmail, $this->_config->general->siteTitle); $mail->addTo($user->login, $user->login); $mail->setSubject($this->_config->general->siteTitle . ' new password.'); $mail->send(); $this->view->mmsg = 'Thank you! Your new password has been sent to your email. Please check your email and use this new password for authentication.'; } else { $this->view->mmsg = 'We could not find this user in our database for this website... Are you sure you are registered?'; } } $this->view->form = $form; }
/** * Unpublish a div (set a div as draft) * */ public function unpublishdivAction() { $dbId = 0; $msg = 'Unknown status'; $request = $this->getRequest(); if ('pages' == $this->eModule) { $divs = new Pagdivspage(); $traceMsg = 'trace.event.update_content_pages'; } else { $divs = new Pagdivsnews(); $traceMsg = 'trace.event.update_content_news'; } $status = 0; if ($divs->checkRightFromId($request->id, $this->_config->db->safinstances_id, $this->eModule) || $request->id > 0) { $dbId = $request->id; $div = $divs->fetchRow('id=' . $request->id); $div->datemodified = new Zend_Db_Expr("NOW()"); $div->status = 'draft'; $div->params_draft = $div->params; // $div->params=null; $div->content_draft = $div->content; // $div->content=null; $div->save(); $status = 1; $msg = 'Content element save as draft'; Sydney_Db_Trace::add($traceMsg, $request->getModuleName(), Sydney_Tools::getTableName($div), $request->getActionName(), $div->id, $request->pagstructureid); } $this->view->ResultSet = array('message' => $msg, 'status' => $status, 'dbid' => $dbId, 'modal' => false); }
/** * */ public function editnwsfoldersAction() { $rowId = $this->_editfieldAction('Nwsfolders', 'NwsfoldersForm', array('safinstances_id' => Sydney_Tools::getSafinstancesId())); }
/** * Returns the HTML for the possible action for a node * * ( * [id] => 4031 * [label] => Welcome in Sydney docs * [isCollapsed] => * [status] => published * [datemodified] => 2010-11-24 06:38:37 * [date_lastupdate_content] => 2010-11-24 06:38:37 * [who_modified] => Gilles Demaret * [who_lastupdate_content] => Gilles Demaret * [ishome] => 1 * [iscachable] => * [cachetime] => 0 * [menusid] => Array * ( * ) * * [redirecttoid] => 0 * [usersgroups_id] => 2 * [pagorder] => 0 * [kids] => Array * ( * ) * * [stats] => Array * ( * ) * * ) * * * @return String HTML string * @param int $dbid [optional] DB ID of the node * @param int $ishome [optional] */ private function getActionsHtml($dbid = 0, $ishome = 0, $status = 'draft', $node = '') { $hidit = $ishome == 1 ? ' invisible' : ''; $btnStatus = $status != 'published' ? 'publish' : 'unpublish'; $toret = '<div id="adminpageaction-' . $dbid . '" style="display:none; text-align:right;" class="adminpages_action_container">'; $toret .= ' <div class="actionsContainer"> <span class="actions"> <a class="button ' . $btnStatus . '" id="btn_publish_' . $dbid . '" dbid="' . $dbid . '"> ' . ucfirst($btnStatus) . ' </a> <a class="button" href="/adminpages/index/create/parentid/' . $dbid . '"> <img src="' . Sydney_Tools::getRootUrlCdn() . '/sydneyassets/images/ui/button/icon_add.png"/> Add a sub-page </a> <a class="button" href="/adminpages/index/editproperties/id/' . $dbid . '"> Properties </a> <a class="button duplicate" dbid="' . $dbid . '" href="#"> Duplicate </a> <a class="button warning' . $hidit . ' deletenodea" dbid="' . $dbid . '" href="#"> Delete </a> </span> </div>'; $toret .= '</div>'; return $toret; }