/** * Prepare container */ protected function _prepareContainer() { parent::_prepareContainer(); $this->setIsEditButtonEnabled(FALSE); $this->setIsSaveButtonEnabled(FALSE); $this->setIsResetButtonEnabled(FALSE); $this->addButton(array('name' => 'reply', 'id' => 'reply', 'button_text' => 'Reply', 'style_class' => 'form-button', 'icon_class' => 'save', 'url' => Fox::getUrl('*/*/reply', array('id' => $this->getRequest()->getParam('id'))))); }
/** * Get delete button action url * * @return string */ public function getDeleteButtonUrl() { $url = ''; $id = $this->getRequest()->getParam('id', FALSE); if ($id) { $url = Fox::getUrl('*/*/delete', array('id' => $id)); } return $url; }
/** * Prepare container */ protected function _prepareContainer() { if (Fox::getModel('extensionmanager/session')->getFormData()) { $this->editing = true; $this->addButton(array("type" => "button", "button_text" => "Generate Package", "url" => $this->getUrl("*/*/generate-package"), "style_class" => "form-button", "confirm" => true, "confirm_text" => "Unsaved changes to package may lost.")); } $this->deleteButtonUrl = Fox::getUrl("*/*/delete"); $this->setIsDeleteButtonEnabled(TRUE); parent::_prepareContainer(); }
/** * Bulk status update action */ public function groupStatusAction() { try { $model = Fox::getModel('core/cache'); $codes = $this->getGroupActionIds($model); $totalIds = count($codes); $updateType = ''; $dependentParams = $this->getRequest()->getParam('dependents', array()); if (isset($dependentParams['status'])) { if ($dependentParams['status'] == Fox_Core_Model_Cache::STATUS_CLEAR) { $updateType = 'cleared'; if (in_array(Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE, $codes)) { Uni_Core_Preferences::loadPreferences(TRUE); Fox::initializePreferences(); } if (in_array(Fox_Core_Model_Cache::CACHE_CODE_LAYOUT, $codes)) { Uni_Core_CacheManager::clearLayoutCache(); } } else { if ($dependentParams['status'] == Fox_Core_Model_Cache::STATUS_ENABLED) { $updateType = 'enabled'; } else { if ($dependentParams['status'] == Fox_Core_Model_Cache::STATUS_DISABLED) { $updateType = 'disabled'; } } $cacheCodes = '\'' . implode('\',\'', $codes) . '\''; $model->update(array('status' => $dependentParams['status']), 'cache_code IN (' . $cacheCodes . ')'); } Uni_Core_CacheManager::createCacheSettings(); Fox::getHelper('core/message')->setInfo('Total ' . $totalIds . ' cache(s) successfully ' . $updateType . '.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } echo Zend_Json_Encoder::encode(array('redirect' => Fox::getUrl('*/*/'))); }
/** * Get admin actions * * @return array */ public function getAction() { return array('send_newsletter' => Fox::getUrl('*/*/send', array('id' => $this->getId())), 'preview_url' => Fox::getUrl('*/admin_template/preview', array('tId' => $this->getId()))); }
/** * Bulk delete action */ public function groupDeleteAction() { try { $model = Fox::getModel('backup/backup'); $ids = $this->getGroupActionIds($model); $totalIds = count($ids); $filePath = Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . Fox_Backup_Model_Backup::BACKUP_PATH . DIRECTORY_SEPARATOR; if ($totalIds) { foreach ($ids as $d) { $model->load($d); @unlink($filePath . $model->getFileName()); $model->unSetData(); } $model->delete($model->getPrimaryField() . ' IN (' . implode(',', $ids) . ')'); } Fox::getHelper('core/message')->setInfo('Total ' . $totalIds . ' record(s) successfully deleted.'); } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } echo Zend_Json_Encoder::encode(array('redirect' => Fox::getUrl('*/*/'))); }
/** * Get Subscription post url * * @return string */ function getSubscriberPostUrl() { return Fox::getUrl('newsletter/subscriber/subscribe'); }
/** * Create menu html * * @param DOMElement $menu */ private function createMenu($menu) { $sourceQueue = array($menu); $targetQueue = array($this->mnuRoot); while (count($sourceQueue) > 0) { $menu = array_shift($sourceQueue); $parent = array_shift($targetQueue); if ($mChs = $this->getSortedNodes($menu->childNodes)) { foreach ($mChs as $mCh) { if ($mCh->nodeName == 'item') { $node = Uni_Data_XDOMDocument::createNode('li', NULL, $this->mnuDoc); $link = Uni_Data_XDOMDocument::createNode('a', array('href' => Fox::getUrl($mCh->getAttribute('action'))), $this->mnuDoc); $link->appendChild($this->mnuDoc->createTextNode($mCh->nodeValue)); $node->appendChild($link); $parent->appendChild($node); } else { if ($mCh->nodeName == 'menu') { $label = $mCh->getAttribute('label'); $li = Uni_Data_XDOMDocument::createNode('li', NULL, $this->mnuDoc); $parent->appendChild($li); $span = Uni_Data_XDOMDocument::createNode('a', array('href' => '#'), $this->mnuDoc); $span->appendChild($this->mnuDoc->createTextNode($label)); $li->appendChild($span); $ul = Uni_Data_XDOMDocument::createNode('ul', NULL, $this->mnuDoc); $ul->appendChild($this->mnuDoc->createTextNode('')); $li->appendChild($ul); $targetQueue[] = $ul; $sourceQueue[] = $mCh; } } } } } }
/** * Returns url of google analytics setting * * @return string */ public function getAnalyticsSettingUrl() { return Fox::getUrl('admin/system_setting/edit', array('item' => 'admin', 'lbl' => 'Admin')); }
/** * Forget password action * * Sends an email with link to user which redirects to change password interface */ public function forgetPasswordAction() { if (Fox::getModel('admin/session')->getLoginData()) { $this->sendRedirect('*/dashboard/'); } if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $model = Fox::getModel('admin/user'); $model->load($data['username'], 'username'); if ($model->getId()) { $code = strtolower(substr(md5(time() * mt_rand()), 0, 20)); $modelSetCode = Fox::getModel('admin/forgetPassword'); $modelSetCode->load($model->getId(), 'user_id'); $modelSetCode->setUserId($model->getId()); $modelSetCode->setCode($code); $modelSetCode->setCreatedOn(Fox_Core_Model_Date::getCurrentDate('Y-m-d H:i:s')); $modelSetCode->save(); Fox::getHelper('core/message')->setInfo('Change Password link has been sent to your email id.'); try { $modelTemplate = Fox::getModel('core/email/template'); $sender = Fox::getPreference('admin/password/forgot_email_sender'); $template = Fox::getPreference('admin/password/forgot_email_template'); $modelTemplate->sendTemplateMail($template, $model->getEmail(), $sender, array('name' => $model->getFirstname(), 'link' => Fox::getUrl('*/*/change-password', array('user_id' => $model->getId(), 'code' => $code)))); } catch (Exception $e) { } $this->sendRedirect('*/*/'); } else { throw new Exception('Invalid username was given.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
/** * Get menu html * * @param string $key Menu group key * @return string */ public function getMenu($key) { $menuHTML = ''; $cacheSettings = Uni_Core_CacheManager::loadCacheSettings(); $isCacheEnabled = isset($cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT]) ? $cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT] : FALSE; $package = Fox::getPreference(Uni_Controller_Action::MODE_ADMIN . '/package'); $theme = Fox::getPreference(Uni_Controller_Action::MODE_ADMIN . '/theme'); $cacheMenuBasePath = CACHE_DIR . DIRECTORY_SEPARATOR . Fox_Core_Model_Cache::CACHE_CODE_LAYOUT . DIRECTORY_SEPARATOR . Uni_Controller_Action::MODE_WEB . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . self::CACHE_MENU_FOLDER; file_exists($cacheMenuBasePath) && is_dir($cacheMenuBasePath) || mkdir($cacheMenuBasePath, 0777, TRUE); $cacheMenuPath = $cacheMenuBasePath . DIRECTORY_SEPARATOR . $key . '.menu'; if ($isCacheEnabled && file_exists($cacheMenuPath)) { $cacheMenuDoc = new DOMDocument(); $cacheMenuDoc->loadHTMLFile($cacheMenuPath); $menuHTML = $cacheMenuDoc->saveXML(); unset($cacheMenuDoc); } else { $menuGroupModel = Fox::getModel('navigation/menugroup'); $menuGroupModel->load($key, 'key'); if ($menuGroupModel->getId() && $menuGroupModel->getStatus() == Fox_Navigation_Model_Menugroup::STATUS_ENABLED) { $menuModel = Fox::getModel('navigation/menu'); $menuList = $menuModel->getMenuItemsByGroup($key); $mnuDoc = new DOMDocument(); $mnuDoc->formatOutput = true; $mnuRoot = NULL; if (count($menuList)) { $mnuRoot = Uni_Data_XDOMDocument::createNode(self::ROOT_TAG, array('class' => 'menu_container'), $mnuDoc); $mnuDoc->appendChild($mnuRoot); foreach ($menuList as $menu) { $node = Uni_Data_XDOMDocument::createNode(self::LEAF_TAG, array('class' => 'menu_nav' . ($menu['style_class'] ? ' ' . $menu['style_class'] : '')), $mnuDoc); if (strpos($menu['link'], 'http://', 0) === 0 || strpos($menu['link'], 'https://', 0) === 0) { $link = $menu['link']; } else { $link = Fox::getUrl($menu['link']); } $link = Uni_Data_XDOMDocument::createNode('a', array('href' => $link, 'target' => $menu['open_window'], 'class' => $menu['style_class']), $mnuDoc); $link->appendChild($mnuDoc->createTextNode($menu['title'])); $node->appendChild($link); $mnuRoot->appendChild($node); } } if (isset($mnuDoc)) { $menuHTML = $mnuDoc->saveXML($mnuRoot); if ($isCacheEnabled) { $mnuDoc->saveHTMLFile($cacheMenuPath); @chmod($cacheMenuPath, 0777); } } unset($mnuDoc); } } return $menuHTML; }
/** * Controller predispatch method * * Called before action method */ function preDispatch() { parent::preDispatch(); if (!Fox::getModel('admin/session')->getLoginData()) { if (!('admin' === strtolower($this->getRequest()->getModuleName()) && 'index' === strtolower($this->getRequest()->getControllerName()) && 'index' === strtolower($this->getRequest()->getActionName())) && !('admin' === strtolower($this->getRequest()->getModuleName()) && 'index' === strtolower($this->getRequest()->getControllerName()) && 'change-password' === strtolower($this->getRequest()->getActionName())) && !('admin' === strtolower($this->getRequest()->getModuleName()) && 'index' === strtolower($this->getRequest()->getControllerName()) && 'forget-password' === strtolower($this->getRequest()->getActionName())) && !('admin' === strtolower($this->getRequest()->getModuleName()) && 'index' === strtolower($this->getRequest()->getControllerName()) && 'logout' === strtolower($this->getRequest()->getActionName()))) { setcookie('requested_uri', $this->getRequestUriAfterBaseUrl(), time() + 3600 * 24, $this->getFrontController()->getBaseUrl()); if ($this->getRequest()->getParam('isAjax', FALSE)) { echo '<script type="text/javascript">window.location.reload();</script>'; exit; } else { $this->sendRedirect('admin'); } } } else { if (isset($_COOKIE['requested_uri'])) { $redirect = $_COOKIE['requested_uri']; $path = explode('/', $redirect); if (count($path) == 3 && !$path[2]) { $redirect = $redirect . 'index'; } else { if (count($path) == 2) { if (!$path[1]) { $redirect .= 'index'; } $redirect = $redirect . '/index'; } else { if (count($path) == 1) { $redirect = $redirect . '/index/index'; } } } $paths = explode('/', $redirect); $moduleName = $paths[0]; $controllerName = strtolower($paths[1]); $actionName = strtolower($paths[2]); setcookie('requested_uri', '', time() - 3600 * 24, $this->getFrontController()->getBaseUrl()); if (!('admin' === $moduleName && 'access-denied' === $controllerName && $actionName === 'index') && !('admin' === $moduleName && 'index' === $controllerName && 'logout' === $actionName) && !Fox::getHelper('admin/acl')->isAllowed($moduleName . '/' . $controllerName . '/' . $actionName)) { if ($this->getRequest()->getParam('isAjax', FALSE)) { echo '<script type="text/javascript">window.location.href=' . Fox::getUrl('*/access-denied/') . ';</script>'; exit; } else { $this->sendRedirect('*/access-denied/'); } } else { $this->sendRedirect($redirect); } } else { $moduleName = strtolower($this->getRequest()->getModuleName()); $controllerName = strtolower($this->getRequest()->getControllerName()); $actionName = strtolower($this->getRequest()->getActionName()); if (!('admin' === $moduleName && 'access-denied' === $controllerName && $actionName === 'index') && !('admin' === $moduleName && 'index' === $controllerName && 'logout' === $actionName) && !Fox::getHelper('admin/acl')->isAllowed($moduleName . '/' . $controllerName . '/' . $actionName)) { if ($this->getRequest()->getParam('isAjax', FALSE)) { echo '<script type="text/javascript">window.location.href=\'' . Fox::getUrl('*/access-denied/') . '\';</script>'; exit; } else { $this->sendRedirect('*/access-denied/'); } } } } }
/** * Bulk unsubscribe action */ public function groupUnsubscribeAction() { try { $model = Fox::getModel('newsletter/subscriber'); $ids = $this->getGroupActionIds($model); $totalIds = count($ids); $count = 0; if ($totalIds) { for ($i = 0; $i < $totalIds; $i++) { $model->load($ids[$i]); if ($model->getId() && $model->unsubscribe()) { $count++; } $model->unsetData(); } Fox::getHelper('core/message')->setInfo('Total ' . $count . ' record(s) successfully unsubscribed.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } echo Zend_Json_Encoder::encode(array('redirect' => Fox::getUrl('*/*/'))); }
/** * @return string the XML, or false if an error occurred */ function getMenuMarkup() { $menuQueue = array(); $menuTree = new Uni_Data_XDOMDocument(); $root = Uni_Data_XDOMDocument::createNode('div', array('id' => 'setting-menu', 'class' => 'accordion'), $menuTree); $xPath = new DOMXPath($this->finalMenuTree); $menus = $xPath->query('/settings/menu'); $menus = $this->getSortedNodes($menus); foreach ($menus as $menu) { $h3 = Uni_Data_XDOMDocument::createNode('h3', array('class' => 'accordion-header'), $menuTree); $a = Uni_Data_XDOMDocument::createNode('a', array('href' => '#'), $menuTree); $a->appendChild($menuTree->createTextNode($menu->getAttribute('label'))); $h3->appendChild($a); $div = Uni_Data_XDOMDocument::createNode('div', array('class' => 'accordion-content'), $menuTree); $ul = Uni_Data_XDOMDocument::createNode('ul', NULL, $menuTree); $div->appendChild($ul); $root->appendChild($h3); $root->appendChild($div); $menuQueue[$menu->getAttribute('name')] = $ul; } $items = $xPath->query('/settings/item'); $items = $this->getSortedNodes($items); foreach ($items as $item) { $li = Uni_Data_XDOMDocument::createNode('li', NULL, $menuTree); $a = Uni_Data_XDOMDocument::createNode('a', array('href' => Fox::getUrl('admin/system_setting/edit', array('item' => $item->getAttribute('name'), 'lbl' => urlencode($item->getAttribute('label'))))), $menuTree); $a->appendChild($menuTree->createTextNode($item->getAttribute('label'))); $li->appendChild($a); if ($parent = $menuQueue[$item->getAttribute('menu')]) { $parent->appendChild($li); } } return $menuTree->saveXML($root); }
/** * Get url for database configuration form * * @return string */ public function getConfigureUrl() { return Fox::getUrl('*/wizard/configure-post'); }
/** * Alias to Fox::getUrl() * * @param string $rout * @param array $params * @param boolean $reset * @return string */ public function getUrl($rout = '*/*/*', array $params = array(), $reset = TRUE) { return Fox::getUrl($rout, $params, $reset); }
/** * Bulk delete action */ public function groupDeleteAction() { try { $model = Fox::getModel('eav/attribute'); $ids = $this->getGroupActionIds($model); $totalIds = count($ids); if ($totalIds) { $model->delete($model->getPrimaryField() . ' IN (' . implode(',', $ids) . ')'); } Fox::getHelper('core/message')->setInfo('Total ' . $totalIds . ' record(s) successfully deleted.'); } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } echo Zend_Json_Encoder::encode(array('redirect' => Fox::getUrl('*/*/'))); }
/** * Get backup download path * * @return array */ public function getBackupAction() { return array('download_path' => Fox::getUrl('*/*/download', array('id' => $this->getId())), 'delete_path' => Fox::getUrl('*/*/delete', array('id' => $this->getId()))); }
/** * Get role url * * @return string */ public function getRoleUrl() { return Fox::getUrl('*/*/save'); }
/** * Bulk status update action */ public function groupStatusAction() { try { $model = Fox::getModel('navigation/menu'); $ids = $this->getGroupActionIds($model); $totalIds = count($ids); $dependentParams = $this->getRequest()->getParam('dependents', array()); if (isset($dependentParams['status'])) { if ($totalIds) { $model->update(array('status' => $dependentParams['status']), $model->getPrimaryField() . ' IN (' . implode(',', $ids) . ')'); } Fox::getHelper('core/message')->setInfo('Total ' . $totalIds . ' record(s) successfully updated.'); } } catch (Exception $e) { Fox::getHelper('core/message')->setError($e->getMessage()); } echo Zend_Json_Encoder::encode(array('redirect' => Fox::getUrl('*/*/'))); }
/** * Prepare group action */ function _prepareGroupAction() { $this->setGroupActionField('id'); $this->addGroupAction('delete', array('label' => 'Delete', 'url' => Fox::getUrl('*/*/group-delete'), 'confirm' => 'Are you sure?')); }
/** * Get update action url * * @return string */ public function getUpdateUrl() { return Fox::getUrl('*/*/update'); }
/** * Confirm newsletter subscription * * Sends subscription success email * * @param string $code * @return boolean */ public function confirm($code) { if ($this->getCode() == $code) { $this->setStatus(self::STATUS_SUBSCRIBED)->save(); $vars['name'] = $this->getName(); $vars['unsubscribe_link'] = Fox::getUrl('newsletter/subscriber/unsubscribe', array('id' => $this->getId(), 'code' => $code)); $this->sendSubscriptionSuccessMail($this->getEmail(), $vars); return true; } return false; }
/** * Get member remove image url * * @return string */ public function getRemoveImageUrl() { return Fox::getUrl('member/account/remove-image'); }
/** * Get url * * @param string $url * @return string */ public static function getUrl($url = '') { return Fox::getUrl($url); }
/** * Get news list url * * @return string */ function getListUrl() { return Fox::getUrl('news'); }
/** * Prepare group actions */ function _prepareGroupAction() { $this->setGroupActionField('cache_code'); $this->addGroupAction('status', array('label' => 'Change status', 'url' => Fox::getUrl('*/*/group-status'), 'dependent' => array(array('name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => array('class' => 'required'), 'multiOptions' => Fox::getModel('core/cache')->getAllStatuses())))); }
/** * Retrieve admin actions for member * * @return array */ public function getMemberAction() { return array('change_password' => Fox::getUrl('*/admin_password/change-password', array('id' => $this->getId())), 'login' => Fox::getUrl('*/*/member-login', array('id' => $this->getId()))); }
/** * Prepare group actions */ function _prepareGroupAction() { $this->setGroupActionField('id'); $this->addGroupAction('delete', array('label' => 'Delete', 'url' => Fox::getUrl('*/*/group-delete'), 'confirm' => 'Are you sure?')); $this->addGroupAction('status', array('label' => 'Change status', 'url' => Fox::getUrl('*/*/group-status'), 'dependent' => array(array('name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => array('class' => 'required'), 'multiOptions' => Fox::getModel('navigation/menu')->getAllStatuses())))); }
/** * Get url for export * * @return string */ public function getExportButtonUrl() { return Fox::getUrl('*/*/' . $this->exportButtonAction); }