• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ElggUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ElggUser的典型用法代码示例。如果您正苦于以下问题:PHP ElggUser类的具体用法?PHP ElggUser怎么用?PHP ElggUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ElggUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:arckinteractive,项目名称:block_users,代码行数:14,代码来源:functions.php


示例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;
}
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:39,代码来源:start.php


示例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');
}
开发者ID:centillien,项目名称:validation_reminder,代码行数:19,代码来源:start.php


示例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;
}
开发者ID:coldtrick,项目名称:csv_exporter,代码行数:61,代码来源:functions.php


示例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);
 }
开发者ID:elgg,项目名称:elgg,代码行数:13,代码来源:ElggCoreFilestoreTest.php


示例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);
}
开发者ID:elgg,项目名称:community_customizations,代码行数:20,代码来源:start.php


示例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();
 }
开发者ID:ibou77,项目名称:elgg,代码行数:14,代码来源:ElggAnnotationTest.php


示例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;
}
开发者ID:pleio,项目名称:csv_exporter,代码行数:58,代码来源:functions.php


示例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;
}
开发者ID:elgg,项目名称:messageboard,代码行数:24,代码来源:start.php


示例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;
}
开发者ID:Daltonmedia,项目名称:stripe,代码行数:26,代码来源:events.php


示例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;
     }
 }
开发者ID:Daltonmedia,项目名称:stripe,代码行数:63,代码来源:StripeClient.php


示例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;
 }
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:27,代码来源:Event.php


示例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;
 }
开发者ID:sephiroth88,项目名称:Elgg,代码行数:27,代码来源:Event.php


示例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;
}
开发者ID:remy40,项目名称:gvrs,代码行数:18,代码来源:functions.php


示例16: share_notify_user

/**
 * Notify $user that $sharer shared his $entity.
 *
 * @param type $user
 * @param type $sharer
 * @param type $entity 
 */
function share_notify_user(ElggUser $user, ElggUser $sharer, ElggEntity $entity)
{
    if (!$user instanceof ElggUser) {
        return false;
    }
    if (!$sharer instanceof ElggUser) {
        return false;
    }
    if (!$entity instanceof ElggEntity) {
        return false;
    }
    $title_str = $entity->title;
    if (!$title_str) {
        $title_str = elgg_get_excerpt($entity->description);
    }
    $site = get_config('site');
    $subject = elgg_echo('share:notifications:subject', array($sharer->name, $title_str));
    $body = elgg_echo('share:notifications:body', array($user->name, $sharer->name, $title_str, $site->name, $entity->getURL(), $sharer->getURL()));
    notify_user($user->guid, $sharer->guid, $subject, $body);
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:27,代码来源:start.php


示例17: __construct

 /**
  * Create a notification event
  *
  * @param ElggData $object The object of the event (ElggEntity, ElggAnnotation, ElggRelationship)
  * @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($object, $action, $actor = null)
 {
     if (!$object instanceof ElggData) {
         throw new InvalidArgumentException('$object is not an instance of ElggData');
     }
     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;
 }
开发者ID:tjcaverly,项目名称:Elgg,代码行数:29,代码来源:Event.php


示例18: __construct

 /**
  * Called before each test object.
  */
 public function __construct()
 {
     elgg_set_ignore_access(true);
     $this->entities = array();
     $this->subtypes = array('object' => array(), 'user' => array(), 'group' => array());
     // sites are a bit wonky.  Don't use them just now.
     $this->types = array('object', 'user', 'group');
     // create some fun objects to play with.
     // 5 with random subtypes
     for ($i = 0; $i < 5; $i++) {
         $subtype = 'test_object_subtype_' . rand();
         $e = new ElggObject();
         $e->subtype = $subtype;
         $e->save();
         $this->entities[] = $e;
         $this->subtypes['object'][] = $subtype;
     }
     // and users
     for ($i = 0; $i < 5; $i++) {
         $subtype = "test_user_subtype_" . rand();
         $e = new ElggUser();
         $e->username = "test_user_" . rand();
         $e->subtype = $subtype;
         $e->save();
         $this->entities[] = $e;
         $this->subtypes['user'][] = $subtype;
     }
     // and groups
     for ($i = 0; $i < 5; $i++) {
         $subtype = "test_group_subtype_" . rand();
         $e = new ElggGroup();
         $e->subtype = $subtype;
         $e->save();
         $this->entities[] = $e;
         $this->subtypes['group'][] = $subtype;
     }
     parent::__construct();
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:41,代码来源:ElggCoreGetEntitiesBaseTest.php


示例19: publication_login_check

/**
 * Updates author's list when an invited author registers
 *
 * @param string $event
 * @param string $object_type
 * @param ElggUser $object
 */
function publication_login_check($event, $object_type, $object)
{
    if (empty($object->firstpublication) || empty($object->exauthor_name)) {
        return;
    }
    $exauthor_name = $object->exauthor_name;
    $pub = get_entity($object->firstpublication);
    if (empty($pub) || !$pub instanceof Publication) {
        return;
    }
    add_entity_relationship($pub->getGUID(), 'author', $object->getGUID());
    unset($object->firstpubication);
    unset($object->exauthor_name);
    $authors = $pub->authors;
    $authors = explode(',', $authors);
    foreach ($authors as $key => $value) {
        if ($value == $exauthor_name) {
            $authors[$key] = $object->getGUID();
        }
    }
    $authors = implode(',', $authors);
    $pub->authors = $authors;
}
开发者ID:Beaufort8,项目名称:elgg-publication,代码行数:30,代码来源:events.php


示例20: testElggRiverDisableEnable

 public function testElggRiverDisableEnable()
 {
     $user = new \ElggUser();
     $user->save();
     $entity = new \ElggObject();
     $entity->save();
     $params = array('view' => 'river/relationship/friend/create', 'action_type' => 'create', 'subject_guid' => $user->guid, 'object_guid' => $entity->guid);
     $id = elgg_create_river_item($params);
     $river = elgg_get_river(array('ids' => array($id)));
     $this->assertIdentical($river[0]->enabled, 'yes');
     $user->disable();
     // should no longer be able to get the river
     $river = elgg_get_river(array('ids' => array($id)));
     $this->assertIdentical($river, array());
     // renabling the user should re-enable the river
     access_show_hidden_entities(true);
     $user->enable();
     access_show_hidden_entities(false);
     $river = elgg_get_river(array('ids' => array($id)));
     $this->assertIdentical($river[0]->enabled, 'yes');
     $user->delete();
     $entity->delete();
 }
开发者ID:ibou77,项目名称:elgg,代码行数:23,代码来源:ElggCoreRiverAPITest.php



注:本文中的ElggUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Elite_Vaf_Helper_Data类代码示例发布时间:2022-05-23
下一篇:
PHP ElggObject类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap