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


PHP waContact类代码示例

本文整理汇总了PHP中waContact的典型用法代码示例。如果您正苦于以下问题:PHP waContact类的具体用法?PHP waContact怎么用?PHP waContact使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: capture

 /**
  * @todo test and complete code
  */
 public function capture($transaction_raw_data)
 {
     $result = '';
     try {
         //$order_id, $amount, $phone_number, $description;
         $soap_client = $this->getQiwiSoapClient();
         $parameters = new createBill();
         $contact = new waContact($order_data['customer_id']);
         $mobile_phone = preg_replace('/^\\s*\\+\\s*7/', '', $contact->get('phone.mobile', 'default'));
         //TODO verify phone
         $mobile_phone = preg_replace('/[\\D]+/', '', $mobile_phone);
         $parameters->login = $this->login;
         $parameters->password = $this->password;
         $parameters->user = $phone_number;
         $parameters->amount = $amount;
         $parameters->comment = $description;
         $parameters->txn = $this->getInvoiceId($transaction_raw_data['order_id']);
         $parameters->lifetime = date('d.m.Y H:i:s', time() + 3600 * max(1, (int) $this->lifetime));
         $parameters->alarm = $this->alarm;
         $parameters->create = 1;
         $response = $soap_client->createBill($parameters);
         self::log($this->id, $soap_client->getDebug());
         if ($response->createBillResult) {
             $result = $this->getResponseCodeDescription($response->createBillResult);
             self::log($this->id, array(__METHOD__ . " #{$order_id}\tphone:{$phone_number}\t{$result}"));
         }
     } catch (SoapFault $sf) {
         $result = $sf->getMessage();
         self::log($this->id, $sf->getMessage());
         self::log($this->id, $soap_client->getDebug());
     }
     return $result;
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:36,代码来源:qiwiPayment.class.php

示例2: execute

 public function execute()
 {
     // Задаём лайаут для фронтенда
     $this->setLayout(new guestbook2FrontendLayout());
     // Получаем hash из GET параметров
     $hash = waRequest::get('hash');
     // Проверяем хэш
     if (!$hash || strlen($hash) < 33) {
         $this->redirect(wa()->getRouteUrl('/frontend'));
     }
     // Получаем contact_id из хэша
     $contact_id = substr($hash, 16, -16);
     $hash = substr($hash, 0, 16) . substr($hash, -16);
     $contact = new waContact($contact_id);
     // Проверяем валидность хэша
     if ($contact->getSettings($this->getAppId(), 'confirm_hash') === $hash) {
         // Удаляем хэш
         $contact->delSettings($this->getAppId(), 'confirm_hash');
         // Выставляем статус confirmed для email-адреса контакта
         $contact['email'] = array('value' => $contact->get('email', 'default'), 'status' => 'confirmed');
         // Сохраняем контакт
         $contact->save();
     } else {
         // Если хэш неправильный, то просто редирект на главную страницу
         $this->redirect(wa()->getRouteUrl('/frontend'));
     }
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:27,代码来源:guestbook2FrontendConfirm.action.php

示例3: gen

 /**
  * @param $id
  * @param array $params
  * @return shopCouponPluginCoupon
  */
 public static function gen($id, $params = array())
 {
     $m = new shopCouponModel();
     $tm = new shopCouponPluginTemplateModel();
     if (!($gen = $tm->getById($id))) {
         return new shopCouponPluginCoupon();
     }
     if (!($candidates = self::_candidates($gen))) {
         return new shopCouponPluginCoupon();
     }
     // Кто-то читает код? :)
     // Стоит проверять в цикле, чтоб наверняка?
     //do{
     $exists = $m->select('code')->where('code IN(?)', $candidates)->fetchAll(null, true);
     $candidates = array_diff($candidates, $exists);
     $code = reset($candidates);
     //} while(empty($code));
     $comment = $gen['comment'];
     if (!empty($params['contact_id'])) {
         $contact = new waContact($params['contact_id']);
         if ($contact->exists()) {
             $comment .= "\n" . _wp('for') . ' ' . $contact->getName();
         }
         $comment = trim($comment);
     }
     try {
         $code = mb_substr($code, 0, 32);
         $coupon = array('code' => $code, 'type' => $gen['type'], 'limit' => $gen['limit'], 'value' => $gen['value'], 'comment' => $comment, 'expire_datetime' => $gen['expire_hours'] ? date('Y-m-d H:i:s', time() + $gen['expire_hours'] * 3600) : null, 'create_datetime' => date('Y-m-d H:i:s'), 'create_contact_id' => $gen['create_contact_id']);
         $m->insert($coupon);
     } catch (waDbException $e) {
         $coupon = array();
     }
     return new shopCouponPluginCoupon($coupon);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:39,代码来源:shopCouponPlugin.class.php

示例4: execute

 public function execute()
 {
     $form = shopHelper::getCustomerForm();
     if ($form->post()) {
         $customer_validation_disabled = wa()->getSetting('disable_backend_customer_form_validation');
         if ($customer_validation_disabled || $form->isValid()) {
             $c = new waContact();
             if ($customer_validation_disabled) {
                 $errors = array();
                 $c->save($form->post());
             } else {
                 $errors = $c->save($form->post(), true);
             }
             if (!$errors) {
                 $scm = new shopCustomerModel();
                 $scm->createFromContact($c->getId());
                 echo '<script>$.customers.reloadSidebar(); window.location.hash = "#/id/' . $c->getId() . '"</script>';
                 exit;
             }
             // Show errors that waContact returned, e.g. email must be unique.
             foreach ($errors as $fld => $list) {
                 foreach ($list as $err) {
                     $form->errors($fld, $err);
                 }
             }
         }
     }
     $this->view->assign('form', $form);
     $this->view->assign('customer_validation_disabled', wa()->getSetting('disable_backend_customer_form_validation'));
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:30,代码来源:shopCustomersAdd.action.php

示例5: execute

 public function execute()
 {
     try {
         $discountcard = waRequest::post('discountcard', array());
         $model = new shopDiscountcardsPluginModel();
         if (!empty($discountcard['id'])) {
             $model->updateById($discountcard['id'], $discountcard);
             $discountcard = $model->getById($discountcard['id']);
         } elseif (empty($discountcard['discountcard'])) {
             throw new waException('Ошибка: Не указан номер дисконтной карты');
         } else {
             if ($model->getByField('discountcard', $discountcard['discountcard'])) {
                 throw new waException('Ошибка: Номер дисконтной карты не уникален');
             }
             $id = $model->insert($discountcard);
             $discountcard = $model->getById($id);
         }
         if (!empty($discountcard['contact_id'])) {
             $contact = new waContact($discountcard['contact_id']);
             $discountcard['contact_name'] = $contact->get('name');
         }
         $discountcard['amount'] = shop_currency($discountcard['amount']);
         $this->response = $discountcard;
     } catch (Exception $ex) {
         $this->setError($ex->getMessage());
     }
 }
开发者ID:klxqz,项目名称:discountcards,代码行数:27,代码来源:shopDiscountcardsPluginBackendSaveDiscountcard.controller.php

示例6: save

 public function save(waContact $contact, $fields)
 {
     if (!isset($fields['categories'])) {
         return TRUE;
     }
     if (empty($fields['categories'][0])) {
         $fields['categories'] = array();
     }
     if (wa()->getApp() == 'contacts' && !wa()->getUser()->getRights('contacts', 'category.all')) {
         // only save categories available for current user to see, and do not change others
         $crm = new contactsRightsModel();
         $cats = $this->getModel()->getContactCategories($contact->getId());
         $allowed = $crm->getAllowedCategories();
         $set = $fields['categories'] ? array_flip($fields['categories']) : array();
         foreach ($allowed as $id => $cat) {
             if (isset($set[$id])) {
                 $cats[$id] = true;
             } else {
                 unset($cats[$id]);
             }
         }
         $fields['categories'] = array_keys($cats);
     }
     $this->getModel()->setContactCategories($contact->getId(), $fields['categories']);
     return TRUE;
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:26,代码来源:waContactCategoryStorage.class.php

示例7: get

 /**
  * @param waContact $contact
  * @param array|string $fields
  * @param bool $old_value
  * @return array|void
  */
 public function get(waContact $contact, $fields = array(), $old_value = false)
 {
     if (!is_array($fields)) {
         $all_fields = array($fields);
     } else {
         $all_fields = $fields;
     }
     $result = array();
     $load_fields = array();
     foreach ($all_fields as $field_id) {
         if ($contact->issetCache($field_id, $old_value)) {
             $result[$field_id] = $contact->getCache($field_id, $old_value);
         } else {
             if (strpos($field_id, ':') === false) {
                 $result[$field_id] = null;
             }
             $load_fields[] = $field_id;
         }
     }
     if ((!$fields || $load_fields) && $contact->getId()) {
         if ($load_result = $this->load($contact, $load_fields)) {
             $result = $load_result + $result;
         }
         $contact->setCache($result);
     }
     if (!is_array($fields)) {
         return $result[$fields];
     } else {
         return $result;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:37,代码来源:waContactStorage.class.php

示例8: afterAuth

 /**
  * @param array $data
  * @return waContact
  */
 protected function afterAuth($data)
 {
     $app_id = $this->getStorage()->get('auth_app');
     $contact_id = 0;
     // find contact by auth adapter id, i.e. facebook_id
     $contact_data_model = new waContactDataModel();
     $row = $contact_data_model->getByField(array('field' => $data['source'] . '_id', 'value' => $data['source_id'], 'sort' => 0));
     if ($row) {
         $contact_id = $row['contact_id'];
     }
     // try find user by email
     if (!$contact_id && isset($data['email'])) {
         $sql = "SELECT c.id FROM wa_contact_emails e\n            JOIN wa_contact c ON e.contact_id = c.id\n            WHERE e.email = s:email AND e.sort = 0 AND c.password != ''";
         $contact_model = new waContactModel();
         $contact_id = $contact_model->query($sql, array('email' => $data['email']))->fetchField('id');
         // save source_id
         if ($contact_id) {
             $contact_data_model->insert(array('contact_id' => $contact_id, 'field' => $data['source'] . '_id', 'value' => $data['source_id'], 'sort' => 0));
         }
     }
     // create new contact
     if (!$contact_id) {
         $contact = new waContact();
         $data[$data['source'] . '_id'] = $data['source_id'];
         $data['create_method'] = $data['source'];
         $data['create_app_id'] = $app_id;
         // set random password (length = default hash length - 1, to disable ability auth using login and password)
         $contact->setPassword(substr(waContact::getPasswordHash(uniqid(time(), true)), 0, -1), true);
         unset($data['source']);
         unset($data['source_id']);
         if (isset($data['photo_url'])) {
             $photo_url = $data['photo_url'];
             unset($data['photo_url']);
         } else {
             $photo_url = false;
         }
         $contact->save($data);
         $contact_id = $contact->getId();
         if ($contact_id && $photo_url) {
             $photo_url_parts = explode('/', $photo_url);
             // copy photo to tmp dir
             $path = wa()->getTempPath('auth_photo/' . $contact_id . '.' . end($photo_url_parts), $app_id);
             $photo = file_get_contents($photo_url);
             file_put_contents($path, $photo);
             $contact->setPhoto($path);
         }
     } else {
         $contact = new waContact($contact_id);
     }
     // auth user
     if ($contact_id) {
         wa()->getAuth()->auth(array('id' => $contact_id));
         return $contact;
     }
     return false;
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:60,代码来源:waOAuthController.class.php

示例9: save

 public function save(waContact $contact, $fields)
 {
     if (!$this->model) {
         $this->model = new waContactModel();
     }
     if ($contact->getId()) {
         return $this->model->updateById($contact->getId(), $fields);
     } else {
         return $this->model->insert($fields);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:11,代码来源:waContactInfoStorage.class.php

示例10: save

 public function save(waContact $contact, $fields)
 {
     if (!isset($fields['categories'])) {
         return TRUE;
     }
     if (empty($fields['categories'][0])) {
         $fields['categories'] = array();
     }
     $this->getModel()->setContactCategories($contact->getId(), $fields['categories']);
     return TRUE;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:11,代码来源:waContactCategoryStorage.class.php

示例11: set

 public function set(waContact $contact, $value, $params = array(), $add = false)
 {
     if ($this->isMulti()) {
         throw new waException('Multi-checkboxes are not implemented.');
     }
     if (!$value) {
         return '';
     }
     // Only update timestamp if checkbox was not set before the save
     $old = $contact->get($this->id);
     return $old ? $old : time();
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:12,代码来源:waContactCheckboxField.class.php

示例12: save

 public function save(waContact $contact, $fields)
 {
     $this->getModel();
     if (isset($fields['birthday']) && isset($fields['birthday']['value'])) {
         $fields = array_merge($fields, $fields['birthday']['value']);
         unset($fields['birthday']);
     }
     if ($contact->getId()) {
         return $this->model->updateById($contact->getId(), $fields);
     } else {
         return $this->model->insert($fields);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:13,代码来源:waContactInfoStorage.class.php

示例13: handlerSignup

 /**
  * Обработчик хука signup
  *
  * @param waContact $contact
  */
 public function handlerSignup($contact)
 {
     $category_id = $this->getSettings('category_id');
     $ContactCategory = new waContactCategoryModel();
     // проверим на всякий случай есть-ли еще такая категория
     // а то вдруг ее какой-нибудь дурак удалил, а в настройке плагина она осталась
     // ресурсов на проверку нужно мало, а дураков на свете много
     $category_id = $ContactCategory->select('id')->where('id=:id', array('id' => $category_id))->fetchField();
     if ($contact instanceof waContact && $contact->getId() && $category_id) {
         $ContactCategories = new waContactCategoriesModel();
         $ContactCategories->add($contact->getId(), $category_id);
     }
 }
开发者ID:Syrnik,项目名称:reugroup,代码行数:18,代码来源:shopReugroupPlugin.class.php

示例14: prepareItem

 /** Add `when` and `who` fields (used in templated) to given item db row. */
 public static function prepareItem($item)
 {
     $item['name'] = htmlspecialchars($item['name']);
     $item['when'] = $item['done'] ? waDateTime::format('humandatetime', $item['done']) : '';
     $item['who'] = '';
     if ($item['contact_id'] && wa()->getUser()->getId() != $item['contact_id']) {
         $c = new waContact($item['contact_id']);
         try {
             $item['who'] = htmlspecialchars($c->getName());
         } catch (Exception $e) {
         }
     }
     return $item;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:15,代码来源:checklistsItem.class.php

示例15: settingsAction

 public function settingsAction($params)
 {
     $blog_id = $params['id'];
     $html = '<div class="fields-group">
     <div class="field">
         <div class="name">' . _wp('Subscribed via email') . '</div>
         <div class="value">';
     $model = new blogEmailsubscriptionModel();
     $contacts = $model->getSubscribers($blog_id);
     $rights = wa()->getUser()->getRights('contacts');
     $html .= '<ul class="menu-v">';
     if (!$contacts) {
         $html .= '<li>' . _wp('none') . '</li>';
     }
     foreach ($contacts as $c) {
         $html .= '<li>';
         if ($rights) {
             $html .= '<a href="' . wa()->getConfig()->getBackendUrl(true) . 'contacts/#/contact/' . $c['id'] . '">';
         }
         $html .= '<i class="icon16 userpic20" style="background-image: url(' . waContact::getPhotoUrl($c['id'], $c['photo'], 20) . ')"></i>';
         $html .= '<span>' . htmlspecialchars($c['name']) . '</span>';
         if ($rights) {
             $html .= '</a>';
         }
         $html .= '</li>';
     }
     $html .= '</ul></div></div></div>';
     return array('settings' => $html);
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:29,代码来源:blogEmailsubscriptionPlugin.class.php


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