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

PHP Group_member类代码示例

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

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



在下文中一共展示了Group_member类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: leave

 static function leave($group_id, $profile_id)
 {
     $member = Group_member::pkeyGet(array('group_id' => $group_id, 'profile_id' => $profile_id));
     if (empty($member)) {
         throw new Exception(_("Not part of group."));
     }
     $result = $member->delete();
     if (!$result) {
         common_log_db_error($member, 'INSERT', __FILE__);
         throw new Exception(_("Group leave failed."));
     }
     return true;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:13,代码来源:Group_member.php


示例3: complete

 /**
  * Complete a pending group join...
  *
  * @return Group_member object on success
  */
 function complete()
 {
     $join = null;
     $profile = $this->getMember();
     $group = $this->getGroup();
     if (Event::handle('StartJoinGroup', array($profile, $group))) {
         $join = Group_member::join($group->id, $profile->id);
         $this->delete();
         Event::handle('EndJoinGroup', array($profile, $group));
     }
     if (!$join) {
         throw new Exception('Internal error: group join failed.');
     }
     $join->notify();
     return $join;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:21,代码来源:Group_join_queue.php


示例4: showContent

 function showContent()
 {
     $notice = $this->nli->notice;
     $out = $this->nli->out;
     $mem = Group_member::getKV('uri', $notice->uri);
     if (!empty($mem)) {
         $out->elementStart('div', 'join-activity');
         $profile = $mem->getMember();
         $group = $mem->getGroup();
         // TRANS: Text for "joined list" item in activity plugin.
         // TRANS: %1$s is a profile URL, %2$s is a profile name,
         // TRANS: %3$s is a group home URL, %4$s is a group name.
         $out->raw(sprintf(_m('<a href="%1$s">%2$s</a> joined the group <a href="%3$s">%4$s</a>.'), $profile->profileurl, $profile->getBestName(), $group->homeUrl(), $group->getBestName()));
         $out->elementEnd('div');
     } else {
         parent::showContent();
     }
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:18,代码来源:joinlistitem.php


示例5: onEndUserRegister

 function onEndUserRegister($profile, $user)
 {
     $profile = $user->getProfile();
     foreach ($this->join as $nickname) {
         $group = User_group::getForNickname($nickname);
         if ($group && !$profile->isMember($group)) {
             try {
                 if (Event::handle('StartJoinGroup', array($group, $user))) {
                     Group_member::join($group->id, $user->id);
                     Event::handle('EndJoinGroup', array($group, $user));
                 }
             } catch (Exception $e) {
                 // TRANS: Server exception.
                 // TRANS: %1$s is a user nickname, %2$s is a group nickname.
                 throw new ServerException(sprintf(_m('Could not join user %1$s to group %2$s.'), $user->nickname, $group->nickname));
             }
         }
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:19,代码来源:ForceGroupPlugin.php


示例6: atompubPrepare

 protected function atompubPrepare()
 {
     $this->_profile = Profile::getKV('id', $this->trimmed('profile'));
     if (!$this->_profile instanceof Profile) {
         // TRANS: Client exception.
         throw new ClientException(_('No such profile.'), 404);
     }
     $this->_group = User_group::getKV('id', $this->trimmed('group'));
     if (!$this->_group instanceof User_group) {
         // TRANS: Client exception thrown when referencing a non-existing group.
         throw new ClientException(_('No such group.'), 404);
     }
     $kv = array('group_id' => $groupId, 'profile_id' => $this->_profile->id);
     $this->_membership = Group_member::pkeyGet($kv);
     if (!$this->_membership instanceof Group_member) {
         // TRANS: Client exception thrown when trying to show membership of a non-subscribed group
         throw new ClientException(_('Not a member.'), 404);
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:20,代码来源:atompubshowmembership.php


示例7: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $profileId = $this->trimmed('profile');
     $this->_profile = Profile::staticGet('id', $profileId);
     if (empty($this->_profile)) {
         // TRANS: Client exception.
         throw new ClientException(_('No such profile.'), 404);
     }
     $groupId = $this->trimmed('group');
     $this->_group = User_group::staticGet('id', $groupId);
     if (empty($this->_group)) {
         // TRANS: Client exception thrown when referencing a non-existing group.
         throw new ClientException(_('No such group.'), 404);
     }
     $kv = array('group_id' => $groupId, 'profile_id' => $profileId);
     $this->_membership = Group_member::pkeyGet($kv);
     if (empty($this->_membership)) {
         // TRANS: Client exception thrown when trying to show membership of a non-subscribed group
         throw new ClientException(_('Not a member.'), 404);
     }
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:30,代码来源:atompubshowmembership.php


示例8: 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


示例9: moveActivity

 function moveActivity($act, $sink, $user, $remote)
 {
     if (empty($user)) {
         throw new Exception(sprintf(_("No such user %s."), $act->actor->id));
     }
     switch ($act->verb) {
         case ActivityVerb::FAVORITE:
             $this->log(LOG_INFO, "Moving favorite of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             // push it, then delete local
             $sink->postActivity($act);
             $notice = Notice::staticGet('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $fave = Fave::pkeyGet(array('user_id' => $user->id, 'notice_id' => $notice->id));
                 $fave->delete();
             }
             break;
         case ActivityVerb::POST:
             $this->log(LOG_INFO, "Moving notice {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             // XXX: send a reshare, not a post
             $sink->postActivity($act);
             $notice = Notice::staticGet('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $notice->delete();
             }
             break;
         case ActivityVerb::JOIN:
             $this->log(LOG_INFO, "Moving group join of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
             $sink->postActivity($act);
             $group = User_group::staticGet('uri', $act->objects[0]->id);
             if (!empty($group)) {
                 Group_member::leave($group->id, $user->id);
             }
             break;
         case ActivityVerb::FOLLOW:
             if ($act->actor->id == $user->uri) {
                 $this->log(LOG_INFO, "Moving subscription to {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
                 $sink->postActivity($act);
                 $other = Profile::fromURI($act->objects[0]->id);
                 if (!empty($other)) {
                     Subscription::cancel($user->getProfile(), $other);
                 }
             } else {
                 $otherUser = User::staticGet('uri', $act->actor->id);
                 if (!empty($otherUser)) {
                     $this->log(LOG_INFO, "Changing sub to {$act->objects[0]->id}" . "by {$act->actor->id} to {$remote->nickname}.");
                     $otherProfile = $otherUser->getProfile();
                     Subscription::start($otherProfile, $remote);
                     Subscription::cancel($otherProfile, $user->getProfile());
                 } else {
                     $this->log(LOG_NOTICE, "Not changing sub to {$act->objects[0]->id}" . "by remote {$act->actor->id} " . "to {$remote->nickname}.");
                 }
             }
             break;
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:55,代码来源:activitymover.php


示例10: 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();
     try {
         if (Event::handle('StartJoinGroup', array($this->group, $cur))) {
             Group_member::join($this->group->id, $cur->id);
             Event::handle('EndJoinGroup', array($this->group, $cur));
         }
     } catch (Exception $e) {
         $this->serverError(sprintf(_('Could not join user %1$s to group %2$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(_('%1$s joined group %2$s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $lf = new LeaveForm($this, $this->group);
         $lf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:35,代码来源:joingroup.php


示例11: deleteMembership

 /**
  * Delete the membership (leave the group)
  *
  * @return void
  */
 function deleteMembership()
 {
     if (empty($this->auth_user) || $this->auth_user->id != $this->_profile->id) {
         // TRANS: Client exception thrown when deleting someone else's membership.
         throw new ClientException(_("Cannot delete someone else's" . " membership."), 403);
     }
     if (Event::handle('StartLeaveGroup', array($this->_group, $this->auth_user))) {
         Group_member::leave($this->_group->id, $this->auth_user->id);
         Event::handle('EndLeaveGroup', array($this->_group, $this->auth_user));
     }
     return;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:17,代码来源:atompubshowmembership.php


示例12: 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


示例13: 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


示例14: onEndNoticeAsActivity

 public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped = null)
 {
     switch ($stored->verb) {
         case ActivityVerb::UNFAVORITE:
             // FIXME: do something here
             break;
         case ActivityVerb::JOIN:
             $mem = Group_member::getKV('uri', $stored->getUri());
             if ($mem instanceof Group_member) {
                 $group = $mem->getGroup();
                 $act->title = $stored->getTitle();
                 $act->objects = array(ActivityObject::fromGroup($group));
             }
             break;
         case ActivityVerb::LEAVE:
             // FIXME: ????
             break;
         case ActivityVerb::FOLLOW:
             $sub = Subscription::getKV('uri', $stored->uri);
             if ($sub instanceof Subscription) {
                 $profile = Profile::getKV('id', $sub->subscribed);
                 if ($profile instanceof Profile) {
                     $act->title = $stored->getTitle();
                     $act->objects = array($profile->asActivityObject());
                 }
             }
             break;
         case ActivityVerb::UNFOLLOW:
             // FIXME: ????
             break;
     }
     return true;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:33,代码来源:ActivityPlugin.php


示例15: _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


示例16: handle

 function handle($channel)
 {
     $group = $this->getGroup($this->other);
     $cur = $this->user;
     if (!$group) {
         // TRANS: Error text shown when trying to leave a group that does not exist.
         $channel->error($cur, _('No such group.'));
         return;
     }
     if (!$cur->isMember($group)) {
         // TRANS: Error text shown when trying to leave an existing group the user is not a member of.
         $channel->error($cur, _('You are not a member of that group.'));
         return;
     }
     try {
         if (Event::handle('StartLeaveGroup', array($group, $cur))) {
             Group_member::leave($group->id, $cur->id);
             Event::handle('EndLeaveGroup', array($group, $cur));
         }
     } catch (Exception $e) {
         // TRANS: Message given having failed to remove a user from a group.
         // TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
         $channel->error($cur, sprintf(_('Could not remove user %1$s from group %2$s.'), $cur->nickname, $group->nickname));
         return;
     }
     // TRANS: Message given having removed a user from a group.
     // TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
     $channel->output($cur, sprintf(_('%1$s left group %2$s.'), $cur->nickname, $group->nickname));
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:29,代码来源:command.php


示例17: addMembership

 /**
  * add a new favorite
  *
  * @return void
  */
 function addMembership()
 {
     // XXX: Refactor this; all the same for atompub
     if (empty($this->auth_user) || $this->auth_user->id != $this->_profile->id) {
         // TRANS: Client exception thrown when trying subscribe someone else to a group.
         throw new ClientException(_("Cannot add someone else's" . " membership."), 403);
     }
     $xml = file_get_contents('php://input');
     $dom = DOMDocument::loadXML($xml);
     if ($dom->documentElement->namespaceURI != Activity::ATOM || $dom->documentElement->localName != 'entry') {
         // TRANS: Client error displayed when not using an Atom entry.
         throw new ClientException(_('Atom post must be an Atom entry.'));
         return;
     }
     $activity = new Activity($dom->documentElement);
     $membership = null;
     if (Event::handle('StartAtomPubNewActivity', array(&$activity))) {
         if ($activity->verb != ActivityVerb::JOIN) {
             // TRANS: Client error displayed when not using the join verb.
             throw new ClientException(_('Can only handle join activities.'));
         }
         $groupObj = $activity->objects[0];
         if ($groupObj->type != ActivityObject::GROUP) {
             // TRANS: Client exception thrown when trying to join something which is not a group
             throw new ClientException(_('Can only join groups.'));
         }
         $group = User_group::getKV('uri', $groupObj->id);
         if (empty($group)) {
             // XXX: import from listed URL or something
             // TRANS: Client exception thrown when trying to subscribe to a non-existing group.
             throw new ClientException(_('Unknown group.'));
         }
         $old = Group_member::pkeyGet(array('profile_id' => $this->auth_user->id, 'group_id' => $group->id));
         if (!empty($old)) {
             // TRANS: Client exception thrown when trying to subscribe to an already subscribed group.
             throw new ClientException(_('Already a member.'));
         }
         $profile = $this->auth_user->getProfile();
         if (Group_block::isBlocked($group, $profile)) {
             // XXX: import from listed URL or something
             // TRANS: Client exception thrown when trying to subscribe to group while blocked from that group.
             throw new ClientException(_('Blocked by admin.'));
         }
         $this->auth_user->joinGroup($group);
         Event::handle('EndAtomPubNewActivity', array($activity, $membership));
     }
     if (!empty($membership)) {
         $act = $membership->asActivity();
         header('Content-Type: application/atom+xml; charset=utf-8');
         header('Content-Location: ' . $act->selfLink);
         $this->startXML();
         $this->raw($act->asString(true, true, true));
         $this->endXML();
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:60,代码来源:atompubmembershipfeed.php


示例18: 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();
     try {
         if (Event::handle('StartJoinGroup', array($this->group, $cur))) {
             Group_member::join($this->group->id, $cur->id);
             Event::handle('EndJoinGroup', array($this->group, $cur));
         }
     } catch (Exception $e) {
         // TRANS: Server error displayed when joining a group failed in the database.
         // TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
         $this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'), $cur->nickname, $this->group->nickname));
         return;
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for join group page after joining.
         $this->element('title', null, sprintf(_m('TITLE', '%1$s joined group %2$s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $lf = new LeaveForm($this, $this->group);
         $lf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:39,代码来源:joingroup.php


示例19: joinGroup

 function joinGroup($user, $activity)
 {
     // XXX: check that actor == subject
     $uri = $activity->objects[0]->id;
     $group = User_group::staticGet('uri', $uri);
     if (empty($group)) {
         $oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]);
         if (!$oprofile->isGroup()) {
             // TRANS: Client exception thrown when trying to join a remote group that is not a group.
             throw new ClientException(_("Remote profile is not a group!"));
         }
         $group = $oprofile->localGroup();
     }
     assert(!empty($group));
     if ($user->isMember($group)) {
         // TRANS: Client exception thrown when trying to join a group the importing user is already a member of.
         throw new ClientException(_("User is already a member of this group."));
     }
     if (Event::handle('StartJoinGroup', array($group, $user))) {
         Group_member::join($group->id, $user->id);
         Event::handle('EndJoinGroup', array($group, $user));
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:23,代码来源:activityimporter.php


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Groups类代码示例发布时间:2022-05-23
下一篇:
PHP Group_User类代码示例发布时间: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