X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FGroupPrivateMessage%2FGroupPrivateMessagePlugin.php;h=2fd9e3ef429b71ea211a3d8e978d21ec9133062e;hb=048af5ac732c5fc37b5f218fb498576987e7f69e;hp=6e31d699257383fcf924824743c7f9ed108d92ee;hpb=25198a8d4cee5b2182f1ecb99192a4108a01afa4;p=quix0rs-gnu-social.git diff --git a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php index 6e31d69925..2fd9e3ef42 100644 --- a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php +++ b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php @@ -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,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::staticGet('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); } @@ -324,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') { @@ -358,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; @@ -393,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 @@ -441,7 +350,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 +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); @@ -484,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; @@ -499,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' =>