protected function _load() { $this->_container = $this->_find(); $isPublished = $this->_checkPublished(); if (end($this->_options) == 'ajax') { $this->_view = new Zend_View(array('scriptPath' => dirname(__FILE__) . '/views')); $this->_view->websiteUrl = Zend_Controller_Action_HelperBroker::getStaticHelper('website')->getUrl(); $this->_view->type = $this->_type; $this->_view->name = $this->_name; if ($this->_pageId == null) { $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl($this->_toasterOptions['url']); $this->_pageId = $page->getId(); } $this->_view->pageId = $this->_pageId; $this->_view->isPublished = $isPublished; $this->_view->controls = Tools_Security_Acl::isAllowed($this) ? $this->_generateAdminControl(self::POPUP_WIDTH, self::POPUP_HEIGHT) : ''; $params = Zend_Json::encode(Zend_Controller_Front::getInstance()->getRequest()->getParams()); $this->_view->params = $params; $this->_cacheId = $this->_name . '_' . $this->_type . '_pid_' . $this->_pageId . '_' . Zend_Controller_Action_HelperBroker::getStaticHelper('Session')->getCurrentUser()->getRoleId() . substr(md5($params), 0, 27); return !$isPublished && !Tools_Security_Acl::isAllowed($this) ? '' : $this->_view->render('ajax.phtml'); } $content = $this->_container === null ? '' : $this->_container->getContent(); if (Tools_Security_Acl::isAllowed($this)) { $content .= $this->_generateAdminControl(self::POPUP_WIDTH, self::POPUP_HEIGHT); if ((bool) Zend_Controller_Action_HelperBroker::getStaticHelper('config')->getConfig('inlineEditor')) { $content = '<div class="container-wrapper ' . ($isPublished ? '' : 'unpublished') . '">' . $content . '</div>'; } elseif (!$isPublished) { $content = '<div class="unpublished">' . $content . '</div>'; } } else { $content = !$isPublished ? '' : $content; } return $content; }
protected function _load() { if (empty($this->_options)) { throw new Exceptions_SeotoasterWidgetException('No options provided'); } if (is_numeric(reset($this->_options))) { $userId = array_shift($this->_options); $this->_user = Application_Model_Mappers_UserMapper::getInstance()->find($userId); if (is_null($this->_user)) { return ''; } } elseif ($this->_sessionHelper->getCurrentUser()->getRoleId() === Tools_Security_Acl::ROLE_GUEST) { return ''; } else { $this->_user = $this->_sessionHelper->getCurrentUser(); } $this->_user->loadAttributes(); if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS) || $this->_user->getId() === $this->_sessionHelper->getCurrentUser()->getId()) { $this->_editableMode = true; Zend_Layout::getMvcInstance()->getView()->headScript()->appendFile($this->_websiteHelper->getUrl() . 'system/js/internal/user-attributes.js'); } $method = strtolower(array_shift($this->_options)); try { return $this->{'_render' . ucfirst($method)}(); } catch (Exception $e) { return '<b>Method ' . $method . ' doesn\'t exist</b>'; } }
private function _renderMainMenu() { $pagesList = array(); $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllMainMenuPages(); $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config'); $showMemberPages = (bool) $configHelper->getConfig('memPagesInMenu'); $isAllowed = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED); $isPageProtected = function ($page) use($isAllowed, $showMemberPages) { if (is_array($page['extraOptions']) && in_array(Application_Model_Models_Page::OPT_PROTECTED, $page['extraOptions']) && !$isAllowed && !$showMemberPages) { return true; } return false; }; $pagesList = array_filter($pages, function ($page) use($isPageProtected) { return !$isPageProtected($page) && $page['parentId'] == Application_Model_Models_Page::IDCATEGORY_CATEGORY; }); foreach ($pagesList as &$catPage) { $catId = $catPage['id']; $catPage['subPages'] = array_filter($pages, function ($page) use($isPageProtected, $catId) { return $page['parentId'] == $catId && !$isPageProtected($page); }); } if (is_null($this->_menuTemplate)) { $this->_view->pages = $pagesList; return $this->_view->render('mainmenu.phtml'); } else { return self::renderMenuTemplate($pagesList, $this->_menuTemplate); } }
/** * The put action handles PUT requests and receives an 'id' parameter; it * should update the server resource state of the resource identified by * the 'id' value. */ public function putAction() { $id = intval(filter_var($this->_request->getParam('id'), FILTER_VALIDATE_INT)); $data = json_decode($this->_request->getRawBody(), true); if ($id && !empty($data)) { if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS) && $id !== $this->_sessionHelper->getCurrentUser()->getId()) { $this->_error(self::REST_STATUS_FORBIDDEN); } $user = Application_Model_Mappers_UserMapper::getInstance()->find($id); if ($user instanceof Application_Model_Models_User) { Application_Model_Mappers_UserMapper::getInstance()->loadUserAttributes($user); foreach ($data as $attribute => $value) { $setter = 'set' . ucfirst(strtolower($attribute)); if (method_exists($user, $setter)) { $user->{$setter}($value); } else { $user->setAttribute($attribute, $value); } } $user->setPassword(false); Application_Model_Mappers_UserMapper::getInstance()->save($user); return array('status' => 'ok'); } } }
private function _renderFeaturedArea($params) { if (!is_array($params) || empty($params) || !isset($params[0]) || !$params[0] || preg_match('~^\\s*$~', $params[0])) { throw new Exceptions_SeotoasterWidgetException($this->_translator->translate('Featured area name required.')); } $areaName = $params[0]; $pagesCount = isset($params[1]) && $params[1] ? $params[1] : self::AREA_PAGES_COUNT; $maxDescriptionLength = isset($params[2]) && is_numeric($params[2]) ? intval($params[2]) : self::AREA_DESC_LENGTH; $random = intval(end($params)) === 1 ? true : false; $featuredArea = Application_Model_Mappers_FeaturedareaMapper::getInstance()->findByName($areaName); if ($featuredArea === null) { if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return ''; } return $this->_translator->translate('Featured area ') . $areaName . $this->_translator->translate(' does not exist'); } $featuredArea->setLimit($pagesCount)->setRandom($random); $this->_view->useImage = isset($params[3]) && ($params[3] == 'img' || $params[3] == 'imgc') ? $params[3] : false; $this->_view->faPages = $featuredArea->getPages(); $this->_view->faId = $featuredArea->getId(); $this->_view->faName = $featuredArea->getName(); $this->_view->faPageDescriptionLength = $maxDescriptionLength; // adding cache tag for this fa array_push($this->_cacheTags, 'fa_' . $areaName); array_push($this->_cacheTags, 'pageTags'); $areaPages = $featuredArea->getPages(); foreach ($areaPages as $page) { array_push($this->_cacheTags, 'pageid_' . $page->getId()); } return $this->_view->render('area.phtml'); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CONTENT) && !Tools_Security_Acl::isActionAllowed()) { $this->_redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->_helper->AjaxContext()->addActionContexts(array('manageform' => 'json', 'delete' => 'json', 'loadforms' => 'json', 'receiveform' => 'json'))->initContext('json'); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGES)) { $this->_redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->_helper->AjaxContext()->addActionContexts(array('loadfalist' => 'json', 'addpagetofa' => 'json', 'rempagefromfa' => 'json', 'delete' => 'json'))->initContext('json'); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_MEDIA)) { $this->_redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->_websiteConfig = Zend_Registry::get('website'); $this->_translator = Zend_Registry::get('Zend_Translate'); $this->_helper->AjaxContext()->addActionContexts(array('getdirectorycontent' => 'json', 'removefile' => 'json', 'loadfolders' => 'json'))->initContext('json'); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CONFIG)) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->_websiteConfig = Zend_Registry::get('website'); $this->view->helpSection = 'config'; $this->_translator = Zend_Registry::get('Zend_Translate'); $this->_configMapper = Application_Model_Mappers_ConfigMapper::getInstance(); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_THEMES)) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->_websiteConfig = Zend_Registry::get('website'); $this->_themeConfig = Zend_Registry::get('theme'); $this->_translator = Zend_Registry::get('Zend_Translate'); $this->_helper->AjaxContext()->addActionContexts(array('pagesviatemplate' => 'json'))->initContext('json'); }
public function init() { if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGES) && !Tools_Security_Acl::isActionAllowed()) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->view->websiteUrl = $this->_helper->website->getUrl(); if ('' == $this->getRequest()->getParam('format', '')) { $this->getRequest()->setParam('format', 'json'); } /* @var Zend_Controller_Action_Helper_ContextSwitch $contextSwitch */ $this->_helper->contextSwitch->addContext('html', array('suffix' => 'html', 'headers' => array('Content-Type' => 'text/html')))->addActionContexts(array('edit404page' => 'json', 'rendermenu' => 'json', 'listpages' => array('json', 'html'), 'publishpages' => 'json', 'checkforsubpages' => 'json', 'toggleoptimized' => 'json'))->initContext(); }
protected function _load() { $this->_container = $this->_find(); $headerContent = null === $this->_container ? '' : $this->_container->getContent(); if (Tools_Security_Acl::isAllowed($this)) { $headerContent .= $this->_generateAdminControl(600, 140); //$this->_addAdminLink($this->_type, (!$headerContent) ? null : $header->getId(), 'Click to edit header', 604, 130); if ((bool) Zend_Controller_Action_HelperBroker::getExistingHelper('config')->getConfig('inlineEditor')) { $headerContent = '<div class="container-wrapper">' . $headerContent . '</div>'; } } return $headerContent; }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PUBLIC)) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } if (!Tools_Security_Acl::isActionAllowed()) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->_helper->AjaxContext()->addActionContexts(array('loaddeeplinkslist' => 'json', 'loadredirectslist' => 'json', 'removeredirect' => 'json', 'removedeeplink' => 'json', 'loadsculptingdata' => 'json', 'addsilotopage' => 'json', 'silocat' => 'json', 'unsilocat' => 'json', 'managesilos' => 'json'))->initContext('json'); $this->_helper->contextSwitch()->addActionContext('sitemap', 'xml')->initContext(); $this->_translator = Zend_Registry::get('Zend_Translate'); $this->view->websiteUrl = $this->_helper->website->getUrl(); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PUBLIC)) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } if (!Tools_Security_Acl::isActionAllowed()) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->_helper->AjaxContext()->addActionContext('triggerinstall', 'json')->initContext('json'); $this->_helper->AjaxContext()->addActionContext('trigger', 'json')->initContext('json'); $this->_helper->AjaxContext()->addActionContext('delete', 'json')->initContext('json'); $this->_helper->AjaxContext()->addActionContext('list', 'json')->initContext('json'); $this->view->websiteUrl = $this->_helper->website->getUrl(); }
public function init() { parent::init(); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_MEDIA)) { $this->_redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->_websiteConfig = Zend_Registry::get('website'); $this->_themeConfig = Zend_Registry::get('theme'); $this->_translator = Zend_Registry::get('Zend_Translate'); $this->_caller = $this->getRequest()->getParam('caller'); $this->_uploadHandler = new Zend_File_Transfer_Adapter_Http(); // $this->_uploadHandler->setDestination(realpath($this->_websiteConfig['path'] . $this->_websiteConfig['tmp'])); if (!extension_loaded('fileinfo')) { $this->_checkMime = false; } }
public function init() { parent::init(); $this->_websiteData = Zend_Registry::get('website'); if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CONTENT) && !Tools_Security_Acl::isActionAllowed()) { $this->redirect($this->_helper->website->getUrl(), array('exit' => true)); } $this->_helper->viewRenderer->setNoRender(true); $this->_containerType = $this->getRequest()->getParam('containerType'); $this->_contentForm = $this->_initCorrectForm(); $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->view->currentTheme = $this->_helper->config->getConfig('currentTheme'); // content help section $this->view->helpSection = 'content'; $this->_helper->AjaxContext()->addActionContext('loadfiles', 'json')->initContext('json'); $this->_helper->AjaxContext()->addActionContext('refreshfolders', 'json')->initContext('json'); }
protected function _load() { if (!isset($this->_options[0])) { throw new Exceptions_SeotoasterWidgetException('Not enough parameters for the widget <strong>prepop</strong>.'); } $prepop = Application_Model_Mappers_ContainerMapper::getInstance()->findByName($this->_name, $this->_pageId, $this->_type); if ($prepop) { $this->_prepopContent = $prepop->getContent(); $this->_prepopContainerId = $prepop->getId(); } // User role should be a member or not only for reading at least to be able to edit if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CONTENT) || $this->_readonly) { if ($this->_options[0] == self::TYPE_CHECKBOX) { $translator = $this->_translator; $this->_prepopContent = implode(' ', array_map(function ($option) use($translator) { return $translator->translate(ucfirst($option)); }, array_filter(explode('~', $this->_prepopContent)))); } if (array_search(self::OPTION_LINKS, $this->_options)) { $this->_view->prepopName = $this->_prepopName; $this->_view->prepopContent = $this->_prepopContent; return $this->_view->render('prepopLink.phtml'); } elseif ($this->_readonly) { return $this->_prepopContent; } else { return '<span class="prepop-content" id="prepop-' . $this->_prepopName . '">' . $this->_prepopContent . '</span>'; } } if (array_search(self::OPTION_LINKS, $this->_options)) { $optionKey = array_search(self::OPTION_LINKS, $this->_options); $this->_options[$optionKey] = ''; } //assign common view vars for the prepop $this->_view->prepopContent = $this->_prepopContent; $this->_view->prepopConainerId = $this->_prepopContainerId; $this->_view->elementType = $this->_options[0]; $rendererName = '_renderPrepop' . ucfirst(array_shift($this->_options)); if (method_exists($this, $rendererName)) { return $this->{$rendererName}(); } throw new Exceptions_SeotoasterWidgetException($this->_translator->translate('Wrong prepop type')); }
public function dispatch() { $method = strtoupper($this->_request->getMethod()); if ($method === 'POST' && null !== ($extraMethod = $this->_request->getParam('_method', null))) { $extraMethod = strtoupper(filter_var($extraMethod, FILTER_SANITIZE_STRING)); if (in_array($extraMethod, array('PUT', 'DELETE'))) { $method = $extraMethod; } } $action = strtolower($method) . 'Action'; $aclResource = strtolower(get_called_class() . '_' . $method); if (method_exists($this, $action)) { if (Tools_Security_Acl::isAllowed($aclResource)) { return $this->_jsonHelper->direct($this->{$action}()); } else { $this->_error(null, self::REST_STATUS_FORBIDDEN); } } else { throw new Exceptions_SeotoasterPluginException(get_called_class() . ' doesn\'t have ' . $method . ' implemented'); } }
protected function _load() { $pluginName = strtolower(array_shift($this->_options)); if (!$pluginName) { return $this->_translator->translate('Plugin name not specified.'); } $plugin = Application_Model_Mappers_PluginMapper::getInstance()->findByName($pluginName); if ($plugin !== null) { if ($plugin->getStatus() != Application_Model_Models_Plugin::ENABLED) { return $this->_translator->translate('You need install the ') . $plugin->getName() . $this->_translator->translate(' plug-in to view and use this great feature.') . ' <a href="http://www.seotoaster.com/website-plugins-marketplace.html" target="_blank">' . $this->_translator->translate('Download plug-ins here') . ' ' . '</a>' . $this->_translator->translate('and watch a short video to learn how to install plug-ins on your website') . ' <a href="http://www.seotoaster.com/how-to-add-a-plugin.html" target="_blank">' . $this->_translator->translate('here') . '</a>.'; } try { $toasterPlugin = Tools_Factory_PluginFactory::createPlugin($plugin->getName(), $this->_options, $this->_toasterOptions); return $toasterPlugin->run(); } catch (Exceptions_SeotoasterPluginException $spe) { if (Tools_System_Tools::debugMode()) { error_log($spe->getMessage() . "\n" . $spe->getTraceAsString()); } if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return $spe->getMessage(); } } catch (Exceptions_SeotoasterException $se) { if (Tools_System_Tools::debugMode()) { error_log($se->getMessage() . "\n" . $se->getTraceAsString()); } if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return $se->getMessage(); } } catch (Exception $e) { if (Tools_System_Tools::debugMode()) { error_log($e->getMessage() . "\n" . $e->getTraceAsString()); } //return $e->getMessage(); } } if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return $this->_translator->translate('You need the') . ' ' . $pluginName . ' ' . $this->_translator->translate('plug-in to view and use this great feature.') . ' <a href="http://www.seotoaster.com/website-plugins-marketplace.html" target="_blank">' . $this->_translator->translate('Download plug-ins here') . ' ' . '</a>' . $this->_translator->translate('and watch a short video to learn how to install plug-ins on your website') . ' <a href="http://www.seotoaster.com/how-to-add-a-plugin.html" target="_blank">' . $this->_translator->translate('here') . '</a>.'; } return ''; }
protected function _load() { $pagesList = array(); $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllMainMenuPages(); $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config'); $showMemberPages = (bool) $configHelper->getConfig('memPagesInMenu'); $isAllowed = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED); $flatPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllStaticMenuPages(); $nomenuPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllNoMenuPages(); foreach ($pages as $key => $page) { if ($page['parentId'] == 0) { if ((bool) $page['protected'] && !$isAllowed && !$showMemberPages) { continue; } $pagesList[$key]['category'] = $page; foreach ($pages as $subPage) { if (isset($subPage['protected']) && (bool) $subPage['protected'] && !$isAllowed && !$showMemberPages) { continue; } if ($subPage['parentId'] == $page['id']) { $pagesList[$key]['subPages'][] = $subPage; } } } } $this->_view->pages = $pagesList; $this->_view->flatPages = $flatPages; if (isset($this->_options[0])) { if ($this->_options[0] == 'nomenuPages') { $this->_view->nomenuPages = $nomenuPages; } } $newslogPlugin = Application_Model_Mappers_PluginMapper::getInstance()->findByName('newslog'); if ($newslogPlugin instanceof Application_Model_Models_Plugin) { if ($newslogPlugin->getStatus() == Application_Model_Models_Plugin::ENABLED) { $this->_view->newsFolder = Newslog_Models_Mapper_ConfigurationMapper::getInstance()->fetchConfigParam('folder'); } } return $this->_view->render('sitemap.phtml'); }
protected function _load() { if (!$this->_checkEnabled()) { return ''; } if (!is_array($this->_options) || empty($this->_options) || !isset($this->_options[0]) || !$this->_options[0] || preg_match('~^\\s*$~', $this->_options[0])) { throw new Exceptions_SeotoasterException($this->_translator->translate('You should specify code container name.')); } $this->_container = Application_Model_Mappers_ContainerMapper::getInstance()->findByName($this->_name, $this->_pageId, $this->_type); $codeContent = null === $this->_container ? '' : $this->_container->getContent(); if (!preg_match('~<script~', $codeContent)) { ob_start(); $returned = eval($codeContent); $codeContent = ob_get_clean(); ob_get_flush(); $codeContent .= $returned; } if (Tools_Security_Acl::isAllowed($this)) { $codeContent .= $this->_generateAdminControl(964, 594); } return $codeContent; }
private static function _validate($name) { $miscData = Zend_Registry::get('misc'); $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website'); $pluginDirectory = $websiteHelper->getPath() . $miscData['pluginsPath'] . strtolower($name); unset($miscData); unset($websiteHelper); if (!is_dir($pluginDirectory)) { if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { throw new Exceptions_SeotoasterPluginException($pluginDirectory . ' is not a directory.'); } throw new Exceptions_SeotoasterPluginException('<!-- ' . $pluginDirectory . ' is not a directory. -->'); } $pluginClassPath = $pluginDirectory . '/' . $name . '.php'; if (!file_exists($pluginClassPath)) { if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { throw new Exceptions_SeotoasterPluginException($pluginClassPath . ' not found.'); } throw new Exceptions_SeotoasterPluginException('<!--' . $pluginClassPath . ' not found. -->'); } require_once $pluginClassPath; }
/** * Renders search form widget * @return string Widget html code * @throws Exceptions_SeotoasterWidgetException If search results page not provided or doesn't exists */ private function _renderSearchForm() { $searchResultPage = Application_Model_Mappers_PageMapper::getInstance()->fetchByOption(self::PAGE_OPTION_SEARCH, true); if (!$searchResultPage instanceof Application_Model_Models_Page) { if (isset($this->_options[0]) && intval($this->_options[0])) { $searchResultPage = Application_Model_Mappers_PageMapper::getInstance()->find(intval($this->_options[0])); if (!$searchResultPage instanceof Application_Model_Models_Page) { throw new Exceptions_SeotoasterWidgetException($this->_translator->translate('Search results page not found')); } } else { throw new Exceptions_SeotoasterWidgetException($this->_translator->translate('Search results page is not selected')); } } $searchForm = new Application_Form_Search(); $searchFormAction = $searchResultPage->getUrl(); if ($searchFormAction !== 'index.html') { $searchForm->setAction($this->_websiteHelper->getUrl() . $searchFormAction); } else { $searchForm->setAction($this->_websiteHelper->getUrl()); } $this->_view->searchForm = $searchForm; $this->_view->showReindexOption = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS) && Tools_Search_Tools::isEmpty(); return $this->_view->render('form.phtml'); }
private function _pageRunkSculptingDemand($page, $pageContent) { // run pr sculpting only for the not logged users if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { //Checking if page has silo? if ($page->getSiloId()) { $pageContent = Tools_Seo_Tools::runPageRankSculpting($page->getSiloId(), $pageContent); $this->view->sculptingReplacement = Zend_Registry::get('sculptingReplacement'); } } return $pageContent; }
public function indexAction() { $this->_helper->page->doCanonicalRedirect('go'); //if logged in user trys to go to the login page - redirect him to the main page if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED)) { $this->_redirect($this->_helper->website->getUrl()); } $loginForm = new Application_Form_Login(); if ($this->getRequest()->isPost()) { if ($loginForm->isValid($this->getRequest()->getParams())) { $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter'), 'user', 'email', 'password', 'MD5(?)'); $authAdapter->setIdentity($loginForm->getValue('email')); $authAdapter->setCredential($loginForm->getValue('password')); $authResult = $authAdapter->authenticate(); if ($authResult->isValid()) { $authUserData = $authAdapter->getResultRowObject(null, 'password'); if (null !== $authUserData) { $user = new Application_Model_Models_User((array) $authUserData); $user->setLastLogin(date(Tools_System_Tools::DATE_MYSQL)); $user->setIpaddress($_SERVER['REMOTE_ADDR']); $this->_helper->session->setCurrentUser($user); Application_Model_Mappers_UserMapper::getInstance()->save($user); unset($user); $this->_helper->cache->clean(); if ($authUserData->role_id == Tools_Security_Acl::ROLE_MEMBER) { $this->_memberRedirect(); } if (isset($this->_helper->session->redirectUserTo)) { $this->_redirect($this->_helper->website->getUrl() . $this->_helper->session->redirectUserTo, array('exit' => true)); } $this->_redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->_helper->website->getUrl()); } } $signInType = $this->getRequest()->getParam('singintype'); if ($signInType && $signInType == Tools_Security_Acl::ROLE_MEMBER) { $this->_memberRedirect(false); } $this->_checkRedirect(false, array('email' => 'There is no user with such login and password.')); } else { $this->_checkRedirect(false, array('email' => 'Login should be a valid email address')); } } else { //getting available system translations $this->view->languages = $this->_helper->language->getLanguages(); //getting messages $errorMessages = $this->_helper->flashMessenger->getMessages(); if (!empty($errorMessages)) { foreach ($errorMessages as $message) { foreach ($message as $elementName => $msg) { $loginForm->getElement($elementName)->setAttribs(array('class' => 'notvalid', 'title' => $msg)); } } } $this->view->messages = $this->_helper->flashMessenger->getMessages(); //unset url redirect set from any login widget unset($this->_helper->session->redirectUserTo); $loginForm->removeDecorator('HtmlTag'); $loginForm->setElementDecorators(array('ViewHelper', 'Errors', 'Label', array('HtmlTag', array('tag' => 'p')))); $this->view->loginForm = $loginForm; } }
protected function _run() { return Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED) ? $this->_spaceContent : ''; }
public function exportAction() { if ($this->getRequest()->isPost()) { if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS)) { $users = Application_Model_Mappers_UserMapper::getInstance()->fetchAll(); $dataToExport = array(); foreach ($users as $user) { $usrData = $user->toArray(); unset($usrData['password']); unset($usrData['id']); unset($usrData['attributes']); $dataToExport[] = $usrData; } $exportResult = Tools_System_Tools::arrayToCsv($dataToExport, array($this->_helper->language->translate('E-mail'), $this->_helper->language->translate('Role'), $this->_helper->language->translate('Full name'), $this->_helper->language->translate('Last login date'), $this->_helper->language->translate('Registration date'), $this->_helper->language->translate('IP address'))); if ($exportResult) { $usersArchive = Tools_System_Tools::zip($exportResult); $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename=' . Tools_Filesystem_Tools::basename($usersArchive))->setHeader('Content-type', 'application/force-download'); readfile($usersArchive); $this->getResponse()->sendResponse(); } exit; } } }
protected function _run() { return Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL) ? $this->_spaceContent : ''; }
public function init() { $this->setName($this->_name)->setMethod(Zend_FORM::METHOD_POST)->setDecorators(array('FormElements', 'Form'))->setElementDecorators(array('ViewHelper', 'Label', new Zend_Form_Decorator_HtmlTag(array('tag' => 'div', 'class' => 'grid_12 mt10px'))))->setElementFilters(array('StringTrim', 'StripTags')); $this->addElement('hidden', 'currentTheme', array('value' => $this->_currentTheme, 'readonly' => true)); /*$this->addElement('text', 'adminEmail', array( 'value' => $this->_adminEmail, 'label' => 'Admin Email', 'validators' => array(new Zend_Validate_EmailAddress()) ));*/ $this->addElement('text', Tools_System_Tools::RECAPTCHA_PUBLIC_KEY, array('value' => $this->_recaptchaPublicKey, 'label' => 'reCAPTCHA public key')); $this->addElement('text', Tools_System_Tools::RECAPTCHA_PRIVATE_KEY, array('value' => $this->_recaptchaPrivateKey, 'label' => 'reCAPTCHA private Key')); $this->addElement('text', 'imgSmall', array('value' => $this->_imgSmall, 'label' => 'Small Image Size', 'validators' => array(new Zend_Validate_Int()))); $this->addElement('text', 'imgMedium', array('value' => $this->_imgMedium, 'label' => 'Medium Image Size', 'validators' => array(new Zend_Validate_Int()))); $this->addElement('text', 'imgLarge', array('value' => $this->_imgLarge, 'label' => 'Large Image Size', 'validators' => array(new Zend_Validate_Int()))); $this->addElement('text', 'teaserSize', array('value' => $this->_teaserSize, 'label' => 'Page Teaser Image Size', 'validators' => array(new Zend_Validate_Int()))); $this->addElement('checkbox', 'useSmtp', array('value' => $this->_useSmtp, 'label' => 'Use SMTP?')); $this->addElement('text', 'smtpHost', array('value' => $this->_smtpHost, 'label' => 'SMTP Hostname', 'placeholder' => 'e.g., smtp.gmail.com')); $this->addElement('text', 'smtpLogin', array('value' => $this->_smtpLogin, 'label' => 'SMTP Login', 'autocomplete' => 'off')); $this->addElement('password', 'smtpPassword', array('value' => $this->_smtpPassword, 'label' => 'SMTP Password', 'autocomplete' => 'off', 'renderPassword' => Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS))); $this->addElement('text', 'smtpPort', array('value' => $this->_smtpPort, 'class' => 'optional', 'label' => 'SMTP Port', 'placeholder' => 'empty by default', 'validators' => array(new Zend_Validate_Digits()))); $this->addElement('select', 'smtpSsl', array('label' => 'SSL', 'class' => 'optional', 'multiOptions' => array(0 => 'no', 'ssl' => 'SSL', 'tls' => 'TLS'))); $this->addElement('select', 'language', array('value' => $this->_language, 'label' => 'Website Language')); $this->addElement('text', 'suLogin', array('value' => $this->_suLogin, 'label' => 'E-mail', 'validators' => array(new Zend_Validate_EmailAddress()), 'ignore' => true)); $this->addElement('password', 'suPassword', array('value' => $this->_suPassword, 'label' => 'Password', 'validators' => array(array('StringLength', true, array(4))), 'ignore' => true, 'placeholder' => '*******')); $this->addElement(new Zend_Form_Element_Checkbox(array('name' => 'memPagesInMenu', 'value' => $this->_showProtectedPagesInMenu, 'label' => 'Member pages in menu?'))); $this->addElement(new Zend_Form_Element_Button(array('name' => 'submit', 'type' => 'submit', 'label' => 'Save', 'class' => 'icon-save mr-grid', 'ignore' => true, 'escape' => false))); $this->addElement('checkbox', 'mediaServers', array('value' => $this->_mediaServers, 'label' => 'Use mediaServers?')); $this->addElement('checkbox', 'inlineEditor', array('value' => $this->_inlineEditor, 'label' => 'Enable edit zones highlighting?')); $this->addElement('select', 'canonicalScheme', array('value' => $this->_canonicalScheme, 'label' => 'Set canonicalization tag to', 'multiOptions' => array(Zend_Controller_Request_Http::SCHEME_HTTP => 'http', Zend_Controller_Request_Http::SCHEME_HTTPS => 'https'))); }
protected function _load() { if (!is_array($this->_options) || empty($this->_options) || !isset($this->_options[0]) || !$this->_options[0] || preg_match('~^\\s*$~', $this->_options[0])) { throw new Exceptions_SeotoasterException($this->_translator->translate('You should provide a form name.')); } if (strtolower($this->_options[0]) == 'conversioncode') { return $this->_conversionCode($this->_options); } $sessionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Session'); $useCaptcha = isset($this->_options[1]) && $this->_options[1] == 'captcha' ? true : false; $useRecaptcha = isset($this->_options[1]) && $this->_options[1] == 'recaptcha' ? true : false; $uploadLimitSize = is_numeric(end($this->_options)) ? end($this->_options) : self::UPLOAD_LIMIT_SIZE; $formMapper = Application_Model_Mappers_FormMapper::getInstance(); $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $form = $formMapper->findByName($this->_options[0]); $pageHelper = new Helpers_Action_Page(); $pageHelper->init(); if ($useCaptcha || $useRecaptcha) { if ($form != null) { $form->setCaptcha(1); $formMapper->save($form); } if ($useRecaptcha) { $recaptchaTheme = 'red'; $recaptchaWidgetId = uniqid('recaptcha_widget_'); if (isset($this->_options[2])) { $recaptchaTheme = $this->_options[2]; if ($recaptchaTheme == 'custom') { $this->_view->customRecaptcha = true; } } $this->_view->recaptchaWidgetId = $recaptchaWidgetId; $this->_view->addScriptPath($this->_websiteHelper->getPath() . 'seotoaster_core/application/views/scripts/backend/form/'); $this->_view->recaptchaCode = Tools_System_Tools::generateRecaptcha($recaptchaTheme, $recaptchaWidgetId); } if ($useCaptcha) { $this->_view->captchaId = Tools_System_Tools::generateCaptcha(); } } if (isset($sessionHelper->toasterFormError)) { $this->_view->toasterFormError = $sessionHelper->toasterFormError; unset($sessionHelper->toasterFormError); } if (isset($sessionHelper->toasterFormSuccess)) { $this->_view->toasterFormSuccess = $sessionHelper->toasterFormSuccess; unset($sessionHelper->toasterFormSuccess); } $trackingConversionUrl = 'form-' . $this->_options[0] . '-thank-you'; $trackingConversionUrl = $pageHelper->filterUrl($trackingConversionUrl); $trackingPageExist = $pageMapper->findByUrl($trackingConversionUrl); if ($trackingPageExist instanceof Application_Model_Models_Page) { $this->_view->trackingConversionUrl = $trackingConversionUrl; } $this->_view->useRecaptcha = $useRecaptcha; $this->_view->useCaptcha = $useCaptcha; $this->_view->form = Application_Model_Mappers_FormMapper::getInstance()->findByName($this->_options[0]); $this->_view->allowMidification = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL); $this->_view->formName = $this->_options[0]; $this->_view->uploadLimitSize = $uploadLimitSize; $filter = new Zend_Filter_Alnum(); $this->_view->formId = $filter->filter($this->_options[0]); $this->_view->pageId = $this->_toasterOptions['id']; $this->_view->websiteTmp = $this->_websiteHelper->getTmp(); $this->_view->formUrl = $this->_toasterOptions['url']; return $this->_view->render('form.phtml'); }