本文整理汇总了PHP中waContact::get方法的典型用法代码示例。如果您正苦于以下问题:PHP waContact::get方法的具体用法?PHP waContact::get怎么用?PHP waContact::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waContact
的用法示例。
在下文中一共展示了waContact::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: payment
public function payment($data, $order_data, $auto_submit = false)
{
$data['order_id'] = $order_data['order_id'];
if ($order_data['currency_id'] != 'USD') {
throw new waPaymentException(_w('Order currency is not USD but payment gateway provide only USD transactions'));
}
$type_trans = array_flip(self::$type_trans);
if (!empty($data['type']) && !empty($type_trans[$data['type']])) {
$type = $type_trans[$data['type']];
} else {
$type = self::OPERATION_AUTH_ONLY;
}
if (empty($order_data['description_en'])) {
$order_data['description_en'] = 'Order #' . $order_data['order_id'] . ' (' . gmdate('F, d Y') . ')';
}
$c = new waContact($order_data['contact_id']);
$locale = $c->getLocale();
$form_fields = array('x_login' => $this->login, 'x_amount' => number_format($order_data['amount'], 2, '.', ''), 'x_description' => $order_data['description_en'], 'x_invoice_num' => $order_data['order_id'], 'x_fp_sequence' => rand(1, 1000), 'x_fp_timestamp' => time(), 'x_test_request' => 'false', 'x_show_form' => 'PAYMENT_FORM', 'x_type' => $type, 'x_version' => '3.1', 'x_method' => 'CC', 'x_cust_id' => $order_data['contact_id'], 'x_customer_ip' => wa()->getRequest()->server('REMOTE_ADDR'), 'x_duplicate_window' => '28800', 'x_first_name' => waLocale::transliterate($c->get('firstname'), $locale), 'x_last_name' => waLocale::transliterate($c->get('lastname'), $locale), 'x_company' => waLocale::transliterate($c->get('company'), $locale), 'x_address' => waLocale::transliterate($c->get('address:street', 'default'), $locale), 'x_city' => waLocale::transliterate($c->get('address:city', 'default'), $locale), 'x_state' => waLocale::transliterate($c->get('address:region', 'default'), $locale), 'x_zip' => waLocale::transliterate($c->get('address:zip', 'default'), $locale), 'x_country' => waLocale::transliterate($c->get('address:country', 'default'), $locale), 'x_phone' => $c->get('phone', 'default'), 'x_email' => $c->get('email', 'default'), 'x_relay_response' => isset($data['x_relay_response']) ? $data['x_relay_response'] : 'true', 'x_relay_url' => $this->getRelayUrl(), 'wa_success_url' => $this->getAdapter()->getBackUrl(waAppPayment::URL_SUCCESS, $data), 'wa_decline_url' => $this->getAdapter()->getBackUrl(waAppPayment::URL_DECLINE, $data), 'wa_cancel_url' => $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $data), 'wa_app_id' => $this->app_id, 'wa_merchant_id' => $this->merchant_id);
$form_fields['x_fp_hash'] = '';
// @TODO: get from common 'address' field
if (phpversion() >= '5.1.2') {
$form_fields['x_fp_hash'] = hash_hmac('md5', $this->login . "^" . $form_fields['x_fp_sequence'] . "^" . $form_fields['x_fp_timestamp'] . "^" . $form_fields['x_amount'] . "^", $this->trans_key);
} else {
$form_fields['x_fp_hash'] = bin2hex(mhash(MHASH_MD5, $this->login . "^" . $form_fields['x_fp_sequence'] . "^" . $form_fields['x_fp_timestamp'] . "^" . $form_fields['x_amount'] . "^", $this->trans_key));
}
if ($this->form_header) {
$form_fields['x_header_html_payment_form'] = $this->form_header;
}
$view = wa()->getView();
$view->assign('url', wa()->getRootUrl());
$view->assign('form_fields', $form_fields);
$view->assign('form_url', $this->getEndpointUrl());
$view->assign('auto_submit', $auto_submit);
return $view->fetch($this->path . '/templates/payment.html');
}
示例2: getContact
protected function getContact()
{
// Create new temporary waContact object
$contact = new waContact(wa()->getUser()->getId());
// Assign address with the right extension, if no extension is set
if ($this->form->fields('address.shipping') && !$contact->get('address.shipping') && ($addresses = $contact->get('address'))) {
$contact->set('address.shipping', $addresses[0]);
}
if ($this->form->fields('address.billing') && !$contact->get('address.billing') && ($addresses = $contact->get('address.shipping'))) {
$contact->set('address.billing', $addresses[0]);
}
return $contact;
}
示例3: 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
示例4: 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;
}
示例5: 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'));
}
}
示例6: execute
public function execute()
{
$this->contact = wa()->getUser();
$data = json_decode(waRequest::post('data'), true);
if (!$data || !is_array($data)) {
$this->response = array('errors' => array(), 'data' => array());
return;
}
// Make sure only allowed fields are saved
$allowed = array();
foreach (waContactFields::getAll('person') as $f) {
if ($f->getParameter('allow_self_edit')) {
$allowed[$f->getId()] = true;
}
}
$data = array_intersect_key($data, $allowed);
$oldLocale = $this->getUser()->getLocale();
// Validate and save contact if no errors found
$errors = $this->contact->save($data, true);
if ($errors) {
$response = array();
} else {
// New data formatted for JS
$response['name'] = $this->contact->get('name', 'js');
foreach ($data as $field_id => $field_value) {
if (!isset($errors[$field_id])) {
$response[$field_id] = $this->contact->get($field_id, 'js');
}
}
// Top fields
$response['top'] = array();
foreach (array('email', 'phone', 'im') as $f) {
if ($v = $this->contact->get($f, 'top,html')) {
$response['top'][] = array('id' => $f, 'name' => waContactFields::get($f)->getName(), 'value' => is_array($v) ? implode(', ', $v) : $v);
}
}
}
// Reload page with new language if user just changed it in own profile
if ($oldLocale != $this->contact->getLocale()) {
$response['reload'] = TRUE;
}
$this->response = array('errors' => $errors, 'data' => $response);
}
示例7: afterSignup
/**
* This method is called upon successful creation of a new contact
* It sends a welcome message to the new user
*
* Этот метод вызывается после успешного создания нового контакта
* В нём будет отправлено приветственное письмо новому пользователю
*
* @param waContact $contact
*/
public function afterSignup(waContact $contact)
{
// Adding contact to system category guestbook2 (named by the app ID)
// to be able to easily view all contacts registered in the guestbook
// or who have left a comment, in the Contacts app
// Добавляем контакт в системную категорию guestbook2 (по ID приложения)
// Чтобы в приложении Контакты можно было легко посмотреть все контакты,
// которые были зарегистрированы в гостевой книге, либо что-то написали в ней
$contact->addToCategory($this->getAppId());
// Getting contact's main email address
// Получаем главный email контакта
$email = $contact->get('email', 'default');
// If not specified, do nothing
// Если он не задан, ничего не делаем
if (!$email) {
return;
}
// Generating random hash
// Генерируем случайный хэш
$hash = md5(uniqid(time(), true));
// Saving the hash in contact info table with the app id
// Сохраняем этот хэш в таблице свойств контакта, указывая приложение
$contact->setSettings($this->getAppId(), 'confirm_hash', $hash);
// Adding contact id to the hash for easier search and verification by hash (see guestbook2FrontendConfirmAction)
// Добавляем в хэш номер контакта, чтобы было проще искать и проверять по хэшу (см. guestbook2FrontendConfirmAction)
$hash = substr($hash, 0, 16) . $contact->getId() . substr($hash, 16);
// Creating confirmation link with an absolute URL
// Формируем абсолютную ссылку подтверждения
$confirmation_url = wa()->getRouteUrl('/frontend/confirm', true) . "?hash=" . $hash;
// Creating a link to the app's home page with an absolute URL
// Формируем абсолютную ссылку на главную страницу приложения
$root_url = wa()->getRouteUrl('/frontend', true);
// Getting account name
// Получаем название аккаунта
$app_settings_model = new waAppSettingsModel();
$account_name = htmlspecialchars($app_settings_model->get('webasyst', 'name', 'Webasyst'));
// Generating message body
// Формируем тело письма
$body = _w('Hi') . ' ' . htmlspecialchars($contact->getName()) . ',<br>
<br>
' . sprintf(_w('Please confirm your account at %s by clicking this link:'), $account_name) . '<br>
<a href="' . $confirmation_url . '"><strong>' . $confirmation_url . '</strong></a><br>
<br>
--<br>
' . $account_name . '<br>
<a href="' . $root_url . '">' . $root_url . '</a>';
$subject = _w('Confirm your account');
// Sending email message
// Отправляем письмо
$message = new waMailMessage($subject, $body);
$message->setTo($email, $contact->getName());
$message->send();
}
示例8: 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();
}
示例9: getContactField
public function getContactField($field, $format = null)
{
if ($this->getContact()) {
$value = $this->contact->get($field, $format);
if (is_array($value)) {
$res = reset($value);
$value = $res['value'];
}
return $value;
} else {
return null;
}
}
示例10: execute
public function execute()
{
$id = $this->getRequest()->request('id', null, waRequest::TYPE_INT);
$sort = $this->getRequest()->request('sort', null, waRequest::TYPE_INT);
if ($id && $sort !== null) {
$lat = $this->getRequest()->request('lat', '', waRequest::TYPE_STRING);
$lng = $this->getRequest()->request('lng', '', waRequest::TYPE_STRING);
$contact = new waContact($id);
$address = array();
foreach ($contact->get('address') as $i => $addr) {
$address[$i] = array('value' => $addr['data'], 'ext' => $addr['ext']);
}
$address[$sort]['value']['lat'] = $lat;
$address[$sort]['value']['lng'] = $lng;
$contact->save(array('address' => $address));
}
}
示例11: run
public function run()
{
$app_settings_model = new waAppSettingsModel();
$contact_settings_model = new waContactSettingsModel();
$app_settings_model->set('blog', 'last_reminder_cron_time', time());
// remider settings for all users
$reminders = $contact_settings_model->select('contact_id, value')->where("app_id='blog' AND name='reminder'")->fetchAll('contact_id', true);
if (!$reminders) {
return;
}
$time = time();
// do job no more one time in 24 hours
$last_cron_times = $contact_settings_model->select('contact_id')->where("app_id='blog' AND name='last_reminder_cron_time' AND value <= " . ($time - 86400))->fetchAll('contact_id', true);
$reminders_allowed = array_keys($last_cron_times);
if (!$reminders_allowed) {
return;
}
$post_model = new blogPostModel();
$backend_url = $app_settings_model->get('blog', 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
$message_count = 0;
foreach ($reminders_allowed as $contact_id) {
$days = $reminders[$contact_id];
// get all deadline posts for this contact
$posts = $post_model->select("id, title, datetime")->where("status='" . blogPostModel::STATUS_DEADLINE . "' AND contact_id=" . $contact_id . " AND datetime < '" . date('Y-m-d H:i:s', $time + $days * 86400) . "'")->order('datetime')->fetchAll();
if ($posts) {
$contact = new waContact($contact_id);
$email = $contact->get('email', 'default');
$message = new waMailMessage(_w('Scheduled blog posts'), $this->getMessage($posts, $time, $backend_url));
try {
$message->setTo($email);
if ($message->send()) {
$message_count++;
}
} catch (Exception $e) {
}
}
$contact_settings_model->set($contact_id, 'blog', 'last_reminder_cron_time', $time);
}
/**
* Notify plugins about sending reminder
* @event followup_send
* @return void
*/
wa()->event('reminder_send', $message_count);
}
示例12: prepareSave
public function prepareSave($value, waContact $contact = null)
{
if (!$contact) {
return $value;
}
if ($contact['is_company']) {
$name = $contact['company'];
} else {
$fst = trim($contact['firstname']);
$mdl = trim($contact['middlename']);
$lst = trim($contact['lastname']);
$cmp = trim($contact['company']);
$eml = trim($contact->get('email', 'default'));
$name = array();
if ($fst || $fst === '0' || $mdl || $mdl === '0' || $lst || $lst === '0') {
$name[] = $lst;
$name[] = $fst;
$name[] = $mdl;
} else {
if ($cmp || $cmp === '0') {
$name[] = $cmp;
} else {
if ($eml) {
$pos = strpos($eml, '@');
if ($pos == false) {
$name[] = $eml;
} else {
$name[] = substr($eml, 0, $pos);
}
}
}
}
foreach ($name as $i => $n) {
if (!$n && $n !== '0') {
unset($name[$i]);
}
}
$name = trim(implode(' ', $name));
}
if (!$name && $name !== '0') {
$name = $contact->getId() ? $contact->getId() : '';
}
return $name;
}
示例13: getContactInfo
/** Using $this->id get waContact and save it in $this->contact;
* Load vars into $this->view specific to waContact. */
protected function getContactInfo()
{
$system = wa();
if ($this->id == $system->getUser()->getId()) {
$this->contact = $system->getUser();
$this->view->assign('own_profile', TRUE);
} else {
$this->contact = new waContact($this->id);
}
//
// Load vars into view
//
$this->view->assign('contact', $this->contact);
// who created this contact and when
$this->view->assign('contact_create_time', waDateTime::format('datetime', $this->contact['create_datetime'], $system->getUser()->getTimezone()));
if ($this->contact['create_contact_id']) {
try {
$author = new waContact($this->contact['create_contact_id']);
if ($author['name']) {
$this->view->assign('author', $author);
}
} catch (Exception $e) {
// Contact not found. Ignore silently.
}
}
// Info above tabs
$fields = array('email', 'phone', 'im');
$top = array();
foreach ($fields as $f) {
if ($v = $this->contact->get($f, 'top,html')) {
$top[] = array('id' => $f, 'name' => waContactFields::get($f)->getName(), 'value' => is_array($v) ? implode(', ', $v) : $v);
}
}
$this->view->assign('top', $top);
// Main contact editor data
$fieldValues = $this->contact->load('js', TRUE);
$contactFields = waContactFields::getInfo($this->contact['is_company'] ? 'company' : 'person', TRUE);
$this->view->assign('contactFields', $contactFields);
$this->view->assign('fieldValues', $fieldValues);
// Contact categories
$cm = new waContactCategoriesModel();
$this->view->assign('contact_categories', array_values($cm->getContactCategories($this->id)));
}
示例14: payment
public function payment($payment_form_data, $order_data, $auto_submit = false)
{
$order = waOrder::factory($order_data);
$description = preg_replace('/[^\\.\\?,\\[]\\(\\):;"@\\%\\s\\w\\d]+/', ' ', $order->description);
$description = preg_replace('/[\\s]{2,}/', ' ', $description);
if (!in_array($order->currency, $this->allowedCurrency())) {
throw new waPaymentException('Invalid currency');
}
list(, $lang) = explode("_", wa()->getLocale());
$contact = new waContact(wa()->getUser()->getId());
list($email) = $contact->get('email', 'value');
$redirectUrl = $this->getRelayUrl() . '?&fondy_id=' . $this->fondy_id . '&app_id=' . $this->app_id . '&merchants_id=' . $this->merchant_id;
$formFields = array('order_id' => $order_data['order_id'] . self::ORDER_SEPARATOR . time(), 'merchant_id' => $this->fondy_id, 'order_desc' => $description, 'amount' => $this->getAmount($order), 'currency' => $order->currency, 'server_callback_url' => $redirectUrl, 'response_url' => $redirectUrl . '&show_user_response=1', 'lang' => strtolower($lang), 'sender_email' => $email);
$formFields['signature'] = $this->getSignature($formFields);
$view = wa()->getView();
$view->assign('form_fields', $formFields);
$view->assign('form_url', $this->getEndpointUrl());
$view->assign('auto_submit', $auto_submit);
return $view->fetch($this->path . '/templates/payment.html');
}
示例15: getFormFieldsHtml
/**
* @description Get HTML with contact info (field name => field html)
* @return array
*/
protected function getFormFieldsHtml()
{
if (!$this->contact) {
$this->contact = $this->getContact();
}
if (!$this->form) {
$this->form = $this->getForm();
}
$user_info = array();
foreach ($this->form->fields as $id => $field) {
if (!in_array($id, array('password', 'password_confirm'))) {
if ($id === 'photo') {
$user_info[$id] = array('name' => _ws('Photo'), 'value' => '<img src="' . $this->contact->getPhoto() . '">');
} else {
$user_info[$id] = array('name' => $this->form->fields[$id]->getName(null, true), 'value' => $this->contact->get($id, 'html'));
}
}
}
return $user_info;
}