当前位置: 首页>>代码示例>>PHP>>正文


PHP AdminTab::validateRules方法代码示例

本文整理汇总了PHP中AdminTab::validateRules方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminTab::validateRules方法的具体用法?PHP AdminTab::validateRules怎么用?PHP AdminTab::validateRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdminTab的用法示例。


在下文中一共展示了AdminTab::validateRules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 function postProcess()
 {
     global $cookie, $link, $currentIndex;
     if (Tools::isSubmit('viewcms') and $id_cms = (int) Tools::getValue('id_cms') and $cms = new CMS($id_cms, (int) $cookie->id_lang) and Validate::isLoadedObject($cms)) {
         $redir = $link->getCMSLink($cms);
         if (!$cms->active) {
             $admin_dir = dirname($_SERVER['PHP_SELF']);
             $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
             $redir .= '?adtoken=' . Tools::encrypt('PreviewCMS' . $cms->id) . '&ad=' . $admin_dir;
         }
         Tools::redirectAdmin($redir);
     } elseif (Tools::isSubmit('deletecms')) {
         if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID')) {
             Configuration::updateValue('PS_CONDITIONS', 0);
             Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0);
         }
         $cms = new CMS((int) Tools::getValue('id_cms'));
         $cms->cleanPositions($cms->id_cms_category);
         if (!$cms->delete()) {
             $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . ' (' . mysql_error() . ')</b>';
         } else {
             Tools::redirectAdmin($currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=1&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
         }
     } elseif (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 $cms = new CMS();
                 $result = true;
                 $result = $cms->deleteSelection(Tools::getValue($this->table . 'Box'));
                 if ($result) {
                     $cms->cleanPositions((int) Tools::getValue('id_cms_category'));
                     Tools::redirectAdmin($currentIndex . '&conf=2&token=' . Tools::getAdminTokenLite('AdminCMSContent') . '&id_category=' . (int) Tools::getValue('id_cms_category'));
                 }
                 $this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
             } else {
                 $this->_errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif (Tools::isSubmit('submitAddcms') or Tools::isSubmit('submitAddcmsAndPreview')) {
         parent::validateRules();
         if (!sizeof($this->_errors)) {
             if (!($id_cms = (int) Tools::getValue('id_cms'))) {
                 $cms = new CMS();
                 $this->copyFromPost($cms, 'cms');
                 if (!$cms->add()) {
                     $this->_errors[] = Tools::displayError('An error occurred while creating object.') . ' <b>' . $this->table . ' (' . mysql_error() . ')</b>';
                 } elseif (Tools::isSubmit('submitAddcmsAndPreview')) {
                     $preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int) $cookie->id_lang);
                     if (!$cms->active) {
                         $admin_dir = dirname($_SERVER['PHP_SELF']);
                         $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
                         $token = Tools::encrypt('PreviewCMS' . $cms->id);
                         $preview_url .= $object->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
                     }
                     Tools::redirectAdmin($preview_url);
                 } else {
                     Tools::redirectAdmin($currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=3&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
                 }
             } else {
                 $cms = new CMS($id_cms);
                 $this->copyFromPost($cms, 'cms');
                 if (!$cms->update()) {
                     $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . ' (' . mysql_error() . ')</b>';
                 } elseif (Tools::isSubmit('submitAddcmsAndPreview')) {
                     $preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int) $cookie->id_lang);
                     if (!$cms->active) {
                         $admin_dir = dirname($_SERVER['PHP_SELF']);
                         $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
                         $token = Tools::encrypt('PreviewCMS' . $cms->id);
                         $preview_url .= $object->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
                     }
                     Tools::redirectAdmin($preview_url);
                 } else {
                     Tools::redirectAdmin($currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=4&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
                 }
             }
         }
     } elseif (Tools::getValue('position')) {
         if ($this->tabAccess['edit'] !== '1') {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         } elseif (!Validate::isLoadedObject($object = $this->loadObject())) {
             $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
         } elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
             $this->_errors[] = Tools::displayError('Failed to update the position.');
         } else {
             Tools::redirectAdmin($currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=4' . (($id_category = (int) Tools::getValue('id_cms_category')) ? '&id_cms_category=' . $id_category : '') . '&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
         }
     } elseif (Tools::isSubmit('status') and Tools::isSubmit($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 if ($object->toggleStatus()) {
                     Tools::redirectAdmin($currentIndex . '&conf=5' . ((int) Tools::getValue('id_cms_category') ? '&id_cms_category=' . (int) Tools::getValue('id_cms_category') : '') . '&token=' . Tools::getValue('token'));
                 } else {
                     $this->_errors[] = Tools::displayError('An error occurred while updating status.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
//.........这里部分代码省略.........
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:101,代码来源:AdminCMS.php


注:本文中的AdminTab::validateRules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。