本文整理汇总了PHP中waContact::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP waContact::getName方法的具体用法?PHP waContact::getName怎么用?PHP waContact::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waContact
的用法示例。
在下文中一共展示了waContact::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: afterSignup
/**
* Этот метод вызывается после успешного создания нового контакта
* В нём будет отправлено приветственное письмо новому пользователю
* @param waContact $contact
*/
public function afterSignup(waContact $contact)
{
// Добавляем контакт в системную категорию guestbook2 (по ID приложения)
// Чтобы в приложении контакты можно было легко посмотреть все контакты,
// которые были зарегистрированы в гостевой книге, либо что-то написали в ней
$contact->addToCategory($this->getAppId());
// Получаем главный email контакта
$email = $contact->get('email', 'default');
// Если он не задан, ничего не делаем
if (!$email) {
return;
}
// Генерируем случайный хэш
$hash = md5(uniqid(time(), true));
// Сохраняем этот хэш в таблице свойств контакта, указывая приложение
$contact->setSettings($this->getAppId(), 'confirm_hash', $hash);
// Добавляем в хэш номер контакта, чтобы было проще искать и проверять по хэшу (см. guestbook2FrontendConfirmAction)
$hash = substr($hash, 0, 16) . $contact->getId() . substr($hash, 16);
// Формируем абсолютную ссылку подтверждения
$confirmation_url = wa()->getRouteUrl('/frontend/confirm', true) . "?hash=" . $hash;
// Формируем абсолютную ссылку на главную страницу приложения
$root_url = wa()->getRouteUrl('/frontend', true);
// Получаем название аккаунта
$app_settings_model = new waAppSettingsModel();
$account_name = htmlspecialchars($app_settings_model->get('webasyst', 'name', 'Webasyst'));
// Формируем тело письма
$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');
// Отправляем письмо
$message = new waMailMessage($subject, $body);
$message->setTo($email, $contact->getName());
$message->send();
}
示例4: 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;
}
示例5: execute
public function execute()
{
$id = waRequest::request('id', null, waRequest::TYPE_INT);
$contact = new waContact($id);
$contact->getName();
// Customer orders
$im = new shopOrderItemsModel();
$orders_collection = new shopOrdersCollection('search/contact_id=' . $id);
$orders = $orders_collection->getOrders('*,items,params', 0, 500);
shopHelper::workupOrders($orders);
foreach ($orders as &$o) {
$o['total_formatted'] = waCurrency::format('%{s}', $o['total'], $o['currency']);
$o['shipping_name'] = ifset($o['params']['shipping_name'], '');
$o['payment_name'] = ifset($o['params']['payment_name'], '');
}
$this->view->assign('orders', $orders);
$this->view->assign('contact', $contact);
$this->view->assign('def_cur_tmpl', str_replace('0', '%s', waCurrency::format('%{s}', 0, wa()->getConfig()->getCurrency())));
}
示例6: getAuthorInfo
public static function getAuthorInfo($id, $photo_size = self::SMALL_AUTHOR_PHOTO_SIZE)
{
static $authors_info = array();
$id = max(0, intval($id));
if (!isset($authors_info[$id][$photo_size])) {
$contact = new waContact($id);
$authors_info[$id][$photo_size] = array();
$authors_info[$id][$photo_size]['id'] = $id;
if ($id) {
$authors_info[$id][$photo_size]['name'] = $contact->getName();
}
$authors_info[$id][$photo_size]['photo'] = $contact->getPhoto($photo_size);
}
return $authors_info[$id][$photo_size];
}
示例7: send
public function send(waContact $contact)
{
$email = $contact->get('email', 'default');
if (!$email) {
return;
}
$subject = _ws("Thank you for signing up!");
$this->view->assign('email', $email);
$this->view->assign('name', $contact->getName());
// send email confirmation link
$this->sendConfirmationLink($contact);
$template_file = $this->getConfig()->getConfigPath('mail/Signup.html', true, 'webasyst');
if (file_exists($template_file)) {
$body = $this->view->fetch('string:' . file_get_contents($template_file));
} else {
$body = $this->view->fetch(wa()->getAppPath('templates/mail/Signup.html', 'webasyst'));
}
try {
$m = new waMailMessage($subject, $body);
$m->setTo($email, $contact->getName());
$from = $this->getFrom();
if ($from) {
$m->setFrom($from);
}
return (bool) $m->send();
} catch (Exception $e) {
return false;
}
}
示例8: formalizeData
protected function formalizeData($transaction_raw_data)
{
$unpack = $this->unpackTransactionCode($transaction_raw_data['VendorTxCode']);
list($contact_id, $currency) = array_slice($unpack, 3);
$contact = new waContact($contact_id);
$view_data = implode(' ', array('Name: ' . $contact->getName(), 'Phone: ' . $contact->get('phone', 'default'), 'Email: ' . $contact->get('email', 'default')));
$status = $transaction_raw_data['Status'];
if ($status == 'OK') {
$type = waPayment::OPERATION_AUTH_CAPTURE;
$state = waPayment::STATE_AUTH;
} else {
$type = waPayment::OPERATION_CANCEL;
$state = waPayment::STATE_CANCELED;
}
$transaction_data = parent::formalizeData($transaction_raw_data);
$transaction_data = array_merge($transaction_data, array('type' => $type, 'native_id' => ifset($transaction_raw_data['VPSTxId']), 'amount' => ifset($transaction_raw_data['Amount']), 'currency_id' => $currency, 'customer_id' => $contact_id, 'result' => 1, 'order_id' => $this->order_id, 'view_data' => $view_data, 'state' => $state));
return $transaction_data;
}
示例9: authorPrepare
protected function authorPrepare($contact_id)
{
$this->where[] = 'p.contact_id=' . (int) $contact_id;
$this->order_by = 'p.upload_datetime DESC,p.id';
$contact = new waContact($contact_id);
$this->addTitle(_w('Uploaded by') . ' ' . $contact->getName());
}
示例10: getCustomerForm
/**
* Returns instance of class waContactForm.
*
* @param int|waContact|null $id Optional id of contact or contact object whose data must be pre-filled in contact form.
* @param bool $ensure_address Whether address fields must be included regardless of store's contact fields settings.
* @return waContactForm
*/
public static function getCustomerForm($id = null, $ensure_address = false)
{
$settings = wa('shop')->getConfig()->getCheckoutSettings();
if (!isset($settings['contactinfo'])) {
$settings = wa('shop')->getConfig()->getCheckoutSettings(true);
}
$fields_config = ifset($settings['contactinfo']['fields'], array());
$address_config = ifset($fields_config['address'], array());
unset($fields_config['address']);
if (wa()->getEnv() == 'backend') {
// new order
if (!isset($fields_config['address.shipping']) || !$id) {
$fields_config['address.shipping'] = array();
} elseif (!empty($fields_config['address.shipping']) && $id && $id instanceof waContact) {
$address = $id->getFirst('address.shipping');
if ($address && !empty($address['data'])) {
foreach ($address['data'] as $subfield => $v) {
if (!isset($fields_config['address.shipping']['fields'][$subfield])) {
$fields_config['address.shipping']['fields'][$subfield] = array();
}
}
}
}
}
if ($ensure_address && !isset($fields_config['address.billing']) && !isset($fields_config['address.shipping'])) {
$fields_config['address'] = $address_config;
}
$form = waContactForm::loadConfig($fields_config, array('namespace' => 'customer'));
if ($id) {
if (is_numeric($id)) {
$contact = new waContact($id);
$contact->getName();
// make sure contact exists; throws exception otherwise
} elseif ($id instanceof waContact) {
$contact = $id;
}
if (isset($contact)) {
$form->setValue($contact);
}
}
return $form;
}
示例11: execute
public function execute()
{
$id = waRequest::request('id', null, waRequest::TYPE_INT);
$scm = new shopCustomerModel();
$customer = $scm->getById($id);
try {
$contact = new waContact($id);
$contact->getName();
} catch (waException $e) {
// !!! What to do when shop_customer exists, but no wa_contact found?
throw $e;
}
$ccsm = new waContactCategoriesModel();
$contact_categories = $ccsm->getContactCategories($id);
$contacts_url = wa()->getAppUrl('contacts');
// Info above tabs
$top = array();
foreach (array('email', 'phone', 'im') as $f) {
if ($v = $contact->get($f, 'top,html')) {
$top[] = array('id' => $f, 'name' => waContactFields::get($f)->getName(), 'value' => is_array($v) ? implode(', ', $v) : $v);
}
}
// Get photo
$photo = $contact->get('photo');
$config = $this->getConfig();
$use_gravatar = $config->getGeneralSettings('use_gravatar');
$gravatar_default = $config->getGeneralSettings('gravatar_default');
if (!$photo && $use_gravatar) {
$photo = shopHelper::getGravatar($contact->get('email', 'default'), 96, $gravatar_default);
} else {
$photo = $contact->getPhoto(96);
}
$contact['photo'] = $photo;
// Customer orders
$im = new shopOrderItemsModel();
$orders_collection = new shopOrdersCollection('search/contact_id=' . $id);
$total_count = $orders_collection->count();
$orders = $orders_collection->getOrders('*,items,params', 0, $total_count);
shopHelper::workupOrders($orders);
foreach ($orders as &$o) {
$o['total_formatted'] = waCurrency::format('%{s}', $o['total'], $o['currency']);
$o['shipping_name'] = ifset($o['params']['shipping_name'], '');
$o['payment_name'] = ifset($o['params']['payment_name'], '');
// !!! TODO: shipping and payment icons
}
// Customer reviews
$prm = new shopProductReviewsModel();
$reviews = $prm->getList('*,is_new,product', array('escape' => false, 'where' => array('contact_id' => $id), 'limit' => false));
// Customer affiliate transactions history
$atm = new shopAffiliateTransactionModel();
$affiliate_history = $atm->getByContact($id);
$this->view->assign('top', $top);
$this->view->assign('orders', $orders);
$this->view->assign('reviews', $reviews);
$this->view->assign('contact', $contact);
$this->view->assign('customer', $customer);
$this->view->assign('contacts_url', $contacts_url);
$this->view->assign('affiliate_history', $affiliate_history);
$this->view->assign('contact_categories', $contact_categories);
$this->view->assign('def_cur_tmpl', str_replace('0', '%s', waCurrency::format('%{s}', 0, wa()->getConfig()->getCurrency())));
$this->view->assign('point_rate', str_replace(',', '.', (double) str_replace(',', '.', wa()->getSetting('affiliate_usage_rate'))));
$fields = waContactFields::getAll('person');
if (isset($fields['name'])) {
unset($fields['name']);
}
$this->view->assign('fields', $fields);
$this->view->assign('orders_default_view', $config->getOption('orders_default_view'));
/*
* @event backend_customer
* @return array[string]array $return[%plugin_id%] array of html output
* @return array[string][string]string $return[%plugin_id%]['info_section'] html output
* @return array[string][string]string $return[%plugin_id%]['name_suffix'] html output
* @return array[string][string]string $return[%plugin_id%]['header'] html output
* @return array[string][string]string $return[%plugin_id%]['action_link'] html output
*/
$this->view->assign('backend_customer', wa()->event('backend_customer', $customer));
}
示例12: getOrder
public function getOrder($id, $extend = false, $escape = true)
{
$order = $this->getById($id);
if (!$order) {
return array();
}
$order_params_model = new shopOrderParamsModel();
$order['params'] = $order_params_model->get($id);
if ($order['contact_id']) {
$contact = new waContact($order['contact_id']);
$order['contact'] = array('id' => $order['contact_id'], 'name' => $contact->getName(), 'email' => $contact->get('email', 'default'), 'phone' => $contact->get('phone', 'default'));
$config = wa('shop')->getConfig();
$use_gravatar = $config->getGeneralSettings('use_gravatar');
$gravatar_default = $config->getGeneralSettings('gravatar_default');
if (!$contact->get('photo') && $use_gravatar) {
$order['contact']['photo_50x50'] = shopHelper::getGravatar($order['contact']['email'], 50, $gravatar_default);
} else {
$order['contact']['photo_50x50'] = $contact->getPhoto(50);
}
} else {
$order['contact'] = $this->extractConctactInfo($order['params']);
}
if (!empty($order['params']['coupon_id'])) {
$coupon_model = new shopCouponModel();
$coupon = $coupon_model->getById($order['params']['coupon_id']);
$order['coupon'] = array();
if ($coupon) {
$order['coupon'] = $coupon;
} else {
if (!empty($order['params']['coupon_code'])) {
$order['coupon']['code'] = $order['params']['coupon_code'];
}
}
}
$order_items_model = new shopOrderItemsModel();
$order['items'] = $order_items_model->getItems($id, $extend);
if ($escape) {
if (!empty($order['items'])) {
foreach ($order['items'] as &$product) {
if (!empty($product['name'])) {
$product['name'] = htmlspecialchars($product['name']);
}
if (!empty($product['item']['name'])) {
$product['item']['name'] = htmlspecialchars($product['item']['name']);
}
if (!empty($product['skus'])) {
foreach ($product['skus'] as &$sku) {
if (!empty($sku['name'])) {
$sku['name'] = htmlspecialchars($sku['name']);
}
unset($sku);
}
}
if (!empty($product['services'])) {
foreach ($product['services'] as &$service) {
if (!empty($service['name'])) {
$service['name'] = htmlspecialchars($service['name']);
}
if (!empty($service['item']['name'])) {
$service['item']['name'] = htmlspecialchars($service['item']['name']);
}
if (!empty($service['variants'])) {
foreach ($service['variants'] as &$variant) {
$variant['name'] = htmlspecialchars($variant['name']);
unset($variant);
}
}
unset($service);
}
}
unset($product);
}
}
$order['contact']['name'] = htmlspecialchars($order['contact']['name']);
}
return $order;
}