本文整理汇总了PHP中User_group::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP User_group::getByID方法的具体用法?PHP User_group::getByID怎么用?PHP User_group::getByID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User_group
的用法示例。
在下文中一共展示了User_group::getByID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: join
/**
* Method to add a user to a group.
* In most cases, you should call Profile->joinGroup() instead.
*
* @param integer $group_id Group to add to
* @param integer $profile_id Profile being added
*
* @return Group_member new membership object
*/
static function join($group_id, $profile_id)
{
$member = new Group_member();
$member->group_id = $group_id;
$member->profile_id = $profile_id;
$member->created = common_sql_now();
$member->uri = self::newUri(Profile::getByID($profile_id), User_group::getByID($group_id), $member->created);
$result = $member->insert();
if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__);
// TRANS: Exception thrown when joining a group fails.
throw new Exception(_("Group join failed."));
}
return $member;
}
示例2: figureOutScope
public static function figureOutScope(Profile $actor, array $groups, $scope = null)
{
$scope = is_null($scope) ? self::defaultScope() : intval($scope);
// For private streams
try {
$user = $actor->getUser();
// FIXME: We can't do bit comparison with == (Legacy StatusNet thing. Let's keep it for now.)
if ($user->private_stream && ($scope === Notice::PUBLIC_SCOPE || $scope === Notice::SITE_SCOPE)) {
$scope |= Notice::FOLLOWER_SCOPE;
}
} catch (NoSuchUserException $e) {
// TODO: Not a local user, so we don't know about scope preferences... yet!
}
// Force the scope for private groups
foreach ($groups as $group_id) {
try {
$group = User_group::getByID($group_id);
if ($group->force_scope) {
$scope |= Notice::GROUP_SCOPE;
break;
}
} catch (Exception $e) {
common_log(LOG_ERR, 'Notice figureOutScope threw exception: ' . $e->getMessage());
}
}
return $scope;
}
示例3: 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(Profile::getByID($mem->profile_id), User_group::getByID($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");
}
示例4: doPreparation
protected function doPreparation()
{
$this->group = User_group::getByID($this->arg('id'));
}