当前位置: 首页>>代码示例>>PHP>>正文


PHP Group_member::find方法代码示例

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


在下文中一共展示了Group_member::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: blockProfile

 static function blockProfile($group, $profile, $blocker)
 {
     // Insert the block
     $block = new Group_block();
     $block->query('BEGIN');
     $block->group_id = $group->id;
     $block->blocked = $profile->id;
     $block->blocker = $blocker->id;
     $result = $block->insert();
     if (!$result) {
         common_log_db_error($block, 'INSERT', __FILE__);
         return null;
     }
     // Delete membership if any
     $member = new Group_member();
     $member->group_id = $group->id;
     $member->profile_id = $profile->id;
     if ($member->find(true)) {
         $result = $member->delete();
         if (!$result) {
             common_log_db_error($member, 'DELETE', __FILE__);
             return null;
         }
     }
     // Commit, since both have been done
     $block->query('COMMIT');
     return $block;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:28,代码来源:Group_block.php

示例2: byMember

 /**
  * Get stream of memberships by member
  *
  * @param integer $memberId profile ID of the member to fetch for
  * @param integer $offset   offset from start of stream to get
  * @param integer $limit    number of memberships to get
  *
  * @return Group_member stream of memberships, use fetch() to iterate
  */
 static function byMember($memberId, $offset = 0, $limit = GROUPS_PER_PAGE)
 {
     $membership = new Group_member();
     $membership->profile_id = $memberId;
     $membership->orderBy('created DESC');
     $membership->limit($offset, $limit);
     $membership->find();
     return $membership;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:18,代码来源:Group_member.php

示例3: getGroups

 function getGroups()
 {
     $groups = array();
     $gm = new Group_member();
     $gm->profile_id = $this->user->id;
     if (!empty($this->after)) {
         $gm->whereAdd("created > '" . common_sql_date($this->after) . "'");
     }
     if ($gm->find()) {
         while ($gm->fetch()) {
             $groups[] = clone $gm;
         }
     }
     return $groups;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:15,代码来源:useractivitystream.php

示例4: _getNthMem

 /**
  * Get the Nth most recent group membership for this user
  *
  * @param User    $user The user to get memberships for
  * @param integer $n    How far to count back
  *
  * @return Group_member a membership or null
  */
 private function _getNthMem($user, $n)
 {
     $mem = new Group_member();
     $mem->profile_id = $user->id;
     $mem->orderBy('created DESC');
     $mem->limit($n - 1, 1);
     if ($mem->find(true)) {
         return $mem;
     } else {
         return null;
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:20,代码来源:SubscriptionThrottlePlugin.php

示例5: isAdmin

 function isAdmin($group)
 {
     $mem = new Group_member();
     $mem->group_id = $group->id;
     $mem->profile_id = $this->id;
     $mem->is_admin = 1;
     if ($mem->find()) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:12,代码来源:Profile.php

示例6: handle

 /**
  * Handle the request
  *
  * Save the new message
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (empty($this->user)) {
         $this->clientError(_('No such user.'), 404, $this->format);
         return;
     }
     if (empty($this->group)) {
         $this->clientError(_('Group not found.'), 404, $this->format);
         return false;
     }
     $member = new Group_member();
     $member->group_id = $this->group->id;
     $member->profile_id = $this->auth_user->id;
     if (!$member->find(true)) {
         $this->serverError(_('You are not a member of this group.'));
         return;
     }
     $result = $member->delete();
     if (!$result) {
         common_log_db_error($member, 'DELETE', __FILE__);
         $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $this->user->nickname, $this->group->nickname));
         return;
     }
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);
             break;
         case 'json':
             $this->showSingleJsonGroup($this->group);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:49,代码来源:apigroupleave.php

示例7: initGroupMemberURI

function initGroupMemberURI()
{
    printfnq("Ensuring all group memberships have a URI...");
    $mem = new Group_member();
    $mem->whereAdd('uri IS NULL');
    if ($mem->find()) {
        while ($mem->fetch()) {
            try {
                $mem->decache();
                $mem->query(sprintf('update group_member set uri = "%s" ' . 'where profile_id = %d ' . 'and group_id = %d ', Group_member::newURI($mem->profile_id, $mem->group_id, $mem->created), $mem->profile_id, $mem->group_id));
            } catch (Exception $e) {
                common_log(LOG_ERR, "Error updated membership URI: " . $e->getMessage());
            }
        }
    }
    printfnq("DONE.\n");
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:17,代码来源:upgrade.php

示例8: getGroups

 function getGroups($offset = 0, $limit = PROFILES_PER_PAGE)
 {
     $ids = array();
     $keypart = sprintf('profile:groups:%d', $this->id);
     $idstring = self::cacheGet($keypart);
     if ($idstring !== false) {
         $ids = explode(',', $idstring);
     } else {
         $gm = new Group_member();
         $gm->profile_id = $this->id;
         if ($gm->find()) {
             while ($gm->fetch()) {
                 $ids[] = $gm->group_id;
             }
         }
         self::cacheSet($keypart, implode(',', $ids));
     }
     if (!is_null($offset) && !is_null($limit)) {
         $ids = array_slice($ids, $offset, $limit);
     }
     try {
         return User_group::multiGet('id', $ids);
     } catch (NoResultException $e) {
         return null;
         // throw exception when we handle it everywhere
     }
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:27,代码来源:Profile.php

示例9: handle

 /**
  * Handle the request
  *
  * Save the new message
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (!$this->scoped instanceof Profile) {
         // TRANS: Client error displayed when trying to have a non-existing user leave a group.
         $this->clientError(_('No such user.'), 404);
     }
     if (!$this->group instanceof User_group) {
         // TRANS: Client error displayed when trying to leave a group that does not exist.
         $this->clientError(_('Group not found.'), 404);
     }
     $member = new Group_member();
     $member->group_id = $this->group->id;
     $member->profile_id = $this->scoped->id;
     if (!$member->find(true)) {
         // TRANS: Server error displayed when trying to leave a group the user is not a member of.
         $this->serverError(_('You are not a member of this group.'));
     }
     try {
         $this->user->leaveGroup($this->group);
     } catch (Exception $e) {
         // TRANS: Server error displayed when leaving a group failed in the database.
         // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
         $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $this->scoped->getNickname(), $this->group->nickname));
     }
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);
             break;
         case 'json':
             $this->showSingleJsonGroup($this->group);
             break;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), 404);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:44,代码来源:apigroupleave.php

示例10: handle

 /**
  * Handle the request
  *
  * Save the new message
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (empty($this->user)) {
         // TRANS: Client error displayed when trying to have a non-existing user leave a group.
         $this->clientError(_('No such user.'), 404, $this->format);
         return;
     }
     if (empty($this->group)) {
         // TRANS: Client error displayed when trying to leave a group that does not exist.
         $this->clientError(_('Group not found.'), 404, $this->format);
         return false;
     }
     $member = new Group_member();
     $member->group_id = $this->group->id;
     $member->profile_id = $this->auth_user->id;
     if (!$member->find(true)) {
         // TRANS: Server error displayed when trying to leave a group the user is not a member of.
         $this->serverError(_('You are not a member of this group.'));
         return;
     }
     try {
         $this->user->leaveGroup($this->group);
     } catch (Exception $e) {
         // TRANS: Server error displayed when leaving a group failed in the database.
         // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
         $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $cur->nickname, $this->group->nickname));
         return;
     }
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);
             break;
         case 'json':
             $this->showSingleJsonGroup($this->group);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:54,代码来源:apigroupleave.php

示例11: handle

 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @param array $args unused
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $cur = common_current_user();
     $member = new Group_member();
     $member->group_id = $this->group->id;
     $member->profile_id = $cur->id;
     if (!$member->find(true)) {
         $this->serverError(_('Could not find membership record.'));
         return;
     }
     $result = $member->delete();
     if (!$result) {
         common_log_db_error($member, 'INSERT', __FILE__);
         $this->serverError(sprintf(_('Could not remove user %s to group %s'), $cur->nickname, $this->group->nickname));
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         $this->element('title', null, sprintf(_('%s left group %s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $jf = new JoinForm($this, $this->group);
         $jf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)));
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:39,代码来源:leavegroup.php

示例12: getGroups

 function getGroups($offset = 0, $limit = PROFILES_PER_PAGE)
 {
     $ids = array();
     $keypart = sprintf('profile:groups:%d', $this->id);
     $idstring = self::cacheGet($keypart);
     if ($idstring !== false) {
         $ids = explode(',', $idstring);
     } else {
         $gm = new Group_member();
         $gm->profile_id = $this->id;
         //harrie
         //$gm->is_admin = '1';
         //echo '<pre>';
         //var_dump($gm);
         //exit('111');
         if ($gm->find()) {
             while ($gm->fetch()) {
                 $ids[] = $gm->group_id;
             }
         }
         self::cacheSet($keypart, implode(',', $ids));
     }
     $groups = array();
     foreach ($ids as $id) {
         $group = User_group::staticGet('id', $id);
         if (!empty($group)) {
             $groups[] = $group;
         }
     }
     return new ArrayWrapper($groups);
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:31,代码来源:Profile.php

示例13: getGroups

 function getGroups()
 {
     $groups = array();
     $gm = new Group_member();
     $gm->profile_id = $this->user->id;
     if ($gm->find()) {
         while ($gm->fetch()) {
             $groups[] = clone $gm;
         }
     }
     return $groups;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:12,代码来源:useractivitystream.php

示例14: getMemberIDs

 function getMemberIDs($offset = 0, $limit = null)
 {
     $gm = new Group_member();
     $gm->selectAdd();
     $gm->selectAdd('profile_id');
     $gm->group_id = $this->id;
     $gm->orderBy('created DESC');
     if (!is_null($limit)) {
         $gm->limit($offset, $limit);
     }
     $ids = array();
     if ($gm->find()) {
         while ($gm->fetch()) {
             $ids[] = $gm->profile_id;
         }
     }
     return $ids;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:18,代码来源:User_group.php

示例15: blowGroupCache

 function blowGroupCache($blowLast = false)
 {
     $cache = common_memcache();
     if ($cache) {
         $group_inbox = new Group_inbox();
         $group_inbox->notice_id = $this->id;
         if ($group_inbox->find()) {
             while ($group_inbox->fetch()) {
                 $cache->delete(common_cache_key('group:notices:' . $group_inbox->group_id));
                 if ($blowLast) {
                     $cache->delete(common_cache_key('group:notices:' . $group_inbox->group_id . ';last'));
                 }
                 $member = new Group_member();
                 $member->group_id = $group_inbox->group_id;
                 if ($member->find()) {
                     while ($member->fetch()) {
                         $cache->delete(common_cache_key('user:notices_with_friends:' . $member->profile_id));
                         if ($blowLast) {
                             $cache->delete(common_cache_key('user:notices_with_friends:' . $member->profile_id . ';last'));
                         }
                     }
                 }
             }
         }
         $group_inbox->free();
         unset($group_inbox);
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:28,代码来源:Notice.php


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