X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FGroupPrivateMessage%2FGroupPrivateMessagePlugin.php;h=0f5c1a88309a35d1f0f02bf8e6b9b5956750ea4b;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=6e31d699257383fcf924824743c7f9ed108d92ee;hpb=bfc33f39998821fa3e18719af6983fc1b889da7f;p=quix0rs-gnu-social.git diff --git a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php index 6e31d69925..0f5c1a8830 100644 --- a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php +++ b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php @@ -61,114 +61,20 @@ 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 * - * @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'), @@ -195,7 +101,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @see Action */ - function onEndGroupGroupNav($groupnav) + function onEndGroupGroupNav(Menu $groupnav) { $action = $groupnav->action; $group = $groupnav->group; @@ -218,7 +124,7 @@ class GroupPrivateMessagePlugin extends Plugin * * @result boolean hook value */ - function onEndGroupSave($group) + function onEndGroupSave(User_group $group) { $gps = new Group_privacy_settings(); @@ -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,23 @@ 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; + $group = $action->getGroup(); - if (!empty($action->group)) { - $gps = Group_privacy_settings::staticGet('group_id', $action->group->id); + if ($group instanceof User_group) { + $gps = Group_privacy_settings::getKV('group_id', $group->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 +234,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 +268,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 +303,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 @@ -415,7 +325,7 @@ class GroupPrivateMessagePlugin extends Plugin foreach (array_unique($match[1]) as $nickname) { $group = User_group::getForNickname($nickname, $profile); - if (empty($group)) { + if (!$group instanceof User_group) { continue; } @@ -441,7 +351,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 +382,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 +394,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; @@ -496,10 +406,10 @@ class GroupPrivateMessagePlugin extends Plugin return true; } - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'GroupPrivateMessage', - 'version' => STATUSNET_VERSION, + 'version' => GNUSOCIAL_VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:GroupPrivateMessage', 'rawdescription' =>