]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'master' into social-master
authorRoland Haeder <roland@mxchange.org>
Tue, 10 Mar 2015 23:19:35 +0000 (00:19 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 10 Mar 2015 23:19:35 +0000 (00:19 +0100)
101 files changed:
.gitmodules [new file with mode: 0644]
classes/Confirm_address.php
classes/File.php
classes/File_redirection.php
classes/File_thumbnail.php
classes/Notice.php
lib/apiaction.php [changed mode: 0755->0644]
lib/default.php
lib/framework.php
lib/imagefile.php
lib/noticeform.php
lib/util.php
plugins/AccountManager/AccountManagerPlugin.php
plugins/ActivitySpam/ActivitySpamPlugin.php
plugins/ActivitySpam/classes/spam_score.php
plugins/Aim/extlib/phptoclib/aimclassw.php [changed mode: 0755->0644]
plugins/Aim/extlib/phptoclib/dconnection.php [changed mode: 0755->0644]
plugins/AntiBrute/AntiBrutePlugin.php [changed mode: 0755->0644]
plugins/Blacklist/BlacklistPlugin.php
plugins/Blog/classes/Blog_entry.php
plugins/BlogspamNet/BlogspamNetPlugin.php
plugins/Bookmark/BookmarkPlugin.php
plugins/Bookmark/classes/Bookmark.php
plugins/DirectionDetector/DirectionDetectorPlugin.php
plugins/DomainWhitelist/DomainWhitelistPlugin.php
plugins/Event/classes/Happening.php
plugins/Event/classes/RSVP.php
plugins/GNUsocialPhoto/classes/Photo.php
plugins/GNUsocialVideo/classes/Video.php
plugins/Irc/extlib/phergie/Phergie/Autoload.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Bot.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Config.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Connection.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Driver/Abstract.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Driver/Exception.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Driver/Streams.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Event/Request.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Event/Response.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Exception.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Hostmask.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Abstract.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Acl.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/AltNick.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/AudioScrobbler.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/AutoJoin.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Censor.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Ctcp.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Exception.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Handler.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Invisible.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Join.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Part.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Ping.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Pong.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Prioritize.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Quit.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Reload.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Plugin/Serve.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Process/Abstract.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Process/Exception.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Phergie/Tools/LogViewer/index.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Tests/Phergie/Plugin/Mock.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/Tests/Phergie/Plugin/TestNonInstantiablePluginFromFile.php [changed mode: 0755->0644]
plugins/Irc/extlib/phergie/phergie.php [changed mode: 0755->0644]
plugins/Minify/MinifyPlugin.php
plugins/Mobile/WAP20Plugin.php
plugins/MobileProfile/MobileProfilePlugin.php
plugins/ModHelper/ModHelperPlugin.php
plugins/ModLog/ModLogPlugin.php
plugins/ModPlus/ModPlusPlugin.php
plugins/Mollom/MollomPlugin.php
plugins/NoticeTitle/NoticeTitlePlugin.php
plugins/NoticeTitle/classes/Notice_title.php
plugins/OStatus/OStatusPlugin.php
plugins/OStatus/extlib/phpseclib/Crypt/RC2.php [changed mode: 0755->0644]
plugins/Oembed/classes/File_oembed.php
plugins/Poll/classes/Poll.php
plugins/Poll/classes/Poll_response.php
plugins/QnA/classes/QnA_Answer.php
plugins/QnA/classes/QnA_Question.php
plugins/QnA/forms/qnanewquestion.php
plugins/Recaptcha/RecaptchaPlugin.php
plugins/RegisterThrottle/RegisterThrottlePlugin.php
plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
plugins/SearchSub/classes/SearchSub.php
plugins/Spotify/SpotifyPlugin.php
plugins/Statistics/README.md [new symlink]
plugins/Statistics/StatisticsPlugin.php [new symlink]
plugins/Statistics/actions [new symlink]
plugins/SubMirror/classes/SubMirror.php
plugins/TagSub/classes/TagSub.php
plugins/TwitterBridge/daemons/synctwitterfriends.php [changed mode: 0755->0644]
plugins/TwitterBridge/daemons/twitterstatusfetcher.php [changed mode: 0755->0644]
plugins/UserFlag/UserFlagPlugin.php
plugins/UserLimit/UserLimitPlugin.php
plugins/WebFinger/WebFingerPlugin.php
scripts/fixup_group_profiles.php [new file with mode: 0755]
statistics_plugin [new submodule]
tests/oauth/fetch_temp_creds.php [changed mode: 0755->0644]
tests/oauth/fetch_token_creds.php [changed mode: 0755->0644]
tests/oauth/oauth_verify_creds.php [changed mode: 0755->0644]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..8714c3f
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "statistics_plugin"]
+       path = statistics_plugin
+       url = https://dev.pztrn.name/statistics_plugin.git
index 0ed7796ad40b8458de85c6538d166ad4ee38b13d..97c69872a60d1cb524c357e0a2b1f37a62a09b6f 100644 (file)
@@ -56,7 +56,7 @@ class Confirm_address extends Managed_DataObject
         return null;
     }
 
-    static function saveNew($user, $address, $addressType, $extra=null)
+    static function saveNew(User $user, $address, $addressType, $extra=null)
     {
         $ca = new Confirm_address();
 
index ce2f9401618286bcfd9485f8f3682add5c8df0f2..1fcc83dd8845f22943d406627ddda6d4be7d01fb 100644 (file)
@@ -394,17 +394,20 @@ class File extends Managed_DataObject
             }
         }
 
-        if ($width === null) {
+        if ($width === null || $width < 1) {
             $width = common_config('thumbnail', 'width');
             $height = common_config('thumbnail', 'height');
             $crop = common_config('thumbnail', 'crop');
         }
 
-        if ($height === null) {
+        if ($height === null || $height < 1) {
             $height = $width;
             $crop = true;
         }
 
+        // Debug log (convert crop to int to have TRUE being displayed as 1 and FALSE as 0)
+        common_debug('[' . __METHOD__ . ':' . __LINE__ . ']: width=' . $width . ',height=' . $height . ',crop=' . intval($crop));
+
         // Get proper aspect ratio width and height before lookup
         // We have to do it through an ImageFile object because of orientation etc.
         // Only other solution would've been to rotate + rewrite uploaded files.
@@ -434,8 +437,20 @@ class File extends Managed_DataObject
                 || $box['w'] < 1 || $box['x'] >= $image->width
                 || $box['h'] < 1 || $box['y'] >= $image->height) {
             // Fail on bad width parameter. If this occurs, it's due to algorithm in ImageFile->scaleToFit
-            common_debug("Boundary box parameters for resize of {$image->filepath} : ".var_export($box,true));
-            throw new ServerException('Bad thumbnail size parameters.');
+            common_debug("Boundary box parameters for resize of {$this->filepath} : ".var_export($box,true));
+            throw new ServerException('Bad thumbnail size parameters. maxsize=' .
+                common_config('thumbnail', 'maxsize') .
+                ',box[width]=' . $box['width'] .
+                ',box[height]=' . $box['height'] .
+                ',box[w]=' . $box['w'] .
+                ',box[h]=' . $box['h'] .
+                ',box[x]=' . $box['x'] .
+                ',box[y]=' . $box['y'] .
+                ',this->width=' . $this->width .
+                ',this->heigh=' . $this->height .
+                ',this->filepath=' . $this->filepath .
+                ',this->filename=' . $this->filename
+            );
         }
 
         common_debug(sprintf('Generating a thumbnail of File id==%u of size %ux%u', $this->id, $width, $height));
index 0bcccc6cffbbb52ecd8aa4b0100e2afe6cd93dda..292e6372a65374687385e2180254c57849ff4077 100644 (file)
@@ -332,7 +332,7 @@ class File_redirection extends Managed_DataObject
         return $out_url;
     }
 
-    function saveNew($data, $file_id, $url) {
+    function saveNew(array $data, $file_id, $url) {
         $file_redir = new File_redirection;
         $file_redir->url = $url;
         $file_redir->file_id = $file_id;
index 6a92b07d0cda40bfde4e3e9c7a128cc91551e4f4..11236f087d3e2241b652d09bfcc6b08222279438 100644 (file)
@@ -61,6 +61,9 @@ class File_thumbnail extends Managed_DataObject
      * @param int $file_id
      */
     public static function saveNew($data, $file_id) {
+        // @TODO Must be an object (see below code)
+        assert(is_object($data));
+
         if (!empty($data->thumbnail_url)) {
             // Non-photo types such as video will usually
             // show us a thumbnail, though it's not required.
index 3825e07a0f51745cd770f23c6c6e77491acc7e85..8dc5479b4956b8698f91ec77277c45c49d2fa28d 100644 (file)
@@ -416,7 +416,7 @@ class Notice extends Managed_DataObject
      * @return Notice
      * @throws ClientException
      */
-    static function saveNew($profile_id, $content, $source, array $options=null) {
+    static function saveNew($profile_id, $content, $source, array $options=array()) {
         $defaults = array('uri' => null,
                           'url' => null,
                           'conversation' => null,   // URI of conversation
@@ -427,13 +427,16 @@ class Notice extends Managed_DataObject
                           'object_type' => null,
                           'verb' => null);
 
-        if (!empty($options) && is_array($options)) {
+        /*
+         * Above type-hint is already array, so simply count it, this saves
+         * "some" CPU cycles.
+         */
+        if (count($options) > 0) {
             $options = array_merge($defaults, $options);
-            extract($options);
-        } else {
-            extract($defaults);
         }
 
+        extract($options);
+
         if (!isset($is_local)) {
             $is_local = Notice::LOCAL_PUBLIC;
         }
old mode 100755 (executable)
new mode 100644 (file)
index 6d6677f2872de15232f448b9b835259536db160e..72b82e820fa3026a39feae26da52529d513f6e66 100644 (file)
@@ -211,6 +211,7 @@ $default =
         array('server' => null,
               'dir' => INSTALLDIR . '/file/',
               'path' => $_path . '/file/',
+              'chmod' => 0644,        // Access rights (chmod) for any attachments
               'sslserver' => null,
               'sslpath' => null,
               'ssl' => null,
index 6e71fea62cbf5773852aa66725772e27192d4cf7..b7fd44512c58fa850c5a42f14f9da9aa83c7cf30 100644 (file)
@@ -27,7 +27,7 @@ define('GNUSOCIAL_LIFECYCLE', 'release'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+',
 
 define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
 
-define('GNUSOCIAL_CODENAME', 'The Spanish Invasion');
+define('GNUSOCIAL_CODENAME', 'Only a fixed bug is a good bug.');
 
 define('AVATAR_PROFILE_SIZE', 96);
 define('AVATAR_STREAM_SIZE', 48);
index d2f281254b028f6f8f4b078a2140a8588a53cdf6..46402d89d7cc2560defbc476b5c03f6b8e459df5 100644 (file)
@@ -253,6 +253,9 @@ class ImageFile
             if ($this->rotate == 0) {
                 // No rotational difference, just copy it as-is
                 @copy($this->filepath, $outpath);
+
+                // And set chmod
+                @chmod($outpath, common_config('attachments', 'chmod'));
                 return $outpath;
             } elseif (abs($this->rotate) == 90) {
                 // Box is rotated 90 degrees in either direction,
@@ -351,6 +354,9 @@ class ImageFile
             throw new Exception(_('Unknown file type'));
         }
 
+        // Always chmod 0644 (default) to have other processes (e.g. queue daemon read it)
+        @chmod($outpath, common_config('attachments', 'chmod'));
+
         imagedestroy($image_src);
         imagedestroy($image_dest);
     }
index f1f322ae332de9d75ba55e8199613155dd0d17df..161eb67a5061e9553d165086fdaf22b209364ce5 100644 (file)
@@ -97,7 +97,7 @@ class NoticeForm extends Form
      *                        '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?
@@ -109,10 +109,6 @@ class NoticeForm extends Form
 
         parent::__construct($action);
 
-        if (is_null($options)) {
-            $options = array();
-        }
-
         $this->actionName  = $action->trimmed('action');
 
         $prefill = array('content', 'inreplyto', 'lat', 
index b802f7b2a1800f85e6e3ce64da746f52e7ee195b..22962325778f3f09ab28575007f637f995d91b01 100644 (file)
@@ -667,7 +667,7 @@ function common_linkify_mention($mention)
  *
  * @access private
  */
-function common_find_mentions($text, $notice)
+function common_find_mentions($text, Notice $notice)
 {
     try {
         $sender = Profile::getKV('id', $notice->profile_id);
index 768f71510f24c334752c9e223042eaf8008dd50e..24a95395a3d79ffbd3cabd0f4940c18c9abd0277 100644 (file)
@@ -61,7 +61,7 @@ class AccountManagerPlugin extends Plugin
                         common_local_url('AccountManagementControlDocument'));
     }
 
-    function onStartShowHTML($action)
+    function onStartShowHTML(Action $action)
     {
         //Account management discovery link
         header('Link: <'.common_local_url('AccountManagementControlDocument').'>; rel="'. AccountManagerPlugin::AM_REL.'"; type="application/json"');
index ae4bf9a7fbbd1c57fbaf61e6158abb518c9cf7c8..8d924dea97e015f6111de9c35b46d9bbfb01dbfb 100644 (file)
@@ -118,7 +118,7 @@ class ActivitySpamPlugin extends Plugin
         return true;
     }
 
-    function onNoticeDeleteRelated($notice) {
+    function onNoticeDeleteRelated(Notice $notice) {
         $score = Spam_score::getKV('notice_id', $notice->id);
         if (!empty($score)) {
             $score->delete();
@@ -126,7 +126,7 @@ class ActivitySpamPlugin extends Plugin
         return true;
     }
 
-    function onUserRightsCheck($profile, $right, &$result) {
+    function onUserRightsCheck(Profile $profile, $right, &$result) {
         switch ($right) {
         case self::REVIEWSPAM:
         case self::TRAINSPAM:
index 5c583a2e0722ebb3d72d90b0623c3befac1cf39d..6a2a11d0698895d46a23ced6c58cca58cef3160e 100644 (file)
@@ -53,7 +53,7 @@ class Spam_score extends Managed_DataObject
     public $score;       // float
     public $created;     // datetime
 
-    function saveNew($notice, $result) {
+    function saveNew(Notice $notice, $result) {
 
         $score = new Spam_score();
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index c223049781041ea00059d53e551d9a7bd6392edd..1780f42e62736fdaedba9982513999251f10df8c 100644 (file)
@@ -122,7 +122,7 @@ class BlacklistPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onStartRegisterUser(&$user, &$profile)
+    function onStartRegisterUser(User &$user, Profile &$profile)
     {
         $homepage = strtolower($profile->homepage);
 
index 1f585dce4ff854c15b5b1c5ac8d0f7cebbd89671..26ed41f452037cb0514de1dc32392098321d5d0b 100644 (file)
@@ -107,12 +107,8 @@ class Blog_entry extends Managed_DataObject
         );
     }
 
-    static function saveNew($profile, $title, $content, $options=null)
+    static function saveNew(Profile $profile, $title, $content, array $options = array())
     {
-        if (is_null($options)) {
-            $options = array();
-        }
-
         $be             = new Blog_entry();
         $be->id         = (string) new UUID();
         $be->profile_id = $profile->id;
@@ -218,7 +214,7 @@ class Blog_entry extends Managed_DataObject
         }
     }
 
-    static function fromNotice($notice)
+    static function fromNotice(Notice $notice)
     {
         return Blog_entry::getKV('uri', $notice->uri);
     }
index 2cab69be30e03672b33dd1aab8926baf0d69fdb7..3df1e29f2e4cd3e5f87b8043bdedc9bd3de86c48 100644 (file)
@@ -65,7 +65,7 @@ class BlogspamNetPlugin extends Plugin
         }
     }
 
-    function onStartNoticeSave($notice)
+    function onStartNoticeSave(Notice $notice)
     {
         $args = $this->testArgs($notice);
         common_debug("Blogspamnet args = " . print_r($args, TRUE));
index 47663271aa4864938c84724cc267de629f57adfa..8f7e827d78184636ee91245b1978ab12dd1bc106 100644 (file)
@@ -61,7 +61,7 @@ class BookmarkPlugin extends MicroAppPlugin
      *
      * @return boolean hook value
      */
-    function onUserRightsCheck($profile, $right, &$result)
+    function onUserRightsCheck(Profile $profile, $right, &$result)
     {
         if ($right == self::IMPORTDELICIOUS) {
             $result = !$profile->isSilenced();
@@ -223,7 +223,7 @@ class BookmarkPlugin extends MicroAppPlugin
      *
      * @return boolean hook value
      */
-    function onEndProfileSettingsActions($action)
+    function onEndProfileSettingsActions(Action $action)
     {
         $user = common_current_user();
 
index a99df87ee3d7da8da3a2117839f9d4d3a96d7a58..b86746dde797c6f76c9d446bc68b4f7e01c1ff30 100644 (file)
@@ -92,7 +92,7 @@ class Bookmark extends Managed_DataObject
      *
      * @return Bookmark found bookmark or null
      */
-    static function getByNotice($notice)
+    static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -105,7 +105,7 @@ class Bookmark extends Managed_DataObject
      *
      * @return Bookmark bookmark found or null
      */
-    static function getByURL($profile, $url)
+    static function getByURL(Profile $profile, $url)
     {
         $nb = new Bookmark();
 
@@ -131,8 +131,8 @@ class Bookmark extends Managed_DataObject
      *
      * @return Notice saved notice
      */
-    static function saveNew($profile, $title, $url, $rawtags, $description,
-                            $options=null)
+    static function saveNew(Profile $profile, $title, $url, $rawtags, $description,
+                            array $options=array())
     {
         if (!common_valid_http_url($url)) {
             throw new ClientException(_m('Only web bookmarks can be posted (HTTP or HTTPS).'));
@@ -145,10 +145,6 @@ class Bookmark extends Managed_DataObject
             throw new ClientException(_m('Bookmark already exists.'));
         }
 
-        if (empty($options)) {
-            $options = array();
-        }
-
         if (array_key_exists('uri', $options)) {
             $other = Bookmark::getKV('uri', $options['uri']);
             if (!empty($other)) {
index 289196b4a9627a6d60e5176895b2bfae73a79ae7..73ea99940804e800b3d304c44725483937e22edc 100644 (file)
@@ -36,7 +36,7 @@ class DirectionDetectorPlugin extends Plugin {
      *
      * @param object $notice notice is going to be saved
      */
-    public function onStartNoticeSave($notice){
+    public function onStartNoticeSave(Notice $notice) {
         if(!preg_match('/<span class="rtl">/', $notice->rendered) && self::isRTL($notice->content))
             $notice->rendered = '<span class="rtl">'.$notice->rendered.'</span>';
         return true;
@@ -48,7 +48,7 @@ class DirectionDetectorPlugin extends Plugin {
      * @param string $content
      * @return boolean
      */
-    public static function isRTL($content){
+    public static function isRTL($content) {
         $content = self::getClearText($content);
         $words = explode(' ', $content);
         $rtl = 0;
@@ -71,7 +71,7 @@ class DirectionDetectorPlugin extends Plugin {
      * @param string $str
      * @return boolean
      */
-    public static function startsWithRTLCharacter($str){
+    public static function startsWithRTLCharacter($str ){
         if (strlen($str) < 1) {
             return false;
         }
@@ -106,7 +106,7 @@ class DirectionDetectorPlugin extends Plugin {
      * @param string $str
      * @return string
      */
-    private static function getClearText($str){
+    private static function getClearText($str) {
         $str = preg_replace('/@[^ ]+|![^ ]+|#[^ ]+/u', '', $str); // reply, tag, group
         $str = preg_replace('/^RT[: ]{1}| RT | RT: |^RD[: ]{1}| RD | RD: |[♺♻:]/u', '', $str); // redent, retweet
         $str = preg_replace("/[ \r\t\n]+/", ' ', trim($str)); // remove spaces
index 2e15dd809a2c521974002006b39ae00603a9598a..76486f65b041f735a0fad43efcb19c97160b6294 100644 (file)
@@ -65,7 +65,7 @@ class DomainWhitelistPlugin extends Plugin
      *
      * @return boolean hook flag
      */
-    function onEndShowStatusNetScripts($action) {
+    public function onEndShowStatusNetScripts(Action $action) {
         $name = $action->arg('action');
         if ($name == 'invite') {
             $action->script($this->getPath() . '/js/whitelistinvite.js');
@@ -73,13 +73,14 @@ class DomainWhitelistPlugin extends Plugin
         return true;
     }
 
-    function onRequireValidatedEmailPlugin_Override($user, &$knownGood)
+    public function onRequireValidatedEmailPlugin_Override(User $user, &$knownGood)
     {
         $knownGood = (!empty($user->email) && $this->matchesWhitelist($user->email));
         return true;
     }
 
-    function onEndValidateUserEmail($user, $email, &$valid)
+    // @TODO Most callers are given NULL as first argument
+    public function onEndValidateUserEmail($user, $email, &$valid)
     {
         if ($valid) { // it's otherwise valid
             if (!$this->matchesWhitelist($email)) {
@@ -102,7 +103,7 @@ class DomainWhitelistPlugin extends Plugin
         return true;
     }
 
-    function onStartAddEmailAddress($user, $email)
+    public function onStartAddEmailAddress(User $user, $email)
     {
         if (!$this->matchesWhitelist($email)) {
             // TRANS: Exception thrown when an e-mail address does not match the site's domain whitelist.
index 3a094ece6cf3fe34672784e60544d3872b8a28d8..3d2a1738b5e21e8427d8d0f7f848f6e74faf2ff9 100644 (file)
@@ -102,7 +102,7 @@ class Happening extends Managed_DataObject
         );
     }
 
-    static function saveNew($profile, $start_time, $end_time, $title, $location, $description, $url, $options=array())
+    static function saveNew(Profile $profile, $start_time, $end_time, $title, $location, $description, $url, array $options=array())
     {
         if (array_key_exists('uri', $options)) {
             $other = Happening::getKV('uri', $options['uri']);
@@ -207,7 +207,7 @@ class Happening extends Managed_DataObject
         return Notice::getKV('uri', $this->uri);
     }
 
-    static function fromNotice($notice)
+    static function fromNotice(Notice $notice)
     {
         return Happening::getKV('uri', $notice->uri);
     }
index 7266ea7493aa0ba7a508a8a78ca0e358750aefb0..c9504bf601cfafac25576f444a9939215207010a 100644 (file)
@@ -107,7 +107,7 @@ class RSVP extends Managed_DataObject
         );
     }
 
-    function saveNew($profile, $event, $verb, $options=array())
+    function saveNew(Profile $profile, $event, $verb, array $options = array())
     {
         if (array_key_exists('uri', $options)) {
             $other = RSVP::getKV('uri', $options['uri']);
@@ -315,7 +315,7 @@ class RSVP extends Managed_DataObject
                               $this->response);
     }
 
-    static function toHTML($profile, $event, $response)
+    static function toHTML(Profile $profile, Event $event, $response)
     {
         $fmt = null;
 
index a6e01a8c1b385f1fffdc55b4da3647b8f627efd3..c530ca030c7309d0bb8ff6f4680dafb0e9cde6cc 100644 (file)
@@ -46,7 +46,7 @@ class Photo extends Managed_DataObject
     public $description;       // text
     public $profile_id;        // int
 
-    public static function getByNotice($notice)
+    public static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -81,7 +81,7 @@ class Photo extends Managed_DataObject
         );
     }
 
-    static function saveNew(Profile $profile, $photo_uri, $thumb_uri, $title, $description, $options=array())
+    static function saveNew(Profile $profile, $photo_uri, $thumb_uri, $title, $description, array $options=array())
     {
         $photo = new Photo();
 
index d2dd0469a1f6b4d94b0fe64909ccbe20ca1bec46..9746948e16f93aefc7bc2fc2ef7f2024d188df0e 100644 (file)
@@ -43,7 +43,7 @@ class Video extends Managed_DataObject
     public $url;               // varchar (255)
     public $profile_id;        // int
 
-    public static function getByNotice($notice)
+    public static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -75,7 +75,7 @@ class Video extends Managed_DataObject
         );
     }
 
-    static function saveNew(Profile $profile, $url, $options=array())
+    static function saveNew(Profile $profile, $url, array $options=array())
     {
         $vid = new Video();
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1dd3bdcf345fcd685cabdfe9ba3ad304d3e3ced0..cb51e980f3760c95e5345b16a77a032f8c72c877 100644 (file)
@@ -152,7 +152,7 @@ class MinifyPlugin extends Plugin
         return JSMin::minify($code);
     }
 
-    static function minifyCss($code, $options = array()) {
+    static function minifyCss($code, array $options = array()) {
         require_once('Minify/CSS.php');
         return Minify_CSS::minify($code,$options);
     }
index fc5008cda6ff91b29990031ef4a4d6a1d245c0e1..a48a32e9f1ecb16e1519f0b14993e5482923d0ae 100644 (file)
@@ -43,7 +43,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
 
 class WAP20Plugin extends Plugin
 {
-    function onStartShowHTML($action)
+    function onStartShowHTML(Action $action)
     {
 
     }
index 5d0fd2ddb9a041ed6666c262155448e4d5f35b4b..9d7075a3a267750560922a399da57575e60ececc 100644 (file)
@@ -59,7 +59,7 @@ class MobileProfilePlugin extends WAP20Plugin
         parent::__construct();
     }
 
-    function onStartShowHTML($action)
+    function onStartShowHTML(Action $action)
     {
         // XXX: This should probably graduate to WAP20Plugin
 
@@ -316,14 +316,14 @@ class MobileProfilePlugin extends WAP20Plugin
         $action->elementEnd('address');
     }
 
-    function onStartShowAside($action)
+    function onStartShowAside(Action $action)
     {
         if ($this->serveMobile) {
             return false;
         }
     }
 
-    function onStartShowLocalNavBlock($action)
+    function onStartShowLocalNavBlock(Action $action)
     {
         if ($this->serveMobile) {
             // @todo FIXME: "Show Navigation" / "Hide Navigation" needs i18n
index 2752a2153947302d251aabf8374d381e32412f44..b37ea445788aa651a7172ec0dad28bcaebb62199 100644 (file)
@@ -42,7 +42,7 @@ class ModHelperPlugin extends Plugin
         return true;
     }
 
-    function onUserRightsCheck($profile, $right, &$result)
+    function onUserRightsCheck(Profile $profile, $right, &$result)
     {
         if (in_array($right, self::$rights)) {
             // Hrm.... really we should confirm that the *other* user isn't privleged. :)
index 32c96be0e8c0722b5d7249adc0012beacc7455d6..e659ee57c39afce27336ed081d3e3f041eb2f8f3 100644 (file)
@@ -71,7 +71,7 @@ class ModLogPlugin extends Plugin
         return true;
     }
 
-    function onEndGrantRole($profile, $role)
+    function onEndGrantRole(Profile $profile, $role)
     {
         $modlog = new ModLog();
 
@@ -79,7 +79,7 @@ class ModLogPlugin extends Plugin
         $modlog->profile_id = $profile->id;
 
         $cur = common_current_user();
-        
+
         if (!empty($cur)) {
             $modlog->moderator_id = $cur->id;
         }
@@ -93,7 +93,7 @@ class ModLogPlugin extends Plugin
         return true;
     }
 
-    function onEndRevokeRole($profile, $role)
+    function onEndRevokeRole(Profile $profile, $role)
     {
         $modlog = new ModLog();
 
@@ -102,7 +102,7 @@ class ModLogPlugin extends Plugin
         $modlog->profile_id = $profile->id;
 
         $cur = common_current_user();
-        
+
         if (!empty($cur)) {
             $modlog->moderator_id = $cur->id;
         }
@@ -173,7 +173,7 @@ class ModLogPlugin extends Plugin
         }
     }
 
-    function onUserRightsCheck($profile, $right, &$result) {
+    function onUserRightsCheck(Profile $profile, $right, &$result) {
         switch ($right) {
         case self::VIEWMODLOG:
             $result = ($profile->hasRole(Profile_role::MODERATOR) || $profile->hasRole('modhelper'));
index 8433f2737b920d250b8a10785d47f756fdd6176a..3f029ba90958feb5c0b4fc0814e2b0971583306a 100644 (file)
@@ -94,7 +94,7 @@ class ModPlusPlugin extends Plugin
      *
      * @param ProfileListItem $item
      */
-    function onStartProfileListItemProfile($item)
+    function onStartProfileListItemProfile(ProfileListItem $item)
     {
         $this->showProfileOptions($item->out, $item->profile->getProfile());
         return true;
index 382ce2ee5bb782b2aa327004cd98952a618f0f85..b4c9c1cf69620357a90117ef1879284c6b593b5b 100644 (file)
@@ -70,7 +70,7 @@ class MollomPlugin extends Plugin
     public $private_key;
     public $servers;
 
-    function onStartNoticeSave($notice)
+    function onStartNoticeSave(Notice $notice)
     {
       if ( $this->public_key ) {
         //Check spam
index 960cb935f715ced90e5ec2102c353a2e8f619351..87e07d5a63fb75fdadf5d76e0adbec6cf5d4525d 100644 (file)
@@ -246,7 +246,7 @@ class NoticeTitlePlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onNoticeDeleteRelated($notice)
+    function onNoticeDeleteRelated(Notice $notice)
     {
         $nt = Notice_title::getKV('notice_id', $notice->id);
 
@@ -264,7 +264,7 @@ class NoticeTitlePlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onStartShowHeadTitle($action)
+    function onStartShowHeadTitle(Action $action)
     {
         $actionName = $action->trimmed('action');
 
index 610e32fca757bcff1ff39f16f3652c4ad66a578d..66ad948e6d9cb376b5d6c38cbd231fd4de43cb2b 100644 (file)
@@ -77,7 +77,7 @@ class Notice_title extends Managed_DataObject
      *
      * @return string title of the notice, or null if none
      */
-    static function fromNotice($notice)
+    static function fromNotice(Notice $notice)
     {
         $nt = Notice_title::getKV('notice_id', $notice->id);
         if (empty($nt)) {
index 66c8e47f8cb53ede29c88668c02f6c387158384e..6062749ce63e4f1d53ec1384a80f17db9415bf48 100644 (file)
@@ -233,7 +233,7 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    function onStartTagProfileAction($action, $profile)
+    function onStartTagProfileAction(Action $action, Profile $profile)
     {
         $err = null;
         $uri = $action->trimmed('uri');
@@ -267,7 +267,7 @@ class OStatusPlugin extends Plugin
     /*
      * If the field being looked for is URI look for the profile
      */
-    function onStartProfileCompletionSearch($action, $profile, $search_engine) {
+    public function onStartProfileCompletionSearch(Action $action, Profile $profile, $search_engine) {
         if ($action->field == 'uri') {
             $profile->joinAdd(array('id', 'user:id'));
             $profile->whereAdd('uri LIKE "%' . $profile->escape($q) . '%"');
@@ -306,7 +306,7 @@ class OStatusPlugin extends Plugin
      * @param array &$mention in/out param: set of found mentions
      * @return boolean hook return value
      */
-    function onEndFindMentions(Profile $sender, $text, &$mentions)
+    function onEndFindMentions(Profile $sender, $text, array &$mentions)
     {
         $matches = array();
 
@@ -389,7 +389,7 @@ class OStatusPlugin extends Plugin
      * @param Profile &$profile
      * @return hook return code
      */
-    function onStartCommandGetProfile($command, $arg, &$profile)
+    public function onStartCommandGetProfile(Command $command, $arg, Profile &$profile = null)
     {
         $oprofile = $this->pullRemoteProfile($arg);
         if ($oprofile instanceof Ostatus_profile && !$oprofile->isGroup()) {
@@ -416,7 +416,7 @@ class OStatusPlugin extends Plugin
      * @param User_group &$group
      * @return hook return code
      */
-    function onStartCommandGetGroup($command, $arg, &$group)
+    function onStartCommandGetGroup(Command $command, $arg, User_group &$group = null)
     {
         $oprofile = $this->pullRemoteProfile($arg);
         if ($oprofile instanceof Ostatus_profile && $oprofile->isGroup()) {
@@ -481,7 +481,7 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    function onEndShowStatusNetScripts($action) {
+    public function onEndShowStatusNetScripts(Action $action) {
         $action->script($this->path('js/ostatus.js'));
         return true;
     }
old mode 100755 (executable)
new mode 100644 (file)
index fda16368376257e57d0ad75b20ea51e4b48c3cdf..32dfca0968d3351084969bf490c48a821865015b 100644 (file)
@@ -103,6 +103,9 @@ class File_oembed extends Managed_DataObject
      * @param int $file_id
      */
     public static function saveNew($data, $file_id) {
+        // @TODO Must be an object
+        assert(is_object($data));
+
         $file_oembed = new File_oembed;
         $file_oembed->file_id = $file_id;
         if (!isset($data->version)) {
index 15441420285d332cdf5daac06fac8b2c44d04e1a..850b5fc0578ed47e30ccaaded8e0196e9fe70827 100644 (file)
@@ -82,7 +82,7 @@ class Poll extends Managed_DataObject
      *
      * @return Poll found poll or null
      */
-    static function getByNotice($notice)
+    static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -167,12 +167,8 @@ class Poll extends Managed_DataObject
      *
      * @return Notice saved notice
      */
-    static function saveNew($profile, $question, $opts, $options=null)
+    static function saveNew(Profile $profile, $question, $opts, array $options = array())
     {
-        if (empty($options)) {
-            $options = array();
-        }
-
         $p = new Poll();
 
         $p->id          = UUID::gen();
index 0fc08443fa7ee3ecd5fb71cce05fc60c9dbe2c60..0700780921d8be972b8ca362b815092e134a3435 100644 (file)
@@ -85,7 +85,7 @@ class Poll_response extends Managed_DataObject
      *
      * @return Poll_response found response or null
      */
-    static function getByNotice($notice)
+    static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -123,12 +123,8 @@ class Poll_response extends Managed_DataObject
      *
      * @return Notice saved notice
      */
-    static function saveNew($profile, $poll, $selection, $options=null)
+    static function saveNew(Profile $profile, $poll, $selection, array $options=array())
     {
-        if (empty($options)) {
-            $options = array();
-        }
-
         if (!$poll->isValidSelection($selection)) {
             // TRANS: Client exception thrown when responding to a poll with an invalid option.
             throw new ClientException(_m('Invalid poll selection.'));
index 57f55c2748552c808207da5908d9f7735f1f57e4..1eb74a66c6411b587bd30ab7ea5778f12cc7f3c1 100644 (file)
@@ -105,7 +105,7 @@ class QnA_Answer extends Managed_DataObject
      *
      * @return QnA_Answer found response or null
      */
-    static function getByNotice($notice)
+    static function getByNotice(Notice $notice)
     {
         $answer = self::getKV('uri', $notice->uri);
         if (empty($answer)) {
@@ -124,7 +124,7 @@ class QnA_Answer extends Managed_DataObject
         return Notice::getKV('uri', $this->uri);
     }
 
-    static function fromNotice($notice)
+    static function fromNotice(Notice $notice)
     {
         return QnA_Answer::getKV('uri', $notice->uri);
     }
@@ -179,7 +179,7 @@ class QnA_Answer extends Managed_DataObject
         );
     }
 
-    static function toHTML($profile, $question, $answer)
+    static function toHTML(Profile $profile, $question, $answer)
     {
         $notice = $question->getNotice();
 
@@ -237,12 +237,8 @@ class QnA_Answer extends Managed_DataObject
      *
      * @return Notice saved notice
      */
-    static function saveNew($profile, $question, $text, $options = null)
+    static function saveNew(Profile $profile, $question, $text, array $options = array())
     {
-        if (empty($options)) {
-            $options = array();
-        }
-
         $answer              = new QnA_Answer();
         $answer->id          = UUID::gen();
         $answer->profile_id  = $profile->id;
index 66eb1b12362b7b826f307212bb20f5fded21946d..977f93fe4704022fb02d34d4e801cd554a6a5877 100644 (file)
@@ -97,7 +97,7 @@ class QnA_Question extends Managed_DataObject
      *
      * @return Question found question or null
      */
-    static function getByNotice($notice)
+    static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -164,7 +164,7 @@ class QnA_Question extends Managed_DataObject
         return $a->count();
     }
 
-    static function fromNotice($notice)
+    static function fromNotice(Notice $notice)
     {
         return QnA_Question::getKV('uri', $notice->uri);
     }
@@ -179,7 +179,7 @@ class QnA_Question extends Managed_DataObject
         return self::toString($this->getProfile(), $this);
     }
 
-    static function toHTML($profile, $question)
+    static function toHTML(Profile $profile, $question)
     {
         $notice = $question->getNotice();
 
@@ -237,7 +237,7 @@ class QnA_Question extends Managed_DataObject
      *
      * @return Notice saved notice
      */
-    static function saveNew($profile, $title, $description, $options = array())
+    static function saveNew(Profile $profile, $title, $description, array $options = array())
     {
         $q = new QnA_Question();
 
index eca01879822d2a03af8f282012ed0c684e3395ee..760c38905105542be66132cb5e843949dd032255 100644 (file)
@@ -56,7 +56,7 @@ class QnanewquestionForm extends Form
      *
      * @return void
      */
-    function __construct($out = null, $title = null, $description = null, $options = null)
+    function __construct($out = null, $title = null, $description = null, array $options = array())
     {
         parent::__construct($out);
         $this->title       = $title;
index 13709e23ab7cb769a7d57f80ba316022b3378ed3..3b77caff139888c890bfc722bf65e78e6c570897 100644 (file)
@@ -85,6 +85,16 @@ class RecaptchaPlugin extends Plugin
         return true;
     }
 
+    /**
+     * Called when someone tries to register.
+     *
+     * We check the IP here to determine if it goes over any of our
+     * configured limits.
+     *
+     * @param Action $action Action that is being executed
+     *
+     * @return boolean hook value
+     */
     function onStartRegistrationTry(Action $action)
     {
         $resp = recaptcha_check_answer ($this->private_key,
index 4a965608e1bf3aefb3e0aaf483e9127b59cf4553..d09642a6330872d0206d5a00406674c87ae4a3ee 100644 (file)
@@ -241,7 +241,7 @@ class RegisterThrottlePlugin extends Plugin
      *
      * @return boolean hook value
      */
-    public function onEndGrantRole($profile, $role)
+    public function onEndGrantRole(Profile $profile, $role)
     {
         if (!self::$enabled) {
             return true;
index 99f61dcf02ce5e97d019f9f9cbb54640ee4e5967..c4f959a4c9d3d9b312c37a5068c5c01f51994ae1 100644 (file)
@@ -95,7 +95,7 @@ class RequireValidatedEmailPlugin extends Plugin
      *
      * @return bool hook result code
      */
-    function onStartNoticeSave($notice)
+    function onStartNoticeSave(Notice $notice)
     {
         $user = User::getKV('id', $notice->profile_id);
         if (!empty($user)) { // it's a remote notice
@@ -116,7 +116,7 @@ class RequireValidatedEmailPlugin extends Plugin
      *
      * @return bool hook result code
      */
-    function onStartRegisterUser(&$user, &$profile)
+    function onStartRegisterUser(User &$user, Profile &$profile)
     {
         $email = $user->email;
 
@@ -136,7 +136,7 @@ class RequireValidatedEmailPlugin extends Plugin
      *
      * @return bool
      */
-    protected function validated($user)
+    protected function validated(User $user)
     {
         // The email field is only stored after validation...
         // Until then you'll find them in confirm_address.
index f3a44854b2730ed81870152772c5f73bea8cac32..0d5828695b18217b6ddcdaaddc3af168972def70 100644 (file)
@@ -91,6 +91,18 @@ class SearchSub extends Managed_DataObject
         return $ts;
     }
 
+    /**
+     * Getter for Profile instance
+     *
+     * @return $profile        Profile instance
+     */
+    public function getProfile () {
+        assert($this->profile_id > 0);
+        $profile = new Profile();
+        $profile->id = $this->profile_id;
+        return $profile;
+    }
+
     /**
      * End a search subscription!
      *
index f001fc39092c200369c7f41e3805eb8ac2459e5a..2754d180218683c0e96fad4ae2ba8ef7f0bcfa59 100644 (file)
@@ -54,7 +54,7 @@ class SpotifyPlugin extends Plugin
         parent::__construct();
     }
 
-    function onStartNoticeSave($notice)
+    function onStartNoticeSave(Notice $notice)
     {
         $notice->rendered = preg_replace_callback('/spotify:[a-z]{5,6}:[a-z0-9]{22}/i',
                                                   "renderSpotifyURILink",
diff --git a/plugins/Statistics/README.md b/plugins/Statistics/README.md
new file mode 120000 (symlink)
index 0000000..e98992b
--- /dev/null
@@ -0,0 +1 @@
+../../statistics_plugin/README.md
\ No newline at end of file
diff --git a/plugins/Statistics/StatisticsPlugin.php b/plugins/Statistics/StatisticsPlugin.php
new file mode 120000 (symlink)
index 0000000..41ced2e
--- /dev/null
@@ -0,0 +1 @@
+../../statistics_plugin/StatisticsPlugin-gnusocial.php
\ No newline at end of file
diff --git a/plugins/Statistics/actions b/plugins/Statistics/actions
new file mode 120000 (symlink)
index 0000000..dd018ab
--- /dev/null
@@ -0,0 +1 @@
+../../statistics_plugin/actions/
\ No newline at end of file
index de63841e729e84f44f712d7efaa0c3bbb5f555ba..cdbbed6726e415c2ddcbd24d18cbef7ba7a36fe6 100644 (file)
@@ -188,10 +188,11 @@ class SubMirror extends Managed_DataObject
      * Kind of dirty, but if pulling an external data feed into an account
      * that may be what you want.
      *
-     * @param Notice $notice
-     * @return mixed Notice on successful repeat, true if already repeated, false on failure
+     * @param  Profile $profile
+     * @param  Notice  $notice
+     * @return mixed   Notice on successful repeat, true if already repeated, false on failure
      */
-    protected function copyNotice($profile, $notice)
+    protected function copyNotice(Profile $profile, Notice $notice)
     {
         $options = array('is_local' => Notice::LOCAL_PUBLIC,
                          'url' => $notice->getUrl(), // pass through the foreign link...
index 5bc0c436ee8f7d3639d273896c98ae4436b81545..43c573e7cbb58258dd97253ed8b2da1db3b70841 100644 (file)
@@ -132,4 +132,16 @@ class TagSub extends Managed_DataObject
 
         return $tags;
     }
+
+    /**
+     * Getter for Profile instance
+     *
+     * @return $profile        Profile instance
+     */
+    public function getProfile () {
+        assert($this->profile_id > 0);
+        $profile = new Profile();
+        $profile->id = $this->profile_id;
+        return $profile;
+    }
 }
index 27ebefb05377612d783d8bb41d391dc4dbef0327..986dd901a0f0a86ef828d001f7b16553fd3edac1 100644 (file)
@@ -152,6 +152,8 @@ class UserFlagPlugin extends Plugin
      * @param boolean &$result out, result of the check
      *
      * @return boolean hook result
+     * @TODO Other implementing classes expect Profile here!!!
+     * @WARNING
      */
     function onUserRightsCheck($user, $right, &$result)
     {
index bd88ad000c5f46752f93ac8933667d8f8352cdfb..ed4ff9df497267bda79f09ac6c5290a1e0467a47 100644 (file)
@@ -55,6 +55,16 @@ class UserLimitPlugin extends Plugin
         return true;
     }
 
+    /**
+     * Called when someone tries to register.
+     *
+     * We check the IP here to determine if it goes over any of our
+     * configured limits.
+     *
+     * @param Action $action Action that is being executed
+     *
+     * @return boolean hook value
+     */
     function onStartRegistrationTry(Action $action)
     {
         $this->_checkMaxUsers();
index 5b7dc20d8681c50f61b302660dc03e38b21b87af..80da17dff6977c31bf671bc345a83fb6ffb67531 100644 (file)
@@ -125,7 +125,7 @@ class WebFingerPlugin extends Plugin
     /**
      * Add a link header for LRDD Discovery
      */
-    public function onStartShowHTML($action)
+    public function onStartShowHTML(Action $action)
     {
         if ($action instanceof ShowstreamAction) {
             $acct = 'acct:'. $action->profile->nickname .'@'. common_config('site', 'server');
diff --git a/scripts/fixup_group_profiles.php b/scripts/fixup_group_profiles.php
new file mode 100755 (executable)
index 0000000..43cdfd0
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/env php
+<?php
+/*
+ * 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/>.
+ */
+
+// 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('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+require_once(INSTALLDIR . '/scripts/commandline.inc.php');
+error_reporting(E_ALL | E_STRICT);
+
+$relative = common_path('group/');
+print('Searching for profiles with relative=' . $relative . ' ...' . PHP_EOL);
+
+$profile = new Profile();
+$profile->whereAdd("`profileurl` LIKE '" . $relative . "%'");
+$cnt = $profile->find();
+
+print('Found ' . $cnt . ' profiles.' . PHP_EOL);
+
+if ($cnt == 0) {
+    // Nothing to do
+    print('All profiles are fixed. :-)' . PHP_EOL);
+    exit;
+}
+
+$profiles = array();
+
+while ($profile->fetch()) {
+    array_push($profiles, "'" . $profile->nickname . "'");
+}
+
+// Cleanup
+unset($profile);
+
+print('Have ' . count($profiles) . ' profiles found.' . PHP_EOL);
+
+// Make sure both are equal
+assert(count($profiles) == $cnt);
+
+print('Looking for matching user groups without local groups ...' . PHP_EOL);
+
+$group = new User_group();
+$group->whereAdd("`nickname` IN (" . implode(', ', $profiles) . ") AND `uri` NOT LIKE '" . $relative . "%'");
+$cnt = $group->find();
+
+print('Found ' . $cnt . ' groups.' . PHP_EOL);
+
+while ($group->fetch()) {
+    print('Fixing profile for group #' . $group->id . ',nickname=' . $group->nickname . ' to ' . $group->uri . ' ...' . PHP_EOL);
+
+    if ($group->profile_id < 1) {
+        print('INCONSISTENCY - Group ' . $group->nickname . ' has no profile_id set. Cannot fix!' . PHP_EOL);
+    }
+
+    $profile = new Profile();
+    $profile->id = $group->profile_id;
+    $cnt2 = $profile->find();
+
+    if ($cnt2 == 0) {
+        print('INCONSISTENCY - Cannot find profile ' . $group->nickname . ' - skipped!' . PHP_EOL);
+        continue;
+    } elseif ($cnt2 > 1) {
+        print('INCONSISTENCY - Group ' . $group->nickname . ' has more than one (' . $cnt2 . ') profiles - skipped!' . PHP_EOL);
+        continue;
+    } else {
+       // Dummy fetch
+       $profile->fetch();
+    }
+
+    $original = clone($profile);
+    $profile->profileurl = $group->uri;
+
+    $result = $profile->update($original);
+    if (!$result) {
+        common_log_db_error($profile, 'UPDATE', __FILE__);
+    }
+}
diff --git a/statistics_plugin b/statistics_plugin
new file mode 160000 (submodule)
index 0000000..441a38c
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 441a38c20487faf6078e70f1055f20a5412a2fa1
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)