當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Ad::deleteAd方法代碼示例

本文整理匯總了PHP中Model_Ad::deleteAd方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Ad::deleteAd方法的具體用法?PHP Model_Ad::deleteAd怎麽用?PHP Model_Ad::deleteAd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Ad的用法示例。


在下文中一共展示了Model_Ad::deleteAd方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteAction

 public function deleteAction()
 {
     $this->userRole = $this->_helper->checkUserRole->check();
     $this->view->headTitle()->append($this->view->translate('Delete your profile'));
     $id = (int) $this->getRequest()->getParam('id');
     $auth = Zend_Auth::getInstance();
     //check if user is auth
     if ($auth->hasIdentity() == FALSE) {
         $this->_helper->_flashMessenger->addMessage($this->view->translate('You are not allowed to view this page'));
         $this->_redirect('/' . $this->view->lang . '/woeid/' . $this->location . '/give');
         return;
     }
     $admodel = new Model_Ad();
     $ad = $admodel->getAd($id);
     if ($auth->getIdentity()->id == $ad['user_owner'] || $this->userRole == 1) {
         //if is the user owner owner lets delete it
         if ($this->getRequest()->isPost()) {
             $del = $this->getRequest()->getPost('del');
             if ($del == 'Yes') {
                 //delete ad
                 $admodel->deleteAd($id);
                 //delete from memcached if exists in memory
                 //check if the ad exists in memcached
                 $oBackend = new Zend_Cache_Backend_Memcached(array('servers' => array(array('host' => '127.0.0.1', 'port' => '11211')), 'compression' => true));
                 // configure caching frontend strategy
                 $oFrontend = new Zend_Cache_Core(array('lifetime' => 3600 * 24 * 7, 'caching' => true, 'cache_id_prefix' => 'singleAd', 'logging' => false, 'write_control' => true, 'automatic_serialization' => true, 'ignore_user_abort' => true));
                 // build a caching object
                 $cacheAd = Zend_Cache::factory($oFrontend, $oBackend);
                 $cacheTest = $cacheAd->test($id);
                 if ($cacheTest == true) {
                     $cacheAd->remove($id);
                 }
                 /////
                 $this->_helper->_flashMessenger->addMessage($this->view->translate('Ad deleted successfully.'));
                 $this->_redirect('/' . $this->view->lang . '/woeid/' . $this->location . '/give');
                 return;
             } else {
                 $this->_helper->_flashMessenger->addMessage($this->view->translate('Nice to hear that :-)'));
                 $this->_redirect('/' . $this->view->lang . '/woeid/' . $this->location . '/give');
                 return;
             }
         } else {
             $id = $this->_getParam('id', 0);
         }
     } else {
         $this->_helper->_flashMessenger->addMessage($this->view->translate('You are not allowed to view this page'));
         $this->_redirect('/' . $this->view->lang . '/woeid/' . $this->location . '/give');
         return;
     }
 }
開發者ID:Arteaga2k,項目名稱:nolotiro,代碼行數:50,代碼來源:AdController.php


注:本文中的Model_Ad::deleteAd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。