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


PHP Group_member::pkeyGet方法代码示例

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


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

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

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

示例3: 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:microcosmx,项目名称:experiments,代码行数:30,代码来源:atompubshowmembership.php

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

示例5: onEndJoinGroup

 function onEndJoinGroup($group, $profile)
 {
     // Only do this if config is enabled
     if (!$this->JoinGroup) {
         return true;
     }
     if (!$profile->isLocal()) {
         return true;
     }
     // TRANS: Text for "joined group" item in activity plugin.
     // TRANS: %1$s is a profile URL, %2$s is a profile name,
     // TRANS: %3$s is a group URL, %4$s is a group name.
     $rendered = sprintf(_m('<a href="%1$s">%2$s</a> joined the group <a href="%3$s">%4$s</a>.'), $profile->getUrl(), $profile->getBestName(), $group->homeUrl(), $group->getBestName());
     // TRANS: Text for "joined group" item in activity plugin.
     // TRANS: %1$s is a profile name, %2$s is a profile URL,
     // TRANS: %3$s is a group name, %4$s is a group URL.
     $content = sprintf(_m('%1$s (%2$s) joined the group %3$s (%4$s).'), $profile->getBestName(), $profile->getUrl(), $group->getBestName(), $group->homeUrl());
     $mem = Group_member::pkeyGet(array('group_id' => $group->id, 'profile_id' => $profile->id));
     $notice = Notice::saveNew($profile->id, $content, ActivityPlugin::SOURCE, array('rendered' => $rendered, 'urls' => array(), 'groups' => array($group->id), 'uri' => $mem->getURI(), 'verb' => ActivityVerb::JOIN, 'object_type' => ActivityObject::GROUP));
     return true;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:21,代码来源:ActivityPlugin.php

示例6: makeAdmin

 /**
  * Make user an admin
  *
  * @return void
  */
 function makeAdmin()
 {
     $member = Group_member::pkeyGet(array('group_id' => $this->group->id, 'profile_id' => $this->profile->id));
     if (empty($member)) {
         $this->serverError(_('Can\'t get membership record for %s in group %s'), $this->profile->getBestName(), $this->group->getBestName());
     }
     $orig = clone $member;
     $member->is_admin = 1;
     $result = $member->update($orig);
     if (!$result) {
         common_log_db_error($member, 'UPDATE', __FILE__);
         $this->serverError(_('Can\'t make %s an admin for group %s'), $this->profile->getBestName(), $this->group->getBestName());
     }
     foreach ($this->args as $k => $v) {
         if ($k == 'returnto-action') {
             $action = $v;
         } else {
             if (substr($k, 0, 9) == 'returnto-') {
                 $args[substr($k, 9)] = $v;
             }
         }
     }
     if ($action) {
         common_redirect(common_local_url($action, $args), 303);
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:33,代码来源:makeadmin.php

示例7: makeAdmin

 /**
  * Make user an admin
  *
  * @return void
  */
 function makeAdmin()
 {
     $member = Group_member::pkeyGet(array('group_id' => $this->group->id, 'profile_id' => $this->profile->id));
     if (empty($member)) {
         // TRANS: Server error displayed when trying to make another user admin on the Make Admin page fails
         // TRANS: because the group membership record could not be gotten.
         // TRANS: %1$s is the to be admin user, %2$s is the group user should be admin for.
         $this->serverError(_('Can\'t get membership record for %1$s in group %2$s.'), $this->profile->getBestName(), $this->group->getBestName());
     }
     $orig = clone $member;
     $member->is_admin = 1;
     $result = $member->update($orig);
     if (!$result) {
         common_log_db_error($member, 'UPDATE', __FILE__);
         // TRANS: Server error displayed when trying to make another user admin on the Make Admin page fails
         // TRANS: because the group adminship record coud not be saved properly.
         // TRANS: %1$s is the to be admin user, %2$s is the group user is already admin for.
         $this->serverError(_('Can\'t make %1$s an admin for group %2$s.'), $this->profile->getBestName(), $this->group->getBestName());
     }
     $this->returnToPrevious();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:26,代码来源:makeadmin.php

示例8: isAdmin

 function isAdmin(User_group $group)
 {
     $gm = Group_member::pkeyGet(array('profile_id' => $this->id, 'group_id' => $group->id));
     return !empty($gm) && $gm->is_admin;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:5,代码来源:Profile.php

示例9: get_option_value

$nickname = get_option_value('n', 'nickname');
$groupname = get_option_value('g', 'group');
if (empty($nickname) || empty($groupname)) {
    print "Must provide a nickname and group.\n";
    exit(1);
}
try {
    $user = User::getKV('nickname', $nickname);
    if (empty($user)) {
        throw new Exception("No user named '{$nickname}'.");
    }
    $group = User_group::getKV('nickname', $groupname);
    if (empty($group)) {
        throw new Exception("No group named '{$groupname}'.");
    }
    $member = Group_member::pkeyGet(array('group_id' => $group->id, 'profile_id' => $user->id));
    if (empty($member)) {
        $member = new Group_member();
        $member->group_id = $group->id;
        $member->profile_id = $user->id;
        $member->created = common_sql_now();
        if (!$member->insert()) {
            throw new Exception("Can't add '{$nickname}' to '{$groupname}'.");
        }
    }
    if ($member->is_admin) {
        throw new Exception("'{$nickname}' is already an admin of '{$groupname}'.");
    }
    $orig = clone $member;
    $member->is_admin = 1;
    if (!$member->update($orig)) {
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:31,代码来源:makegroupadmin.php


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