本文整理汇总了PHP中ElggUser类的典型用法代码示例。如果您正苦于以下问题:PHP ElggUser类的具体用法?PHP ElggUser怎么用?PHP ElggUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ElggUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_blocked
/**
* Is $blocked_user blocked by $blocking_user?
*
* @param ElggUser $blocked_user
* @param ElggUser $blocking_user
* @return type bool
*/
function is_blocked(\ElggUser $blocked_user, \ElggUser $blocking_user)
{
if (!$blocked_user instanceof \ElggUser || !$blocking_user instanceof \ElggUser) {
return false;
}
return (bool) check_entity_relationship($blocking_user->getGUID(), 'blocked', $blocked_user->getGUID());
}
示例2: notification_tools_enable_for_new_user
/**
* Enable personal and friend notifications for new users
*
* We do this using 'create, user' event instead of 'register, user' plugin
* hook so that it affects also users created by an admin.
*
* @param string $event 'create'
* @param string $type 'user'
* @param ElggUser $user
* @return boolean
*/
function notification_tools_enable_for_new_user($event, $type, $user)
{
$personal = elgg_get_plugin_setting('default_personal_methods', 'notification_tools');
// Set methods for personal notifications
if ($personal) {
$personal_methods = explode(',', $personal);
foreach ($personal_methods as $method) {
$prefix = "notification:method:{$method}";
$user->{$prefix} = true;
}
}
$collection = elgg_get_plugin_setting('default_collection_methods', 'notification_tools');
// Set methods for notifications about friends' activity
if ($collection) {
$collection_methods = explode(',', $collection);
// Here we just mark the default methods. The core notification plugin
// will take care of creating the actual 'notify<method>' relationships
// between user and each friends.
foreach ($collection_methods as $method) {
$setting_name = "collections_notifications_preferences_{$method}";
// The -1 seems like a weird value but that's what the core
// is using for whatever reason.
$user->{$setting_name} = '-1';
}
}
$user->save();
return true;
}
示例3: createTestUser
protected function createTestUser($username = 'fileTest')
{
$user = new ElggUser();
$user->username = $username;
$guid = $user->save();
// load user to have access to creation time
return get_entity($guid);
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:8,代码来源:filestore.php
示例4: send_validation_reminder_mail
/**
* Send validation reminder to a specified user with
* some parameters.
*
* @param ElggUser $user User to send the reminder to
* @param int $enddate The end date in a unix timestamp
* @param int $pastdays The days we've passed since the validation
*/
function send_validation_reminder_mail($user, $enddate, $pastdays)
{
$daysleft = $enddate - $pastdays;
$site = elgg_get_site_entity();
$code = uservalidationbyemail_generate_code($user->getGUID(), $user->email);
$link = $site->url . 'uservalidationbyemail/confirm?u=' . $user->getGUID() . '&c=' . $code;
$subject = elgg_echo('validation_reminder:validate:token:subject', array($user->name, $site->name), $user->language);
$body = elgg_echo('validation_reminder:validate:token:body', array($user->name, $pastdays, $site->name, $user->token, $link, $daysleft, $site->name, $site->url), $user->language);
// Send validation email
notify_user($user->guid, $site->guid, $subject, $body, array(), 'email');
}
示例5: csv_exporter_get_exportable_values
/**
* Get a list of all the exportable values for the given type/subtype
*
* @param string $type the entity type
* @param string $subtype the entity subtype
* @param bool $readable readable values or just for processing (default: false)
*
* @return array
*/
function csv_exporter_get_exportable_values($type, $subtype = '', $readable = false)
{
$result = [];
if (empty($type)) {
return $result;
}
if ($type == 'object' && empty($subtype)) {
return $result;
}
$class = get_subtype_class($type, $subtype);
if (!empty($class)) {
$dummy = new $class();
} else {
switch ($type) {
case 'object':
$dummy = new ElggObject();
break;
case 'group':
$dummy = new ElggGroup();
break;
case 'site':
$dummy = new ElggSite();
break;
case 'user':
$dummy = new ElggUser();
break;
}
}
$exports = (array) $dummy->toObject();
$defaults = array_keys($exports);
if ($readable) {
$new_defaults = [];
foreach ($defaults as $name) {
if (elgg_language_key_exists($name)) {
$lan = elgg_echo($name);
} elseif (elgg_language_key_exists("csv_exporter:exportable_value:{$name}")) {
$lan = elgg_echo("csv_exporter:exportable_value:{$name}");
} else {
$lan = $name;
}
$new_defaults[$lan] = $name;
}
$defaults = $new_defaults;
}
$params = ['type' => $type, 'subtype' => $subtype, 'readable' => $readable, 'defaults' => $defaults];
$result = elgg_trigger_plugin_hook('get_exportable_values', 'csv_exporter', $params, $defaults);
if (is_array($result)) {
// prevent duplications
$result = array_unique($result);
}
return $result;
}
示例6: createTestUser
protected function createTestUser($username = 'fileTest')
{
// in case a test failure left the user
$user = get_user_by_username($username);
if ($user) {
return $user;
}
$user = new \ElggUser();
$user->username = $username;
$guid = $user->save();
// load user to have access to creation time
return get_entity($guid);
}
示例7: customizations_purge_messages
/**
* Delete messages from a user who is being deleted
*
* @param string $event
* @param string $type
* @param ElggUser $user
*/
function customizations_purge_messages($event, $type, $user)
{
// make sure we delete them all
$entity_disable_override = access_get_show_hidden_status();
access_show_hidden_entities(true);
$messages = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'messages', 'metadata_name' => 'fromId', 'metadata_value' => $user->getGUID(), 'limit' => 0));
if ($messages) {
foreach ($messages as $e) {
$e->delete();
}
}
access_show_hidden_entities($entity_disable_override);
}
示例8: testCanEdit
public function testCanEdit()
{
$user = new \ElggUser();
$user->save();
$id = $this->entity->annotate('test', 'foo', ACCESS_LOGGED_IN, elgg_get_logged_in_user_guid());
$a = elgg_get_annotation_from_id($id);
$this->assertTrue($a->canEdit());
$this->assertFalse($a->canEdit($user->guid));
$id = $this->entity->annotate('test', 'foo2', ACCESS_LOGGED_IN, $user->guid);
$a = elgg_get_annotation_from_id($id);
$this->assertTrue($a->canEdit());
$this->assertTrue($a->canEdit($user->guid));
$user->delete();
}
示例9: csv_exporter_get_exportable_values
/**
* Get a list of all the exportable values for the given type/subtype
*
* @param string $type the entity type
* @param string $subtype the entity subtype
* @param bool $readable readable values or just for processing (default: false)
*
* @return array
*/
function csv_exporter_get_exportable_values($type, $subtype = "", $readable = false)
{
$result = array();
if (empty($type)) {
return $result;
}
if ($type == "object" && empty($subtype)) {
return $result;
}
$class = get_subtype_class($type, $subtype);
if (!empty($class)) {
$dummy = new $class();
} else {
switch ($type) {
case "object":
$dummy = new ElggObject();
break;
case "group":
$dummy = new ElggGroup();
break;
case "site":
$dummy = new ElggSite();
break;
case "user":
$dummy = new ElggUser();
break;
}
}
$defaults = $dummy->getExportableValues();
if ($readable) {
$new_defaults = array();
foreach ($defaults as $name) {
if ($name != elgg_echo($name)) {
$lan = elgg_echo($name);
} else {
$lan = elgg_echo("csv_exporter:exportable_value:" . $name);
}
$new_defaults[$lan] = $name;
}
$defaults = $new_defaults;
}
$params = array("type" => $type, "subtype" => $subtype, "readable" => $readable, "defaults" => $defaults);
$result = elgg_trigger_plugin_hook("get_exportable_values", "csv_exporter", $params, $defaults);
if (is_array($result)) {
// prevent duplications
$result = array_unique($result);
}
return $result;
}
示例10: messageboard_add
/**
* Add messageboard post
*
* @param ElggUser $poster User posting the message
* @param ElggUser $owner User who owns the message board
* @param string $message The posted message
* @param int $access_id Access level (see defines in elgglib.php)
* @return bool
*/
function messageboard_add($poster, $owner, $message, $access_id = ACCESS_PUBLIC)
{
$result_id = $owner->annotate('messageboard', $message, $access_id, $poster->guid);
if (!$result_id) {
return false;
}
elgg_create_river_item(array('view' => 'river/object/messageboard/create', 'action_type' => 'messageboard', 'subject_guid' => $poster->guid, 'object_guid' => $owner->guid, 'access_id' => $access_id, 'annotation_id' => $result_id));
// Send notification only if poster isn't the owner
if ($poster->guid != $owner->guid) {
$subject = elgg_echo('messageboard:email:subject', array(), $owner->language);
$body = elgg_echo('messageboard:email:body', array($poster->name, $message, elgg_get_site_url() . "messageboard/owner/" . $owner->username, $poster->name, $poster->getURL()), $owner->language);
notify_user($owner->guid, $poster->guid, $subject, $body);
}
return $result_id;
}
示例11: stripe_register_user
/**
* Check if the email of the user has already been associated with a Stripe customer
* If so, map them
*
* @param string $event
* @param string $type
* @param ElggUser $user
* @param true
*/
function stripe_register_user($event, $type, $user)
{
$customer_ref = elgg_get_plugin_setting($user->email, 'stripe');
if (!$customer_ref) {
return;
}
$customer_ref = unserialize($customer_ref);
if (is_array($customer_ref) && sizeof($customer_ref)) {
$user->setPrivateSetting('stripe_customer_id', $customer_ref[0]);
$customer_ref = array_reverse($customer_ref);
foreach ($customer_ref as $c_ref) {
create_metadata($user->guid, 'stripe_customer_id', $c_ref, '', $user->guid, ACCESS_PUBLIC, true);
}
}
elgg_unset_plugin_setting($user->email, 'stripe');
return true;
}
示例12: createCustomer
/**
* Create a new customer
* @param ElggUser $user
* @param array $data
* @return Stripe_Customer|false
*/
public function createCustomer($user = null, $data = array())
{
$fields = array('account_balance', 'card', 'coupon', 'plan', 'quantity', 'trial_end', 'metadata', 'description', 'email');
try {
foreach ($data as $key => $value) {
if (!in_array($key, $fields)) {
$data[$key] = '';
}
}
$data = array_filter($data);
if ($user) {
if (!$data['email']) {
$data['email'] = $user->email;
}
if (!$data['description']) {
$data['description'] = $user->name;
}
if (!is_array($data['metadata'])) {
$data['metadata'] = array();
}
$data['metadata']['guid'] = $user->guid;
$data['metadata']['username'] = $user->username;
}
$customer = Stripe_Customer::create($data);
if ($user && $user->guid) {
// Store any customer IDs this user might have for reference
$stripe_ids = $user->stripe_customer_id;
if (!$stripe_ids) {
$stripe_ids = array();
} else {
if (!is_array($stripe_ids)) {
$stripe_ids = array($stripe_ids);
}
}
if (!in_array($customer->id, $stripe_ids)) {
create_metadata($user->guid, 'stripe_customer_id', $customer->id, '', $user->guid, ACCESS_PUBLIC, true);
}
// Store current Customer ID
$user->setPrivateSetting('stripe_customer_id', $customer->id);
} else {
// Store customer IDs with their email reference locally
// so that users can be assigned their existing customer ID upon registration
$customer_ref = elgg_get_plugin_setting($customer->email, 'stripe');
if ($customer_ref) {
$customer_ref = unserialize($customer_ref);
} else {
$customer_ref = array();
}
array_unshift($customer_ref, $customer->id);
elgg_set_plugin_setting($customer->email, serialize($customer_ref), 'stripe');
}
return $customer;
} catch (Exception $ex) {
$this->log($ex);
return false;
}
}
示例13: __construct
/**
* Create a notification event
*
* @param \ElggData $object The object of the event (\ElggEntity)
* @param string $action The name of the action (default: create)
* @param \ElggUser $actor The user that caused the event (default: logged in user)
*
* @throws \InvalidArgumentException
*/
public function __construct(\ElggData $object, $action, \ElggUser $actor = null)
{
if (elgg_instanceof($object)) {
$this->object_type = $object->getType();
$this->object_subtype = $object->getSubtype();
$this->object_id = $object->getGUID();
} else {
$this->object_type = $object->getType();
$this->object_subtype = $object->getSubtype();
$this->object_id = $object->id;
}
if ($actor == null) {
$this->actor_guid = _elgg_services()->session->getLoggedInUserGuid();
} else {
$this->actor_guid = $actor->getGUID();
}
$this->action = $action;
}
示例14: __construct
/**
* Create a notification event
*
* @param \ElggData $object The object of the event (\ElggEntity)
* @param string $action The name of the action (default: create)
* @param \ElggUser $actor The user that caused the event (default: logged in user)
*
* @throws \InvalidArgumentException
*/
public function __construct(\ElggData $object, $action, \ElggUser $actor = null)
{
if (elgg_instanceof($object)) {
$this->object_type = $object->getType();
$this->object_subtype = $object->getSubtype();
$this->object_id = $object->getGUID();
} else {
$this->object_type = $object->getType();
$this->object_subtype = $object->getSubtype();
$this->object_id = $object->id;
}
if ($actor == null) {
$this->actor_guid = elgg_get_logged_in_user_guid();
} else {
$this->actor_guid = $actor->getGUID();
}
$this->action = $action;
}
示例15: group_tools_invite_user
function group_tools_invite_user(ElggGroup $group, ElggUser $user, $text = "", $resend = false)
{
$result = false;
if (!empty($user) && $user instanceof ElggUser && !empty($group) && $group instanceof ElggGroup && ($loggedin_user = elgg_get_logged_in_user_entity())) {
// Create relationship
$relationship = add_entity_relationship($group->getGUID(), "invited", $user->getGUID());
if ($relationship || $resend) {
// Send email
$url = elgg_get_site_url() . "groups/invitations/" . $user->username;
$subject = elgg_echo("groups:invite:subject", array($user->name, $group->name));
$msg = elgg_echo("group_tools:groups:invite:body", array($user->name, $loggedin_user->name, $group->name, $text, $url));
if ($res = notify_user($user->getGUID(), $group->getOwnerGUID(), $subject, $msg)) {
$result = true;
}
}
}
return $result;
}