/** * * @param User $user * @param boolean $indent * @param boolean $outputMode: UserActivityStream::OUTPUT_STRING to return a string, * or UserActivityStream::OUTPUT_RAW to go to raw output. * Raw output mode will attempt to stream, keeping less * data in memory but will leave $this->activities incomplete. */ function __construct($user, $indent = true, $outputMode = UserActivityStream::OUTPUT_STRING) { parent::__construct($user, null, $indent); $this->outputMode = $outputMode; if ($this->outputMode == self::OUTPUT_STRING) { // String buffering? Grab all the notices now. $notices = $this->getNotices(); } elseif ($this->outputMode == self::OUTPUT_RAW) { // Raw output... need to restructure from the stringer init. $this->xw = new XMLWriter(); $this->xw->openURI('php://output'); if (is_null($indent)) { $indent = common_config('site', 'indent'); } $this->xw->setIndent($indent); // We'll fetch notices later. $notices = array(); } else { throw new Exception('Invalid outputMode provided to ' . __METHOD__); } // Assume that everything but notices is feasible // to pull at once and work with in memory... $subscriptions = $this->getSubscriptions(); $subscribers = $this->getSubscribers(); $groups = $this->getGroups(); $faves = $this->getFaves(); $objs = array_merge($subscriptions, $subscribers, $groups, $faves, $notices); // Sort by create date usort($objs, 'UserActivityStream::compareObject'); // We'll keep these around for later, and interleave them into // the output stream with the user's notices. foreach ($objs as $obj) { $this->activities[] = $obj->asActivity(); } }
function prepare($args) { parent::prepare($args); if (common_config('singleuser', 'enabled')) { $nickname_arg = User::singleUserNickname(); } else { $nickname_arg = $this->arg('nickname'); } $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->arg('page') && $this->arg('page') != 1) { $args['page'] = $this->arg['page']; } common_redirect(common_local_url('peopletagsforuser', $args), 301); } $this->user = User::getKV('nickname', $nickname); if (!$this->user) { // TRANS: Client error displayed trying to perform an action related to a non-existing user. $this->clientError(_('No such user.'), 404); } $this->tagged = $this->user->getProfile(); if (!$this->tagged) { // TRANS: Error message displayed when referring to a user without a profile. $this->serverError(_('User has no profile.')); } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; return true; }
/** * Constructor * * @param User $user the user for the feed * @param User $cur the current authenticated user, if any * @param boolean $indent flag to turn indenting on or off * * @return void */ function __construct($user, $cur = null, $indent = true) { parent::__construct($cur, $indent); $this->user = $user; if (!empty($user)) { $profile = $user->getProfile(); $ao = ActivityObject::fromProfile($profile); array_push($ao->extra, $profile->profileInfo($cur)); // XXX: For users, we generate an author _AND_ an <activity:subject> // This is for backward compatibility with clients (especially // StatusNet's clients) that assume the Atom will conform to an // older version of the Activity Streams API. Subject should be // removed in future versions of StatusNet. $this->addAuthorRaw($ao->asString('author')); $depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.'; $this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject')); } // TRANS: Title in atom user notice feed. %s is a user name. $title = sprintf(_("%s timeline"), $user->nickname); $this->setTitle($title); $sitename = common_config('site', 'name'); $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename); $this->setSubtitle($subtitle); $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); $logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); $this->setLogo($logo); $this->setUpdated('now'); $this->addLink(common_local_url('showstream', array('nickname' => $user->nickname))); $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom')); $this->setId($self); $this->setSelfLink($self); $this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json')); }
/** * Constructor * * @param User $user the user for the feed * @param User $cur the current authenticated user, if any * @param boolean $indent flag to turn indenting on or off * * @return void */ function __construct($user, $cur = null, $indent = true) { parent::__construct($cur, $indent); $this->user = $user; if (!empty($user)) { $profile = $user->getProfile(); $this->addAuthor($profile->nickname, $user->uri); $this->setActivitySubject($profile->asActivityNoun('subject')); } // TRANS: Title in atom user notice feed. %s is a user name. $title = sprintf(_("%s timeline"), $user->nickname); $this->setTitle($title); $sitename = common_config('site', 'name'); $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename); $this->setSubtitle($subtitle); $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); $logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); $this->setLogo($logo); $this->setUpdated('now'); $this->addLink(common_local_url('showstream', array('nickname' => $user->nickname))); $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom')); $this->setId($self); $this->setSelfLink($self); $this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json')); }
function updateKeys(&$orig) { $this->_connect(); $parts = array(); foreach (array('id', 'service', 'uri', 'nickname') as $k) { if (strcmp($this->{$k}, $orig->{$k}) != 0) { $parts[] = $k . ' = ' . $this->_quote($this->{$k}); } } if (count($parts) == 0) { // No changes return true; } $toupdate = implode(', ', $parts); $table = $this->tableName(); if (common_config('db', 'quote_identifiers')) { $table = '"' . $table . '"'; } $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . ' WHERE id = ' . $this->id; $orig->decache(); $result = $this->query($qry); if ($result) { $this->encache(); } return $result; }
/** * Handle the request * * Show the user's groups * * @param array $args $_REQUEST data (unused) * * @return void */ function handle($args) { parent::handle($args); $sitename = common_config('site', 'name'); // TRANS: Used as title in check for group membership. %s is a user name. $title = sprintf(_("%s's groups"), $this->user->nickname); $taguribase = TagURI::base(); $id = "tag:{$taguribase}:Groups"; $link = common_local_url('usergroups', array('nickname' => $this->user->nickname)); $subtitle = sprintf(_('%1$s groups %2$s is a member of.'), $sitename, $this->user->nickname); switch ($this->format) { case 'xml': $this->showXmlGroups($this->groups); break; case 'rss': $this->showRssGroups($this->groups, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . 'api/statusnet/groups/list/' . $this->user->id . '.atom'; $this->showAtomGroups($this->groups, $title, $id, $link, $subtitle, $selfuri); break; case 'json': $this->showJsonGroups($this->groups); break; default: $this->clientError(_('API method not found.'), 404, $this->format); break; } }
/** * Data elements of the form * * @return void */ function formData() { $this->out->hidden('subaction', 'apikey'); $this->out->elementStart('fieldset'); $this->out->elementStart('p'); // TRANS: Explanation of what needs to be done to connect to a Yammer network. $this->out->text(_m('Before we can connect to your Yammer network, ' . 'you will need to register the importer as an ' . 'application authorized to pull data on your behalf. ' . 'This registration will work only for your own network. ' . 'Follow this link to register the app at Yammer; ' . 'you will be prompted to log in if necessary:')); $this->out->elementEnd('p'); $this->out->elementStart('p', array('class' => 'magiclink')); $this->out->element('a', array('href' => 'https://www.yammer.com/client_applications/new', 'target' => '_blank'), _m('Open Yammer application registration form')); $this->out->elementEnd('p'); // TRANS: Instructions. $this->out->element('p', array(), _m('Copy the consumer key and secret you are given into the form below:')); $this->out->elementStart('ul', array('class' => 'form_data')); $this->out->elementStart('li'); // TRANS: Field label for a Yammer consumer key. $this->out->input('consumer_key', _m('Consumer key:'), common_config('yammer', 'consumer_key')); $this->out->elementEnd('li'); $this->out->elementStart('li'); // TRANS: Field label for a Yammer consumer secret. $this->out->input('consumer_secret', _m('Consumer secret:'), common_config('yammer', 'consumer_secret')); $this->out->elementEnd('li'); $this->out->elementEnd('ul'); // TRANS: Button text for saving a Yammer API registration. $this->out->submit('submit', _m('BUTTON', 'Save'), 'submit', null, _m('Save the entered consumer key and consumer secret.')); $this->out->elementEnd('fieldset'); }
function onArgsInitialize($args) { $path = common_config('site', 'path'); if (common_config('site', 'ssl') == 'always' && ($path == '/' || !$path)) { header('Strict-Transport-Security: max-age=' . $this->max_age . +($this->includeSubDomains ? '; includeSubDomains' : '')); } }
/** * Class handler. * * @param array $args query arguments * * @return boolean false if user doesn't exist */ function handle($args) { parent::handle($args); $type = $this->trimmed('type'); $short_name = ''; if ($type == 'people') { $type = 'peoplesearch'; // TRANS: ShortName in the OpenSearch interface when trying to find users. $short_name = _('People Search'); } else { $type = 'noticesearch'; // TRANS: ShortName in the OpenSearch interface when trying to find notices. $short_name = _('Notice Search'); } header('Content-Type: application/opensearchdescription+xml'); $this->startXML(); $this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/')); $short_name = common_config('site', 'name') . ' ' . $short_name; $this->element('ShortName', null, $short_name); $this->element('Contact', null, common_config('site', 'email')); $this->element('Url', array('type' => 'text/html', 'method' => 'get', 'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---'))))); $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico')); $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), Theme::path('logo.png')); $this->element('AdultContent', null, 'false'); $this->element('Language', null, common_language()); $this->element('OutputEncoding', null, 'UTF-8'); $this->element('InputEncoding', null, 'UTF-8'); $this->elementEnd('OpenSearchDescription'); $this->endXML(); }
/** * Prepare to run */ function prepare($args) { parent::prepare($args); if (!common_config('inboxes', 'enabled')) { $this->serverError(_('Inboxes must be enabled for groups to work.')); return false; } if (!common_logged_in()) { $this->clientError(_('You must be logged in to leave a group.')); return false; } $nickname_arg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); common_redirect(common_local_url('leavegroup', $args), 301); return false; } if (!$nickname) { $this->clientError(_('No nickname.'), 404); return false; } $this->group = User_group::staticGet('nickname', $nickname); if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; } $cur = common_current_user(); if (!$cur->isMember($this->group)) { $this->clientError(_('You are not a member of that group.'), 403); return false; } return true; }
/** * Check for an API key, and throw an exception if it's not set * * @param array $args URL and POST params * * @return boolean continuation flag */ function prepare($args) { GNUsocial::setApi(true); // reduce exception reports to aid in debugging parent::prepare($args); if (!common_config('globalapi', 'enabled')) { throw new ClientException(_('Global API not enabled.'), 403); } $apikey = $this->trimmed('apikey'); if (empty($apikey)) { throw new ClientException(_('No API key.'), 403); } $expected = common_config('globalapi', 'key'); if ($expected != $apikey) { // FIXME: increment a counter by IP address to prevent brute-force // attacks on the key. throw new ClientException(_('Bad API key.'), 403); } $email = common_canonical_email($this->trimmed('email')); if (empty($email)) { throw new ClientException(_('No email address.')); } if (!Validate::email($email, common_config('email', 'check_domain'))) { throw new ClientException(_('Invalid email address.')); } $this->email = $email; return true; }
/** * Show the menu * * @return void */ function show() { $this->actionName = $this->action->trimmed('action'); $this->action->elementStart('ul', array('class' => 'nav')); if (Event::handle('StartPublicGroupNav', array($this))) { if (!common_config('singleuser', 'enabled')) { // TRANS: Menu item in search group navigation panel. $this->out->menuItem(common_local_url('public'), _m('MENU', 'Public'), _('Public timeline'), $this->actionName == 'public', 'nav_timeline_public'); } // TRANS: Menu item in search group navigation panel. $this->out->menuItem(common_local_url('groups'), _m('MENU', 'Groups'), _('User groups'), $this->actionName == 'groups', 'nav_groups'); if (!common_config('performance', 'high')) { // TRANS: Menu item in search group navigation panel. $this->out->menuItem(common_local_url('publictagcloud'), _m('MENU', 'Recent tags'), _('Recent tags'), $this->actionName == 'publictagcloud', 'nav_recent-tags'); } if (count(common_config('nickname', 'featured')) > 0) { // TRANS: Menu item in search group navigation panel. $this->out->menuItem(common_local_url('featured'), _m('MENU', 'Featured'), _('Featured users'), $this->actionName == 'featured', 'nav_featured'); } if (!common_config('singleuser', 'enabled')) { // TRANS: Menu item in search group navigation panel. $this->out->menuItem(common_local_url('favorited'), _m('MENU', 'Popular'), _('Popular notices'), $this->actionName == 'favorited', 'nav_timeline_favorited'); } Event::handle('EndPublicGroupNav', array($this)); } $this->action->elementEnd('ul'); }
function getTags() { $profile = Profile::current(); $keypart = sprintf('Inbox:notice_tag:%d:%d', $this->user->id, $profile->id); $tag = Memcached_DataObject::cacheGet($keypart); if ($tag === false) { $stream = new InboxNoticeStream($this->user, $profile); $ids = $stream->getNoticeIds(0, Inbox::MAX_NOTICES, null, null); if (empty($ids)) { $tag = array(); } else { $weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff')); // @fixme should we use the cutoff too? Doesn't help with indexing per-user. $qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'WHERE notice.id in (' . implode(',', $ids) . ')' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC '; $limit = TAGS_PER_SECTION; $offset = 0; if (common_config('db', 'type') == 'pgsql') { $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; } else { $qry .= ' LIMIT ' . $offset . ', ' . $limit; } $t = new Notice_tag(); $t->query($qry); $tag = array(); while ($t->fetch()) { $tag[] = clone $t; } } Memcached_DataObject::cacheSet($keypart, $tag, 3600); } return new ArrayWrapper($tag); }
function getNoticeIds($offset, $limit, $since_id, $max_id) { $notice = new Notice(); $notice->selectAdd(); // clears it $notice->selectAdd('id'); $notice->orderBy('created DESC, id DESC'); if (!is_null($offset)) { $notice->limit($offset, $limit); } if (common_config('public', 'localonly')) { $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC); } else { // -1 == blacklisted, -2 == gateway (i.e. Twitter) $notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC); $notice->whereAdd('is_local !=' . Notice::GATEWAY); } Notice::addWhereSinceId($notice, $since_id); Notice::addWhereMaxId($notice, $max_id); $ids = array(); if ($notice->find()) { while ($notice->fetch()) { $ids[] = $notice->id; } } $notice->free(); $notice = NULL; return $ids; }
protected function getStream() { if (!$this->scoped instanceof Profile && common_config('public', 'localonly')) { $this->clientError(_('Network wide public feed is not permitted without authorization'), 403); } return new NetworkPublicNoticeStream($this->scoped); }
/** * Prepare the action * * Reads and validates arguments and instantiates the attributes. * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); if (!common_config('inboxes', 'enabled')) { $this->serverError(_('Inboxes must be enabled for groups to work')); return false; } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('showgroup', $args), 301); return false; } if (!$nickname) { $this->clientError(_('No nickname'), 404); return false; } $this->group = User_group::staticGet('nickname', $nickname); if (!$this->group) { $this->clientError(_('No such group'), 404); return false; } common_set_returnto($this->selfUrl()); return true; }
function handle($args) { parent::handle($args); $secret = common_config('facebook', 'secret'); $sig = ''; ksort($_POST); foreach ($_POST as $key => $val) { if (substr($key, 0, 7) == 'fb_sig_') { $sig .= substr($key, 7) . '=' . $val; } } $sig .= $secret; $verify = md5($sig); if ($verify == $this->arg('fb_sig')) { $flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2); common_debug("Removing foreign link to Facebook - local user ID: {$flink->user_id}, Facebook ID: {$flink->foreign_id}"); $result = $flink->delete(); if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); $this->serverError(_('Couldn\'t remove Facebook user.')); return; } } else { # Someone bad tried to remove facebook link? common_log(LOG_ERR, "Someone from {$_SERVER['REMOTE_ADDR']} " . 'unsuccessfully tried to remove a foreign link to Facebook!'); } }
function getNoticeIds($offset, $limit, $since_id, $max_id) { $notice = new Notice(); $notice->selectAdd(); // clears it $notice->selectAdd('id'); $notice->orderBy('created DESC, id DESC'); if (!is_null($offset)) { $notice->limit($offset, $limit); } if (common_config('public', 'localonly')) { $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC); } else { // -1 == blacklisted, -2 == gateway (i.e. Twitter) $notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC); $notice->whereAdd('is_local !=' . Notice::GATEWAY); } Notice::addWhereSinceId($notice, $since_id); Notice::addWhereMaxId($notice, $max_id); $strSql = sprintf('(content_type=%d or content_type=%d)', NOTICE::CONTENT_TYPE_POST, NOTICE::CONTENT_TYPE_REPEAT); $strSql = sprintf('(content_type in (%d,%d,%d,%d))', NOTICE::CONTENT_TYPE_REPEAT, NOTICE::CONTENT_TYPE_REPEAT | NOTICE::CONTENT_TYPE_MENTIONS, NOTICE::CONTENT_TYPE_POST, NOTICE::CONTENT_TYPE_POST | NOTICE::CONTENT_TYPE_MENTIONS); $notice->whereAdd($strSql); $ids = array(); if ($notice->find()) { while ($notice->fetch()) { $ids[] = $notice->id; } } $notice->free(); $notice = NULL; return $ids; }
function getNotices() { // @fixme there should be a common func for this if (common_config('db', 'type') == 'pgsql') { if (!empty($this->out->tag)) { $tag = pg_escape_string($this->out->tag); } } else { if (!empty($this->out->tag)) { $tag = mysql_escape_string($this->out->tag); } } $weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff')); $cutoff = sprintf("fave.modified > '%s'", common_sql_date(time() - common_config('popular', 'cutoff'))); $qry = "SELECT notice.*, {$weightexpr} as weight "; if (isset($tag)) { $qry .= 'FROM notice_tag, notice JOIN fave ON notice.id = fave.notice_id ' . "WHERE {$cutoff} and notice.id = notice_tag.notice_id and '{$tag}' = notice_tag.tag"; } else { $qry .= 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . "WHERE {$cutoff}"; } $qry .= ' GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . 'notice.rendered,notice.url,notice.created,notice.modified,' . 'notice.reply_to,notice.is_local,notice.source,notice.conversation, ' . 'notice.lat,notice.lon,location_id,location_ns,notice.repeat_of' . ' ORDER BY weight DESC'; $offset = 0; $limit = NOTICES_PER_SECTION + 1; $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; $notice = Memcached_DataObject::cachedQuery('Notice', $qry, 1200); return $notice; }
/** * Handle the request * * Show the user's groups * * @return void */ protected function handle() { parent::handle(); $sitename = common_config('site', 'name'); // TRANS: Used as title in check for group membership. %s is a user name. $title = sprintf(_("%s's groups"), $this->target->nickname); $taguribase = TagURI::base(); $id = "tag:{$taguribase}:Groups"; $link = common_local_url('usergroups', array('nickname' => $this->target->nickname)); $subtitle = sprintf(_('%1$s groups %2$s is a member of.'), $sitename, $this->target->nickname); switch ($this->format) { case 'xml': $this->showXmlGroups($this->groups); break; case 'rss': $this->showRssGroups($this->groups, $title, $link, $subtitle); break; case 'atom': $selfuri = common_local_url('ApiGroupList', array('id' => $this->target->id, 'format' => 'atom')); $this->showAtomGroups($this->groups, $title, $id, $link, $subtitle, $selfuri); break; case 'json': $this->showJsonGroups($this->groups); break; default: // TRANS: Client error displayed when coming across a non-supported API method. $this->clientError(_('API method not found.'), 404); } }
function updateKeys(&$orig) { $this->_connect(); $parts = array(); foreach (array('profile_id', 'application_id', 'token', 'access_type') as $k) { if (strcmp($this->{$k}, $orig->{$k}) != 0) { $parts[] = $k . ' = ' . $this->_quote($this->{$k}); } } if (count($parts) == 0) { // No changes return true; } $toupdate = implode(', ', $parts); $table = $this->tableName(); if (common_config('db', 'quote_identifiers')) { $table = '"' . $table . '"'; } $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . ' WHERE profile_id = ' . $orig->profile_id . ' AND application_id = ' . $orig->application_id . " AND token = '{$orig->token}'"; $orig->decache(); $result = $this->query($qry); if ($result) { $this->encache(); } return $result; }
function getProfiles() { $featured_nicks = common_config('nickname', 'featured'); if (!$featured_nicks) { return null; } $quoted = array(); foreach ($featured_nicks as $nick) { $quoted[] = "'{$nick}'"; } $table = "user"; if (common_config('db', 'quote_identifiers')) { $table = '"' . $table . '"'; } $qry = 'SELECT profile.* ' . 'FROM profile JOIN ' . $table . ' on profile.id = ' . $table . '.id ' . 'WHERE ' . $table . '.nickname in (' . implode(',', $quoted) . ') ' . 'ORDER BY profile.created DESC '; $limit = PROFILES_PER_SECTION + 1; $offset = 0; if (common_config('db', 'type') == 'pgsql') { $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; } else { $qry .= ' LIMIT ' . $offset . ', ' . $limit; } $profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600); return $profile; }
function notifyBackupFile($user, $fileName) { $fileUrl = File::url($fileName); $body = sprintf(_m("The backup file you requested is ready for download.\n\n" . "%s\n" . "Thanks for your time,\n", "%s\n"), $fileUrl, common_config('site', 'name')); $headers = _mail_prepare_headers('offlinebackup', $user->nickname, $user->nickname); mail_to_user($user, _('Backup file ready for download'), $body, $headers); }
/** * Setup the info for the subscription handler. Allow overriding * to point at another cloud hub (not currently used). * * @return void */ function onInitializePlugin() { $this->domain = common_config('rsscloud', 'domain'); $this->port = common_config('rsscloud', 'port'); $this->path = common_config('rsscloud', 'path'); $this->funct = common_config('rsscloud', 'function'); $this->protocol = common_config('rsscloud', 'protocol'); // set defaults $local_server = parse_url(common_path('main/rsscloud/request_notify')); if (empty($this->domain)) { $this->domain = $local_server['host']; } if (empty($this->port)) { $this->port = '80'; } if (empty($this->path)) { $this->path = $local_server['path']; } if (empty($this->funct)) { $this->funct = ''; } if (empty($this->protocol)) { $this->protocol = 'http-post'; } }
/** * Take arguments for running * * This method is called first, and it lets the action class get * all its arguments and validate them. It's also the time * to fetch any relevant data from the database. * * Action classes should run parent::prepare($args) as the first * line of this method to make sure the default argument-processing * happens. * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); if (common_config('singleuser', 'enabled')) { $nickname = User::singleUserNickname(); } else { // PHP 5.4 // $nickname = $this->returnToArgs()[1]['nickname']; // PHP < 5.4 $nickname = $this->returnToArgs(); $nickname = $nickname[1]['nickname']; } $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { // TRANS: Client error displayed when trying to display bookmarks for a non-existing user. $this->clientError(_('No such user.')); return false; } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $stream = new BookmarksNoticeStream($this->user->id, true); $this->notices = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notices->N == 0) { throw new ClientException(_('No such page.'), 404); } return true; }
function checkssl() { if (common_config('site', 'ssl') === 'sometimes' || common_config('site', 'ssl') === 'always') { return true; } return false; }
/** * Show the menu * * @return void */ function show() { $cur = common_current_user(); $action = $this->action->trimmed('action'); $this->out->elementStart('ul', array('class' => 'nav')); if (Event::handle('StartSubGroupNav', array($this))) { $this->out->menuItem(common_local_url('showstream', array('nickname' => $this->user->nickname)), _m('MENU', 'Profile'), empty($profile) ? $this->user->nickname : $profile->getBestName(), $action == 'showstream', 'nav_profile'); $this->out->menuItem(common_local_url('subscriptions', array('nickname' => $this->user->nickname)), _m('MENU', 'Subscriptions'), sprintf(_('People %s subscribes to.'), $this->user->nickname), $action == 'subscriptions', 'nav_subscriptions'); $this->out->menuItem(common_local_url('subscribers', array('nickname' => $this->user->nickname)), _m('MENU', 'Subscribers'), sprintf(_('People subscribed to %s.'), $this->user->nickname), $action == 'subscribers', 'nav_subscribers'); if ($cur && $cur->id == $this->user->id) { // Possibly site admins should be able to get in here too $pending = $this->countPendingSubs(); if ($pending || $cur->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE) { $this->out->menuItem(common_local_url('subqueue', array('nickname' => $this->user->nickname)), sprintf(_m('MENU', 'Pending (%d)'), $pending), sprintf(_('Approve pending subscription requests.'), $this->user->nickname), $action == 'subqueueaction', 'nav_subscribers'); } } $this->out->menuItem(common_local_url('usergroups', array('nickname' => $this->user->nickname)), _m('MENU', 'Groups'), sprintf(_('Groups %s is a member of.'), $this->user->nickname), $action == 'usergroups', 'nav_usergroups'); $this->out->menuItem(common_local_url('peopletagsubscriptions', array('nickname' => $this->user->nickname)), _m('MENU', 'Lists'), sprintf(_('List subscriptions by %s.'), $this->user->nickname), in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')), 'nav_timeline_peopletags'); if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) { $this->out->menuItem(common_local_url('invite'), _m('MENU', 'Invite'), sprintf(_('Invite friends and colleagues to join you on %s.'), common_config('site', 'name')), $action == 'invite', 'nav_invite'); } Event::handle('EndSubGroupNav', array($this)); } $this->out->elementEnd('ul'); }
function getChannel() { $user = $this->user; $profile = $user->getProfile(); $c = array('url' => common_local_url('userrss', array('nickname' => $user->nickname)), 'title' => sprintf(_('%s timeline'), $user->nickname), 'link' => $profile->profileurl, 'description' => sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, common_config('site', 'name'))); return $c; }
static function get() { if (empty(self::$qm)) { if (Event::handle('StartNewQueueManager', array(&self::$qm))) { $enabled = common_config('queue', 'enabled'); $type = common_config('queue', 'subsystem'); if (!$enabled) { // does everything immediately self::$qm = new UnQueueManager(); } else { switch ($type) { case 'db': self::$qm = new DBQueueManager(); break; case 'stomp': self::$qm = new StompQueueManager(); break; default: throw new ServerException("No queue manager class for type '{$type}'"); } } } } return self::$qm; }
/** * Constructor * * @param Group $group the group for the feed * @param User $cur the current authenticated user, if any * @param boolean $indent flag to turn indenting on or off * * @return void */ function __construct($group, $cur = null, $indent = true) { parent::__construct($cur, $indent); $this->group = $group; // TRANS: Title in atom group notice feed. %s is a group name. $title = sprintf(_("%s timeline"), $group->nickname); $this->setTitle($title); $sitename = common_config('site', 'name'); $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $group->nickname, $sitename); $this->setSubtitle($subtitle); $avatar = $group->homepage_logo; $logo = $avatar ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE); $this->setLogo($logo); $this->setUpdated('now'); $self = common_local_url('ApiTimelineGroup', array('id' => $group->id, 'format' => 'atom')); $this->setId($self); $this->setSelfLink($self); // For groups, we generate an author _AND_ an <activity:subject> // Versions of StatusNet under 0.9.7 treat <author> as a person // XXX: remove this workaround in future versions $ao = ActivityObject::fromGroup($group); $this->addAuthorRaw($ao->asString('author')); $depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.'; $this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject')); $this->addLink($group->homeUrl()); }