本文整理汇总了PHP中Contact::import方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::import方法的具体用法?PHP Contact::import怎么用?PHP Contact::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::import方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index_action
/**
* Main action to display contacts
*/
function index_action($filter = null)
{
// Check if we need to add contacts
$mps = MultiPersonSearch::load('contacts');
$imported = 0;
foreach ($mps->getAddedUsers() as $userId) {
$user_to_add = User::find($userId);
if ($user_to_add) {
$new_contact = array('owner_id' => User::findCurrent()->id, 'user_id' => $user_to_add->id);
if ($filter && $this->group) {
$new_contact['group_assignments'][] = array('statusgruppe_id' => $this->group->id, 'user_id' => $user_to_add->id);
}
$imported += (bool) Contact::import($new_contact)->store();
}
}
if ($imported) {
PageLayout::postMessage(MessageBox::success(sprintf(_("%s Kontakte wurden hinzugefügt."), $imported)));
}
$mps->clearSession();
// write filter to local
$this->filter = $filter;
// Deal with navigation
Navigation::activateItem('community/contacts');
// Edit CSS for quicknavigation
PageLayout::addStyle('div.letterlist span {color: #c3c8cc;}');
if ($filter) {
$selected = $this->group;
$contacts = SimpleCollection::createFromArray(User::findMany($selected->members->pluck('user_id')));
} else {
$contacts = User::findCurrent()->contacts;
}
$this->allContacts = $contacts;
// Retrive first letter and store in that contactgroup
$this->contacts = array();
foreach ($contacts as $contact) {
$this->contacts[strtoupper(SimpleCollection::translitLatin1($contact->nachname[0]))][] = $contact;
}
// Humans are a lot better with sorted results
ksort($this->contacts);
$this->contacts = array_map(function ($g) {
return SimpleCollection::createFromArray($g)->orderBy('nachname, vorname');
}, $this->contacts);
// Init sidebar
$this->initSidebar($filter);
// Init person search
$mps = MultiPersonSearch::get('contacts')->setTitle(_('Kontakte hinzufügen'))->setDefaultSelectedUser($this->allContacts->pluck('user_id'))->setExecuteURL($this->url_for('contact/index/' . $filter))->setSearchObject(new StandardSearch('user_id'));
// Set default title
$this->title = _('Alle Kontakte');
// If we have a group
if ($selected) {
// Set title of Table
$this->title = $selected->name;
// Set title of multipersonsearch
$mps->setTitle(sprintf(_('Kontakte zu %s hinzufügen'), $selected->name));
$mps->addQuickfilter(_('Kontakte'), User::findCurrent()->contacts->pluck('user_id'));
}
// Render multiperson search
$this->multiPerson = $mps->render();
}
示例2: buddy_action
/**
* Controller for all buddy related action.
*
* The following actions are supported:
* - "add" to add a user to the current user's buddy list
* - "remove" to remove a user from the current user's buddy list
*
* @param String $action The action to be executed
*/
public function buddy_action($action = 'add')
{
$username = Request::username('username');
if ($action === 'add' && $username !== null) {
if (Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => User::findByUsername($username)->id))->store()) {
PageLayout::postMessage(MessageBox::success(_('Der Benutzer wurde zu Ihren Kontakten hinzugefügt.')));
}
} elseif ($action === 'remove' && $username !== null) {
$contact = Contact::find(array(User::findCurrent()->id, User::findByUsername($username)->id));
if ($contact && $contact->delete()) {
PageLayout::postMessage(MessageBox::success(_('Der Benutzer gehört nicht mehr zu Ihren Kontakten.')));
}
}
$this->redirect('online');
}
示例3: follow_user_action
/**
* Current user is going to follow (add as buddy) the given user, who could
* also be an external contact.
*/
public function follow_user_action()
{
if (!$GLOBALS['perm']->have_perm("autor")) {
throw new AccessDeniedException();
}
if (Request::get("external_contact")) {
$user = BlubberExternalContact::find(Request::option("user_id"));
} else {
$user = new BlubberUser(Request::option("user_id"));
}
if (!$user->isNew()) {
if (is_a($user, "BlubberExternalContact")) {
$statement = DBManager::get()->prepare("INSERT IGNORE INTO blubber_follower " . "SET studip_user_id = :user_id, " . "external_contact_id = :contact_id, " . "left_follows_right = '1' " . "");
$success = $statement->execute(array('user_id' => $GLOBALS['user']->id, 'contact_id' => $user->getId()));
if ($success) {
NotificationCenter::postNotification('BlubberExternalContactDidAdd', $user);
}
} else {
Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => $user->id))->store();
}
}
$this->render_json(array('success' => 1, 'message' => (string) MessageBox::success(_("Kontakt hinzugefügt"))));
}
示例4: addToContactGroup
/**
* Add a user to a contact group
*
* @put /contact_group/:group_id/members/:user_id
*/
public function addToContactGroup($group_id, $user_id)
{
$group = $this->requireContactGroup($group_id);
$user = $this->requireUser($user_id);
// prevent duplicates
$exists = $group->members->findBy('user_id', $user_id)->first();
if ($exists) {
$this->halt(204);
}
$new_contact = array('owner_id' => $GLOBALS['user']->id, 'user_id' => $user->id);
$new_contact['group_assignments'][] = array('statusgruppe_id' => $group->id, 'user_id' => $user->id);
$success = (bool) \Contact::import($new_contact)->store();
if (!$success) {
$this->error(500);
}
$this->status(201);
}
示例5: json_decode
<?php
/**
* ownCloud - gsync plugin
*
* @author Victor Dubiniuk
* @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
namespace OCA_Gsync;
\OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('contacts');
\OCP\App::checkAppEnabled('gsync');
$refreshToken = \OCP\Config::getUserValue(\OCP\User::getUser(), 'gsync', 'refresh_token', '');
if ($refreshToken) {
$response = Request::getAccessTokenByRefreshToken($refreshToken);
$respData = json_decode($response, true);
App::log('Autosync session.' . $response, \OCP\Util::DEBUG);
Contact::import(@$respData['access_token']);
}
exit;
示例6:
<?php
/**
* ownCloud - gsync plugin
*
* @author Victor Dubiniuk
* @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
namespace OCA_Gsync;
App::initAjaxController();
Contact::import(@$_POST['access_token']);
\OCP\JSON::success(array());