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


PHP AF::setJsonHeaders方法代码示例

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


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

示例1: deleteAction

 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Tax();
         $model->model_uset_id = $this->user->user_id;
         if ($model->fillFromDbPk($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(__('tax_not_deleted'));
         } else {
             $countE = AF::get($_POST, 'countE', 100000);
             // if the delete request came from an update page, we need to redirect
             if (count($modelsID) >= $countE || stripos($_SERVER['HTTP_REFERER'], 'taxes/update') !== false) {
                 $link = AF::link(array('taxes' => 'view'));
                 Message::echoJsonRedirect($link);
             } else {
                 Message::echoJsonSuccess(__('tax_deleted'));
             }
         }
     }
     $this->redirect('view');
     //$this->redirect();
 }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例2: cloneAction

 function cloneAction()
 {
     if (isset($_POST['clone'])) {
         $model = AFActiveDataProvider::models('Campaign');
         $campaigns = $model->getCampaigns();
         $campaigns = AF::userAccess()->array2RestrictionArray('campaign_id', $campaigns);
         AF::setJsonHeaders('json');
         echo json_encode(array('campaigns' => $campaigns));
         die;
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         $campaign_id = AF::get($_POST, 'campaign_id', 0);
         $pixel_ids = AF::get($_POST, 'pixel_id', 0);
         if (AF::userAccess()->hasRestrictions('campaign_id')) {
             $rf = AF::userAccess()->getRestrictionSearchFields('campaign_id', array());
             if (!in_array($campaign_id, $rf)) {
                 Message::echoJsonError(__('pixel_not_cloned'));
             }
         }
         if (!$pixel_ids && !$campaign_id) {
             Message::echoJsonError(__('campaign_id_not_found'));
         }
         $pixels = explode(',', $pixel_ids);
         $message = array();
         $newIDs = array();
         $isMany = count($pixels) > 1 ? true : false;
         $isThisCampaign = true;
         foreach ($pixels as $pixel_id) {
             $model = new Pixel();
             if (!$model->fillFromDbPk($pixel_id)) {
                 if ($isMany) {
                     continue;
                 }
                 Message::echoJsonError(__('pixel_not_found'));
             }
             if ($model->campaign_id != $campaign_id) {
                 $model->campaign_id = $campaign_id;
                 $isThisCampaign = false;
             }
             if (!$model->cloneModel()) {
                 if ($isMany) {
                     continue;
                 }
                 Message::echoJsonError(__('pixel_not_found'));
             }
             $newID = $newIDs[] = $model->getPkValue();
             $message[] = __('pixel_cloned') . ' <a href="' . $this->controller . '/update/id=' . $newID . '">' . __('edit') . ' (ID: ' . $newID . ')</a><br>';
             unset($model);
         }
         if (!$message) {
             Message::echoJsonError(__('pixel_not_cloned'));
         }
         $message = implode($message);
         $newIDs = implode(',', $newIDs);
         $v = array('message' => $message);
         if ($isThisCampaign) {
             $v['newid'] = $newIDs;
         }
         Message::echoJsonSuccess($v);
     }
 }
开发者ID:,项目名称:,代码行数:62,代码来源:

示例3: removeAction

 function removeAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Event();
         $t = explode('-', $id);
         if (isset($t[0]) && isset($t[1])) {
             $model->removeEventProduct($t[0], $t[1]);
         } else {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('events_not_deleted'));
         } else {
             Message::echoJsonSuccess(__('events_deleted'));
         }
     }
     $this->redirect();
 }
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: removeemailAction

 function removeemailAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = false;
     foreach ($modelsID as $id) {
         $idsArray = explode('-', $id);
         if (count($idsArray) != 3) {
             $errors = true;
         }
         $model = new CampaignEmail();
         if ($model->findByPk(array('campaign_id' => $idsArray[0], 'day' => $idsArray[1], 'template_id' => $idsArray[2]))) {
             $model->model_uset_id = $this->user->user_id;
             $model->delete();
         } else {
             $errors = true;
         }
         if ($model->getErrors()) {
             $errors = true;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('campaign_email_no_deleted'));
         } else {
             Message::echoJsonSuccess(__('campaign_email_deleted'));
         }
     }
     $this->redirect();
 }
开发者ID:,项目名称:,代码行数:32,代码来源:

示例5: cloneModel

 protected function cloneModel($modelName)
 {
     $modelNameS = strtolower($modelName);
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         $idTemp = AF::get($_POST, 'id', 0);
         // added handling of possible addlData array passed over via the clone model function in all.js
         $addlData = AF::get($_POST, 'addlData', 0);
         if (!$idTemp) {
             Message::echoJsonError(__($modelNameS . '_id_not_found'));
         }
         $ids = explode(',', $idTemp);
         $message = array();
         $newIDs = array();
         $isMany = count($ids) > 1 ? true : false;
         foreach ($ids as $id) {
             $model = new $modelName();
             if (!$model->fillFromDbPk($id)) {
                 if ($isMany) {
                     continue;
                 }
                 Message::echoJsonError(__($modelNameS . '_not_found'));
             }
             // added pass of addl to model function
             if (!$model->cloneModel($id, $addlData)) {
                 if ($isMany) {
                     continue;
                 }
                 Message::echoJsonError(__($modelNameS . '_not_cone'));
             }
             $newID = $newIDs[] = $model->getPkValue();
             $message[] = __($modelNameS . '_cloned') . ' <a href="' . $this->controller . '/update/id=' . $newID . '">' . __('edit') . ' (ID: ' . $newID . ')</a><br>';
             unset($model);
         }
         if (!$message) {
             Message::echoJsonError(__($modelNameS . '_not_cloned'));
         }
         $message = implode($message);
         $newIDs = implode(',', $newIDs);
         $v = array('message' => $message, 'newid' => $newIDs);
         Message::echoJsonSuccess($v);
     }
 }
开发者ID:,项目名称:,代码行数:43,代码来源:

示例6: process

 public function process()
 {
     // States list request from sales site
     if ($this->wsType == 'st') {
         // set headers
         AF::setJsonHeaders('json');
         // country_id has already been verified as set
         $states = State::model()->getStatesByCID($this->post['country_id']);
         // return json state list if present
         Message::echoJsonSuccess(array('message' => $states));
         exit;
     }
     // CRM Order
     if ($this->wsType == 'x1') {
         // EXISTING CUSTOMER CHECK
         if (!$this->newCustomer) {
             $this->customer = Customer::model()->fillFromDbPk($this->post['customer_id']);
             $this->shippingAddress = Address::model()->fillFromDbPk($this->post['address_id']);
             $this->billingAddress = Address::model()->fillFromDbPk($this->post['billing_address_id']);
         }
         // if customer already built then check for blacklist
         $this->buildCustomer();
         // EXISTING ORDER Check - DON'T NEED THIS I THINK
         $this->order = new Order();
         /*if (!$this->newCustomer && $this->order->fillFromDbPk($this->customer->getCustomerOkOrder($this->campaign->campaign_id)))
         		$this->apiError('An "OK" order already exists for this customer.  Order ID ' . $this->order->order_id);*/
         // addresses
         if (!isset($this->shippingAddress) || !$this->shippingAddress->getPkvalue()) {
             $this->buildAddress();
             if ($this->post['billingSameAsShipping']) {
                 $this->billingAddress = $this->shippingAddress;
             } else {
                 $this->buildAddress('billing');
             }
         }
         // payment before order.  if no payment specified allow order to still be built
         if ($this->isPayment && isset($this->post['payment_id']) && $this->post['payment_id']) {
             $this->payment = Payment::model()->fillFromDbPk($this->post['payment_id']);
         }
         if ($this->isPayment) {
             $this->buildPayment();
         }
         // order
         $this->buildOrder();
         // pay or return
         if ($this->isPayment) {
             $this->webPayment();
         } else {
             $this->order->status = 'ok';
             $this->order->addFlags('paid');
             // this needs to be set in order to have the order get sent to fulfillment
             $this->order->amount_product = '0.00';
             $this->order->amount_shipping = '0.00';
             $this->order->save();
         }
         $this->apiSuccess('Order ' . $this->order->order_id . ' created');
     }
     // Build prospect, click and customer info
     if (in_array($this->wsType, array('p', 'l'))) {
         $this->customer = new Customer();
         $this->order = new Order();
         $this->prospect = new Prospect();
         // EXISTING ORDER/CUSTOMER CHECK - make sure there isn't already an order for this campaign and email
         if ($this->customer->getCustomerByEmail($this->post['email']) && $this->customer->getCustomerOkOrder($this->campaign->campaign_id) && $this->order->fillFromDbPk($this->customer->getCustomerOkOrder($this->campaign->campaign_id))) {
             $this->thankYou(true);
         }
         // BlueSnap Pending Order Check
         // Has an order already been submitted to the gateway and is pending final approval?  If so, redirect to the thankyou page
         if (isset($this->customer->customer_id) && $this->order->orderPendingAttemptExists($this->campaign->campaign_id, $this->customer->customer_id)) {
             $this->thankYou(true);
         }
         // Existing Prospect check if customer already exists.  If no prospect, build click
         if ($this->customer->getPkValue()) {
             if (!$this->prospect->prospectExists($this->customer->customer_id, $this->campaign->campaign_id)) {
                 $this->buildClick();
             } else {
                 //prospect already exists. let's update the updated column
                 $this->prospect->created = 'NOW():sql';
                 //date("Y-m-d H:i:s");
                 $this->prospect->save();
                 // check the click info.  if its new then we need to double check it all
                 $this->buildClick($this->prospect->click_id);
             }
         } else {
             $this->buildClick();
         }
         $this->buildCustomer();
         $this->buildAddress();
         $this->buildProspect();
         // if this is not a lastchance request, then redirect the user to the order page
         if ($this->wsType != 'l') {
             // build return object.  SET TO HTTPS WHEN TESTING IS COMPLETE
             $url = $this->campaign->order_url . '?tempOrderId=' . $this->prospect->getPkValue();
             $this->apiSuccess($url);
         }
     }
     // Build Order
     if (in_array($this->wsType, array('o', 'l'))) {
         if ($this->wsType == 'o') {
             // load objects
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例7: getpaymentsbycustomerAction

 function getpaymentsbycustomerAction()
 {
     $this->checkLogin();
     AF::setJsonHeaders('json');
     $customer_id = AF::get($_POST, 'customer_id', false);
     if (isset($customer_id) && $customer_id) {
         $cusPayments = new Payments('Payment');
         $cusPayments->loadPaymentsByCustomer($customer_id);
         $payments = $cusPayments->records;
         unset($cusPayments);
     } else {
         $payments = "error";
     }
     if (is_array($payments)) {
         // build a friendly array
         $payments2 = array();
         foreach ($payments as $payment) {
             $payments2[] = $payment->crmFormat();
         }
         unset($payments);
         $payments = $payments2;
     } else {
         $payments = array();
     }
     Message::echoJsonSuccess(array('message' => $payments));
     //echo json_encode($payments);
     die;
 }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例8: addeventAction

 function addeventAction()
 {
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         $eventType = (int) AF::get($_POST, 'event_type', 0);
         $eventID = (int) AF::get($_POST, 'event_id', 0);
         $productID = (int) AF::get($_POST, 'product_id', 0);
         if (isset($_POST['model']) && $_POST['model'] == 'Product') {
             $errors = array();
             if (!$eventID) {
                 $errors['event_id'] = 'Required';
             }
             if (!$eventType) {
                 $errors['event_type'] = 'Required';
             }
             if (!$productID) {
                 $errors['product_id'] = 'Required';
             }
             if ($errors) {
                 $answer['errors'] = $errors;
                 Message::echoJson('error', $answer);
             }
             $eventModel = new Event();
             $eventModel->addProductByID($eventID, $productID);
             $link = AF::link(array('products' => 'update'), array('id' => $productID));
             Message::echoJson('success', array('redirect' => $link));
         }
         if ($eventType) {
             //Events type list
             $eventModel = new Event();
             $eventsTypes = $eventModel->getEventsByTypeID($eventType);
             if ($eventsTypes) {
                 Message::echoJsonSuccess(array('message' => $eventsTypes));
             } else {
                 Message::echoJsonError(__('unknown_error'));
             }
             die;
         }
     }
     $this->redirect();
 }
开发者ID:,项目名称:,代码行数:41,代码来源:


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