/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+ public function getObjectType()
+ {
+ return ActivityObject::GROUP;
+ }
+
+
public static function schemaDef()
{
return array(
{
if (!isset($this->_profile[$this->profile_id])) {
$profile = Profile::getKV('id', $this->profile_id);
+
if (!$profile instanceof Profile) {
- throw new GroupNoProfileException($this);
+
+ $profile = new Profile();
+ $profile->nickname = $this->nickname;
+ $profile->fullname = $this->fullname;
+ $profile->profileurl = $this->mainpage;
+ $profile->homepage = $this->homepage;
+ $profile->bio = $this->description;
+ $profile->location = $this->location;
+ $profile->created = common_sql_now();
+ $this->profile_id = $profile->insert();
+
+ //throw new GroupNoProfileException($this);
}
+
$this->_profile[$this->profile_id] = $profile;
}
return $this->_profile[$this->profile_id];
*/
function getRequests($offset=0, $limit=null)
{
- $qry =
- 'SELECT profile.* ' .
- 'FROM profile JOIN group_join_queue '.
- 'ON profile.id = group_join_queue.profile_id ' .
- 'WHERE group_join_queue.group_id = %d ' .
- 'ORDER BY group_join_queue.created DESC ';
+ $rq = new Group_join_queue();
+ $rq->group_id = $this->id;
+
+ $members = new Profile();
+
+ $members->joinAdd(['id', $rq, 'profile_id']);
if ($limit != null) {
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $members->limit($offset, $limit);
}
- $members = new Profile();
+ $members->find();
- $members->query(sprintf($qry, $this->id));
return $members;
}
function setOriginal($filename)
{
- $imagefile = new ImageFile($this->id, Avatar::path($filename));
+ // This should be handled by the Profile->setOriginal function so user and group avatars are handled the same
+ $imagefile = new ImageFile(null, Avatar::path($filename));
+
+ $sizes = array('homepage_logo' => AVATAR_PROFILE_SIZE,
+ 'stream_logo' => AVATAR_STREAM_SIZE,
+ 'mini_logo' => AVATAR_MINI_SIZE);
$orig = clone($this);
$this->original_logo = Avatar::url($filename);
- $this->homepage_logo = Avatar::url($imagefile->resize(AVATAR_PROFILE_SIZE));
- $this->stream_logo = Avatar::url($imagefile->resize(AVATAR_STREAM_SIZE));
- $this->mini_logo = Avatar::url($imagefile->resize(AVATAR_MINI_SIZE));
+ foreach ($sizes as $name=>$size) {
+ $filename = Avatar::filename($this->profile_id, image_type_to_extension($imagefile->preferredType()),
+ $size, common_timestamp());
+ $imagefile->resizeTo(Avatar::path($filename), array('width'=>$size, 'height'=>$size));
+ $this->$name = Avatar::url($filename);
+ }
common_debug(common_log_objstring($this));
return $this->update($orig);
}
function isPrivate()
{
return ($this->join_policy == self::JOIN_POLICY_MODERATE &&
- $this->force_scope == 1);
+ intval($this->force_scope) === 1);
}
public function isLocal()