コード例 #1
0
 /**
  * Mark advertisement as deactivated : STATUS = 50
  */
 public function action_deactivate()
 {
     $deact_ad = new Model_Ad($this->request->param('id'));
     if ($deact_ad->loaded()) {
         if (Auth::instance()->get_user()->id_user != $deact_ad->id_user) {
             Alert::set(Alert::ALERT, __("This is not your advertisement."));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
         }
         if ($deact_ad->deactivate()) {
             Alert::set(Alert::SUCCESS, __('Advertisement is deactivated'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
         } else {
             Alert::set(Alert::ALERT, __("Warning, Advertisement is already marked as 'deactivated'"));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
         }
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
コード例 #2
0
ファイル: ads.php プロジェクト: AndresGrams/openclassifieds2
 /**
  * Handle DELETE requests.
  * actually just disables the ad ;)
  */
 public function action_delete()
 {
     try {
         if (is_numeric($id_ad = $this->request->param('id'))) {
             $ad = new Model_Ad();
             $ad->where('id_ad', '=', $id_ad)->where('id_user', '=', $this->user->id_user)->find();
             if ($ad->loaded()) {
                 if ($ret = $ad->deactivate()) {
                     $this->rest_output($ret);
                 } else {
                     $this->_error($ret);
                 }
             } else {
                 $this->_error(__('Advertisement not found'), 404);
             }
         } else {
             $this->_error(__('Advertisement not found'), 404);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }
コード例 #3
0
ファイル: ad.php プロジェクト: kleitz/openclassifieds2
 /**
  * Mark advertisement as deactivated : STATUS = 50
  */
 public function action_deactivate()
 {
     $id = $this->request->param('id');
     $param_current_url = Core::get('current_url');
     $format_id = explode('_', $id);
     foreach ($format_id as $id) {
         if (isset($id) and is_numeric($id)) {
             $deact_ad = new Model_Ad($id);
             $deact_ad->deactivate();
         }
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is deactivated'));
     if ($param_current_url == Model_Ad::STATUS_NOPUBLISHED and in_array(core::config('general.moderation'), Model_Ad::$moderation_status)) {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'moderate')));
     } elseif ($param_current_url == Model_Ad::STATUS_PUBLISHED) {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')));
     } else {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')) . '?status=' . $param_current_url);
     }
 }