public function editAction() { if ($this->_request->getParam('dataPage')) { $dataPage = $this->_request->getParam('dataPage'); $id = $this->_request->getParam('id'); $item = $this->_modelMapper->find($id, $this->_model); $item->setOptions($dataPage); $category = $this->_modelCategoriesMapper->find($item->getCategoryId(), new Pipeline_Model_PipelineCategories()); $fullPath = $category ? $category->getPath() . '/' . $item->getPath() : $item->getPath(); $item->setFullPath($fullPath); $this->setUploadImage($item); $markdown = $dataPage['contentMarkdown']; $context_html = Michelf\MarkdownExtra::defaultTransform($markdown); $item->setContentHtml($context_html); $this->_modelMapper->save($item); $this->_redirector->gotoUrlAndExit('/pipeline/' . $item->getFullPath()); } parent::editAction(); $form = $this->_forms['edit']; $imageTableElement = $form->getElement('imageTable'); $imageTablePrepend = '<button type="button" class="btn btn-default" id="imageTableLoadBtn"><span class="glyphicon glyphicon-save"></span></button>'; $imageTableValue = $imageTableElement->getValue(); if (!is_null($imageTableValue)) { $imageTablePrepend .= '<a href="' . $imageTableValue . '" class="btn btn-default" target="_blank"><span class="glyphicon glyphicon-eye-open"></span></a>'; //$imageTablePrepend .= '<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></button>'; } $imageTableElement->setAttrib('prepend_btn', $imageTablePrepend); $this->setViewPipelineProperties(); }
public function indexAction() { //!!! ЗАЦИКЛИВАЕТ ПЕРЕАДРЕСАЦИЮ ЕСЛИ ПОЛЬЗОВАТЕЛЬ АВТОРИЗОВАН // И НЕ ДОПУЩЕН ДО РЕСУРСА // проверяем, авторизирован ли пользователь /*if (Zend_Auth::getInstance()->hasIdentity()) { Zend_Debug::dump($this->_request->getParams()); // если да, то делаем редирект, чтобы исключить многократную авторизацию if($this->_request->getParam('currentUrl')) $this->_redirector->gotoUrlAndExit($this->_request->getParam('currentUrl')); $this->_redirector->gotoSimpleAndExit('index', 'index'); }*/ $this->_helper->layout->setLayout('layout_auth'); // создаём форму и передаём её во view $form = new Admin_Form_Auth(); $this->view->assign('form_auth', $form); // Если к нам идёт Post запрос if ($this->getRequest()->isPost()) { // Принимаем его $formData = $this->getRequest()->getPost(); // Если форма заполнена верно if ($form->isValid($formData)) { // получаем введённые данные $username = $this->getRequest()->getPost('username'); $password = $this->getRequest()->getPost('password'); $authAdapter = new Admin_Model_Auth($username, $password); // получаем экземпляр Zend_Auth $auth = Zend_Auth::getInstance(); // делаем попытку авторизировать пользователя $result = $auth->authenticate($authAdapter); //Zend_Debug::dump($this->_curUrl); // если авторизация прошла успешно if ($result->isValid()) { // используем адаптер для извлечения оставшихся данных о пользователе //$identity = $authAdapter->getResultRowObject(); $identity = $result->getIdentity(); // получаем доступ к хранилищу данных Zend $authStorage = $auth->getStorage(); // помещаем туда информацию о пользователе, // чтобы иметь к ним доступ при конфигурировании Acl $authStorage->write($identity); // Используем библиотечный helper для редиректа // на текущий url $this->_redirector->gotoUrlAndExit($this->_curUrl); //return; } else { $this->view->assign('errMessage', 'Вы ввели неверное имя пользователя или неверный пароль'); } } } if (Zend_Auth::getInstance()->hasIdentity() && $this->getParam('forbiddenResource')) { $this->view->assign('forbiddenResource', $this->getParam('forbiddenResource')); } }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { if (in_array(System_String::StrToLower($request->getControllerName()), array('admin', 'panel')) && false == $request->isXmlHttpRequest() && false == $request->getParam('direct')) { $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoUrlAndExit('#' . $this->_view->baseUrl() . $this->_view->currentUrl()); } }
public function addAction() { if ($this->_request->isPost()) { $url = $this->_request->getParam('currentUrl'); if ($this->_request->getParam('dataFormProducts')) { $dataProducts = $this->_request->getParam('dataFormProducts'); //основные - sku, name, description, note, sorting, path $product = new Catalog_Model_Products($dataProducts); //modDate, order $product->setMetaTitle($dataProducts['name'])->setMetaDescription($dataProducts['description'])->setMetaKeywords($dataProducts['name'])->setOrder($dataProducts['sorting'])->setActive(1)->setDeleted(0)->setAddDate(date("Y-m-d H:i:s"))->setModDate(date("Y-m-d H:i:s")); $this->_modelMapper->save($product); $productId = $this->_modelMapper->getDbTable()->getAdapter()->lastInsertId(); $categoriesMapperXref = new Catalog_Model_Mapper_CategoriesXref(); $categoriesMapperXref->save(new Catalog_Model_CategoriesXref(array('productId' => $productId, 'categoryId' => $this->_request->getParam('categoryId')))); $product = $this->_modelMapper->find($productId, $this->_model); $upload = new Zend_File_Transfer(); $uploadPath = '/upload/products/' . $product->getId() . '/'; //image if ($upload->isUploaded('fileLoadImage')) { $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadImage'); $product->setUploadPath($uploadPath)->setImage($imageFile['fileLoadImage']['name']); } //draft if ($upload->isUploaded('fileLoadDraft')) { $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadDraft'); $product->setUploadPathDraft($uploadPath)->setDraft($imageFile['fileLoadDraft']['name']); } $this->_modelMapper->save($product); $url = '/catalog/' . $product->getFullPath(); } $this->clearCache('CatalogProductsList'); $this->_redirector->gotoUrlAndExit($url); } //Zend_Debug::dump($this->_request->getParams()); }
public function editAction() { if ($this->_request->getParam('dataPage')) { $dataPage = $this->_request->getParam('dataPage'); $id = $this->_request->getParam('id'); $categories = $this->_modelMapper->find($id, $this->_model); $categories->setOptions($dataPage); $this->setUploadImage($categories); $markdown = $dataPage['contentMarkdown']; $context_html = Michelf\MarkdownExtra::defaultTransform($markdown); $categories->setContentHtml($context_html); $this->_modelMapper->save($categories); $this->_redirector->gotoUrlAndExit('/manufacture/' . $categories->getPath()); } parent::editAction(); }
public function editAction() { $itemId = $this->_request->getParam('id'); if (is_null($itemId)) { $this->_redirector->gotoUrlAndExit($this->getCurrentUrl()); return; } $item = $this->_modelMapper->find($itemId, new Forum_Model_Forum()); $oldContent = $item->getContent(); $markdown = $this->_request->getParam('contentMarkdown'); if ($markdown && $markdown != '') { $context_html = Michelf\MarkdownExtra::defaultTransform($markdown); $item->setContent($context_html); $item->setContentMarkdown($markdown); $item->setTimestamp(date("Y-m-d H:i:s")); if ($this->_userAuth->email != $item->getEmail()) { $item->setAuthor($this->_userAuth->name); $item->setEmail($this->_userAuth->email); $this->sendEditMail($item, $oldContent); } $this->_modelMapper->save($item); } $cacheName = !$item->getParentId() ? 'forumQuestions' : 'forumReply'; $this->clearCache($cacheName); $this->_redirector->gotoUrlAndExit($this->getCurrentUrl()); }
public function editAction() { if ($this->_request->getParam('dataPage')) { $dataPage = $this->_request->getParam('dataPage'); $id = $this->_request->getParam('id'); $item = $this->_modelMapper->find($id, $this->_model); $item->setOptions($dataPage); $categories = $this->_modelCategoriesMapper->find($item->getCategoryId(), new Media_Model_MediaCategories()); $fullPath = $categories->getPath() . '/' . $item->getPath(); $item->setFullPath($fullPath); $this->setUploadImage($item); $markdown = $dataPage['contentMarkdown']; $context_html = Michelf\MarkdownExtra::defaultTransform($markdown); $item->setContentHtml($context_html); $this->_modelMapper->save($item); $this->_redirector->gotoUrlAndExit('/media/' . $item->getFullPath()); } parent::editAction(); }
public function indexAction() { $fullPath = $this->getFullPath(); if (is_null($fullPath)) { $this->_redirector->gotoSimpleAndExit('index', 'index'); } $category = $this->_categoryMapper->findByFulPath($fullPath, new Oil_Model_OilCategories()); if (is_null($category)) { //throw new Zend_Controller_Action_Exception("Страница не найдена", 404); //перенаправляем в товар, может быть это товар $this->forward('view', 'oil'); return; } if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) { $this->forward('json', 'oil-categories', 'admin', array('id' => $category->getId())); return; } if (Zend_Auth::getInstance()->hasIdentity()) { $this->_request->setParams(array('dataItem' => array('controller' => 'oil-categories', 'id' => $category->getId(), 'active' => $category->getActive(), 'deleted' => $category->getDeleted()))); } if ($category->getDeleted() != '0') { if (!Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'oil-categories', 'action' => 'index'), 'adminEdit', true); } $this->view->assign(array('category' => $category, 'title' => $category->getTitle(), 'adminPath' => 'oil-categories/list/' . $category->getId())); if ($category->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Controller_Action_Exception("Раздел временно не доступен", 500); } if ($category->getId() != 0) { $select = $this->_categoryMapper->getDbTable()->select(); $select->where('parent_id = ?', $category->getId())->where('deleted != ?', 1)->order('sorting ASC'); $categories = $this->_categoryMapper->fetchAll($select); if (empty($categories)) { $this->forward('index', 'oil', 'oil', array('category' => $category)); return; } $this->view->categories = $categories; } else { $this->_redirector->gotoUrlAndExit('/oil/', array('code' => 301)); } }
/** * Check permission user * @author Nguyễn Mạnh Hùng * @email manhhung86it@gmail.com * @version 1.0 * @param Zend_Controller_Request_Abstract $request * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $module = $request->getParam('module', 'front'); $auth = Zend_Auth::getInstance(); $controller = $request->getControllerName(); $action = $request->getActionName(); $redirector = new Zend_Controller_Action_Helper_Redirector(); //check quyen truy cap vao admin if ($module != 'login' && !$auth->hasIdentity()) { $redirector->gotoUrlAndExit(SITE_URL . '/auth/login'); } }
public function seoAction() { $itemId = $this->_request->getParam('id'); if (is_null($itemId)) { $this->getRedirector()->gotoSimpleAndExit('index'); } $item = $this->getModelMapper()->find($itemId, $this->getModel()); if (is_null($item)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } if ($this->_request->getParam('dataFormSeo')) { $item->setOptions($this->_request->getParam('dataFormSeo')); $this->getModelMapper()->save($item); } $this->_redirector->gotoUrlAndExit($this->_request->getParam('currentUrl')); }
public function seoAction() { $pageId = $this->_request->getParam('id'); if (is_null($pageId)) { $this->_redirector->gotoSimpleAndExit('index'); } $page = $this->_modelMapper->find($pageId, new Pages_Model_Pages()); if ($this->getRequest()->isPost()) { if ($this->getRequest()->getParam('dataFormSeo')) { $dataFormSeo = $this->getRequest()->getParam('dataFormSeo'); $page->setOptions($dataFormSeo); $this->_modelMapper->save($page); } } $url = $page->getPath() != 'home' ? '/' . $page->getPath() : '/'; $this->_redirector->gotoUrlAndExit($url); }
public function disabledAction() { $categoryId = $this->_request->getParam('id'); if (is_null($categoryId)) { $this->_redirector->gotoSimpleAndExit('index'); } $category = $this->_modelMapper->find($categoryId, new Catalog_Model_Categories()); if (is_null($category)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } if ($this->_request->isPost()) { $url = $this->_request->getParam('currentUrl'); $enabled = $category->getActive() != 0 ? 0 : 1; $category->setActive($enabled); $this->_modelMapper->save($category); $this->clearCache('CatalogCategories'); $this->_redirector->gotoUrlAndExit($url); } }
public function verificarLogin($request, &$view) { $s = new Zend_Session_Namespace("USUARIO"); $cName = $request->getControllerName(); $aName = $request->getActionName(); $mName = $request->getModuleName(); $livre = array(); if ($mName != "default") { if (!in_array($mName . "-" . $cName . "-" . $aName, $livre)) { $s = new Zend_Session_Namespace("USUARIO"); $usr = $s->usuario; if (empty($usr)) { $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoUrlAndExit($view->url(array('module' => 'admin', 'controller' => 'index', 'action' => 'login'))); } else { $view->usuario = $usr; } } } }
/** * logout action * @author Nguyen Manh Hung */ public function logoutAction() { $layoutPath = APPLICATION_PATH . '/templates/login'; $option = array('layout' => 'index', 'layoutPath' => $layoutPath); Zend_Layout::startMvc($option); $translate = Zend_Registry::get('Zend_Translate'); $this->view->title = 'Đăng Xuất - ' . $translate->_("TEXT_DEFAULT_TITLE"); $this->view->headTitle($this->view->title); $authAdapter = Zend_Auth::getInstance(); $authAdapter->clearIdentity(); $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoUrlAndExit(SITE_URL . '/auth/login'); }
public function indexAction() { $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoUrlAndExit(SITE_URL . '/hethong/users'); }