public $uri; // varchar(255) unique_key
public $mainpage; // varchar(255)
public $join_policy; // tinyint
+ public $force_scope; // tinyint
/* Static get */
- function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); }
+ function staticGet($k,$v=NULL) {
+ return Memcached_DataObject::staticGet('User_group',$k,$v);
+ }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function getNotices($offset, $limit, $since_id=null, $max_id=null)
{
- $stream = new NoticeStream(array($this, '_streamDirect'),
- array(),
- 'user_group:notice_ids:' . $this->id);
+ $stream = new GroupNoticeStream($this);
return $stream->getNotices($offset, $limit, $since_id, $max_id);
}
- function _streamDirect($offset, $limit, $since_id, $max_id)
- {
- $inbox = new Group_inbox();
-
- $inbox->group_id = $this->id;
-
- $inbox->selectAdd();
- $inbox->selectAdd('notice_id');
-
- Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
- Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
-
- $inbox->orderBy('created DESC, notice_id DESC');
-
- if (!is_null($offset)) {
- $inbox->limit($offset, $limit);
- }
-
- $ids = array();
-
- if ($inbox->find()) {
- while ($inbox->fetch()) {
- $ids[] = $inbox->notice_id;
- }
- }
-
- return $ids;
- }
function allowedNickname($nickname)
{
$group->uri = $uri;
$group->mainpage = $mainpage;
$group->created = common_sql_now();
+
if (isset($fields['join_policy'])) {
$group->join_policy = intval($fields['join_policy']);
} else {
$group->join_policy = 0;
}
+ if (isset($fields['force_scope'])) {
+ $group->force_scope = intval($fields['force_scope']);
+ } else {
+ $group->force_scope = 0;
+ }
+
if (Event::handle('StartGroupSave', array(&$group))) {
$result = $group->insert();
throw new ServerException(_('Could not set group membership.'));
}
+ self::blow('profile:groups:%d', $userid);
+
if ($local) {
$local_group = new Local_group();
}
parent::delete();
}
+
+ function isPrivate()
+ {
+ return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
+ $this->force_scope == 1);
+ }
}