2014-05-14 16:46:07 +09:00
|
|
|
|
<?php
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
2014-05-14 16:46:07 +09:00
|
|
|
|
· ·
|
|
|
|
|
· ·
|
|
|
|
|
· Q V I T T E R ·
|
|
|
|
|
· ·
|
|
|
|
|
· http://github.com/hannesmannerheim/qvitter ·
|
|
|
|
|
· ·
|
|
|
|
|
· ·
|
|
|
|
|
· <o) ·
|
|
|
|
|
· /_//// ·
|
|
|
|
|
· (____/ ·
|
|
|
|
|
· (o< ·
|
|
|
|
|
· o> \\\\_\ ·
|
|
|
|
|
· \\) \____) ·
|
|
|
|
|
· ·
|
2015-07-02 22:00:57 +09:00
|
|
|
|
· ·
|
2014-05-14 16:46:07 +09:00
|
|
|
|
· ·
|
|
|
|
|
· Qvitter 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 three of the License or (at ·
|
|
|
|
|
· your option) any later version. ·
|
|
|
|
|
· ·
|
|
|
|
|
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
|
|
|
|
|
· WARRANTY; without even the implied warranty of MERCHANTABILTY 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 Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
|
|
|
|
· ·
|
|
|
|
|
· Contact h@nnesmannerhe.im if you have any questions. ·
|
2015-07-02 22:00:57 +09:00
|
|
|
|
· ·
|
2014-05-14 16:46:07 +09:00
|
|
|
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
|
|
|
|
|
2014-11-28 21:49:00 +09:00
|
|
|
|
const QVITTERDIR = __DIR__;
|
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
class QvitterPlugin extends Plugin {
|
|
|
|
|
|
2015-06-07 03:37:40 +09:00
|
|
|
|
protected $hijack_ui = true;
|
|
|
|
|
|
2015-06-07 17:04:53 +09:00
|
|
|
|
static function settings($setting)
|
2014-05-14 16:46:07 +09:00
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-01-28 05:22:17 +09:00
|
|
|
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
|
|
|
|
· ·
|
|
|
|
|
· S E T T I N G S ·
|
|
|
|
|
· ·
|
2015-07-02 22:00:57 +09:00
|
|
|
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
2014-05-14 16:46:07 +09:00
|
|
|
|
|
2014-11-28 05:04:41 +09:00
|
|
|
|
// THESE SETTINGS CAN BE OVERRIDDEN IN CONFIG.PHP
|
|
|
|
|
// e.g. $config['site']['qvitter']['enabledbydefault'] = 'false';
|
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
// ENABLED BY DEFAULT (true/false)
|
|
|
|
|
$settings['enabledbydefault'] = true;
|
|
|
|
|
|
|
|
|
|
// DEFAULT BACKGROUND COLOR
|
|
|
|
|
$settings['defaultbackgroundcolor'] = '#f4f4f4';
|
|
|
|
|
|
2015-01-28 05:22:17 +09:00
|
|
|
|
// DEFAULT BACKGROUND IMAGE
|
|
|
|
|
$settings['sitebackground'] = 'img/vagnsmossen.jpg';
|
2015-01-22 05:03:38 +09:00
|
|
|
|
|
2015-01-28 05:22:17 +09:00
|
|
|
|
// DEFAULT FAVICON
|
2015-06-02 22:22:09 +09:00
|
|
|
|
$settings['favicon'] = 'img/favicon.ico?v=5';
|
2015-01-22 05:03:38 +09:00
|
|
|
|
|
2015-06-06 23:20:26 +09:00
|
|
|
|
// DEFAULT SPRITE
|
|
|
|
|
$settings['sprite'] = Plugin::staticPath('Qvitter', '').'img/sprite.png?v=40';
|
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
// DEFAULT LINK COLOR
|
|
|
|
|
$settings['defaultlinkcolor'] = '#0084B4';
|
|
|
|
|
|
2015-05-30 00:30:03 +09:00
|
|
|
|
// ENABLE DEFAULT WELCOME TEXT
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$settings['enablewelcometext'] = true;
|
2015-05-30 00:30:03 +09:00
|
|
|
|
|
2015-05-30 00:40:45 +09:00
|
|
|
|
// CUSTOM WELCOME TEXT (overrides the previous setting)
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$settings['customwelcometext'] = false;
|
2015-05-30 00:30:03 +09:00
|
|
|
|
|
|
|
|
|
// Example:
|
2015-05-30 00:40:45 +09:00
|
|
|
|
// $settings['customwelcometext']['sv'] = '<h1>Välkommen till Quitter.se – en federerad<sup>1</sup> mikrobloggsallmänning!</h1><p>Etc etc...</p>';
|
|
|
|
|
// $settings['customwelcometext']['en'] = '<h1>Welcome to Quitter.se – a federated microblog common!</h1><p>Etc etc...</p>';
|
2015-02-05 05:40:56 +09:00
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
// TIME BETWEEN POLLING
|
|
|
|
|
$settings['timebetweenpolling'] = 5000; // ms
|
2015-01-28 05:22:17 +09:00
|
|
|
|
|
2014-09-20 09:53:10 +09:00
|
|
|
|
// URL SHORTENER
|
|
|
|
|
$settings['urlshortenerapiurl'] = 'http://qttr.at/yourls-api.php';
|
2014-11-28 05:04:41 +09:00
|
|
|
|
$settings['urlshortenersignature'] = 'b6afeec983';
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-01-26 03:05:09 +09:00
|
|
|
|
// CUSTOM TERMS OF USE
|
|
|
|
|
$settings['customtermsofuse'] = false;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-02-04 22:44:04 +09:00
|
|
|
|
// IP ADDRESSES BLOCKED FROM REGISTRATION
|
|
|
|
|
$settings['blocked_ips'] = array();
|
2014-05-14 16:46:07 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
2015-07-02 22:00:57 +09:00
|
|
|
|
· ·
|
2014-05-14 16:46:07 +09:00
|
|
|
|
· (o> >o) ·
|
|
|
|
|
· \\\\_\ /_//// .
|
2015-07-02 22:00:57 +09:00
|
|
|
|
· \____) (____/ ·
|
2014-05-14 16:46:07 +09:00
|
|
|
|
· ·
|
2015-07-02 22:00:57 +09:00
|
|
|
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
|
|
|
|
|
|
|
|
|
// config.php settings override the settings in this file
|
2014-11-28 07:39:25 +09:00
|
|
|
|
$configphpsettings = common_config('site','qvitter') ?: array();
|
2014-11-28 05:04:41 +09:00
|
|
|
|
foreach($configphpsettings as $configphpsetting=>$value) {
|
|
|
|
|
$settings[$configphpsetting] = $value;
|
2014-11-28 08:01:25 +09:00
|
|
|
|
}
|
2014-05-14 16:46:07 +09:00
|
|
|
|
|
2014-11-28 08:01:25 +09:00
|
|
|
|
if(isset($settings[$setting])) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
return $settings[$setting];
|
2014-11-28 08:01:25 +09:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-05-14 16:46:07 +09:00
|
|
|
|
}
|
2015-06-07 03:37:40 +09:00
|
|
|
|
|
|
|
|
|
public function initialize()
|
|
|
|
|
{
|
|
|
|
|
// check if we should reroute UI to qvitter
|
|
|
|
|
$scoped = Profile::current();
|
|
|
|
|
$qvitter_enabled_by_user = false;
|
|
|
|
|
$qvitter_disabled_by_user = false;
|
|
|
|
|
if ($scoped instanceof Profile) {
|
|
|
|
|
$qvitter_enabled_by_user = $scoped->getPref('qvitter', 'enable_qvitter', false);
|
|
|
|
|
$qvitter_disabled_by_user = $scoped->getPref('qvitter', 'disable_qvitter', false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-07 19:02:30 +09:00
|
|
|
|
$this->hijack_ui = (self::settings('enabledbydefault') && !$scoped)
|
2015-06-07 03:37:40 +09:00
|
|
|
|
|| (self::settings('enabledbydefault') && !$qvitter_disabled_by_user)
|
|
|
|
|
|| (!self::settings('enabledbydefault') && $qvitter_enabled_by_user);
|
|
|
|
|
|
|
|
|
|
// show qvitter link in the admin panel
|
|
|
|
|
common_config_append('admin', 'panels', 'qvitteradm');
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
// make sure we have a notifications table
|
|
|
|
|
function onCheckSchema()
|
|
|
|
|
{
|
|
|
|
|
$schema = Schema::get();
|
|
|
|
|
$schema->ensureTable('qvitternotification', QvitterNotification::schemaDef());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
// route/reroute urls
|
2014-05-14 16:46:07 +09:00
|
|
|
|
public function onRouterInitialized($m)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-02-26 05:16:24 +09:00
|
|
|
|
$m->connect('api/qvitter/favs_and_repeats/:notice_id.json',
|
|
|
|
|
array('action' => 'ApiFavsAndRepeats'),
|
|
|
|
|
array('notice_id' => '[0-9]+'));
|
2014-05-14 16:46:07 +09:00
|
|
|
|
$m->connect('api/statuses/public_and_external_timeline.:format',
|
|
|
|
|
array('action' => 'ApiTimelinePublicAndExternal',
|
|
|
|
|
'format' => '(xml|json|rss|atom|as)'));
|
|
|
|
|
$m->connect('api/qvitter/update_link_color.json',
|
|
|
|
|
array('action' => 'apiqvitterupdatelinkcolor'));
|
|
|
|
|
$m->connect('api/qvitter/update_background_color.json',
|
|
|
|
|
array('action' => 'apiqvitterupdatebackgroundcolor'));
|
2014-05-16 19:36:30 +09:00
|
|
|
|
$m->connect('api/qvitter/checklogin.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'apiqvitterchecklogin'));
|
2014-05-28 03:40:51 +09:00
|
|
|
|
$m->connect('api/qvitter/allfollowing/:id.json',
|
|
|
|
|
array('action' => 'apiqvitterallfollowing',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
'id' => Nickname::INPUT_FMT));
|
2014-06-02 04:51:28 +09:00
|
|
|
|
$m->connect('api/qvitter/update_cover_photo.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'ApiUpdateCoverPhoto'));
|
2014-11-24 21:47:45 +09:00
|
|
|
|
$m->connect('api/qvitter/update_background_image.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'ApiUpdateBackgroundImage'));
|
2014-11-24 21:47:45 +09:00
|
|
|
|
$m->connect('api/qvitter/update_avatar.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'ApiUpdateAvatar'));
|
2015-01-23 21:20:30 +09:00
|
|
|
|
$m->connect('api/qvitter/upload_image.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'ApiUploadImage'));
|
2014-11-24 21:47:45 +09:00
|
|
|
|
$m->connect('api/qvitter/external_user_show.json',
|
|
|
|
|
array('action' => 'ApiExternalUserShow'));
|
|
|
|
|
$m->connect('api/qvitter/toggle_qvitter.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'ApiToggleQvitter'));
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$m->connect('api/qvitter/statuses/notifications.json',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'apiqvitternotifications'));
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$m->connect(':nickname/notifications',
|
|
|
|
|
array('action' => 'qvitter',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
'nickname' => Nickname::INPUT_FMT));
|
2014-05-14 16:46:07 +09:00
|
|
|
|
$m->connect('settings/qvitter',
|
|
|
|
|
array('action' => 'qvittersettings'));
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$m->connect('panel/qvitter',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'qvitteradminsettings'));
|
2014-05-14 16:46:07 +09:00
|
|
|
|
$m->connect('main/qlogin',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'qvitterlogin'));
|
|
|
|
|
|
2015-06-07 03:37:40 +09:00
|
|
|
|
if ($this->hijack_ui) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$m->connect('', array('action' => 'qvitter'));
|
|
|
|
|
$m->connect('main/all', array('action' => 'qvitter'));
|
|
|
|
|
$m->connect('search/notice', array('action' => 'qvitter'));
|
|
|
|
|
|
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname',
|
|
|
|
|
array('action' => 'showstream'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
2014-05-14 16:46:07 +09:00
|
|
|
|
'qvitter');
|
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/',
|
|
|
|
|
array('action' => 'showstream'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/all',
|
|
|
|
|
array('action' => 'all'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
2014-05-14 16:46:07 +09:00
|
|
|
|
'qvitter');
|
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/subscriptions',
|
|
|
|
|
array('action' => 'subscriptions'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/subscribers',
|
|
|
|
|
array('action' => 'subscribers'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/groups',
|
|
|
|
|
array('action' => 'usergroups'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/replies',
|
|
|
|
|
array('action' => 'replies'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/favorites',
|
|
|
|
|
array('action' => 'showfavorites'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, 'group/:nickname',
|
|
|
|
|
array('action' => 'showgroup'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, 'group/:nickname/members',
|
|
|
|
|
array('action' => 'groupmembers'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT),
|
|
|
|
|
'qvitter');
|
2014-05-14 16:46:07 +09:00
|
|
|
|
|
|
|
|
|
$m->connect('group/:nickname/admins',
|
|
|
|
|
array('action' => 'qvitter'),
|
|
|
|
|
array('nickname' => Nickname::DISPLAY_FMT));
|
|
|
|
|
|
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, 'tag/:tag',
|
|
|
|
|
array('action' => 'showstream'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('tag' => Router::REGEX_TAG),
|
|
|
|
|
'qvitter');
|
2014-09-25 06:20:35 +09:00
|
|
|
|
URLMapperOverwrite::overwrite_variable($m, 'notice/:notice',
|
|
|
|
|
array('action' => 'shownotice'),
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('notice' => '[0-9]+'),
|
|
|
|
|
'qvitter');
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-20 02:01:10 +09:00
|
|
|
|
// if qvitter is opt-out, disable the default register page (if we don't have a valid invitation code)
|
2015-06-07 04:06:35 +09:00
|
|
|
|
$valid_code = isset($_POST['code'])
|
|
|
|
|
? Invitation::getKV('code', $_POST['code'])
|
|
|
|
|
: null;
|
2015-01-20 02:01:10 +09:00
|
|
|
|
if(self::settings('enabledbydefault') && empty($valid_code)) {
|
2014-10-31 08:28:06 +09:00
|
|
|
|
$m->connect('main/register',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
array('action' => 'qvitter'));
|
2014-10-31 08:28:06 +09:00
|
|
|
|
}
|
2015-06-03 06:45:46 +09:00
|
|
|
|
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
2015-06-03 06:45:46 +09:00
|
|
|
|
// add user arrays for some urls, to use to build profile cards
|
|
|
|
|
// this way we don't have to request this in a separate http request
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-04 06:25:55 +09:00
|
|
|
|
if(isset($_GET['withuserarray'])) switch (getPath($_REQUEST)) {
|
|
|
|
|
case 'api/statuses/followers.json':
|
|
|
|
|
case 'api/statuses/friends.json':
|
|
|
|
|
case 'api/statusnet/groups/list.json':
|
|
|
|
|
case 'api/statuses/mentions.json':
|
|
|
|
|
case 'api/favorites.json':
|
|
|
|
|
case 'api/statuses/friends_timeline.json':
|
|
|
|
|
case 'api/statuses/user_timeline.json':
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-03 06:45:46 +09:00
|
|
|
|
// add logged in user's user array
|
|
|
|
|
if (common_logged_in() && !isset($_GET['screen_name'])) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$profilecurrent = Profile::current();
|
2015-06-03 06:45:46 +09:00
|
|
|
|
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($profilecurrent)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// add screen_name's user array
|
2015-07-02 22:00:57 +09:00
|
|
|
|
elseif(isset($_GET['screen_name'])){
|
2015-06-03 06:45:46 +09:00
|
|
|
|
$screen_name_user = User::getKV('nickname', $_GET['screen_name']);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
if($screen_name_user instanceof User) {
|
2015-06-03 06:45:46 +09:00
|
|
|
|
if (common_logged_in()) {
|
|
|
|
|
$profilecurrent = Profile::current();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$currentuser = $profilecurrent->getUser();
|
2015-06-03 06:45:46 +09:00
|
|
|
|
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($screen_name_user->getProfile(),$currentuser)));
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($screen_name_user->getProfile())));
|
2015-06-03 06:45:46 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2015-06-04 06:25:55 +09:00
|
|
|
|
break;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
2014-11-24 21:47:45 +09:00
|
|
|
|
/**
|
|
|
|
|
* Add script to default ui, to be able to toggle Qvitter with one click
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook return
|
2015-07-02 22:00:57 +09:00
|
|
|
|
*/
|
2014-11-24 21:47:45 +09:00
|
|
|
|
|
|
|
|
|
function onEndShowScripts($action){
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
if (common_logged_in()) {
|
2014-11-24 21:47:45 +09:00
|
|
|
|
|
|
|
|
|
$user = common_current_user();
|
|
|
|
|
$profile = $user->getProfile();
|
|
|
|
|
$qvitter_enabled='false';
|
|
|
|
|
|
|
|
|
|
// if qvitter is enabled by default but _not_ disabled by the user,
|
|
|
|
|
if(QvitterPlugin::settings('enabledbydefault')) {
|
|
|
|
|
$disabled = Profile_prefs::getConfigData($profile, 'qvitter', 'disable_qvitter');
|
|
|
|
|
if($disabled == 0) {
|
|
|
|
|
$qvitter_enabled='true';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if qvitter is disabled by default and _enabled_ by the user,
|
|
|
|
|
else {
|
|
|
|
|
$enabled = Profile_prefs::getConfigData($profile, 'qvitter', 'enable_qvitter');
|
|
|
|
|
if($enabled == 1) {
|
|
|
|
|
$qvitter_enabled='true';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-27 20:54:56 +09:00
|
|
|
|
$action->inlineScript(' var toggleQvitterAPIURL = \''.common_path('', true).'api/qvitter/toggle_qvitter.json\';
|
|
|
|
|
var toggleText = \'New '.str_replace("'","\'",common_config('site','name')).'\';
|
|
|
|
|
var qvitterEnabled = '.$qvitter_enabled.';
|
|
|
|
|
var qvitterAllLink = \''.common_local_url('all', array('nickname' => $user->nickname)).'\';
|
2015-07-02 22:00:57 +09:00
|
|
|
|
');
|
2014-12-05 12:48:55 +09:00
|
|
|
|
$action->script($this->path('js/toggleqvitter.js').'?changed='.date('YmdHis',filemtime(QVITTERDIR.'/js/toggleqvitter.js')));
|
2014-11-24 21:47:45 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
/**
|
|
|
|
|
* Menu item for Qvitter
|
|
|
|
|
*
|
|
|
|
|
* @param Action $action action being executed
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook return
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function onEndAccountSettingsNav($action)
|
|
|
|
|
{
|
|
|
|
|
$action_name = $action->trimmed('action');
|
|
|
|
|
|
|
|
|
|
$action->menuItem(common_local_url('qvittersettings'),
|
|
|
|
|
// TRANS: Poll plugin menu item on user settings page.
|
|
|
|
|
_m('MENU', 'Qvitter'),
|
|
|
|
|
// TRANS: Poll plugin tooltip for user settings menu item.
|
|
|
|
|
_m('Enable/Disable Qvitter UI'),
|
|
|
|
|
$action_name === 'qvittersettings');
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
/**
|
|
|
|
|
* Menu item for admin panel
|
|
|
|
|
*
|
|
|
|
|
* @param Action $action action being executed
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook return
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function onEndAdminPanelNav($action)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$action_name = $action->trimmed('action');
|
|
|
|
|
|
|
|
|
|
$action->out->menuItem(common_local_url('qvitteradminsettings'),
|
|
|
|
|
// TRANS: Poll plugin menu item on user settings page.
|
|
|
|
|
_m('MENU', 'Qvitter'),
|
|
|
|
|
// TRANS: Poll plugin tooltip for user settings menu item.
|
|
|
|
|
_m('Qvitter Sidebar Notice'),
|
|
|
|
|
$action_name === 'qvitteradminsettings');
|
|
|
|
|
|
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
|
|
|
|
|
2014-09-10 03:48:44 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-03 02:24:54 +09:00
|
|
|
|
* Add stuff to notices in API responses
|
2014-09-10 03:48:44 +09:00
|
|
|
|
*
|
|
|
|
|
* @param Action $action action being executed
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook return
|
|
|
|
|
*/
|
|
|
|
|
|
2015-02-26 05:16:24 +09:00
|
|
|
|
function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
|
2014-09-10 03:48:44 +09:00
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-10-03 02:24:54 +09:00
|
|
|
|
// groups
|
2014-09-10 03:48:44 +09:00
|
|
|
|
$notice_groups = $notice->getGroups();
|
|
|
|
|
$group_addressees = false;
|
|
|
|
|
foreach($notice_groups as $g) {
|
2014-11-24 21:47:45 +09:00
|
|
|
|
$group_addressees = array('nickname'=>$g->nickname,'url'=>$g->mainpage);
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['statusnet_in_groups'] = $group_addressees;
|
2014-09-10 03:48:44 +09:00
|
|
|
|
|
2015-02-26 05:16:24 +09:00
|
|
|
|
// include the repeat-id, which we need when unrepeating later
|
2015-03-13 07:57:25 +09:00
|
|
|
|
if(array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
|
2015-02-26 05:16:24 +09:00
|
|
|
|
$repeated = Notice::pkeyGet(array('profile_id' => $scoped->id,
|
|
|
|
|
'repeat_of' => $notice->id));
|
|
|
|
|
$twitter_status['repeated_id'] = $repeated->id;
|
|
|
|
|
}
|
2014-11-24 21:47:45 +09:00
|
|
|
|
|
2014-10-03 02:24:54 +09:00
|
|
|
|
// thumb urls
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-10-03 02:24:54 +09:00
|
|
|
|
// find all thumbs
|
|
|
|
|
$attachments = $notice->attachments();
|
2015-01-24 00:28:41 +09:00
|
|
|
|
$attachment_url_to_id = array();
|
2014-10-03 02:24:54 +09:00
|
|
|
|
if (!empty($attachments)) {
|
|
|
|
|
foreach ($attachments as $attachment) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
if(is_object($attachment)) {
|
2015-06-10 06:42:41 +09:00
|
|
|
|
try {
|
|
|
|
|
$enclosure_o = $attachment->getEnclosure();
|
|
|
|
|
$thumb = $attachment->getThumbnail();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-01-26 09:47:45 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb->getUrl();
|
2015-06-10 06:42:41 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
|
|
|
|
|
|
2015-06-17 07:44:18 +09:00
|
|
|
|
// animated gif?
|
|
|
|
|
if($attachment->mimetype == 'image/gif') {
|
|
|
|
|
$image = ImageFile::fromFileObject($attachment);
|
|
|
|
|
if($image->animated == 1) {
|
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
|
2015-06-17 07:44:18 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-10 06:42:41 +09:00
|
|
|
|
} catch (ServerException $e) {
|
|
|
|
|
$thumb = File_thumbnail::getKV('file_id', $attachment->id);
|
|
|
|
|
if ($thumb instanceof File_thumbnail) {
|
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
|
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb->getUrl();
|
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
|
|
|
|
|
|
2015-06-17 07:44:18 +09:00
|
|
|
|
// animated gif?
|
|
|
|
|
if($attachment->mimetype == 'image/gif') {
|
|
|
|
|
$image = ImageFile::fromFileObject($attachment);
|
|
|
|
|
if($image->animated == 1) {
|
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
|
2015-06-17 07:44:18 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-10 06:42:41 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-30 19:50:28 +09:00
|
|
|
|
}
|
2014-10-03 02:24:54 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-10-03 02:24:54 +09:00
|
|
|
|
// add thumbs to $twitter_status
|
|
|
|
|
if (!empty($twitter_status['attachments'])) {
|
|
|
|
|
foreach ($twitter_status['attachments'] as &$attachment) {
|
2015-01-24 00:28:41 +09:00
|
|
|
|
if (!empty($attachment_url_to_id[$attachment['url']])) {
|
2015-01-26 03:05:09 +09:00
|
|
|
|
$attachment['id'] = $attachment_url_to_id[$attachment['url']]['id'];
|
2015-06-10 06:42:41 +09:00
|
|
|
|
$attachment['width'] = $attachment_url_to_id[$attachment['url']]['width'];
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment['height'] = $attachment_url_to_id[$attachment['url']]['height'];
|
2015-06-17 07:44:18 +09:00
|
|
|
|
$attachment['thumb_url'] = $attachment_url_to_id[$attachment['url']]['thumb_url'];
|
|
|
|
|
if(isset($attachment_url_to_id[$attachment['url']]['animated'])) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$attachment['animated'] = $attachment_url_to_id[$attachment['url']]['animated'];
|
2015-06-17 07:44:18 +09:00
|
|
|
|
}
|
2014-10-03 02:24:54 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-24 21:47:45 +09:00
|
|
|
|
// reply-to profile url
|
2015-06-12 23:56:25 +09:00
|
|
|
|
try {
|
|
|
|
|
$reply = $notice->getParent();
|
|
|
|
|
$twitter_status['in_reply_to_profileurl'] = $reply->getProfile()->getUrl();
|
|
|
|
|
} catch (ServerException $e) {
|
|
|
|
|
$twitter_status['in_reply_to_profileurl'] = null;
|
2014-11-24 21:47:45 +09:00
|
|
|
|
}
|
2014-11-25 09:58:30 +09:00
|
|
|
|
|
2015-06-24 22:34:44 +09:00
|
|
|
|
// fave number
|
|
|
|
|
$faves = Fave::byNotice($notice);
|
|
|
|
|
$favenum = count($faves);
|
|
|
|
|
$twitter_status['fave_num'] = $favenum;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-24 22:34:44 +09:00
|
|
|
|
// repeat number
|
|
|
|
|
$repeats = $notice->repeatStream();
|
|
|
|
|
$repeatnum=0;
|
|
|
|
|
while ($repeats->fetch()) {
|
|
|
|
|
$repeatnum++;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['repeat_num'] = $repeatnum;
|
|
|
|
|
|
2014-11-24 21:47:45 +09:00
|
|
|
|
// some more metadata about notice
|
|
|
|
|
if($notice->is_local == '1') {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['is_local'] = true;
|
2014-11-24 21:47:45 +09:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['is_local'] = false;
|
2015-05-25 19:17:38 +09:00
|
|
|
|
if($notice->object_type != 'activity') {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['external_url'] = $notice->getUrl(true);
|
2015-05-25 19:17:38 +09:00
|
|
|
|
}
|
2014-11-24 21:47:45 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
if($notice->object_type == 'activity' || $notice->object_type == 'http://activitystrea.ms/schema/1.0/activity') {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['is_activity'] = true;
|
2014-11-24 21:47:45 +09:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['is_activity'] = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
if($notice->verb == 'qvitter-delete-notice') {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_status['qvitter_delete_notice'] = true;
|
2015-06-19 03:55:46 +09:00
|
|
|
|
}
|
2014-10-03 02:24:54 +09:00
|
|
|
|
|
2014-09-10 03:48:44 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
2014-09-10 03:48:44 +09:00
|
|
|
|
/**
|
2014-11-24 21:47:45 +09:00
|
|
|
|
* Cover photo in API response, also follows_you, etc
|
2014-09-10 03:48:44 +09:00
|
|
|
|
*
|
|
|
|
|
* @return boolean hook return
|
|
|
|
|
*/
|
|
|
|
|
|
2014-09-30 21:52:41 +09:00
|
|
|
|
function onTwitterUserArray($profile, &$twitter_user, $scoped)
|
2014-09-10 03:48:44 +09:00
|
|
|
|
{
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$twitter_user['cover_photo'] = Profile_prefs::getConfigData($profile, 'qvitter', 'cover_photo');
|
|
|
|
|
$twitter_user['background_image'] = Profile_prefs::getConfigData($profile, 'qvitter', 'background_image');
|
|
|
|
|
|
2014-09-10 03:48:44 +09:00
|
|
|
|
|
2014-09-30 21:52:41 +09:00
|
|
|
|
// follows me?
|
|
|
|
|
if ($scoped) {
|
|
|
|
|
$twitter_user['follows_you'] = $profile->isSubscribed($scoped);
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
// local user?
|
2014-11-24 21:47:45 +09:00
|
|
|
|
$twitter_user['is_local'] = $profile->isLocal();
|
2014-09-30 21:52:41 +09:00
|
|
|
|
|
|
|
|
|
|
2014-09-10 03:48:44 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert into notification table
|
|
|
|
|
*/
|
|
|
|
|
function insertNotification($to_profile_id, $from_profile_id, $ntype, $notice_id=false)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-05-19 23:51:42 +09:00
|
|
|
|
$to_user = User::getKV('id', $to_profile_id);
|
2015-06-17 03:20:28 +09:00
|
|
|
|
$from_profile = Profile::getKV($from_profile_id);
|
|
|
|
|
|
|
|
|
|
// don't notify remote profiles
|
|
|
|
|
if (!$to_user instanceof User) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// no notifications from blocked profiles
|
|
|
|
|
if ($to_user->hasBlocked($from_profile)) {
|
2015-05-19 23:51:42 +09:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
// never notify myself
|
2015-05-19 23:51:42 +09:00
|
|
|
|
if($to_profile_id == $from_profile_id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
// insert
|
2015-05-19 23:51:42 +09:00
|
|
|
|
$notif = new QvitterNotification();
|
|
|
|
|
$notif->to_profile_id = $to_profile_id;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notif->from_profile_id = $from_profile_id;
|
2015-05-19 23:51:42 +09:00
|
|
|
|
$notif->ntype = $ntype;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notif->notice_id = $notice_id;
|
|
|
|
|
$notif->created = common_sql_now();
|
2015-05-19 23:51:42 +09:00
|
|
|
|
if (!$notif->insert()) {
|
|
|
|
|
common_log_db_error($notif, 'INSERT', __FILE__);
|
|
|
|
|
return false;
|
2014-09-25 06:20:35 +09:00
|
|
|
|
}
|
2015-05-19 23:51:42 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert likes in notification table
|
|
|
|
|
*/
|
|
|
|
|
public function onEndFavorNotice($profile, $notice)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
// don't notify people favoriting their own notices
|
2014-09-25 06:20:35 +09:00
|
|
|
|
if($notice->profile_id != $profile->id) {
|
2015-01-22 01:49:59 +09:00
|
|
|
|
$this->insertNotification($notice->profile_id, $profile->id, 'like', $notice->id);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
/**
|
|
|
|
|
* Remove likes in notification table on dislike
|
|
|
|
|
*/
|
|
|
|
|
public function onEndDisfavorNotice($profile, $notice)
|
|
|
|
|
{
|
|
|
|
|
$notif = new QvitterNotification();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notif->from_profile_id = $profile->id;
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$notif->notice_id = $notice->id;
|
|
|
|
|
$notif->ntype = 'like';
|
|
|
|
|
$notif->delete();
|
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
/**
|
|
|
|
|
* Insert notifications for replies, mentions and repeats
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
|
|
|
|
function onStartNoticeDistribute($notice) {
|
2015-06-17 07:44:18 +09:00
|
|
|
|
|
2015-06-02 20:30:29 +09:00
|
|
|
|
assert($notice->id > 0); // since we removed tests below
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
2015-01-20 23:47:58 +09:00
|
|
|
|
// don't add notifications for activity type notices
|
|
|
|
|
if($notice->object_type == 'activity') {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
return true;
|
2015-01-20 23:47:58 +09:00
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
2015-05-19 23:51:42 +09:00
|
|
|
|
// mark reply/mention-notifications as read if we're replying to a notice we're notified about
|
|
|
|
|
if($notice->reply_to) {
|
|
|
|
|
|
|
|
|
|
$notification_to_mark_as_seen = QvitterNotification::pkeyGet(array('is_seen' => 0,
|
|
|
|
|
'notice_id' => $notice->reply_to,
|
2015-06-05 03:21:49 +09:00
|
|
|
|
'to_profile_id' => $notice->profile_id));
|
2015-05-19 23:51:42 +09:00
|
|
|
|
if($notification_to_mark_as_seen instanceof QvitterNotification
|
|
|
|
|
&& ($notification_to_mark_as_seen->ntype == 'mention' || $notification_to_mark_as_seen->ntype == 'reply')) {
|
|
|
|
|
$orig = clone($notification_to_mark_as_seen);
|
|
|
|
|
$notification_to_mark_as_seen->is_seen = 1;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notification_to_mark_as_seen->update($orig);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-05-19 23:51:42 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
// repeats
|
|
|
|
|
if ($notice->isRepeat()) {
|
|
|
|
|
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
if ($repeated_notice instanceof Notice) {
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$this->insertNotification($repeated_notice->profile_id, $notice->profile_id, 'repeat', $repeated_notice->id);
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
|
|
|
|
// replies and mentions (no notifications for these if this is a repeat)
|
|
|
|
|
else {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$reply_notification_to = false;
|
2014-09-25 06:20:35 +09:00
|
|
|
|
// check for reply to insert in notifications
|
|
|
|
|
if($notice->reply_to) {
|
2015-06-02 21:04:22 +09:00
|
|
|
|
try {
|
|
|
|
|
$replyauthor = $notice->getParent()->getProfile();
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$reply_notification_to = $replyauthor->id;
|
|
|
|
|
$this->insertNotification($replyauthor->id, $notice->profile_id, 'reply', $notice->id);
|
2015-06-02 21:04:22 +09:00
|
|
|
|
//} catch (NoParentNoticeException $e) { // TODO: catch this when everyone runs latest GNU social!
|
|
|
|
|
// This is not a reply to something (has no parent)
|
|
|
|
|
} catch (NoResultException $e) {
|
2015-06-02 21:44:44 +09:00
|
|
|
|
// Parent author's profile not found! Complain louder?
|
|
|
|
|
common_log(LOG_ERR, "Parent notice's author not found: ".$e->getMessage());
|
2014-09-25 06:20:35 +09:00
|
|
|
|
}
|
2015-06-02 21:04:22 +09:00
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
// check for mentions to insert in notifications
|
2015-06-17 03:20:28 +09:00
|
|
|
|
$mentions = $notice->getReplies();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$sender = Profile::getKV($notice->profile_id);
|
2015-05-19 21:11:33 +09:00
|
|
|
|
$all_mentioned_user_ids = array();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
foreach ($mentions as $mentioned) {
|
2015-06-17 03:20:28 +09:00
|
|
|
|
|
|
|
|
|
// no duplicate mentions
|
|
|
|
|
if(in_array($mentioned, $all_mentioned_user_ids)) {
|
|
|
|
|
continue;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2015-06-17 03:20:28 +09:00
|
|
|
|
$all_mentioned_user_ids[] = $mentioned;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-17 03:20:28 +09:00
|
|
|
|
// only notify if mentioned user is not already notified for reply
|
|
|
|
|
if($reply_notification_to != $mentioned) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$this->insertNotification($mentioned, $notice->profile_id, 'mention', $notice->id);
|
2014-09-25 06:20:35 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete any notifications tied to deleted notices and un-repeats
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
|
|
|
|
public function onNoticeDeleteRelated($notice)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$notif = new QvitterNotification();
|
|
|
|
|
|
|
|
|
|
// unrepeats
|
|
|
|
|
if ($notice->isRepeat()) {
|
|
|
|
|
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notif->notice_id = $repeated_notice->id;
|
|
|
|
|
$notif->from_profile_id = $notice->profile_id;
|
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
// notices
|
|
|
|
|
else {
|
|
|
|
|
$notif->notice_id = $notice->id;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$notif->delete();
|
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
// outputs an activity notice that this notice was deleted
|
|
|
|
|
$profile = $notice->getProfile();
|
|
|
|
|
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
|
|
|
|
|
$profile->getUrl(),
|
|
|
|
|
$profile->getBestName(),
|
|
|
|
|
$notice->getUrl(),
|
|
|
|
|
$notice->uri);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$text = sprintf(_m('%1$s deleted notice {{%2$s}}.'),
|
|
|
|
|
$profile->getBestName(),
|
|
|
|
|
$notice->uri);
|
2015-06-19 03:55:46 +09:00
|
|
|
|
$uri = TagURI::mint('delete-notice:%d:%d:%s',
|
|
|
|
|
$notice->profile_id,
|
|
|
|
|
$notice->id,
|
|
|
|
|
common_date_iso8601(common_sql_now()));
|
|
|
|
|
$notice = Notice::saveNew($notice->profile_id,
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$text,
|
2015-06-19 03:55:46 +09:00
|
|
|
|
ActivityPlugin::SOURCE,
|
|
|
|
|
array('rendered' => $rendered,
|
|
|
|
|
'urls' => array(),
|
|
|
|
|
'uri' => $uri,
|
|
|
|
|
'verb' => 'qvitter-delete-notice',
|
2015-07-02 22:00:57 +09:00
|
|
|
|
'object_type' => ActivityObject::ACTIVITY));
|
2015-06-19 03:55:46 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks for deleted remote notices and deleted the locally
|
|
|
|
|
* A local qvitter-delete-notice is outputted in the onNoticeDeleteRelated event above
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
public function onEndHandleFeedEntry($activity) {
|
|
|
|
|
|
|
|
|
|
if($activity->verb == 'qvitter-delete-notice') {
|
|
|
|
|
|
|
|
|
|
$deleter_profile_uri = $activity->actor->id;
|
|
|
|
|
$deleted_notice_uri = $activity->objects[0]->objects[0]->content;
|
|
|
|
|
$deleted_notice_uri = substr($deleted_notice_uri,strpos($deleted_notice_uri,'{{')+2);
|
|
|
|
|
$deleted_notice_uri = substr($deleted_notice_uri,0,strpos($deleted_notice_uri,'}}'));
|
|
|
|
|
|
|
|
|
|
$deleter_ostatus_profile = Ostatus_profile::getKV('uri', $deleter_profile_uri);
|
|
|
|
|
|
|
|
|
|
if(!$deleter_ostatus_profile instanceof Ostatus_profile) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$deleter_profile = Profile::getKV('id', $deleter_ostatus_profile->profile_id);
|
|
|
|
|
$deleted_notice = Notice::getKV('uri', $deleted_notice_uri);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
if(!($deleter_profile instanceof Profile) || !($deleted_notice instanceof Notice)) {
|
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
if($deleter_profile->id != $deleted_notice->profile_id) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-06-19 03:55:46 +09:00
|
|
|
|
|
|
|
|
|
$deleted_notice->delete();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 03:55:46 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
/**
|
|
|
|
|
* Add notification on subscription, remove on unsubscribe
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
|
|
|
|
public function onEndSubscribe($subscriber, $other)
|
|
|
|
|
{
|
|
|
|
|
if(Subscription::exists($subscriber, $other)) {
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$this->insertNotification($other->id, $subscriber->id, 'follow', 1);
|
2014-09-25 06:20:35 +09:00
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2014-09-25 06:20:35 +09:00
|
|
|
|
public function onEndUnsubscribe($subscriber, $other)
|
|
|
|
|
{
|
|
|
|
|
if(!Subscription::exists($subscriber, $other)) {
|
|
|
|
|
$notif = new QvitterNotification();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notif->to_profile_id = $other->id;
|
|
|
|
|
$notif->from_profile_id = $subscriber->id;
|
2014-09-25 06:20:35 +09:00
|
|
|
|
$notif->ntype = 'follow';
|
|
|
|
|
$notif->delete();
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-09-25 06:20:35 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2014-11-28 09:16:34 +09:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replace GNU Social's default FAQ with Qvitter's
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
|
|
|
|
public function onEndLoadDoc($title, &$output)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-11-28 09:16:34 +09:00
|
|
|
|
if($title == 'faq') {
|
|
|
|
|
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$faq = file_get_contents(QVITTERDIR.'/doc/en/faq.html');
|
|
|
|
|
$faq = str_replace('{instance-name}',common_config('site','name'),$faq);
|
|
|
|
|
$faq = str_replace('{instance-url}',common_config('site','server'),$faq);
|
|
|
|
|
$faq = str_replace('{instance-url-with-protocol}',common_path('', true),$faq);
|
|
|
|
|
|
|
|
|
|
if (common_logged_in()) {
|
2014-11-28 09:16:34 +09:00
|
|
|
|
$user = common_current_user();
|
|
|
|
|
$faq = str_replace('{nickname}',$user->nickname,$faq);
|
|
|
|
|
}
|
|
|
|
|
$output = $faq;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-11-28 09:16:34 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-28 09:16:34 +09:00
|
|
|
|
/**
|
|
|
|
|
* Add menu items to top header in Classic
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
|
|
|
|
public function onStartPrimaryNav($action)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-11-28 09:16:34 +09:00
|
|
|
|
$action->menuItem(common_local_url('doc', array('title' => 'faq')),
|
|
|
|
|
// TRANS: Menu item in primary navigation panel.
|
|
|
|
|
_m('MENU','FAQ'),
|
|
|
|
|
// TRANS: Menu item title in primary navigation panel.
|
|
|
|
|
_('Frequently asked questions'),
|
|
|
|
|
false,
|
|
|
|
|
'top_nav_doc_faq');
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-11-28 09:16:34 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
2015-02-04 22:44:04 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* No registration for blocked ips
|
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
|
|
|
|
*/
|
|
|
|
|
public function onStartUserRegister($profile)
|
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-02-04 22:44:04 +09:00
|
|
|
|
if(is_array(self::settings("blocked_ips"))) {
|
|
|
|
|
if(in_array($_SERVER['REMOTE_ADDR'], self::settings("blocked_ips"))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 22:44:04 +09:00
|
|
|
|
return true;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-01-27 01:13:34 +09:00
|
|
|
|
|
|
|
|
|
/**
|
2015-06-03 06:45:46 +09:00
|
|
|
|
* Add unread notification count to all API responses, when logged in
|
2015-01-27 01:13:34 +09:00
|
|
|
|
*
|
|
|
|
|
* @return boolean hook flag
|
2015-07-02 22:00:57 +09:00
|
|
|
|
*/
|
2015-01-27 01:13:34 +09:00
|
|
|
|
public function onEndSetApiUser($user) {
|
2015-02-13 09:02:03 +09:00
|
|
|
|
if (!$user instanceof User) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-01-27 01:13:34 +09:00
|
|
|
|
|
|
|
|
|
$user_id = $user->id;
|
|
|
|
|
$notification = new QvitterNotification();
|
|
|
|
|
|
|
|
|
|
$notification->selectAdd();
|
|
|
|
|
$notification->selectAdd('ntype');
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notification->selectAdd('count(id) as count');
|
2015-01-27 01:13:34 +09:00
|
|
|
|
$notification->whereAdd("(to_profile_id = '".$user_id."')");
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notification->groupBy('ntype');
|
2015-01-27 01:13:34 +09:00
|
|
|
|
$notification->whereAdd("(is_seen = '0')");
|
2015-07-02 22:00:57 +09:00
|
|
|
|
$notification->whereAdd("(notice_id IS NOT NULL)"); // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
|
2015-01-27 01:13:34 +09:00
|
|
|
|
$notification->find();
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-01-28 09:19:36 +09:00
|
|
|
|
$new_notifications = array();
|
2015-01-27 01:13:34 +09:00
|
|
|
|
while ($notification->fetch()) {
|
|
|
|
|
$new_notifications[$notification->ntype] = $notification->count;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
header('Qvitter-Notifications: '.json_encode($new_notifications));
|
2015-01-27 01:13:34 +09:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
|
2015-06-07 05:13:05 +09:00
|
|
|
|
function onPluginVersion(array &$versions)
|
2014-11-24 21:47:45 +09:00
|
|
|
|
{
|
|
|
|
|
$versions[] = array('name' => 'Qvitter',
|
2015-06-07 17:57:25 +09:00
|
|
|
|
'version' => '5-alpha',
|
2014-11-24 21:47:45 +09:00
|
|
|
|
'author' => 'Hannes Mannerheim',
|
|
|
|
|
'homepage' => 'https://github.com/hannesmannerheim/qvitter',
|
|
|
|
|
'rawdescription' => _m('User interface'));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-06-03 06:45:46 +09:00
|
|
|
|
function qvitterTwitterUserArray($profile, $logged_in=false)
|
|
|
|
|
{
|
|
|
|
|
$twitter_user = array();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$user = $profile->getUser();
|
|
|
|
|
} catch (NoSuchUserException $e) {
|
|
|
|
|
$user = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$twitter_user['id'] = intval($profile->id);
|
|
|
|
|
$twitter_user['name'] = $profile->getBestName();
|
|
|
|
|
$twitter_user['screen_name'] = $profile->nickname;
|
|
|
|
|
$twitter_user['location'] = ($profile->location) ? $profile->location : null;
|
|
|
|
|
$twitter_user['description'] = ($profile->bio) ? $profile->bio : null;
|
|
|
|
|
|
|
|
|
|
// TODO: avatar url template (example.com/user/avatar?size={x}x{y})
|
|
|
|
|
$twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE);
|
|
|
|
|
$twitter_user['profile_image_url_https'] = $twitter_user['profile_image_url'];
|
|
|
|
|
|
|
|
|
|
// START introduced by qvitter API, not necessary for StatusNet API
|
|
|
|
|
$twitter_user['profile_image_url_profile_size'] = Avatar::urlByProfile($profile, AVATAR_PROFILE_SIZE);
|
|
|
|
|
try {
|
|
|
|
|
$avatar = Avatar::getUploaded($profile);
|
|
|
|
|
$origurl = $avatar->displayUrl();
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$origurl = $twitter_user['profile_image_url_profile_size'];
|
|
|
|
|
}
|
|
|
|
|
$twitter_user['profile_image_url_original'] = $origurl;
|
|
|
|
|
|
|
|
|
|
$twitter_user['groups_count'] = $profile->getGroupCount();
|
|
|
|
|
foreach (array('linkcolor', 'backgroundcolor') as $key) {
|
|
|
|
|
$twitter_user[$key] = Profile_prefs::getConfigData($profile, 'theme', $key);
|
|
|
|
|
}
|
|
|
|
|
// END introduced by qvitter API, not necessary for StatusNet API
|
|
|
|
|
|
|
|
|
|
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
|
|
|
|
$twitter_user['protected'] = (!empty($user) && $user->private_stream) ? true : false;
|
|
|
|
|
$twitter_user['followers_count'] = $profile->subscriberCount();
|
|
|
|
|
|
|
|
|
|
// Note: some profiles don't have an associated user
|
|
|
|
|
|
|
|
|
|
$twitter_user['friends_count'] = $profile->subscriptionCount();
|
|
|
|
|
|
|
|
|
|
$twitter_user['created_at'] = ApiAction::dateTwitter($profile->created);
|
|
|
|
|
|
|
|
|
|
$timezone = 'UTC';
|
|
|
|
|
|
|
|
|
|
if (!empty($user) && $user->timezone) {
|
|
|
|
|
$timezone = $user->timezone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$t = new DateTime;
|
|
|
|
|
$t->setTimezone(new DateTimeZone($timezone));
|
|
|
|
|
|
|
|
|
|
$twitter_user['utc_offset'] = $t->format('Z');
|
|
|
|
|
$twitter_user['time_zone'] = $timezone;
|
|
|
|
|
$twitter_user['statuses_count'] = $profile->noticeCount();
|
|
|
|
|
|
|
|
|
|
// Is the requesting user following this user?
|
|
|
|
|
$twitter_user['following'] = false;
|
|
|
|
|
$twitter_user['statusnet_blocking'] = false;
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-03 06:45:46 +09:00
|
|
|
|
$logged_in_profile = Profile::current();
|
|
|
|
|
|
|
|
|
|
if ($logged_in) {
|
|
|
|
|
|
|
|
|
|
$twitter_user['following'] = $logged_in->isSubscribed($profile);
|
|
|
|
|
$twitter_user['statusnet_blocking'] = $logged_in->hasBlocked($profile);
|
|
|
|
|
|
|
|
|
|
$logged_in_profile = $logged_in->getProfile();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// StatusNet-specific
|
|
|
|
|
|
|
|
|
|
$twitter_user['statusnet_profile_url'] = $profile->profileurl;
|
|
|
|
|
|
|
|
|
|
// The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2015-06-03 06:45:46 +09:00
|
|
|
|
Event::handle('TwitterUserArray', array($profile, &$twitter_user, $logged_in_profile, array()));
|
|
|
|
|
|
|
|
|
|
return $twitter_user;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-24 21:47:45 +09:00
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-10 03:48:44 +09:00
|
|
|
|
|
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
/**
|
|
|
|
|
* Overwrites variables in URL-mapping
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class URLMapperOverwrite extends URLMapper
|
|
|
|
|
{
|
2015-06-13 00:16:04 +09:00
|
|
|
|
static function overwrite_variable($m, $path, $args, $paramPatterns, $newaction)
|
2014-05-14 16:46:07 +09:00
|
|
|
|
{
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
|
|
|
|
$m->connect($path, array('action' => $newaction), $paramPatterns);
|
|
|
|
|
|
2015-06-13 00:16:04 +09:00
|
|
|
|
$regex = self::makeRegex($path, $paramPatterns);
|
2015-07-02 22:00:57 +09:00
|
|
|
|
|
2014-05-14 16:46:07 +09:00
|
|
|
|
foreach($m->variables as $n=>$v)
|
2015-07-02 22:00:57 +09:00
|
|
|
|
if($v[1] == $regex)
|
2014-05-14 16:46:07 +09:00
|
|
|
|
$m->variables[$n][0]['action'] = $newaction;
|
|
|
|
|
}
|
|
|
|
|
}
|