Пример #1
0
 static function getSubQueue(Profile $subscriber, Profile $other)
 {
     // This is essentially a pkeyGet but we have an object to return in NoResultException
     $sub = new Subscription_queue();
     $sub->subscriber = $subscriber->id;
     $sub->subscribed = $other->id;
     if (!$sub->find(true)) {
         throw new NoResultException($sub);
     }
     return $sub;
 }
 protected function doPost()
 {
     try {
         $request = Subscription_queue::pkeyGet(array('subscriber' => $this->scoped->id, 'subscribed' => $this->target->id));
         if ($request instanceof Subscription_queue) {
             $request->abort();
         }
     } catch (AlreadyFulfilledException $e) {
         common_debug('Tried to cancel a non-existing pending subscription');
     }
     if (GNUsocial::isAjax()) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title after unsubscribing from a group.
         $this->element('title', null, _m('TITLE', 'Unsubscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $subscribe = new SubscribeForm($this, $this->target);
         $subscribe->show();
         $this->elementEnd('body');
         $this->endHTML();
         exit;
     }
     common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->getNickname())), 303);
 }
Пример #3
0
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     $cur = common_current_user();
     if (empty($cur)) {
         // TRANS: Client error displayed trying to approve group membership while not logged in.
         $this->clientError(_('Must be logged in.'), 403);
         return false;
     }
     if ($this->arg('profile_id')) {
         $this->profile = Profile::staticGet('id', $this->arg('profile_id'));
     } else {
         // TRANS: Client error displayed trying to approve subscriptionswithout specifying a profile to approve.
         $this->clientError(_('Must specify a profile.'));
         return false;
     }
     $this->request = Subscription_queue::pkeyGet(array('subscriber' => $this->profile->id, 'subscribed' => $cur->id));
     if (empty($this->request)) {
         // TRANS: Client error displayed trying to approve subscription for a non-existing request.
         // TRANS: %s is a user nickname.
         $this->clientError(sprintf(_('%s is not in the moderation queue for your subscriptions.'), $this->profile->nickname), 403);
     }
     $this->approve = (bool) $this->arg('approve');
     $this->cancel = (bool) $this->arg('cancel');
     if (!$this->approve && !$this->cancel) {
         // TRANS: Client error displayed trying to approve/deny subscription.
         $this->clientError(_('Internal error: received neither cancel nor abort.'));
     }
     if ($this->approve && $this->cancel) {
         // TRANS: Client error displayed trying to approve/deny  subscription
         $this->clientError(_('Internal error: received both cancel and abort.'));
     }
     return true;
 }
Пример #4
0
 function handle($args)
 {
     parent::handle($args);
     if ($this->boolean('ajax')) {
         StatusNet::setApi(true);
     }
     if (!common_logged_in()) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
         return;
     }
     $user = common_current_user();
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
         return;
     }
     /* Use a session token for CSRF protection. */
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
         return;
     }
     $other_id = $this->arg('unsubscribeto');
     if (!$other_id) {
         // TRANS: Client error displayed when trying to leave a group without specifying an ID.
         $this->clientError(_('No profile ID in request.'));
         return;
     }
     $other = Profile::staticGet('id', $other_id);
     if (!$other) {
         // TRANS: Client error displayed when trying to leave a non-existing group.
         $this->clientError(_('No profile with that ID.'));
         return;
     }
     $this->request = Subscription_queue::pkeyGet(array('subscriber' => $user->id, 'subscribed' => $other->id));
     if (empty($this->request)) {
         // TRANS: Client error displayed when trying to approve a non-existing group join request.
         // TRANS: %s is a user nickname.
         $this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403);
     }
     $this->request->abort();
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title after unsubscribing from a group.
         $this->element('title', null, _m('TITLE', 'Unsubscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $subscribe = new SubscribeForm($this, $other);
         $subscribe->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)), 303);
     }
 }
Пример #5
0
 /**
  * Make a new subscription
  *
  * @param Profile $subscriber party to receive new notices
  * @param Profile $other      party sending notices; publisher
  * @param bool    $force      pass Subscription::FORCE to override local subscription approval
  *
  * @return mixed Subscription or Subscription_queue: new subscription info
  */
 static function start(Profile $subscriber, Profile $other, $force = false)
 {
     if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
         // TRANS: Exception thrown when trying to subscribe while being banned from subscribing.
         throw new Exception(_('You have been banned from subscribing.'));
     }
     if (self::exists($subscriber, $other)) {
         // TRANS: Exception thrown when trying to subscribe while already subscribed.
         throw new AlreadyFulfilledException(_('Already subscribed!'));
     }
     if ($other->hasBlocked($subscriber)) {
         // TRANS: Exception thrown when trying to subscribe to a user who has blocked the subscribing user.
         throw new Exception(_('User has blocked you.'));
     }
     if (Event::handle('StartSubscribe', array($subscriber, $other))) {
         // unless subscription is forced, the user policy for subscription approvals is tested
         if (!$force && $other->requiresSubscriptionApproval($subscriber)) {
             try {
                 $sub = Subscription_queue::saveNew($subscriber, $other);
                 $sub->notify();
             } catch (AlreadyFulfilledException $e) {
                 $sub = Subscription_queue::getSubQueue($subscriber, $other);
             }
         } else {
             $otherUser = User::getKV('id', $other->id);
             $sub = self::saveNew($subscriber, $other);
             $sub->notify();
             self::blow('user:notices_with_friends:%d', $subscriber->id);
             self::blow('subscription:by-subscriber:' . $subscriber->id);
             self::blow('subscription:by-subscribed:' . $other->id);
             $subscriber->blowSubscriptionCount();
             $other->blowSubscriberCount();
             if ($otherUser instanceof User && $otherUser->autosubscribe && !self::exists($other, $subscriber) && !$subscriber->hasBlocked($other)) {
                 try {
                     self::start($other, $subscriber);
                 } catch (AlreadyFulfilledException $e) {
                     // This shouldn't happen due to !self::exists above
                     common_debug('Tried to autosubscribe a user to its new subscriber.');
                 } catch (Exception $e) {
                     common_log(LOG_ERR, "Exception during autosubscribe of {$other->nickname} to profile {$subscriber->id}: {$e->getMessage()}");
                 }
             }
         }
         if ($sub instanceof Subscription) {
             // i.e. not Subscription_queue
             Event::handle('EndSubscribe', array($subscriber, $other));
         }
     }
     return $sub;
 }
Пример #6
0
 function countPendingSubs()
 {
     $req = new Subscription_queue();
     $req->subscribed = $this->user->id;
     return $req->count();
 }
Пример #7
0
 function exists($subscriber, $other)
 {
     $sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->id, 'subscribed' => $other->id));
     return empty($sub) ? false : true;
 }
Пример #8
0
 /**
  * Make a new subscription
  *
  * @param Profile $subscriber party to receive new notices
  * @param Profile $other      party sending notices; publisher
  * @param bool    $force      pass Subscription::FORCE to override local subscription approval
  *
  * @return mixed Subscription or Subscription_queue: new subscription info
  */
 static function start($subscriber, $other, $force = false)
 {
     // @fixme should we enforce this as profiles in callers instead?
     if ($subscriber instanceof User) {
         $subscriber = $subscriber->getProfile();
     }
     if ($other instanceof User) {
         $other = $other->getProfile();
     }
     if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
         // TRANS: Exception thrown when trying to subscribe while being banned from subscribing.
         throw new Exception(_('You have been banned from subscribing.'));
     }
     if (self::exists($subscriber, $other)) {
         // TRANS: Exception thrown when trying to subscribe while already subscribed.
         throw new Exception(_('Already subscribed!'));
     }
     if ($other->hasBlocked($subscriber)) {
         // TRANS: Exception thrown when trying to subscribe to a user who has blocked the subscribing user.
         throw new Exception(_('User has blocked you.'));
     }
     if (Event::handle('StartSubscribe', array($subscriber, $other))) {
         $otherUser = User::staticGet('id', $other->id);
         if ($otherUser && $otherUser->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE && !$force) {
             $sub = Subscription_queue::saveNew($subscriber, $other);
             $sub->notify();
         } else {
             $sub = self::saveNew($subscriber->id, $other->id);
             $sub->notify();
             self::blow('user:notices_with_friends:%d', $subscriber->id);
             self::blow('subscription:by-subscriber:' . $subscriber->id);
             self::blow('subscription:by-subscribed:' . $other->id);
             $subscriber->blowSubscriptionCount();
             $other->blowSubscriberCount();
             if (!empty($otherUser) && $otherUser->autosubscribe && !self::exists($other, $subscriber) && !$subscriber->hasBlocked($other)) {
                 try {
                     self::start($other, $subscriber);
                 } catch (Exception $e) {
                     common_log(LOG_ERR, "Exception during autosubscribe of {$other->nickname} to profile {$subscriber->id}: {$e->getMessage()}");
                 }
             }
         }
         Event::handle('EndSubscribe', array($subscriber, $other));
     }
     return $sub;
 }
Пример #9
0
 /**
  * Check if a pending subscription request is outstanding for this...
  *
  * @param Profile $other
  * @return boolean
  */
 function hasPendingSubscription(Profile $other)
 {
     return Subscription_queue::exists($this, $other);
 }
Пример #10
0
$schema['profile_tag_inbox'] = array('description' => 'Many-many table listing notices associated with people tags.', 'fields' => array('profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'people tag receiving the message'), 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created')), 'primary key' => array('profile_tag_id', 'notice_id'), 'foreign keys' => array('profile_tag_inbox_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), 'profile_tag_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id'))), 'indexes' => array('profile_tag_inbox_created_idx' => array('created'), 'profile_tag_inbox_profile_tag_id_idx' => array('profile_tag_id')));
$schema['profile_tag_subscription'] = array('fields' => array('profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), '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')), 'primary key' => array('profile_tag_id', 'profile_id'), 'foreign keys' => array('profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), 'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id'))), 'indexes' => array('profile_tag_subscription_profile_id_idx' => array('profile_id'), 'profile_tag_subscription_created_idx' => array('created')));
$schema['profile_block'] = array('fields' => array('blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking')), 'foreign keys' => array('profile_block_blocker_fkey' => array('user', array('blocker' => 'id')), 'profile_block_blocked_fkey' => array('profile', array('blocked' => 'id'))), 'primary key' => array('blocker', 'blocked'));
$schema['user_group'] = array('fields' => array('id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'), 'fullname' => array('type' => 'varchar', 'length' => 255, 'description' => 'display name'), 'homepage' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL, cached so we dont regenerate'), 'description' => array('type' => 'text', 'description' => 'group description'), 'location' => array('type' => 'varchar', 'length' => 255, 'description' => 'related physical location, if any'), 'original_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'original size logo'), 'homepage_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'homepage (profile) size logo'), 'stream_logo' => array('type' => 'varchar', 'length' => 255, 'description' => 'stream-sized logo'), 'mini_logo' => array('type' => 'varchar', 'length' => 255, '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' => 255, 'description' => 'universal identifier'), 'mainpage' => array('type' => 'varchar', 'length' => 255, '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')), 'indexes' => array('user_group_nickname_idx' => array('nickname')));
$schema['group_member'] = array('fields' => array('group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), 'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'), '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')), 'primary key' => array('group_id', 'profile_id'), 'foreign keys' => array('group_member_group_id_fkey' => array('user_group', array('group_id' => 'id')), 'group_member_profile_id_fkey' => array('profile', array('profile_id' => 'id'))), 'indexes' => array('group_member_profile_id_idx' => array('profile_id'), 'group_member_created_idx' => array('created')));
$schema['related_group'] = array('fields' => array('group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), 'related_group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created')), 'primary key' => array('group_id', 'related_group_id'), 'foreign keys' => array('related_group_group_id_fkey' => array('user_group', array('group_id' => 'id')), 'related_group_related_group_id_fkey' => array('user_group', array('related_group_id' => 'id'))));
$schema['group_inbox'] = array('description' => 'Many-many table listing notices posted to a given group, or which groups a given notice was posted to.', 'fields' => array('group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group receiving the message'), 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created')), 'primary key' => array('group_id', 'notice_id'), 'foreign keys' => array('group_inbox_group_id_fkey' => array('user_group', array('group_id' => 'id')), 'group_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id'))), 'indexes' => array('group_inbox_created_idx' => array('created'), 'group_inbox_notice_id_idx' => array('notice_id')));
$schema['file'] = array('fields' => array('id' => array('type' => 'serial', 'not null' => true), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'destination URL after following redirections'), 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), 'size' => array('type' => 'int', 'description' => 'size of resource when available'), 'title' => array('type' => 'varchar', 'length' => 255, 'description' => 'title of resource when available'), 'date' => array('type' => 'int', 'description' => 'date of resource according to http query'), 'protected' => array('type' => 'int', 'description' => 'true when URL is private (needs login)'), 'filename' => array('type' => 'varchar', 'length' => 255, 'description' => 'if a local file, name of the file'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('id'), 'unique keys' => array('file_url_key' => array('url')));
$schema['file_oembed'] = array('fields' => array('file_id' => array('type' => 'int', 'not null' => true, 'description' => 'oEmbed for that URL/file'), 'version' => array('type' => 'varchar', 'length' => 20, 'description' => 'oEmbed spec. version'), 'type' => array('type' => 'varchar', 'length' => 20, 'description' => 'oEmbed type: photo, video, link, rich'), 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), 'provider' => array('type' => 'varchar', 'length' => 50, 'description' => 'name of this oEmbed provider'), 'provider_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of this oEmbed provider'), 'width' => array('type' => 'int', 'description' => 'width of oEmbed resource when available'), 'height' => array('type' => 'int', 'description' => 'height of oEmbed resource when available'), 'html' => array('type' => 'text', 'description' => 'html representation of this oEmbed resource when applicable'), 'title' => array('type' => 'varchar', 'length' => 255, 'description' => 'title of oEmbed resource when available'), 'author_name' => array('type' => 'varchar', 'length' => 50, 'description' => 'author name for this oEmbed resource'), 'author_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'author URL for this oEmbed resource'), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL for this oEmbed resource when applicable (photo, link)'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('file_id'), 'foreign keys' => array('file_oembed_file_id_fkey' => array('file', array('file_id' => 'id'))));
$schema['file_redirection'] = array('fields' => array('url' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'short URL (or any other kind of redirect) for file (id)'), 'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'), 'redirections' => array('type' => 'int', 'description' => 'redirect count'), 'httpcode' => array('type' => 'int', 'description' => 'HTTP status code (20x, 30x, etc.)'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('url'), 'foreign keys' => array('file_redirection_file_id_fkey' => array('file' => array('file_id' => 'id'))));
$schema['file_thumbnail'] = array('fields' => array('file_id' => array('type' => 'int', 'not null' => true, 'description' => 'thumbnail for what URL/file'), 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of thumbnail'), 'width' => array('type' => 'int', 'description' => 'width of thumbnail'), 'height' => array('type' => 'int', 'description' => 'height of thumbnail'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('file_id'), 'foreign keys' => array('file_thumbnail_file_id_fkey' => array('file', array('file_id' => 'id'))), 'unique keys' => array('file_thumbnail_url_key' => array('url')));
$schema['file_to_post'] = array('fields' => array('file_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of URL/file'), 'post_id' => array('type' => 'int', 'not null' => true, 'description' => 'id of the notice it belongs to'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('file_id', 'post_id'), 'foreign keys' => array('file_to_post_file_id_fkey' => array('file', array('file_id' => 'id')), 'file_to_post_post_id_fkey' => array('notice', array('post_id' => 'id'))), 'indexes' => array('post_id_idx' => array('post_id')));
$schema['group_block'] = array('fields' => array('group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), 'blocked' => array('type' => 'int', 'not null' => true, 'description' => 'profile that is blocked'), 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date of blocking')), 'primary key' => array('group_id', 'blocked'), 'foreign keys' => array('group_block_group_id_fkey' => array('user_group', array('group_id' => 'id')), 'group_block_blocked_fkey' => array('profile', array('blocked' => 'id')), 'group_block_blocker_fkey' => array('user', array('blocker' => 'id'))));
$schema['group_alias'] = array('fields' => array('alias' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'additional nickname for the group'), 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group profile is blocked from'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date alias was created')), 'primary key' => array('alias'), 'foreign keys' => array('group_alias_group_id_fkey' => array('user_group', array('group_id' => 'id'))), 'indexes' => array('group_alias_group_id_idx' => array('group_id')));
$schema['session'] = array('fields' => array('id' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'), 'session_data' => array('type' => 'text', 'description' => 'session data'), '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')), 'primary key' => array('id'), 'indexes' => array('session_modified_idx' => array('modified')));
$schema['deleted_notice'] = array('fields' => array('id' => array('type' => 'int', 'not null' => true, 'description' => 'identity of notice'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'author of the notice'), 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice record was created'), 'deleted' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice record was created')), 'primary key' => array('id'), 'unique keys' => array('deleted_notice_uri_key' => array('uri')), 'indexes' => array('deleted_notice_profile_id_idx' => array('profile_id')));
$schema['config'] = array('fields' => array('section' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration section'), 'setting' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration setting'), 'value' => array('type' => 'varchar', 'length' => 255, 'description' => 'configuration value')), 'primary key' => array('section', 'setting'));
$schema['profile_role'] = array('fields' => array('profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'account having the role'), 'role' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'string representing the role'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the role was granted')), 'primary key' => array('profile_id', 'role'), 'foreign keys' => array('profile_role_profile_id_fkey' => array('profile', array('profile_id' => 'id'))));
$schema['location_namespace'] = array('fields' => array('id' => array('type' => 'int', 'not null' => true, 'description' => 'identity for this namespace'), 'description' => array('type' => 'varchar', 'length' => 255, 'description' => 'description of the namespace'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the record was created'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('id'));
$schema['login_token'] = array('fields' => array('user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user owning this token'), 'token' => array('type' => 'char', 'length' => 32, 'not null' => true, 'description' => 'token useable for logging in'), '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')), 'primary key' => array('user_id'), 'foreign keys' => array('login_token_user_id_fkey' => array('user', array('user_id' => 'id'))));
$schema['user_location_prefs'] = array('fields' => array('user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'), 'share_location' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Whether to share location data'), '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')), 'primary key' => array('user_id'), 'foreign keys' => array('user_location_prefs_user_id_fkey' => array('user', array('user_id' => 'id'))));
$schema['inbox'] = array('fields' => array('user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user receiving the notice'), 'notice_ids' => array('type' => 'blob', 'description' => 'packed list of notice ids')), 'primary key' => array('user_id'), 'foreign keys' => array('inbox_user_id_fkey' => array('user', array('user_id' => 'id'))));
// @fixme possibly swap this for a more general prefs table?
$schema['user_im_prefs'] = array('fields' => array('user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'), 'screenname' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'screenname on this service'), 'transport' => array('type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'), 'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'), 'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies  from people not subscribed to'), 'microid' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'Publish a MicroID'), 'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'), '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')), 'primary key' => array('user_id', 'transport'), 'unique keys' => array('transport_screenname_key' => array('transport', 'screenname')), 'foreign keys' => array('user_im_prefs_user_id_fkey' => array('user', array('user_id' => 'id'))));
$schema['conversation'] = array('fields' => array('id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), 'uri' => array('type' => 'varchar', 'length' => 225, 'description' => 'URI of the conversation'), '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')), 'primary key' => array('id'), 'unique keys' => array('conversation_uri_key' => array('uri')));
$schema['local_group'] = array('description' => 'Record for a user group on the local site, with some additional info not in user_group', 'fields' => array('group_id' => array('type' => 'int', 'not null' => true, 'description' => 'group represented'), 'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'group represented'), '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')), 'primary key' => array('group_id'), 'foreign keys' => array('local_group_group_id_fkey' => array('user_group', array('group_id' => 'id'))), 'unique keys' => array('local_group_nickname_key' => array('nickname')));
$schema['user_urlshortener_prefs'] = array('fields' => array('user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'), 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), 'maxurllength' => array('type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, null = never'), 'maxnoticelength' => array('type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, null = never'), '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')), 'primary key' => array('user_id'), 'foreign keys' => array('user_urlshortener_prefs_user_id_fkey' => array('user', array('user_id' => 'id'))));
$schema['schema_version'] = array('description' => 'To avoid checking database structure all the time, we store a checksum of the expected schema info for each table here. If it has not changed since the last time we checked the table, we can leave it as is.', 'fields' => array('table_name' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Table name'), 'checksum' => array('type' => 'varchar', 'length' => '64', 'not null' => true, 'description' => 'Checksum of schema array; a mismatch indicates we should check the table more thoroughly.'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified')), 'primary key' => array('table_name'));
$schema['group_join_queue'] = Group_join_queue::schemaDef();
$schema['subscription_queue'] = Subscription_queue::schemaDef();
$schema['oauth_token_association'] = Oauth_token_association::schemaDef();