Beispiel #1
0
 public function get($promoCodeData)
 {
     global $modx;
     global $aqConfigApiPathes;
     require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqPromoCodeForm.messages.php';
     $AQ_PROMO_CODE_GET_MESSAGES = messagesArray('ru');
     $result = $modx->addPackage('aqmPromoCodes', MODX_CORE_PATH . 'components/aqmPromoCodes/model/', 'aqm_');
     $promoCodeItem = array();
     $promoCodesList = array();
     $query = $modx->newQuery('PromoCodes');
     $count = $modx->getCount('PromoCodes');
     $query->limit($promoCodeData['limit'], $promoCodeData['offset']);
     $PromoCodes = $modx->getCollection('PromoCodes', $query);
     foreach ($PromoCodes as $promoCode) {
         $promoCodeItem = array();
         $promoCodeItem['id'] = $promoCode->get('id');
         $promoCodeItem['code'] = $promoCode->get('code');
         $promoCodeItem['description'] = $promoCode->get('description');
         $promoCodeItem['discount'] = $promoCode->get('discount');
         $promoCodeItem['deleted'] = $promoCode->get('deleted');
         $promoCodeItem['status'] = $promoCode->get('status');
         $promoCodeItem['createdon'] = $promoCode->get('createdon');
         $promoCodesList[] = $promoCodeItem;
     }
     if (count($PromoCodes) > 0) {
         $this->isPromoCodeGeted = array('count' => $count, 'total' => count($PromoCodes), 'promoCodes' => $promoCodesList);
     } else {
         $this->isPromoCodeGeted = array('message' => $AQ_PROMO_CODE_GET_MESSAGES['getError']);
     }
     return $this->isPromoCodeGeted;
 }
 public function check($promoCodeData)
 {
     global $modx;
     global $aqConfigApiPathes;
     require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqPromoCodeForm.messages.php';
     $AQ_PROMO_CODE_CHECK_MESSAGES = messagesArray('ru');
     $result = $modx->addPackage('aqmPromoCodes', MODX_CORE_PATH . 'components/aqmPromoCodes/model/', 'aqm_');
     $promoCodeCheck = $modx->getObject('PromoCodes', array('code' => $promoCodeData['code']));
     if (empty($promoCodeCheck)) {
         $this->isPromoCodeChecked = array('message' => $AQ_PROMO_CODE_CHECK_MESSAGES['checkError']);
     } else {
         $this->isPromoCodeChecked = $promoCodeCheck->get('id');
     }
     return $this->isPromoCodeChecked;
 }
 public function create($promoCodeData)
 {
     global $modx;
     global $aqConfigApiPathes;
     require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqPromoCodeForm.messages.php';
     $AQ_PROMO_CODE_CREATE_MESSAGES = messagesArray('ru');
     $result = $modx->addPackage('aqmPromoCodes', MODX_CORE_PATH . 'components/aqmPromoCodes/model/', 'aqm_');
     $promoCode = $modx->newObject('PromoCodes');
     $promoCode->set('code', $promoCodeData['code']);
     $promoCode->set('description', $promoCodeData['description']);
     $promoCode->set('discount', $promoCodeData['discount']);
     $promoCode->set('status', $promoCodeData['status']);
     if ($promoCode->save()) {
         $this->isPromoCodeCreated = $promoCode->getPrimaryKey();
     } else {
         $this->isPromoCodeCreated = array('message' => $AQ_PROMO_CODE_CREATE_MESSAGES['saveError']);
     }
     return $this->isPromoCodeCreated;
 }
Beispiel #4
0
 public function edit($promoCodeData)
 {
     global $modx;
     global $aqConfigApiPathes;
     require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqPromoCodeForm.messages.php';
     $AQ_PROMO_CODE_EDIT_MESSAGES = messagesArray('ru');
     $result = $modx->addPackage('aqmPromoCodes', MODX_CORE_PATH . 'components/aqmPromoCodes/model/', 'aqm_');
     $promoCode = $modx->getObject('PromoCodes', array('id' => $promoCodeData['id']));
     foreach ($promoCodeData as $field => $value) {
         if ($field != 'id') {
             $promoCode->set($field, $promoCodeData[$field]);
         }
     }
     if ($promoCode->save()) {
         $this->isPromoCodeEdited = $promoCode->getPrimaryKey();
     } else {
         $this->isPromoCodeEdited = array('message' => $AQ_PROMO_CODE_EDIT_MESSAGES['saveError']);
     }
     return $this->isPromoCodeEdited;
 }
 public function tryLogin($authorizationData)
 {
     global $modx;
     global $aqConfigApiPathes;
     require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqAuthorization.messages.php';
     $AQ_AUTHORIZATION_MESSAGES = messagesArray('ru');
     $c = array('username' => $authorizationData['login'], 'password' => $authorizationData['password'], 'login_context' => 'web', 'add_contexts' => 'adm,web');
     $response = $modx->runProcessor('security/login', $c);
     if (!empty($response) && !$response->isError()) {
         $modx->user = null;
         $user = $modx->getUser('web');
         $user = $modx->getUser('adm');
         // // $modx->getUser('adm');
         $modx->initialize('adm');
         $user->addSessionContext('web');
         $user->addSessionContext('adm');
         //$profile = $modx->user->getOne('Profile');
         $this->isAuthorizationLogined = array('success' => array('id' => $user->get('id'), 'data' => $user->toArray(), 'context' => $modx->context->get('key'), 'contexts' => $user->getSessionContexts(), 'hasSessionContextAdm' => $user->hasSessionContext('adm'), 'hasSessionContextWeb' => $user->hasSessionContext('web'), 'session' => $_SESSION, 'cookie' => $_COOKIE, 'sess' => $modx->documentObject));
     } else {
         $this->isAuthorizationLogined = array('error' => $AQ_AUTHORIZATION_MESSAGES['loginError']);
     }
     return $this->isAuthorizationLogined;
 }
 public function delete($promoCodeData, $completely = false)
 {
     global $modx;
     global $aqConfigApiPathes;
     require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqPromoCodeForm.messages.php';
     $AQ_PROMO_CODE_DELETE_MESSAGES = messagesArray('ru');
     $result = $modx->addPackage('aqmPromoCodes', MODX_CORE_PATH . 'components/aqmPromoCodes/model/', 'aqm_');
     $promoCode = $modx->getObject('PromoCodes', array('id' => $promoCodeData['id']));
     if ($completely != true) {
         $promoCode->set('deleted', 1);
         if ($promoCode->save()) {
             $this->isPromoCodeDeleted = $promoCodeData['id'];
         } else {
             $this->isPromoCodeDeleted = array('message' => $AQ_PROMO_CODE_DELETE_MESSAGES['deleteError']);
         }
     } else {
         if ($promoCode->remove() != false) {
             $this->isPromoCodeDeleted = $promoCodeData['id'];
         } else {
             $this->isPromoCodeDeleted = array('message' => $AQ_PROMO_CODE_DELETE_MESSAGES['deleteError']);
         }
     }
     return $this->isPromoCodeDeleted;
 }
<?php

global $aqConfigApiPathes;
require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqPromoCodeForm.messages.php';
$AQ_PROMO_CODE_FORM_MESSAGES = messagesArray('ru');
$promoCodeFormValidators = array('id' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['id']['notEmpty'])), array('func' => 'isExistPromoCode', 'params' => array('condition' => 'id', 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['id']['isExistPromoCode']))), 'code' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['code']['notEmpty'])), array('func' => 'min', 'params' => array('condition' => 4, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['code']['min'] . 4)), array('func' => 'notExistPromoCode', 'params' => array('condition' => 'code', 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['code']['notExistPromoCode']))), 'description' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['description']['notEmpty'])), array('func' => 'min', 'params' => array('condition' => 4, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['description']['min'] . ': ' . 4))), 'discount' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['discount']['notEmpty']))), 'status' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_PROMO_CODE_FORM_MESSAGES['status']['notEmpty']))));
<?php

global $aqConfigApiPathes;
require_once $aqConfigApiPathes->getPath('dictionaries') . '/aqAuthorization.messages.php';
$AQ_AUTHORIZATION_MESSAGES = messagesArray('ru');
$authorizationValidators = array('login' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_AUTHORIZATION_MESSAGES['login']['notEmpty'])), array('func' => 'isLoginNumberLimit', 'params' => array('condition' => true, 'message' => $AQ_AUTHORIZATION_MESSAGES['login']['loginNumberLimit'])), array('func' => 'notLoginExist', 'params' => array('condition' => true, 'message' => $AQ_AUTHORIZATION_MESSAGES['login']['notLoginExist']))), 'password' => array(array('func' => 'notEmpty', 'params' => array('condition' => true, 'message' => $AQ_AUTHORIZATION_MESSAGES['password']['notEmpty']))));