list($this->lists,
$this->next_cursor,
- $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->auth_user), $cursor, $count);
+ $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->scoped), $cursor, $count);
}
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return false;
}
define('BOTH', 0);
// @todo XXX: Documentation missing.
- class FoafAction extends Action
+ class FoafAction extends ManagedAction
{
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return true;
}
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
- class GroupbyidAction extends Action
+ class GroupbyidAction extends ManagedAction
{
/** group we're viewing. */
- var $group = null;
+ protected $group = null;
- /**
- * Is this page read-only?
- *
- * @return boolean true
- */
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return true;
}
return true;
}
- /**
- * Handler method
- *
- * @param array $argarray is ignored since it's now passed in in prepare()
- *
- * @return void
- */
- function handle($argarray=null)
+ public function showPage()
{
- common_redirect($this->file->url, 307);
+ common_redirect($this->file->getUrl(false), 301);
}
- /**
- * Return true if read only.
- *
- * MAY override
- *
- * @param array $args other arguments
- *
- * @return boolean is read only action?
- */
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return true;
}
return $c;
}
- function getImage()
- {
- $profile = $this->user->getProfile();
- return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
- }
-
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return true;
}
return $c;
}
- function getImage()
- {
- $profile = $this->user->getProfile();
- return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
- }
-
// override parent to add X-SUP-ID URL
- function initRss($limit=0)
+ function initRss()
{
- $url = common_local_url('sup', null, null, $this->user->id);
+ $url = common_local_url('sup', null, null, $this->target->getID());
header('X-SUP-ID: '.$url);
- parent::initRss($limit);
+ parent::initRss();
}
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return true;
}
return $reply;
}
- protected $_replies = array();
+ protected $_attentionids = array();
/**
- * Pull the complete list of @-reply targets for this notice.
+ * Pull the complete list of known activity context attentions for this notice.
*
- * @return array of integer profile ids
+ * @return array of integer profile ids (also group profiles)
*/
- function getReplies()
+ function getAttentionProfileIDs()
{
- if (isset($this->_replies[$this->id])) {
- return $this->_replies[$this->id];
+ if (!isset($this->_attentionids[$this->getID()])) {
+ $atts = Attention::multiGet('notice_id', array($this->getID()));
+ // (array)null means empty array
+ $this->_attentionids[$this->getID()] = (array)$atts->fetchAll('profile_id');
}
+ return $this->_attentionids[$this->getID()];
+ }
- $replyMap = Reply::listGet('notice_id', array($this->id));
-
- $ids = array();
+ protected $_replies = array();
- foreach ($replyMap[$this->id] as $reply) {
- $ids[] = $reply->profile_id;
+ /**
+ * Pull the complete list of @-mentioned profile IDs for this notice.
+ *
+ * @return array of integer profile ids
+ */
+ function getReplies()
+ {
+ if (!isset($this->_replies[$this->getID()])) {
+ $mentions = Reply::multiGet('notice_id', array($this->getID()));
+ $this->_replies[$this->getID()] = $mentions->fetchAll('profile_id');
}
-
- $this->_setReplies($ids);
-
- return $ids;
+ return $this->_replies[$this->getID()];
}
- function _setReplies($replies)
+ function _setReplies(array $replies)
{
- $this->_replies[$this->id] = $replies;
+ $this->_replies[$this->getID()] = $replies;
}
/**
return ($result == 1) ? true : false;
}
- protected function _inScope($profile)
+ protected function _inScope(Profile $profile=null)
{
- if (!is_null($this->scope)) {
- $scope = $this->scope;
- } else {
- $scope = self::defaultScope();
- }
+ $scope = is_null($this->scope) ? self::defaultScope() : $this->getScope();
- if ($scope == 0 && !$this->getProfile()->isPrivateStream()) { // Not scoping, so it is public.
+ if ($scope === 0 && !$this->getProfile()->isPrivateStream()) { // Not scoping, so it is public.
return !$this->isHiddenSpam($profile);
}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?p=$1 [L,QSA]
- <<<<<<< HEAD
--
-- ## You can also use PATHINFO by using this RewriteRule instead:
-- # RewriteRule (.*) index.php/$1 [L,QSA]
- </IfModule>
-
- <FilesMatch "\.(ini)">
- # For mod_access_compat in Apache <2.4
- #Order allow,deny
-
- # Use this instead for Apache >2.4 (mod_authz_host)
- # Require all denied
- </FilesMatch>
- =======
</IfModule>
<FilesMatch "\.(ini)">
- <IfVersion < 2.3>
- Order allow,deny
- Deny from all
- </IfVersion>
- <IfVersion >= 2.3>
- Require all denied
- </IfVersion>
+ Order allow,deny
</FilesMatch>
-
- >>>>>>> Adding htaccess.sample back*shame*
return null;
}
- static function compareTypes($type, array $objects) // this does verbs too!
- static function compareTypes($type, $objects)
++ static function compareTypes($type, array $objects)
{
$type = self::resolveUri($type);
- foreach ((array)$objects as $object) {
+ foreach ($objects as $object) {
if ($type === self::resolveUri($object)) {
return true;
}
return $checksums;
} catch (Exception $e) {
// no dice!
- common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet.");
+ common_debug("Possibly schema_version table doesn't exist yet.");
}
- PEAR::popErrorHandling();
return $checksums;
}
}
} catch (Exception $e) {
// no dice!
- common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet.");
+ common_debug("Possibly schema_version table doesn't exist yet.");
}
- PEAR::popErrorHandling();
$this->checksums[$table] = $checksum;
}
}
$notice = $this->rsvp->getNotice();
// NB: this will delete the rsvp, too
if (!empty($notice)) {
- common_log(LOG_DEBUG, "Deleting notice...");
+ common_debug("Deleting notice...");
- $notice->delete();
+ $notice->deleteAs($this->scoped);
} else {
- common_log(LOG_DEBUG, "Deleting RSVP alone...");
+ common_debug("Deleting RSVP alone...");
$this->rsvp->delete();
}
} catch (ClientException $ce) {
class ProfileDetailAction extends ShowstreamAction
{
-
- function isReadOnly($args)
+ function isReadOnly(array $args=array())
{
return true;
}
* send immediately but won't get the return value.
*
* @param mixed $entry XML string, Notice, or Activity
+ * @param Profile $actor Acting profile
* @return boolean success
*/
- public function notifyDeferred($entry, $actor)
+ public function notifyDeferred($entry, Profile $actor)
{
if ($this->salmonuri) {
+ common_debug("OSTATUS: user {$actor->getNickname()} ({$actor->getID()}) wants to ping {$this->localProfile()->getNickname()} on {$this->salmonuri}");
$data = array('salmonuri' => $this->salmonuri,
'entry' => $this->notifyPrepXml($entry),
- 'actor' => $actor->id);
+ 'actor' => $actor->getID(),
+ 'target' => $this->localProfile()->getID());
$qm = QueueManager::get();
return $qm->enqueue($data, 'salmon');
* @param Activity $activity
* @param string $method 'push' or 'salmon'
* @return mixed saved Notice or false
- * @todo FIXME: Break up this function, it's getting nasty long
*/
- public function processPost($activity, $method)
+ public function processPost(Activity $activity, $method)
{
- $notice = null;
-
- $profile = ActivityUtils::checkAuthorship($activity, $this->localProfile());
-
- // It's not always an ActivityObject::NOTE, but... let's just say it is.
-
- $note = $activity->objects[0];
-
- // The id URI will be used as a unique identifier for the notice,
- // protecting against duplicate saves. It isn't required to be a URL;
- // tag: URIs for instance are found in Google Buzz feeds.
- $sourceUri = $note->id;
- $dupe = Notice::getKV('uri', $sourceUri);
- if ($dupe instanceof Notice) {
- common_log(LOG_INFO, "OStatus: ignoring duplicate post: $sourceUri");
- return $dupe;
- }
-
- // We'll also want to save a web link to the original notice, if provided.
- $sourceUrl = null;
- if ($note->link) {
- $sourceUrl = $note->link;
- } else if ($activity->link) {
- $sourceUrl = $activity->link;
- } else if (preg_match('!^https?://!', $note->id)) {
- $sourceUrl = $note->id;
- }
-
- // Use summary as fallback for content
-
- if (!empty($note->content)) {
- $sourceContent = $note->content;
- } else if (!empty($note->summary)) {
- $sourceContent = $note->summary;
- } else if (!empty($note->title)) {
- $sourceContent = $note->title;
- } else {
- // @todo FIXME: Fetch from $sourceUrl?
- // TRANS: Client exception. %s is a source URI.
- throw new ClientException(sprintf(_m('No content for notice %s.'),$sourceUri));
- }
-
- // Get (safe!) HTML and text versions of the content
-
- $rendered = common_purify($sourceContent);
- $content = common_strip_html($rendered);
-
- $shortened = common_shorten_links($content);
-
- // If it's too long, try using the summary, and make the
- // HTML an attachment.
-
- $attachment = null;
-
- if (Notice::contentTooLong($shortened)) {
- $attachment = $this->saveHTMLFile($note->title, $rendered);
- $summary = common_strip_html($note->summary);
- if (empty($summary)) {
- $summary = $content;
- }
- $shortSummary = common_shorten_links($summary);
- if (Notice::contentTooLong($shortSummary)) {
- $url = common_shorten_url($sourceUrl);
- $shortSummary = substr($shortSummary,
- 0,
- Notice::maxContent() - (mb_strlen($url) + 2));
- $content = $shortSummary . ' ' . $url;
-
- // We mark up the attachment link specially for the HTML output
- // so we can fold-out the full version inline.
-
- // @todo FIXME i18n: This tooltip will be saved with the site's default language
- // TRANS: Shown when a notice is longer than supported and/or when attachments are present. At runtime
- // TRANS: this will usually be replaced with localised text from StatusNet core messages.
- $showMoreText = _m('Show more');
- $attachUrl = common_local_url('attachment',
- array('attachment' => $attachment->id));
- $rendered = common_render_text($shortSummary) .
- '<a href="' . htmlspecialchars($attachUrl) .'"'.
- ' class="attachment more"' .
- ' title="'. htmlspecialchars($showMoreText) . '">' .
- '…' .
- '</a>';
- }
- }
-
- $options = array('is_local' => Notice::REMOTE,
- 'url' => $sourceUrl,
- 'uri' => $sourceUri,
- 'rendered' => $rendered,
- 'replies' => array(),
- 'groups' => array(),
- 'peopletags' => array(),
- 'tags' => array(),
- 'urls' => array());
-
- // Check for optional attributes...
+ $actor = ActivityUtils::checkAuthorship($activity, $this->localProfile());
- if (!empty($activity->time)) {
- $options['created'] = common_sql_date($activity->time);
- }
-
- if ($activity->context) {
- // TODO: context->attention
- list($options['groups'], $options['replies'])
- = self::filterAttention($profile, $activity->context->attention);
-
- // Maintain direct reply associations
- // @todo FIXME: What about conversation ID?
- if (!empty($activity->context->replyToID)) {
- $orig = Notice::getKV('uri', $activity->context->replyToID);
- if ($orig instanceof Notice) {
- $options['reply_to'] = $orig->id;
- }
- }
- if (!empty($activity->context->conversation)) {
- // we store the URI here, Notice class can look it up later
- $options['conversation'] = $activity->context->conversation;
- }
-
- $location = $activity->context->location;
- if ($location) {
- $options['lat'] = $location->lat;
- $options['lon'] = $location->lon;
- if ($location->location_id) {
- $options['location_ns'] = $location->location_ns;
- $options['location_id'] = $location->location_id;
- }
- }
- }
-
- if ($this->isPeopletag()) {
- $options['peopletags'][] = $this->localPeopletag();
- }
-
- // Atom categories <-> hashtags
- foreach ($activity->categories as $cat) {
- if ($cat->term) {
- $term = common_canonical_tag($cat->term);
- if ($term) {
- $options['tags'][] = $term;
- }
- }
- }
-
- // Atom enclosures -> attachment URLs
- foreach ($activity->enclosures as $href) {
- // @todo FIXME: Save these locally or....?
- $options['urls'][] = $href;
- }
+ $options = array('is_local' => Notice::REMOTE);
try {
- $saved = Notice::saveNew($profile->id,
- $content,
- 'ostatus',
- $options);
- if ($saved instanceof Notice) {
- Ostatus_source::saveNew($saved, $this, $method);
- if (!empty($attachment)) {
- File_to_post::processNew($attachment->id, $saved->id);
- }
- }
+ $stored = Notice::saveActivity($activity, $actor, $options);
+ Ostatus_source::saveNew($stored, $this, $method);
} catch (Exception $e) {
common_log(LOG_ERR, "OStatus save of remote message $sourceUri failed: " . $e->getMessage());
throw $e;
END_OF_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
- if (empty($args[0]) || !Validate::uri($args[0])) {
+ $validate = new Validate();
+
+ if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}
END_OF_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
- if (empty($args[0]) || !Validate::uri($args[0])) {
+ $validate = new Validate();
+
+ if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}
END_OF_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
- if (empty($args[0]) || !Validate::uri($args[0])) {
+ $validate = new Validate();
+
+ if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}
--- /dev/null
- function isReadOnly($args)
+ <?php
+ /**
+ * Public XRDS for OpenID
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Robin Millette <millette@status.net>
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ if (!defined('GNUSOCIAL')) { exit(1); }
+
+ require_once __DIR__.'/../openid.php';
+
+ /**
+ * Public XRDS
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
+ class PublicxrdsAction extends Action
+ {
+ /**
+ * Is read only?
+ *
+ * @return boolean true
+ */
++ function isReadOnly(array $args=array())
+ {
+ return true;
+ }
+
+ /**
+ * Class handler.
+ *
+ * @param array $args array of arguments
+ *
+ * @return nothing
+ */
+ protected function handle()
+ {
+ parent::handle();
+ $xrdsOutputter = new XRDSOutputter();
+ $xrdsOutputter->startXRDS();
+ Event::handle('StartPublicXRDS', array($this,&$xrdsOutputter));
+ Event::handle('EndPublicXRDS', array($this,&$xrdsOutputter));
+ $xrdsOutputter->endXRDS();
+ }
+ }
unset($_DB_DATAOBJECT['CONNECTIONS']);
}
- function getTimeline($flink, $timelineUri = 'home_timeline')
+ function getTimeline(Foreign_link $flink, $timelineUri = 'home_timeline')
{
- if (empty($flink)) {
- common_log(LOG_ERR, $this->name() .
- " - Can't retrieve Foreign_link for foreign ID $fid");
- return;
- }
-
- common_log(LOG_DEBUG, $this->name() . ' - Trying to get ' . $timelineUri .
+ common_debug($this->name() . ' - Trying to get ' . $timelineUri .
' timeline for Twitter user ' . $flink->foreign_id);
$client = null;
$login = true;
return false;
}
--
++
return true;
}
--- /dev/null
-require_once INSTALLDIR.'/scripts/commandline.inc';
+ #!/usr/bin/env php
+ <?php
+ /*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+ $shortoptions = 'i::n::u::y';
+ $longoptions = array('id=', 'nickname=', 'uri=', 'yes');
+
+ $helptext = <<<END_OF_DELETEUSER_HELP
+ deleteprofile.php [options]
+ deletes a profile from the database
+
+ -i --id ID of the profile
+ -n --nickname nickname of a local user
+ -u --uri OStatus profile URI (only remote users, requires OStatus plugin)
+ -y --yes do not wait for confirmation
+
+ END_OF_DELETEUSER_HELP;
+
++require_once INSTALLDIR.'/scripts/commandline.inc.php';
+
+ if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
+ $profile = Profile::getKV('id', $id);
+ if (!$profile instanceof Profile) {
+ print "Can't find profile with ID $id\n";
+ exit(1);
+ }
+ } else if (have_option('n', 'nickname')) {
+ $nickname = get_option_value('n', 'nickname');
+ $user = User::getKV('nickname', $nickname);
+ if (!$user instanceof User) {
+ print "Can't find user with nickname '$nickname'\n";
+ exit(1);
+ }
+ $profile = $user->getProfile();
+ } else if (have_option('u', 'uri')) {
+ $uri = get_option_value('u', 'uri');
+ $oprofile = Ostatus_profile::getKV('uri', $uri);
+ if (!$oprofile instanceof Ostatus_profile) {
+ print "Can't find profile with URI '$uri'\n";
+ exit(1);
+ }
+ $profile = $oprofile->localProfile();
+ } else {
+ print "You must provide either an ID, a URI or a nickname.\n";
+ exit(1);
+ }
+
+ if (!have_option('y', 'yes')) {
+ print "About to PERMANENTLY delete profile '".$profile->getNickname()."' ({$profile->id}). Are you sure? [y/N] ";
+ $response = fgets(STDIN);
+ if (strtolower(trim($response)) != 'y') {
+ print "Aborting.\n";
+ exit(0);
+ }
+ }
+
+ print "Deleting...";
+ $profile->delete();
+ print "DONE.\n";