本文整理汇总了PHP中waContact::getTopFields方法的典型用法代码示例。如果您正苦于以下问题:PHP waContact::getTopFields方法的具体用法?PHP waContact::getTopFields怎么用?PHP waContact::getTopFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waContact
的用法示例。
在下文中一共展示了waContact::getTopFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
$this->view->assign('own_profile', false);
}
$exists = $this->contact->exists();
if ($exists) {
$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.
}
}
$this->view->assign('top', $this->contact->getTopFields());
// Main contact editor data
$fieldValues = $this->contact->load('js', true);
$m = new waContactModel();
if (isset($fieldValues['company_contact_id'])) {
if (!$m->getById($fieldValues['company_contact_id'])) {
$fieldValues['company_contact_id'] = 0;
$this->contact->save(array('company_contact_id' => 0));
}
}
$contactFields = waContactFields::getInfo($this->contact['is_company'] ? 'company' : 'person', true);
// Only show fields that are allowed in own profile
if (!empty($this->params['limited_own_profile'])) {
$allowed = array();
foreach (waContactFields::getAll('person') as $f) {
if ($f->getParameter('allow_self_edit')) {
$allowed[$f->getId()] = true;
}
}
$fieldValues = array_intersect_key($fieldValues, $allowed);
$contactFields = array_intersect_key($contactFields, $allowed);
}
contactsHelper::normalzieContactFieldValues($fieldValues, $contactFields);
$this->view->assign('contactFields', $contactFields);
$this->view->assign('contactFieldsOrder', array_keys($contactFields));
$this->view->assign('fieldValues', $fieldValues);
// Contact categories
$cm = new waContactCategoriesModel();
$this->view->assign('contact_categories', array_values($cm->getContactCategories($this->id)));
} else {
$this->view->assign('contact', array('id' => $this->id));
}
return $exists;
}
示例2: 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');
}
}
$response['top'] = $this->contact->getTopFields();
}
// Reload page with new language if user just changed it in own profile
if ($oldLocale != $this->contact->getLocale()) {
$response['reload'] = TRUE;
}
$response['id'] = $this->contact->getId();
$this->response = array('errors' => $errors, 'data' => $response);
}
示例3: execute
public function execute()
{
if (!$this->getRequest()->request('json', 0)) {
$action = new contactsContactsInfoAction();
echo $action->display();
return;
}
$m = new waContactModel();
$contact_id = $this->getRequest()->request('id', 0, 'int');
$contact = new waContact($contact_id);
$values = $contact->load('js', true);
if (isset($values['company_contact_id'])) {
if (!$m->getById($values['company_contact_id'])) {
$values['company_contact_id'] = 0;
$contact->save(array('company_contact_id' => 0));
}
}
$values['photo_url_96'] = $contact->getPhoto(96);
$values['photo_url_20'] = $contact->getPhoto(20);
$fields = waContactFields::getInfo($contact['is_company'] ? 'company' : 'person', true);
echo json_encode(array('fields' => $fields, 'values' => $values, 'top' => $contact->getTopFields()));
}
示例4: execute
public function execute()
{
$this->id = (int) waRequest::post('id');
// Check access
if (!$this->id) {
if (!$this->getRights('create')) {
throw new waRightsException(_w('Access denied'));
}
} else {
if ($this->id != wa()->getUser()->getId()) {
$cr = new contactsRightsModel();
if ($cr->getRight(null, $this->id) != 'write') {
throw new waRightsException(_w('Access denied'));
}
}
}
$this->type = waRequest::post('type');
$this->contact = new waContact($this->id);
if ($this->type == 'company') {
$this->contact['is_company'] = 1;
}
$data = json_decode(waRequest::post('data'), true);
if (!$this->id && !isset($data['create_method'])) {
$data['create_method'] = 'add';
}
$oldLocale = $this->getUser()->getLocale();
// get old data for logging
if ($this->id) {
$old_data = array();
foreach ($data as $field_id => $field_value) {
$old_data[$field_id] = $this->contact->get($field_id);
}
}
$response = array();
if (!($errors = $this->contact->save($data, true))) {
if ($this->id) {
$new_data = array();
foreach ($data as $field_id => $field_value) {
if (!isset($errors[$field_id])) {
$response[$field_id] = $this->contact->get($field_id, 'js');
$new_data[$field_id] = $this->contact->get($field_id);
}
}
if (empty($errors)) {
$this->logContactEdit($old_data, $new_data);
}
$response['name'] = $this->contact->get('name', 'js');
$response['top'] = $this->contact->getTopFields();
$response['id'] = $this->contact->getId();
} else {
$response = array('id' => $this->contact->getId());
$response['address'] = $this->contact->get('address', 'js');
$this->logAction('contact_add', null, $this->contact->getId());
}
// Update recently added menu item
$name = $this->contact->get('name');
if ($name || $name === '0') {
$history = new contactsHistoryModel();
$history->save('/contact/' . $this->contact->getId(), $name, $this->id ? null : 'add');
$history = $history->get();
// to update history in user's browser
}
}
// Reload page with new language if user just changed it in own profile
if ($this->contact->getId() == $this->getUser()->getId() && $oldLocale != $this->contact->getLocale()) {
$response['reload'] = true;
}
$this->response = array('errors' => $errors, 'data' => $response);
if (isset($history)) {
$this->response['history'] = $history;
}
}
示例5: workupContacts
public function workupContacts(&$contacts)
{
if (!$contacts) {
return array();
}
$contact_fields = array(array_keys(waContactFields::getAll('person', true)), array_keys(waContactFields::getAll('company', true)));
foreach ($contacts as &$c) {
$fields = $contact_fields[intval($c['is_company'])];
$data = array('id' => $c['id']);
foreach ($fields as $fld_id) {
if (array_key_exists($fld_id, $c)) {
$data[$fld_id] = $c[$fld_id];
unset($c[$fld_id]);
}
}
$c = array_merge($data, $c);
}
unset($c);
// load that fields, that are top
if ($this->getRequest()->request('top')) {
foreach ($contacts as &$c) {
$contact = new waContact($c['id']);
$c['top'] = $contact->getTopFields();
}
unset($c);
}
}