]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php
Some fixes/improvements - added getter getGroup() for https://bugz.foocorp.net/T44...
[quix0rs-gnu-social.git] / plugins / GroupPrivateMessage / GroupPrivateMessagePlugin.php
index 6e31d699257383fcf924824743c7f9ed108d92ee..0788161dd30668e61e90aeceb9a8f4896ff9aede 100644 (file)
@@ -61,106 +61,12 @@ class GroupPrivateMessagePlugin extends Plugin
         $schema = Schema::get();
 
         // For storing user-submitted flags on profiles
-
-        $schema->ensureTable('group_privacy_settings',
-                             array(new ColumnDef('group_id',
-                                                 'integer',
-                                                 null,
-                                                 false,
-                                                 'PRI'),
-                                   new ColumnDef('allow_privacy',
-                                                 'integer'),
-                                   new ColumnDef('allow_sender',
-                                                 'integer'),
-                                   new ColumnDef('created',
-                                                 'datetime'),
-                                   new ColumnDef('modified',
-                                                 'timestamp')));
-
-        $schema->ensureTable('group_message',
-                             array(new ColumnDef('id',
-                                                 'char',
-                                                 36,
-                                                 false,
-                                                 'PRI'),
-                                   new ColumnDef('uri',
-                                                 'varchar',
-                                                 255,
-                                                 false,
-                                                 'UNI'),
-                                   new ColumnDef('from_profile',
-                                                 'integer',
-                                                 null,
-                                                 false,
-                                                 'MUL'),
-                                   new ColumnDef('to_group',
-                                                 'integer',
-                                                 null,
-                                                 false,
-                                                 'MUL'),
-                                   new ColumnDef('content',
-                                                 'text'),
-                                   new ColumnDef('rendered',
-                                                 'text'),
-                                   new ColumnDef('url',
-                                                 'varchar',
-                                                 255,
-                                                 false,
-                                                 'UNI'),
-                                   new ColumnDef('created',
-                                                 'datetime')));
-
-        $schema->ensureTable('group_message_profile',
-                             array(new ColumnDef('to_profile',
-                                                 'integer',
-                                                 null,
-                                                 false,
-                                                 'PRI'),
-                                   new ColumnDef('group_message_id',
-                                                 'char',
-                                                 36,
-                                                 false,
-                                                 'PRI'),
-                                   new ColumnDef('created',
-                                                 'datetime')));
-
+        $schema->ensureTable('group_privacy_settings', Group_privacy_settings::schemaDef());
+        $schema->ensureTable('group_message', Group_message::schemaDef());
+        $schema->ensureTable('group_message_profile', Group_message_profile::schemaDef());
         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
      *
@@ -195,7 +101,7 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @see Action
      */
-    function onEndGroupGroupNav($groupnav)
+    function onEndGroupGroupNav(Menu $groupnav)
     {
         $action = $groupnav->action;
         $group  = $groupnav->group;
@@ -240,12 +146,12 @@ class GroupPrivateMessagePlugin extends Plugin
      *
      * @param GroupEditForm $form form being shown
      */
-    function onEndGroupEditFormData($form)
+    function onEndGroupEditFormData(GroupEditForm $form)
     {
         $gps = null;
 
         if (!empty($form->group)) {
-            $gps = Group_privacy_settings::staticGet('group_id', $form->group->id);
+            $gps = Group_privacy_settings::getKV('group_id', $form->group->id);
         }
 
         $form->out->elementStart('li');
@@ -281,19 +187,19 @@ class GroupPrivateMessagePlugin extends Plugin
         return true;
     }
 
-    function onEndGroupSaveForm($action)
+    function onEndGroupSaveForm(GroupAction $action)
     {
         $gps = null;
 
-        if (!empty($action->group)) {
-            $gps = Group_privacy_settings::staticGet('group_id', $action->group->id);
+        if (!empty($action->getGroup())) {
+            $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);
         }
@@ -324,7 +230,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') {
 
@@ -358,7 +264,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;
@@ -393,7 +299,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
@@ -441,7 +347,7 @@ class GroupPrivateMessagePlugin extends Plugin
                                "but group ".$group->nickname." does not allow them.");
                 }
 
-                $user = User::staticGet('id', $notice->profile_id);
+                $user = User::getKV('id', $notice->profile_id);
 
                 if (empty($user)) {
                     common_log(LOG_WARNING,
@@ -472,7 +378,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);
 
@@ -484,10 +390,10 @@ class GroupPrivateMessagePlugin extends Plugin
         return true;
     }
 
-    function onStartShowExportData($action)
+    function onStartShowExportData(GroupAction $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;
@@ -499,7 +405,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' =>