From dd93420b08910a8bf9967dad7906351695d1ac55 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 30 Jan 2016 13:38:25 +0100 Subject: [PATCH] Merged stuff from upstream/master Signed-off-by: Roland Haeder --- actions/apiaccountverifycredentials.php | 2 +- actions/apimediaupload.php | 2 +- actions/replies.php | 2 +- classes/File.php | 3 ++ classes/File_redirection.php | 2 +- classes/Notice.php | 10 ++++++ lib/router.php | 2 +- plugins/Blacklist/BlacklistPlugin.php | 6 ++-- plugins/Bookmark/classes/Bookmark.php | 18 ++++++++++ plugins/Event/classes/RSVP.php | 4 +++ plugins/ForceGroup/ForceGroupPlugin.php | 2 +- .../GNUsocialPhotos/GNUsocialPhotosPlugin.php | 6 ++-- plugins/OStatus/classes/Ostatus_profile.php | 2 ++ plugins/OStatus/lib/salmonaction.php | 9 +++++ .../actions/twitterauthorization.php | 33 +++++++++++++++++++ 15 files changed, 91 insertions(+), 12 deletions(-) diff --git a/actions/apiaccountverifycredentials.php b/actions/apiaccountverifycredentials.php index 12daf3e1e6..f82060f547 100644 --- a/actions/apiaccountverifycredentials.php +++ b/actions/apiaccountverifycredentials.php @@ -57,7 +57,7 @@ class ApiAccountVerifyCredentialsAction extends ApiAuthAction */ protected function handle() { - parent::handle(); + parent::handle($args); if (!in_array($this->format, array('xml', 'json'))) { // TRANS: Client error displayed when coming across a non-supported API method. diff --git a/actions/apimediaupload.php b/actions/apimediaupload.php index c2b4a47b9a..86742e07bd 100644 --- a/actions/apimediaupload.php +++ b/actions/apimediaupload.php @@ -52,7 +52,7 @@ class ApiMediaUploadAction extends ApiAuthAction */ protected function handle() { - parent::handle(); + parent::handle($args); // Workaround for PHP returning empty $_POST and $_FILES when POST // length > post_max_size in php.ini diff --git a/actions/replies.php b/actions/replies.php index efe0d62beb..de6c0dac43 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -152,7 +152,7 @@ class RepliesAction extends ShowstreamAction $this->elementEnd('div'); } - public function isReadOnly(array $args = array()) + public function isReadOnly(array $args=array()) { return true; } diff --git a/classes/File.php b/classes/File.php index 2390f848de..735655489b 100644 --- a/classes/File.php +++ b/classes/File.php @@ -423,6 +423,9 @@ class File extends Managed_DataObject } } + // Debug log (convert crop to int to have TRUE being displayed as 1 and FALSE as 0) + /* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . ']: width=' . $width . ',height=' . $height . ',crop=' . intval($crop)); + return $image->getFileThumbnail($width, $height, $crop); } diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 4afb6d449a..1cbf6796c0 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -397,4 +397,4 @@ class File_redirection extends Managed_DataObject return $this->file; } -} \ No newline at end of file +} diff --git a/classes/Notice.php b/classes/Notice.php index 53832def80..2d3ed9942a 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -3121,5 +3121,15 @@ class Notice extends Managed_DataObject print "."; } print "\n"; + + /** + * Checks whether this notice is in "private scope" (non-public notice) + * + * @return $isPrivate Whether this notice is private + */ + public function isPrivateScope () + { + return ($this->scope != Notice::SITE_SCOPE && + $this->scope != Notice::PUBLIC_SCOPE); } } diff --git a/lib/router.php b/lib/router.php index 1bbcd820a7..bf8cb2b833 100644 --- a/lib/router.php +++ b/lib/router.php @@ -182,7 +182,7 @@ class Router foreach (array('profile', 'avatar', 'password', 'im', 'oauthconnections', 'oauthapps', 'email', 'sms', 'url') as $s) { - $m->connect('settings/'.$s, array('action' => $s.'settings')); + $m->connect('settings/' . $s, array('action' => $s . 'settings')); } if (common_config('oldschool', 'enabled')) { diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php index 1780f42e62..d1ee2912af 100644 --- a/plugins/Blacklist/BlacklistPlugin.php +++ b/plugins/Blacklist/BlacklistPlugin.php @@ -433,17 +433,17 @@ class BlacklistPlugin extends Plugin return $hostname; } - function onStartHandleFeedEntry($activity) + function onStartHandleFeedEntry(Activity $activity) { return $this->_checkActivity($activity); } - function onStartHandleSalmon($activity) + function onStartHandleSalmon(Activity $activity) { return $this->_checkActivity($activity); } - function _checkActivity($activity) + function _checkActivity(Activity $activity) { $actor = $activity->actor; diff --git a/plugins/Bookmark/classes/Bookmark.php b/plugins/Bookmark/classes/Bookmark.php index b593bc1909..7fd3f53ac1 100644 --- a/plugins/Bookmark/classes/Bookmark.php +++ b/plugins/Bookmark/classes/Bookmark.php @@ -92,12 +92,16 @@ class Bookmark extends Managed_DataObject * @return Bookmark The found bookmark object. * @throws NoResultException When you don't find it after all. */ +<<<<<<< .merge_file_ZPs3Af static public function fromStored(Notice $stored) { return self::getByPK(array('uri' => $stored->getUri())); } public function getStored() +======= + static function getByNotice(Notice $notice) +>>>>>>> .merge_file_eD7Wwf { return Notice::getByKeys(array('uri' => $this->getUri())); } @@ -157,7 +161,12 @@ class Bookmark extends Managed_DataObject * * @return Bookmark the Bookmark object */ +<<<<<<< .merge_file_ZPs3Af static function saveActivityObject(ActivityObject $actobj, Notice $stored) +======= + static function saveNew(Profile $profile, $title, $url, $rawtags, $description, + array $options=array()) +>>>>>>> .merge_file_eD7Wwf { $url = null; // each extra element is array('tagname', array('attr'=>'val', ...), 'content') @@ -177,11 +186,20 @@ class Bookmark extends Managed_DataObject throw new ClientException(sprintf(_m('Expected exactly 1 link rel=related in a Bookmark, got %1$d.'), count($relLinkEls))); } +<<<<<<< .merge_file_ZPs3Af if (!strlen($actobj->title)) { throw new ClientException(_m('You must provide a non-empty title.')); } if (!common_valid_http_url($url)) { throw new ClientException(_m('Only web bookmarks can be posted (HTTP or HTTPS).')); +======= + if (array_key_exists('uri', $options)) { + $other = Bookmark::getKV('uri', $options['uri']); + if (!empty($other)) { + // TRANS: Client exception thrown when trying to save a new bookmark that already exists. + throw new ClientException(_m('Bookmark already exists.')); + } +>>>>>>> .merge_file_eD7Wwf } try { diff --git a/plugins/Event/classes/RSVP.php b/plugins/Event/classes/RSVP.php index f6b8c0aa7c..7fa76d7151 100644 --- a/plugins/Event/classes/RSVP.php +++ b/plugins/Event/classes/RSVP.php @@ -91,7 +91,11 @@ class RSVP extends Managed_DataObject ); } +<<<<<<< .merge_file_oq2F7C static public function beforeSchemaUpdate() +======= + function saveNew(Profile $profile, $event, $verb, array $options = array()) +>>>>>>> .merge_file_L3oA6C { $table = strtolower(get_called_class()); $schema = Schema::get(); diff --git a/plugins/ForceGroup/ForceGroupPlugin.php b/plugins/ForceGroup/ForceGroupPlugin.php index 56e33355e8..a27436e6fa 100644 --- a/plugins/ForceGroup/ForceGroupPlugin.php +++ b/plugins/ForceGroup/ForceGroupPlugin.php @@ -49,7 +49,7 @@ class ForceGroupPlugin extends Plugin * @param Notice $notice * @return boolean event hook return */ - function onStartNoticeDistribute($notice) + function onStartNoticeDistribute(Notice $notice) { $profile = $notice->getProfile(); diff --git a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php index 906509fef5..5e0f3f780e 100644 --- a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php +++ b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php @@ -54,7 +54,7 @@ class GNUsocialPhotosPlugin extends Plugin return true; } - function onStartNoticeDistribute($notice) + function onStartNoticeDistribute(Notice $notice) { common_log(LOG_INFO, "event: StartNoticeDistribute"); if (GNUsocialPhotoTemp::$tmp) { @@ -84,7 +84,7 @@ class GNUsocialPhotosPlugin extends Plugin } - function onStartHandleFeedEntry($activity) + function onStartHandleFeedEntry(Activity $activity) { common_log(LOG_INFO, 'photo plugin: onEndAtomPubNewActivity'); $oprofile = Ostatus_profile::ensureActorProfile($activity); @@ -121,7 +121,7 @@ class GNUsocialPhotosPlugin extends Plugin return true; } - function onStartShowNoticeItem($action) + function onStartShowNoticeItem(Action $action) { $photo = GNUsocialPhoto::getKV('notice_id', $action->notice->id); if($photo) { diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 07432d78fa..b4df92e2da 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -894,10 +894,12 @@ class Ostatus_profile extends Managed_DataObject $temp_filename = tempnam(common_get_temp_dir(), 'listener_avatar'); try { $imgData = HTTPClient::quickGet($url); + // Make sure it's at least an image file. ImageFile can do the rest. if (false === getimagesizefromstring($imgData)) { throw new UnsupportedMediaException(_('Downloaded group avatar was not an image.')); } + file_put_contents($temp_filename, $imgData); unset($imgData); // No need to carry this in memory. diff --git a/plugins/OStatus/lib/salmonaction.php b/plugins/OStatus/lib/salmonaction.php index 2f48042820..f328f0916a 100644 --- a/plugins/OStatus/lib/salmonaction.php +++ b/plugins/OStatus/lib/salmonaction.php @@ -79,8 +79,17 @@ class SalmonAction extends Action $this->clientError($e->getMessage()); } +<<<<<<< .merge_file_l1W8if // Cryptographic verification test, throws exception on failure $magic_env->verify($this->actor); +======= + // Cryptographic verification test + if (!$magic_env->verify($this->actor)) { + common_debug("Salmon signature verification failed."); + // TRANS: Client error. + $this->clientError(_m('Salmon signature verification failed.')); + } +>>>>>>> .merge_file_ISiK5f return true; } diff --git a/plugins/TwitterBridge/actions/twitterauthorization.php b/plugins/TwitterBridge/actions/twitterauthorization.php index c9b892b640..d3df46bfef 100644 --- a/plugins/TwitterBridge/actions/twitterauthorization.php +++ b/plugins/TwitterBridge/actions/twitterauthorization.php @@ -56,17 +56,50 @@ class TwitterauthorizationAction extends FormAction var $access_token = null; var $verifier = null; +<<<<<<< .merge_file_Bq71r4 protected $needLogin = false; // authorization page can also be used to create a new user +======= + /** + * Initialize class members. Looks for 'oauth_token' parameter. + * + * @param array $args misc. arguments + * + * @return boolean true + */ + function prepare(array $args=array()) + { + parent::prepare($args); +>>>>>>> .merge_file_Ad5nH4 protected function doPreparation() { $this->oauth_token = $this->arg('oauth_token'); $this->verifier = $this->arg('oauth_verifier'); +<<<<<<< .merge_file_Bq71r4 if ($this->scoped instanceof Profile) { try { $flink = Foreign_link::getByUserID($this->scoped->getID(), TWITTER_SERVICE); $fuser = $flink->getForeignUser(); +======= + return true; + } + + /** + * Handler method + * + * @param array $args is ignored since it's now passed in in prepare() + * + * @return nothing + */ + function handle(array $args=array()) + { + parent::handle($args); + + if (common_logged_in()) { + $user = common_current_user(); + $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE); +>>>>>>> .merge_file_Ad5nH4 // If there's already a foreign link record and a foreign user // (no exceptions were thrown when fetching either of them...) -- 2.30.2