From: Roland Haeder Date: Sun, 12 Apr 2015 14:14:02 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' into social-master X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=200721a2f45dbfa5463ba32165c7f60e517f0622;p=quix0rs-gnu-social.git Merge remote-tracking branch 'upstream/master' into social-master Signed-off-by: Roland Haeder Conflicts: actions/apifriendshipsdestroy.php actions/apifriendshipsexists.php actions/apifriendshipsshow.php actions/replies.php actions/showstream.php classes/File.php classes/Notice.php lib/docfile.php lib/framework.php lib/noticeform.php plugins/APC/APCPlugin.php plugins/Adsense/AdsensePlugin.php plugins/Aim/AimPlugin.php plugins/Aim/lib/aimmanager.php plugins/Blog/BlogPlugin.php plugins/Blog/classes/Blog_entry.php plugins/Directory/actions/groupdirectory.php plugins/Directory/actions/userdirectory.php plugins/Irc/IrcPlugin.php plugins/Irc/extlib/phergie/Tests/Phergie/Plugin/HandlerTest.php plugins/Irc/lib/ircmanager.php plugins/OStatus/OStatusPlugin.php plugins/OStatus/classes/Ostatus_profile.php plugins/Share/actions/apitimelineretweetedtome.php plugins/Spotify/SpotifyPlugin.php plugins/TinyMCE/TinyMCEPlugin.php plugins/VideoThumbnails/VideoThumbnailsPlugin.php plugins/WebFinger/WebFingerPlugin.php plugins/XCache/XCachePlugin.php plugins/YammerImport/actions/yammeradminpanel.php plugins/YammerImport/actions/yammerauth.php plugins/YammerImport/lib/yammerimporter.php --- 200721a2f45dbfa5463ba32165c7f60e517f0622 diff --cc actions/replies.php index 11d9c7c706,49098d0950..1e0e9d64c3 --- a/actions/replies.php +++ b/actions/replies.php @@@ -49,20 -43,8 +43,7 @@@ class RepliesAction extends ManagedActi var $page = null; var $notice; - /** - * Prepare the object - * - * Check the input values and initialize the object. - * Shows an error page on bad input. - * - * @param array $args $_REQUEST data - * - * @return boolean success flag - */ - function prepare(array $args=array()) - protected function doPreparation() { - parent::prepare($args); - $nickname = common_canonical_nickname($this->arg('nickname')); $this->user = User::getKV('nickname', $nickname); diff --cc classes/File_redirection.php index 292e6372a6,8c64c58a80..d52b29feae --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@@ -332,8 -346,9 +346,9 @@@ class File_redirection extends Managed_ return $out_url; } - function saveNew($data, $file_id, $url) { + function saveNew(array $data, $file_id, $url) { $file_redir = new File_redirection; + $file_redir->urlhash = File::hashurl($short_url); $file_redir->url = $url; $file_redir->file_id = $file_id; $file_redir->redirections = intval($data['redirects']); diff --cc classes/Notice.php index 263cc4e323,38e31cb274..e155ccfcc0 --- a/classes/Notice.php +++ b/classes/Notice.php @@@ -1768,13 -1768,12 +1770,12 @@@ class Notice extends Managed_DataObjec $ids = array(); - foreach ($gis[$this->id] as $gi) - { + foreach ($gis[$this->id] as $gi) { $ids[] = $gi->group_id; } - + $groups = User_group::multiGet('id', $ids); - $this->_groups[$this->id] = $groups->fetchAll(); + $this->_setGroups($groups->fetchAll()); return $this->_groups[$this->id]; } @@@ -2780,28 -2722,22 +2757,22 @@@ } } - // Only for followers of the author - - $author = null; + if (!$foundOne) { + return false; + } + } - if ($scope & Notice::FOLLOWER_SCOPE) { + if ($scope & Notice::FOLLOWER_SCOPE || $this->getProfile()->isPrivateStream()) { - try { - $author = $this->getProfile(); - } catch (Exception $e) { - return false; - } - - if (!Subscription::exists($profile, $author)) { - return false; - } + if (!Subscription::exists($profile, $this->getProfile())) { + return false; } - - return !$this->isHiddenSpam($profile); } + + return !$this->isHiddenSpam($profile); } - function isHiddenSpam($profile) { + function isHiddenSpam(Profile $profile=null) { // Hide posts by silenced users from everyone but moderators. @@@ -2866,10 -2802,9 +2837,9 @@@ return $scope; } - static function fillProfiles($notices) + static function fillProfiles(array $notices) { $map = self::getProfiles($notices); - foreach ($notices as $entry=>$notice) { try { if (array_key_exists($notice->profile_id, $map)) { @@@ -2890,22 -2825,17 +2860,17 @@@ foreach ($notices as $notice) { $ids[] = $notice->profile_id; } - $ids = array_unique($ids); - - return Profile::pivotGet('id', $ids); + return Profile::pivotGet('id', $ids); } - static function fillGroups(&$notices) + static function fillGroups(array &$notices) { $ids = self::_idsOf($notices); - $gis = Group_inbox::listGet('notice_id', $ids); - $gids = array(); - foreach ($gis as $id => $gi) - { + foreach ($gis as $id => $gi) { foreach ($gi as $g) { $gids[] = $g->group_id; @@@ -2936,17 -2864,14 +2899,14 @@@ return array_keys($ids); } - static function fillAttachments(&$notices) + static function fillAttachments(array &$notices) { $ids = self::_idsOf($notices); - $f2pMap = File_to_post::listGet('post_id', $ids); - $fileIds = array(); - foreach ($f2pMap as $noticeId => $f2ps) { foreach ($f2ps as $f2p) { - $fileIds[] = $f2p->file_id; + $fileIds[] = $f2p->file_id; } } diff --cc lib/apiaction.php index e672f3a7e6,0eea08bed6..0eea08bed6 mode 100644,100755..100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php diff --cc lib/docfile.php index 2e2afbd014,3331bcd19d..583f7ebc9b --- a/lib/docfile.php +++ b/lib/docfile.php @@@ -105,8 -113,8 +105,8 @@@ class DocFil $paths = array(INSTALLDIR.'/local/doc-src/', INSTALLDIR.'/doc-src/'); - $site = StatusNet::currentSite(); + $site = GNUsocial::currentSite(); - + if (!empty($site)) { array_unshift($paths, INSTALLDIR.'/local/doc-src/'.$site.'/'); } @@@ -119,8 -127,8 +119,8 @@@ $paths = array(INSTALLDIR.'/local/mail-src/', INSTALLDIR.'/mail-src/'); - $site = StatusNet::currentSite(); + $site = GNUsocial::currentSite(); - + if (!empty($site)) { array_unshift($paths, INSTALLDIR.'/local/mail-src/'.$site.'/'); } diff --cc lib/framework.php index b7fd44512c,b71f365c24..c534bebd04 --- a/lib/framework.php +++ b/lib/framework.php @@@ -102,31 -102,9 +102,31 @@@ function addPlugin($name, array $attrs= function _have_config() { - return StatusNet::haveConfig(); + return GNUsocial::haveConfig(); } +function common_get_temp_dir() +{ + // Try to get it from php.ini first + $temp_path = trim(ini_get('upload_tmp_dir')); + + // Is it empty? + if (strlen($temp_path) == 0) { + // Then try sys_get_temp_dir() + $temp_path = trim(sys_get_temp_dir()); + + // Still empty? + if (strlen($temp_path) == 0) { + // Then set it to /tmp (ugly) + // @TODO Hard-coded non-Windows stuff! + $temp_path = '/tmp'; + } + } + + // Return found path + return $temp_path; +} + function GNUsocial_class_autoload($cls) { if (file_exists(INSTALLDIR.'/classes/' . $cls . '.php')) { diff --cc lib/implugin.php index 9542d4d206,5b0f3dbe09..ff6eed3aa5 --- a/lib/implugin.php +++ b/lib/implugin.php @@@ -528,11 -530,16 +530,16 @@@ abstract class ImPlugin extends Plugi * * @return boolean hook return */ - function onEndInitializeQueueManager($manager) + function onEndInitializeQueueManager(QueueManager $manager) { - $manager->connect($this->transport . '-in', new ImReceiverQueueHandler($this), 'im'); - $manager->connect($this->transport, new ImQueueHandler($this)); - $manager->connect($this->transport . '-out', new ImSenderQueueHandler($this), 'im'); + // If we don't require CLI mode, or if we do and GNUSOCIAL_CLI _is_ set, then connect the transports + // This check is made mostly because some IM plugins can't deliver to transports unless they + // have continously running daemons (such as XMPP) and we can't have that over HTTP requests. + if (!$this->requires_cli || defined('GNUSOCIAL_CLI')) { + $manager->connect($this->transport . '-in', new ImReceiverQueueHandler($this), 'im'); + $manager->connect($this->transport, new ImQueueHandler($this)); + $manager->connect($this->transport . '-out', new ImSenderQueueHandler($this), 'im'); + } return true; } diff --cc lib/noticeform.php index 161eb67a50,f9b2309119..698d1f6a60 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@@ -97,18 -97,18 +97,14 @@@ class NoticeForm extends For * 'location_id' ID of location * 'location_ns' Namespace of location */ - function __construct($action, $options=null) + function __construct(Action $action, array $options = array()) { - // XXX: ??? Is this to keep notice forms distinct? - // Do we have to worry about sub-second race conditions? - // XXX: Needs to be above the parent::__construct() call...? + parent::__construct($action); // When creating a notice form we don't want to collide with // possibly existing HTML elements, as naming conventions are similar. - $this->id_suffix = rand(); - - if (is_null($options)) { - $options = array(); - } + $this->id_suffix = mt_rand(); - parent::__construct($action); - $this->actionName = $action->trimmed('action'); $prefill = array('content', 'inreplyto', 'lat', @@@ -260,12 -269,12 +265,12 @@@ 'type' => 'checkbox', 'class' => 'checkbox', 'id' => $this->id() . '-notice_data-geo', - 'checked' => true, // ? + 'checked' => false, // Must be unchecked by default )); - $this->out->text(' '); - // TRANS: Field label to add location to a notice. - $this->out->text(_('Share my location')); - $this->out->elementEnd('label'); + $this->out->element('label', array('class' => 'notice_data-geo', + 'for' => $this->id().'-notice_data-geo'), + // TRANS: Checkbox label to allow sharing geo location in notices. + _('Share my location')); $this->out->elementEnd('div'); // TRANS: Text to not share location for a notice in notice form. diff --cc plugins/DomainStatusNetwork/actions/globalapi.php index faf38378ec,d47a254940..b283ce8da6 --- a/plugins/DomainStatusNetwork/actions/globalapi.php +++ b/plugins/DomainStatusNetwork/actions/globalapi.php @@@ -57,9 -57,9 +57,9 @@@ class GlobalApiAction extends Actio * @return boolean continuation flag */ - function prepare($args) + function prepare(array $args=array()) { - StatusNet::setApi(true); // reduce exception reports to aid in debugging + GNUsocial::setApi(true); // reduce exception reports to aid in debugging parent::prepare($args); diff --cc plugins/GNUsocialVideo/classes/Video.php index 9746948e16,09c1f6b844..9ba395d8ca --- a/plugins/GNUsocialVideo/classes/Video.php +++ b/plugins/GNUsocialVideo/classes/Video.php @@@ -39,11 -39,11 +39,11 @@@ class Video extends Managed_DataObjec public $__table = 'video'; // table name public $id; // char (36) // UUID - public $uri; // varchar (255) // This is the corresponding notice's uri. - public $url; // varchar (255) + public $uri; // varchar (191) This is the corresponding notice's uri. not 255 because utf8mb4 takes more space + public $url; // varchar (191) not 255 because utf8mb4 takes more space public $profile_id; // int - public static function getByNotice($notice) + public static function getByNotice(Notice $notice) { return self::getKV('uri', $notice->uri); } diff --cc plugins/LinkPreview/actions/oembedproxy.php index 095cfe03d7,97b0942441..c0473fb597 --- a/plugins/LinkPreview/actions/oembedproxy.php +++ b/plugins/LinkPreview/actions/oembedproxy.php @@@ -46,10 -46,10 +46,10 @@@ if (!defined('STATUSNET') && !defined(' */ class OembedproxyAction extends OembedAction { - function handle($args) + function handle(array $args=array()) { // Trigger short error responses; not a human-readable web page. - StatusNet::setApi(true); + GNUsocial::setApi(true); // We're not a general oEmbed proxy service; limit to valid sessions. $token = $this->trimmed('token'); diff --cc plugins/Share/actions/apistatusesretweets.php index 0000000000,7af4cd3ec6..82e86b9264 mode 000000,100644..100644 --- a/plugins/Share/actions/apistatusesretweets.php +++ b/plugins/Share/actions/apistatusesretweets.php @@@ -1,0 -1,126 +1,126 @@@ + . + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + + if (!defined('STATUSNET')) { + exit(1); + } + + /** + * Show up to 100 repeats of a notice + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + class ApiStatusesRetweetsAction extends ApiAuthAction + { + const MAXCOUNT = 100; + + var $original = null; + var $cnt = self::MAXCOUNT; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + */ - function prepare($args) ++ function prepare(array $args=array()) + { + parent::prepare($args); + + $id = $this->trimmed('id'); + + $this->original = Notice::getKV('id', $id); + + if (empty($this->original)) { + // TRANS: Client error displayed trying to display redents of a non-exiting notice. + $this->clientError(_('No such notice.'), + 400, $this->format); + return false; + } + + $cnt = $this->trimmed('count'); + + if (empty($cnt) || !is_integer($cnt)) { + $cnt = 100; + } else { + $this->cnt = min((int)$cnt, self::MAXCOUNT); + } + + return true; + } + + /** + * Handle the request + * + * Make a new notice for the update, save it, and show it + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ - function handle($args) ++ function handle(array $args=array()) + { + parent::handle($args); + + $strm = $this->original->repeatStream($this->cnt); + + switch ($this->format) { + case 'xml': + $this->showXmlTimeline($strm); + break; + case 'json': + $this->showJsonTimeline($strm); + break; + default: + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), $code = 404); + break; + } + } + + /** + * 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; + } + } diff --cc plugins/Share/actions/apitimelineretweetedbyme.php index 0000000000,01f3fe378b..4ad4e269af mode 000000,100644..100644 --- a/plugins/Share/actions/apitimelineretweetedbyme.php +++ b/plugins/Share/actions/apitimelineretweetedbyme.php @@@ -1,0 -1,84 +1,84 @@@ + . + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + + if (!defined('STATUSNET')) { + exit(1); + } + + /** + * Show authenticating user's most recent repeats + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + class ApiTimelineRetweetedByMeAction extends ApiAuthAction + { + const DEFAULTCOUNT = 20; + const MAXCOUNT = 200; + const MAXNOTICES = 3200; + + var $repeats = null; + var $cnt = self::DEFAULTCOUNT; + var $page = 1; + var $since_id = null; + var $max_id = null; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ - function prepare($args) ++ function prepare(array $args=array()) + { + parent::prepare($args); + + // TRANS: Server error displayed calling unimplemented API method for 'retweeted by me'. + $this->serverError(_('Unimplemented.'), 503); + + return false; + } + + /** + * Return true if read only. + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ - function isReadOnly($args) ++ function isReadOnly(array $args=array()) + { + return true; + } + } diff --cc plugins/Share/actions/apitimelineretweetedtome.php index 0000000000,92d4b358fe..14091eedee mode 000000,100644..100644 --- a/plugins/Share/actions/apitimelineretweetedtome.php +++ b/plugins/Share/actions/apitimelineretweetedtome.php @@@ -1,0 -1,162 +1,162 @@@ + . + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + + if (!defined('GNUSOCIAL')) { exit(1); } + + /** + * Show most recent notices that are repeats in user's inbox + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + class ApiTimelineRetweetedToMeAction extends ApiAuthAction + { + const DEFAULTCOUNT = 20; + const MAXCOUNT = 200; + const MAXNOTICES = 3200; + + var $repeats = null; + var $cnt = self::DEFAULTCOUNT; + var $page = 1; + var $since_id = null; + var $max_id = null; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + */ + protected function prepare(array $args=array()) + { + parent::prepare($args); + + $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1); + + $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt)); + + $since_id = $this->int('since_id'); + + $max_id = $this->int('max_id'); + + return true; + } + + /** + * Handle the request + * + * show a timeline of the user's repeated notices + * + * @return void + */ + protected function handle() + { + parent::handle(); + + $offset = ($this->page-1) * $this->cnt; + $limit = $this->cnt; + + // TRANS: Title for Atom feed "repeated to me". %s is the user nickname. + $title = sprintf(_("Repeated to %s"), $this->scoped->getNickname()); + $subtitle = sprintf( + // @todo FIXME: $profile is not defined. + // TRANS: Subtitle for API action that shows most recent notices that are repeats in user's inbox. + // TRANS: %1$s is the sitename, %2$s is a user nickname, %3$s is a user profile name. + _('%1$s notices that were to repeated to %2$s / %3$s.'), + $sitename, $this->scoped->getNickname(), $profile->getBestName() + ); + $taguribase = TagURI::base(); + $id = "tag:$taguribase:RepeatedToMe:" . $this->scoped->id; + + $link = common_local_url( + 'all', + array('nickname' => $this->scoped->getNickname()) + ); + + $strm = $this->scoped->repeatedToMe($offset, $limit, $this->since_id, $this->max_id); + + switch ($this->format) { + case 'xml': + $this->showXmlTimeline($strm); + break; + case 'json': + $this->showJsonTimeline($strm); + break; + case 'atom': + header('Content-Type: application/atom+xml; charset=utf-8'); + + $atom = new AtomNoticeFeed($this->scoped->getUser()); + + $atom->setId($id); + $atom->setTitle($title); + $atom->setSubtitle($subtitle); + $atom->setUpdated('now'); + $atom->addLink($link); + + $id = $this->arg('id'); + + $atom->setSelfLink($self); + $atom->addEntryFromNotices($strm); + + $this->raw($atom->getString()); + + break; + case 'as': + header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE); + $doc = new ActivityStreamJSONDocument($this->scoped->getUser()); + $doc->setTitle($title); + $doc->addLink($link, 'alternate', 'text/html'); + $doc->addItemsFromNotices($strm); + $this->raw($doc->asString()); + break; + default: + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), $code = 404); + break; + } + } + + /** + * 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; + } + } diff --cc plugins/Share/actions/apitimelineretweetsofme.php index 0000000000,fe90213665..49990a5335 mode 000000,100644..100644 --- a/plugins/Share/actions/apitimelineretweetsofme.php +++ b/plugins/Share/actions/apitimelineretweetsofme.php @@@ -1,0 -1,172 +1,172 @@@ + . + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + + if (!defined('STATUSNET')) { + exit(1); + } + + /** + * Show authenticating user's most recent notices that have been repeated + * + * @category API + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + class ApiTimelineRetweetsOfMeAction extends ApiAuthAction + { + const DEFAULTCOUNT = 20; + const MAXCOUNT = 200; + const MAXNOTICES = 3200; + + var $repeats = null; + var $cnt = self::DEFAULTCOUNT; + var $page = 1; + var $since_id = null; + var $max_id = null; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + */ - function prepare($args) ++ function prepare(array $args=array()) + { + parent::prepare($args); + + $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1); + + $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt)); + + $since_id = $this->int('since_id'); + + $max_id = $this->int('max_id'); + + return true; + } + + /** + * Handle the request + * + * show a timeline of the user's repeated notices + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ - function handle($args) ++ function handle(array $args=array()) + { + parent::handle($args); + + $offset = ($this->page-1) * $this->cnt; + $limit = $this->cnt; + + // TRANS: Title of list of repeated notices of the logged in user. + // TRANS: %s is the nickname of the logged in user. + $title = sprintf(_("Repeats of %s"), $this->auth_user->nickname); + $sitename = common_config('site', 'name'); + + $profile = $this->auth_user->getProfile(); + + $subtitle = sprintf( + // TRANS: Subtitle of API time with retweets of me. + // TRANS: %1$s is the StatusNet sitename, %2$s is the user nickname, %3$s is the user profile name. + _('%1$s notices that %2$s / %3$s has repeated.'), + $sitename, $this->auth_user->nickname, $profile->getBestName() + ); + + $taguribase = TagURI::base(); + $id = "tag:$taguribase:RepeatsOfMe:" . $this->auth_user->id; + + $link = common_local_url( + 'all', + array('nickname' => $this->auth_user->nickname) + ); + + // This is a really bad query for some reason + + if (!common_config('performance', 'high')) { + $strm = $this->auth_user->repeatsOfMe($offset, $limit, $this->since_id, $this->max_id); + } else { + $strm = new Notice(); + $strm->whereAdd('0 = 1'); + $strm->find(); + } + + switch ($this->format) { + case 'xml': + $this->showXmlTimeline($strm); + break; + case 'json': + $this->showJsonTimeline($strm); + break; + case 'atom': + header('Content-Type: application/atom+xml; charset=utf-8'); + $atom = new AtomNoticeFeed($this->auth_user); + $atom->setId($id); + $atom->setTitle($title); + $atom->setSubtitle($subtitle); + $atom->setUpdated('now'); + $atom->addLink($link); + $atom->setSelfLink($this->getSelfUri()); + $atom->addEntryFromNotices($strm); + $this->raw($atom->getString()); + break; + case 'as': + header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE); + $doc = new ActivityStreamJSONDocument($this->auth_user); + $doc->setTitle($title); + $doc->addLink($link, 'alternate', 'text/html'); + $doc->addItemsFromNotices($strm); + $this->raw($doc->asString()); + break; + default: + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); + break; + } + } + + /** + * 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; + } + } diff --cc plugins/WebFinger/WebFingerPlugin.php index 80da17dff6,e5759e886c..dff3c86bc1 --- a/plugins/WebFinger/WebFingerPlugin.php +++ b/plugins/WebFinger/WebFingerPlugin.php @@@ -31,7 -31,14 +31,14 @@@ if (!defined('GNUSOCIAL')) { exit(1); class WebFingerPlugin extends Plugin { + public $http_alias = false; + + public function initialize() + { + common_config_set('webfinger', 'http_alias', $this->http_alias); + } + - public function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $m->connect('.well-known/host-meta', array('action' => 'hostmeta')); $m->connect('.well-known/host-meta.:format', diff --cc scripts/commandline.inc.php index 1244187b87,0000000000..5f2e1d86ea mode 100644,000000..100644 --- a/scripts/commandline.inc.php +++ b/scripts/commandline.inc.php @@@ -1,248 -1,0 +1,250 @@@ +. + */ + +// -*- mode: php -*- + +# Abort if called from a web server + +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(); +} + +define('GNUSOCIAL', true); +define('STATUSNET', true); //compatibility + ++define('GNUSOCIAL_CLI', true); // to know we're in a CLI environment ++ +// Set various flags so we don't time out on long-running processes + +ini_set("max_execution_time", "0"); +ini_set("max_input_time", "0"); +set_time_limit(0); +mb_internal_encoding('UTF-8'); +error_reporting(0); +# DEBUG: error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); + +// Add extlib to our path so we can get Console_Getopt + +$_extra_path = array(INSTALLDIR.'/extlib/'); + +set_include_path(implode(PATH_SEPARATOR, $_extra_path) . PATH_SEPARATOR . get_include_path()); + +require_once 'Console/Getopt.php'; + +// Note: $shortoptions and $longoptions should be pre-defined! + +$_default_shortoptions = 'qvhc:s:p:'; + +$_default_longoptions = array('quiet', 'verbose', 'help', 'conf=', 'server=', 'path='); + +if (isset($shortoptions)) { + $shortoptions .= $_default_shortoptions; +} else { + $shortoptions = $_default_shortoptions; +} + +if (isset($longoptions)) { + $longoptions = array_merge($longoptions, $_default_longoptions); +} else { + $longoptions = $_default_longoptions; +} + +$parser = new Console_Getopt(); + +$result = $parser->getopt($argv, $shortoptions, $longoptions); + +if (PEAR::isError($result)) { + print $result->getMessage()."\n"; + exit(1); +} else { + list($options, $args) = $result; +} + +function show_help() +{ + global $helptext; + + $_default_help_text = << Use as config file + -s --server= Use as server name + -p --path= Use as path name + -h --help Show this message and quit. + +END_OF_DEFAULT; + if (isset($helptext)) { + print $helptext; + } + print $_default_help_text; + exit(0); +} + +foreach ($options as $option) { + + switch ($option[0]) { + case '--server': + case 's': + $server = $option[1]; + break; + + case '--path': + case 'p': + $path = $option[1]; + break; + + case '--conf': + case 'c': + $conffile = $option[1]; + break; + + case '--help': + case 'h': + show_help(); + } +} + +require_once INSTALLDIR . '/lib/common.php'; + +set_error_handler('common_error_handler'); + +// Set up the language infrastructure so we can localize anything that +// needs to be sent out to users, such as mail notifications. +common_init_language(); + +function _make_matches($opt, $alt) +{ + $matches = array(); + + if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + + return $matches; +} + +function have_option($opt, $alt=null) +{ + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return true; + } + } + + return false; +} + +function get_option_value($opt, $alt=null) +{ + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return $option[1]; + } + } + + return null; +} + +class NoUserArgumentException extends Exception +{ +} + +function getUser() +{ + $user = null; + + if (have_option('i', 'id')) { + $id = get_option_value('i', 'id'); + $user = User::getKV('id', $id); + if (empty($user)) { + throw new Exception("Can't find user with id '$id'."); + } + } else if (have_option('n', 'nickname')) { + $nickname = get_option_value('n', 'nickname'); + $user = User::getKV('nickname', $nickname); + if (empty($user)) { + throw new Exception("Can't find user with nickname '$nickname'"); + } + } else { + throw new NoUserArgumentException("No user argument specified."); + } + + return $user; +} + +/** "Printf not quiet" */ + +function printfnq() +{ + if (have_option('q', 'quiet')) { + return null; + } + + $cargs = func_num_args(); + + if ($cargs == 0) { + return 0; + } + + $args = func_get_args(); + $format = array_shift($args); + + return vprintf($format, $args); +} + +/** "Print when verbose" */ + +function printfv() +{ + if (!have_option('v', 'verbose')) { + return null; + } + + $cargs = func_num_args(); + + if ($cargs == 0) { + return 0; + } + + $args = func_get_args(); + $format = array_shift($args); + + return vprintf($format, $args); +}