+ public function getObjectType()
+ {
+ return ActivityObject::GROUP;
+ }
+
+
+ public static function schemaDef()
+ {
+ return array(
+ 'fields' => array(
+ 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
+ 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
+
+ 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'),
+ 'fullname' => array('type' => 'varchar', 'length' => 191, 'description' => 'display name'),
+ 'homepage' => array('type' => 'varchar', 'length' => 191, 'description' => 'URL, cached so we dont regenerate'),
+ 'description' => array('type' => 'text', 'description' => 'group description'),
+ 'location' => array('type' => 'varchar', 'length' => 191, 'description' => 'related physical location, if any'),
+
+ 'original_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'original size logo'),
+ 'homepage_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'homepage (profile) size logo'),
+ 'stream_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'),
+ 'mini_logo' => array('type' => 'varchar', 'length' => 191, 'description' => 'mini logo'),
+
+ 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
+ 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
+
+ 'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'),
+ 'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page for group info to link to'),
+ 'join_policy' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=open; 1=requires admin approval'),
+ 'force_scope' => array('type' => 'int', 'size' => 'tiny', 'description' => '0=never,1=sometimes,-1=always'),
+ ),
+ 'primary key' => array('id'),
+ 'unique keys' => array(
+ 'user_group_uri_key' => array('uri'),
+// when it's safe and everyone's run upgrade.php 'user_profile_id_key' => array('profile_id'),
+ ),
+ 'foreign keys' => array(
+ 'user_group_id_fkey' => array('profile', array('profile_id' => 'id')),
+ ),
+ 'indexes' => array(
+ 'user_group_nickname_idx' => array('nickname'),
+ 'user_group_profile_id_idx' => array('profile_id'), //make this unique in future
+ ),
+ );
+ }
+
+ protected $_profile = array();
+
+ /**
+ * @return Profile
+ *
+ * @throws GroupNoProfileException if user has no profile
+ */
+ public function getProfile()
+ {
+ if (!isset($this->_profile[$this->profile_id])) {
+ $profile = Profile::getKV('id', $this->profile_id);
+ if (!$profile instanceof Profile) {
+ throw new GroupNoProfileException($this);
+ }
+ $this->_profile[$this->profile_id] = $profile;
+ }
+ return $this->_profile[$this->profile_id];
+ }
+
+ public function getNickname()
+ {
+ return $this->getProfile()->getNickname();
+ }
+
+ public static function defaultLogo($size)