本文整理汇总了PHP中waContact::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP waContact::getId方法的具体用法?PHP waContact::getId怎么用?PHP waContact::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waContact
的用法示例。
在下文中一共展示了waContact::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignUrls
protected function assignUrls()
{
$this->view->assign('tmpimage_url', '?module=photo&action=tmpimage');
$this->view->assign('delete_url', '?module=photo&action=delete&id=' . $this->contact->getId());
$this->view->assign('crop_url', '?module=photo&action=crop');
$this->view->assign('back_url', '#/contact/' . $this->contact->getId() . '/');
}
示例2: 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'));
}
示例3: 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;
}
示例4: save
public function save(waContact $contact, $fields)
{
if (!isset($fields['email'])) {
return true;
}
$data = array();
$delete_flag = false;
$sort = 0;
foreach ($fields['email'] as $sort => $field) {
if ($field === null) {
$sql = "DELETE FROM " . $this->getModel()->getTableName() . " \n WHERE contact_id = i:id AND sort >= i:sort";
$this->getModel()->exec($sql, array('id' => $contact->getId(), 'sort' => $sort));
continue;
}
$status = false;
if (is_array($field)) {
$value = $field['value'];
if (isset($field['status'])) {
$status = $field['status'];
}
} else {
$value = $field;
}
if (!$status) {
$status = wa()->getEnv() == 'frontend' ? 'unconfirmed' : 'unknown';
}
$ext = is_array($field) && isset($field['ext']) ? $field['ext'] : '';
if ($value) {
$data[$sort] = array('email' => $value, 'ext' => $ext, 'status' => $status);
} else {
$sql = "DELETE FROM " . $this->getModel()->getTableName() . " \n WHERE contact_id = i:id AND sort = i:sort";
$this->getModel()->exec($sql, array('id' => $contact->getId(), 'sort' => $sort));
$delete_flag = true;
continue;
}
}
if ($delete_flag) {
$sql = "DELETE FROM " . $this->getModel()->getTableName() . " \n WHERE contact_id = i:id AND sort >= i:sort";
$this->getModel()->exec($sql, array('id' => $contact->getId(), 'sort' => $sort));
}
if ($data) {
// find records to update
$rows = $this->getModel()->getByField(array('contact_id' => $contact->getId(), 'sort' => array_keys($data)), true);
foreach ($rows as $row) {
$this->getModel()->updateById($row['id'], $data[$row['sort']]);
unset($data[$row['sort']]);
}
foreach ($data as $k => $row) {
$data[$k] = $contact->getId() . ", '" . $this->getModel()->escape($row['email']) . "', '" . $this->getModel()->escape($row['ext']) . "', " . (int) $k . ", '" . $this->getModel()->escape($row['status']) . "'";
}
if ($data) {
// insert new records
$sql = "INSERT INTO " . $this->getModel()->getTableName() . " (contact_id, email, ext, sort, status)\n VALUES (" . implode("), (", $data) . ")";
return $this->getModel()->exec($sql);
}
}
return true;
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: assignUrls
protected function assignUrls()
{
if (!empty($this->params['limited_own_profile'])) {
$this->view->assign('tmpimage_url', '?module=profile&action=tmpimage');
$this->view->assign('delete_url', '?module=profile&action=deletePhoto');
$this->view->assign('crop_url', '?module=profile&action=savePhoto');
$this->view->assign('back_url', '?module=profile');
} else {
$this->view->assign('tmpimage_url', '?module=photo&action=tmpimage');
$this->view->assign('delete_url', '?module=photo&action=delete&id=' . $this->contact->getId());
$this->view->assign('crop_url', '?module=photo&action=crop');
$this->view->assign('back_url', '#/contact/' . $this->contact->getId() . '/');
}
}
示例9: 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;
}
}
示例10: logProfileEdit
public function logProfileEdit($old_data, $new_data)
{
$diff = array();
wa_array_diff_r($old_data, $new_data, $diff);
if (!empty($diff)) {
$this->logAction('my_profile_edit', $diff, null, $this->contact->getId());
}
}
示例11: logContactEdit
public function logContactEdit($old_data, $new_data)
{
$diff = array();
wa_array_diff_r($old_data, $new_data, $diff);
if (!empty($diff)) {
$this->logAction('contact_edit', $diff, $this->contact->getId());
}
}
示例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: 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;
}
示例14: 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;
}
示例15: 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();
}