]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php
We're using URLMapper, not Net_URL_Mapper
[quix0rs-gnu-social.git] / plugins / GroupPrivateMessage / GroupPrivateMessagePlugin.php
index 467f384f4d60ccd07743c67323e835e3c15d191a..73d7201e6f726c179a5c99041e17945c454373d7 100644 (file)
@@ -67,48 +67,14 @@ class GroupPrivateMessagePlugin extends Plugin
         return true;
     }
 
-    /**
-     * Load related modules when needed
-     *
-     * @param string $cls Name of the class to be loaded
-     *
-     * @return boolean hook value
-     */
-    function onAutoload($cls)
-    {
-        $dir = dirname(__FILE__);
-
-        switch ($cls)
-        {
-        case 'GroupinboxAction':
-        case 'ShowgroupmessageAction':
-        case 'NewgroupmessageAction':
-            include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
-            return false;
-        case 'Group_privacy_settings':
-        case 'Group_message':
-        case 'Group_message_profile':
-            include_once $dir . '/'.$cls.'.php';
-            return false;
-        case 'GroupMessageCommand':
-        case 'GroupMessageList':
-        case 'GroupMessageListItem':
-        case 'GroupMessageForm':
-            include_once $dir . '/'.strtolower($cls).'.php';
-            return false;
-        default:
-            return true;
-        }
-    }
-
     /**
      * Map URLs to actions
      *
-     * @param Net_URL_Mapper $m path-to-action mapper
+     * @param URLMapper $m path-to-action mapper
      *
      * @return boolean hook value
      */
-    function onRouterInitialized($m)
+    public function onRouterInitialized(URLMapper $m)
     {
         $m->connect('group/:nickname/inbox',
                     array('action' => 'groupinbox'),
@@ -135,7 +101,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @see Action
      */
-    function onEndGroupGroupNav($groupnav)
+    function onEndGroupGroupNav(Menu $groupnav)
     {
         $action = $groupnav->action;
         $group  = $groupnav->group;
@@ -180,7 +146,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @param GroupEditForm $form form being shown
      */
-    function onEndGroupEditFormData($form)
+    function onEndGroupEditFormData(GroupEditForm $form)
     {
         $gps = null;
 
@@ -221,19 +187,22 @@ class GroupPrivateMessagePlugin extends Plugin
         return true;
     }
 
-    function onEndGroupSaveForm($action)
+    function onEndGroupSaveForm(Action $action)
     {
+        // The Action class must contain this method
+        assert(is_callable(array($action, 'getGroup')));
+
         $gps = null;
 
-        if (!empty($action->group)) {
-            $gps = Group_privacy_settings::getKV('group_id', $action->group->id);
+        if ($action->getGroup() instanceof User_group) {
+            $gps = Group_privacy_settings::getKV('group_id', $action->getGroup()->id);
         }
 
         $orig = null;
 
         if (empty($gps)) {
             $gps = new Group_privacy_settings();
-            $gps->group_id = $action->group->id;
+            $gps->group_id = $action->getGroup()->id;
         } else {
             $orig = clone($gps);
         }
@@ -264,7 +233,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onStartIntepretCommand($cmd, $arg, $user, &$result)
+    function onStartInterpretCommand($cmd, $arg, User $user, &$result)
     {
         if ($cmd == 'd' || $cmd == 'dm') {
 
@@ -298,7 +267,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onEndGroupActionsList($widget, $group)
+    function onEndGroupActionsList(Widget $widget, User_group $group)
     {
         $cur = common_current_user();
         $action = $widget->out;
@@ -333,7 +302,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @param
      */
-    function onStartNoticeSave(&$notice) {
+    function onStartNoticeSave(Notice &$notice) {
         // Look for group tags
         // FIXME: won't work for remote groups
         // @fixme if Notice::saveNew is refactored so we can just pull its list
@@ -412,7 +381,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onEndGroupProfileElements($action, $group)
+    function onEndGroupProfileElements(Action $action, User_group $group)
     {
         $gps = Group_privacy_settings::forGroup($group);
 
@@ -424,10 +393,10 @@ class GroupPrivateMessagePlugin extends Plugin
         return true;
     }
 
-    function onStartShowExportData($action)
+    function onStartShowExportData(Action $action)
     {
         if ($action instanceof ShowgroupAction) {
-            $gps = Group_privacy_settings::forGroup($action->group);
+            $gps = Group_privacy_settings::forGroup($action->getGroup());
 
             if ($gps->allow_privacy == Group_privacy_settings::ALWAYS) {
                 return false;
@@ -439,7 +408,7 @@ class GroupPrivateMessagePlugin extends Plugin
     function onPluginVersion(&$versions)
     {
         $versions[] = array('name' => 'GroupPrivateMessage',
-                            'version' => STATUSNET_VERSION,
+                            'version' => GNUSOCIAL_VERSION,
                             'author' => 'Evan Prodromou',
                             'homepage' => 'http://status.net/wiki/Plugin:GroupPrivateMessage',
                             'rawdescription' =>