Exemple #1
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $campaignID = AF::get($this->params, 'campaign_id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new CCombo();
         $model->model_uset_id = $this->user->user_id;
         if ($model->findByPk($id)) {
             $model->delete($id);
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('campship_not_deleted'));
         } else {
             $countE = AF::get($_POST, 'countE', 100000);
             if (count($modelsID) >= $countE) {
                 $link = AF::link(array('ccombo' => 'view'), array('campaign_id' => $campaignID));
                 Message::echoJsonRedirect($link);
             } else {
                 Message::echoJsonSuccess(__('campship_deleted'));
             }
         }
     }
     $this->redirect();
 }
Exemple #2
0
 function updateAction()
 {
     $model = new Campaign();
     if (isset($_POST['country_id'])) {
         $_POST['country_id'] = implode(',', $_POST['country_id']);
     }
     // check if this is an attachment campaign.  if so, we don't want to validate the urls or fulfillment_id if it isnot presesnt
     $attach = false;
     if (isset($_POST['attach']) && $_POST['attach']) {
         $attach = true;
         $_POST['url'] = $_POST['order_url'] = $_POST['return_url'] = 'attach';
         if (!strlen($_POST['fulfillment_id'])) {
             $_POST['fulfillment_id'] = 0;
         }
     } else {
         $_POST['attach'] = 0;
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') {
         $model->fillFromArray($_POST, FALSE);
         $model->user_id_updated = $this->user->user_id;
         $model->updated = 'NOW():sql';
         $model->model_uset_id = $this->user->user_id;
         $fulfillment_change = AF::get($_POST, 'fulfillment_change');
         Campaigns::fulfillmentRelationship($model->campaign_id, $model->fulfillment_id, $fulfillment_change);
         if ($model->restrictions()->save()) {
             Message::echoJsonSuccess(__('campaign_updated'));
         } else {
             Message::echoJsonError(__('campaign_no_updated'));
         }
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->restrictions()->cache()->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $model->country_id = explode(',', $model->country_id);
     Assets::js('jquery.form');
     $this->addToPageTitle('Update campaign');
     //array_unshift($fulfillments, array('fulfillment_id'=>0, 'alias'=>__('none')));
     // Is this used still?
     $ccomboModel = new CCombo();
     $ccomboModel->campaign_id = $model->campaign_id;
     $isCombo = $ccomboModel->checkRelationship();
     $countries = Country::model()->cache()->findAllInArray();
     $profiles = Profile::model()->cache()->findAllInArray();
     // prepend dry run gateway
     array_unshift($profiles, array('profile_id' => 0, 'profile_name' => 'DRY RUN GATEWAY'));
     $fulfillments = Fulfillment::model()->cache()->findAllInArray();
     $currencies = $model->getCountOrders() > 0 ? array() : Currency::model()->cache()->findAllInArray();
     $domains = Domain::model()->cache()->findAllInArray();
     $this->render('update', array('model' => $model, 'countries' => $countries, 'profiles' => $profiles, 'currencies' => $currencies, 'fulfillments' => $fulfillments, 'isCombo' => $isCombo, 'domains' => $domains));
 }