human readable text-field for qvitter's new deleted-notice activity
This commit is contained in:
parent
871fab52b9
commit
0c79026f77
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||||
· ·
|
· ·
|
||||||
· ·
|
· ·
|
||||||
· Q V I T T E R ·
|
· Q V I T T E R ·
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
· o> \\\\_\ ·
|
· o> \\\\_\ ·
|
||||||
· \\) \____) ·
|
· \\) \____) ·
|
||||||
· ·
|
· ·
|
||||||
· ·
|
· ·
|
||||||
· ·
|
· ·
|
||||||
· Qvitter is free software: you can redistribute it and / or modify it ·
|
· 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 ·
|
· under the terms of the GNU Affero General Public License as published by ·
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
||||||
· ·
|
· ·
|
||||||
· Contact h@nnesmannerhe.im if you have any questions. ·
|
· Contact h@nnesmannerhe.im if you have any questions. ·
|
||||||
· ·
|
· ·
|
||||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||||
|
|
||||||
const QVITTERDIR = __DIR__;
|
const QVITTERDIR = __DIR__;
|
||||||
|
@ -42,12 +42,12 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
static function settings($setting)
|
static function settings($setting)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||||
· ·
|
· ·
|
||||||
· S E T T I N G S ·
|
· S E T T I N G S ·
|
||||||
· ·
|
· ·
|
||||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||||
|
|
||||||
// THESE SETTINGS CAN BE OVERRIDDEN IN CONFIG.PHP
|
// THESE SETTINGS CAN BE OVERRIDDEN IN CONFIG.PHP
|
||||||
// e.g. $config['site']['qvitter']['enabledbydefault'] = 'false';
|
// e.g. $config['site']['qvitter']['enabledbydefault'] = 'false';
|
||||||
|
@ -71,10 +71,10 @@ class QvitterPlugin extends Plugin {
|
||||||
$settings['defaultlinkcolor'] = '#0084B4';
|
$settings['defaultlinkcolor'] = '#0084B4';
|
||||||
|
|
||||||
// ENABLE DEFAULT WELCOME TEXT
|
// ENABLE DEFAULT WELCOME TEXT
|
||||||
$settings['enablewelcometext'] = true;
|
$settings['enablewelcometext'] = true;
|
||||||
|
|
||||||
// CUSTOM WELCOME TEXT (overrides the previous setting)
|
// CUSTOM WELCOME TEXT (overrides the previous setting)
|
||||||
$settings['customwelcometext'] = false;
|
$settings['customwelcometext'] = false;
|
||||||
|
|
||||||
// Example:
|
// Example:
|
||||||
// $settings['customwelcometext']['sv'] = '<h1>Välkommen till Quitter.se – en federerad<sup>1</sup> mikrobloggsallmänning!</h1><p>Etc etc...</p>';
|
// $settings['customwelcometext']['sv'] = '<h1>Välkommen till Quitter.se – en federerad<sup>1</sup> mikrobloggsallmänning!</h1><p>Etc etc...</p>';
|
||||||
|
@ -86,30 +86,30 @@ class QvitterPlugin extends Plugin {
|
||||||
// URL SHORTENER
|
// URL SHORTENER
|
||||||
$settings['urlshortenerapiurl'] = 'http://qttr.at/yourls-api.php';
|
$settings['urlshortenerapiurl'] = 'http://qttr.at/yourls-api.php';
|
||||||
$settings['urlshortenersignature'] = 'b6afeec983';
|
$settings['urlshortenersignature'] = 'b6afeec983';
|
||||||
|
|
||||||
// CUSTOM TERMS OF USE
|
// CUSTOM TERMS OF USE
|
||||||
$settings['customtermsofuse'] = false;
|
$settings['customtermsofuse'] = false;
|
||||||
|
|
||||||
// IP ADDRESSES BLOCKED FROM REGISTRATION
|
// IP ADDRESSES BLOCKED FROM REGISTRATION
|
||||||
$settings['blocked_ips'] = array();
|
$settings['blocked_ips'] = array();
|
||||||
|
|
||||||
|
|
||||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||||
· ·
|
· ·
|
||||||
· (o> >o) ·
|
· (o> >o) ·
|
||||||
· \\\\_\ /_//// .
|
· \\\\_\ /_//// .
|
||||||
· \____) (____/ ·
|
· \____) (____/ ·
|
||||||
· ·
|
· ·
|
||||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||||
|
|
||||||
// config.php settings override the settings in this file
|
// config.php settings override the settings in this file
|
||||||
$configphpsettings = common_config('site','qvitter') ?: array();
|
$configphpsettings = common_config('site','qvitter') ?: array();
|
||||||
foreach($configphpsettings as $configphpsetting=>$value) {
|
foreach($configphpsettings as $configphpsetting=>$value) {
|
||||||
$settings[$configphpsetting] = $value;
|
$settings[$configphpsetting] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($settings[$setting])) {
|
if(isset($settings[$setting])) {
|
||||||
return $settings[$setting];
|
return $settings[$setting];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -134,7 +134,7 @@ class QvitterPlugin extends Plugin {
|
||||||
// show qvitter link in the admin panel
|
// show qvitter link in the admin panel
|
||||||
common_config_append('admin', 'panels', 'qvitteradm');
|
common_config_append('admin', 'panels', 'qvitteradm');
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure we have a notifications table
|
// make sure we have a notifications table
|
||||||
function onCheckSchema()
|
function onCheckSchema()
|
||||||
{
|
{
|
||||||
|
@ -142,11 +142,11 @@ class QvitterPlugin extends Plugin {
|
||||||
$schema->ensureTable('qvitternotification', QvitterNotification::schemaDef());
|
$schema->ensureTable('qvitternotification', QvitterNotification::schemaDef());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// route/reroute urls
|
// route/reroute urls
|
||||||
public function onRouterInitialized($m)
|
public function onRouterInitialized($m)
|
||||||
{
|
{
|
||||||
|
|
||||||
$m->connect('api/qvitter/favs_and_repeats/:notice_id.json',
|
$m->connect('api/qvitter/favs_and_repeats/:notice_id.json',
|
||||||
array('action' => 'ApiFavsAndRepeats'),
|
array('action' => 'ApiFavsAndRepeats'),
|
||||||
array('notice_id' => '[0-9]+'));
|
array('notice_id' => '[0-9]+'));
|
||||||
|
@ -158,80 +158,80 @@ class QvitterPlugin extends Plugin {
|
||||||
$m->connect('api/qvitter/update_background_color.json',
|
$m->connect('api/qvitter/update_background_color.json',
|
||||||
array('action' => 'apiqvitterupdatebackgroundcolor'));
|
array('action' => 'apiqvitterupdatebackgroundcolor'));
|
||||||
$m->connect('api/qvitter/checklogin.json',
|
$m->connect('api/qvitter/checklogin.json',
|
||||||
array('action' => 'apiqvitterchecklogin'));
|
array('action' => 'apiqvitterchecklogin'));
|
||||||
$m->connect('api/qvitter/allfollowing/:id.json',
|
$m->connect('api/qvitter/allfollowing/:id.json',
|
||||||
array('action' => 'apiqvitterallfollowing',
|
array('action' => 'apiqvitterallfollowing',
|
||||||
'id' => Nickname::INPUT_FMT));
|
'id' => Nickname::INPUT_FMT));
|
||||||
$m->connect('api/qvitter/update_cover_photo.json',
|
$m->connect('api/qvitter/update_cover_photo.json',
|
||||||
array('action' => 'ApiUpdateCoverPhoto'));
|
array('action' => 'ApiUpdateCoverPhoto'));
|
||||||
$m->connect('api/qvitter/update_background_image.json',
|
$m->connect('api/qvitter/update_background_image.json',
|
||||||
array('action' => 'ApiUpdateBackgroundImage'));
|
array('action' => 'ApiUpdateBackgroundImage'));
|
||||||
$m->connect('api/qvitter/update_avatar.json',
|
$m->connect('api/qvitter/update_avatar.json',
|
||||||
array('action' => 'ApiUpdateAvatar'));
|
array('action' => 'ApiUpdateAvatar'));
|
||||||
$m->connect('api/qvitter/upload_image.json',
|
$m->connect('api/qvitter/upload_image.json',
|
||||||
array('action' => 'ApiUploadImage'));
|
array('action' => 'ApiUploadImage'));
|
||||||
$m->connect('api/qvitter/external_user_show.json',
|
$m->connect('api/qvitter/external_user_show.json',
|
||||||
array('action' => 'ApiExternalUserShow'));
|
array('action' => 'ApiExternalUserShow'));
|
||||||
$m->connect('api/qvitter/toggle_qvitter.json',
|
$m->connect('api/qvitter/toggle_qvitter.json',
|
||||||
array('action' => 'ApiToggleQvitter'));
|
array('action' => 'ApiToggleQvitter'));
|
||||||
$m->connect('api/qvitter/statuses/notifications.json',
|
$m->connect('api/qvitter/statuses/notifications.json',
|
||||||
array('action' => 'apiqvitternotifications'));
|
array('action' => 'apiqvitternotifications'));
|
||||||
$m->connect(':nickname/notifications',
|
$m->connect(':nickname/notifications',
|
||||||
array('action' => 'qvitter',
|
array('action' => 'qvitter',
|
||||||
'nickname' => Nickname::INPUT_FMT));
|
'nickname' => Nickname::INPUT_FMT));
|
||||||
$m->connect('settings/qvitter',
|
$m->connect('settings/qvitter',
|
||||||
array('action' => 'qvittersettings'));
|
array('action' => 'qvittersettings'));
|
||||||
$m->connect('panel/qvitter',
|
$m->connect('panel/qvitter',
|
||||||
array('action' => 'qvitteradminsettings'));
|
array('action' => 'qvitteradminsettings'));
|
||||||
$m->connect('main/qlogin',
|
$m->connect('main/qlogin',
|
||||||
array('action' => 'qvitterlogin'));
|
array('action' => 'qvitterlogin'));
|
||||||
|
|
||||||
if ($this->hijack_ui) {
|
if ($this->hijack_ui) {
|
||||||
$m->connect('', array('action' => 'qvitter'));
|
$m->connect('', array('action' => 'qvitter'));
|
||||||
$m->connect('main/all', array('action' => 'qvitter'));
|
$m->connect('main/all', array('action' => 'qvitter'));
|
||||||
$m->connect('search/notice', array('action' => 'qvitter'));
|
$m->connect('search/notice', array('action' => 'qvitter'));
|
||||||
|
|
||||||
|
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname',
|
||||||
array('action' => 'showstream'),
|
array('action' => 'showstream'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/',
|
||||||
array('action' => 'showstream'),
|
array('action' => 'showstream'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/all',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/all',
|
||||||
array('action' => 'all'),
|
array('action' => 'all'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/subscriptions',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/subscriptions',
|
||||||
array('action' => 'subscriptions'),
|
array('action' => 'subscriptions'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/subscribers',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/subscribers',
|
||||||
array('action' => 'subscribers'),
|
array('action' => 'subscribers'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/groups',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/groups',
|
||||||
array('action' => 'usergroups'),
|
array('action' => 'usergroups'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/replies',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/replies',
|
||||||
array('action' => 'replies'),
|
array('action' => 'replies'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, ':nickname/favorites',
|
URLMapperOverwrite::overwrite_variable($m, ':nickname/favorites',
|
||||||
array('action' => 'showfavorites'),
|
array('action' => 'showfavorites'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, 'group/:nickname',
|
URLMapperOverwrite::overwrite_variable($m, 'group/:nickname',
|
||||||
array('action' => 'showgroup'),
|
array('action' => 'showgroup'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, 'group/:nickname/members',
|
URLMapperOverwrite::overwrite_variable($m, 'group/:nickname/members',
|
||||||
array('action' => 'groupmembers'),
|
array('action' => 'groupmembers'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT),
|
array('nickname' => Nickname::DISPLAY_FMT),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
|
|
||||||
$m->connect('group/:nickname/admins',
|
$m->connect('group/:nickname/admins',
|
||||||
array('action' => 'qvitter'),
|
array('action' => 'qvitter'),
|
||||||
|
@ -239,29 +239,29 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
URLMapperOverwrite::overwrite_variable($m, 'tag/:tag',
|
URLMapperOverwrite::overwrite_variable($m, 'tag/:tag',
|
||||||
array('action' => 'showstream'),
|
array('action' => 'showstream'),
|
||||||
array('tag' => Router::REGEX_TAG),
|
array('tag' => Router::REGEX_TAG),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
URLMapperOverwrite::overwrite_variable($m, 'notice/:notice',
|
URLMapperOverwrite::overwrite_variable($m, 'notice/:notice',
|
||||||
array('action' => 'shownotice'),
|
array('action' => 'shownotice'),
|
||||||
array('notice' => '[0-9]+'),
|
array('notice' => '[0-9]+'),
|
||||||
'qvitter');
|
'qvitter');
|
||||||
}
|
}
|
||||||
|
|
||||||
// if qvitter is opt-out, disable the default register page (if we don't have a valid invitation code)
|
// if qvitter is opt-out, disable the default register page (if we don't have a valid invitation code)
|
||||||
$valid_code = isset($_POST['code'])
|
$valid_code = isset($_POST['code'])
|
||||||
? Invitation::getKV('code', $_POST['code'])
|
? Invitation::getKV('code', $_POST['code'])
|
||||||
: null;
|
: null;
|
||||||
if(self::settings('enabledbydefault') && empty($valid_code)) {
|
if(self::settings('enabledbydefault') && empty($valid_code)) {
|
||||||
$m->connect('main/register',
|
$m->connect('main/register',
|
||||||
array('action' => 'qvitter'));
|
array('action' => 'qvitter'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add user arrays for some urls, to use to build profile cards
|
// 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
|
// this way we don't have to request this in a separate http request
|
||||||
|
|
||||||
if(isset($_GET['withuserarray'])) switch (getPath($_REQUEST)) {
|
if(isset($_GET['withuserarray'])) switch (getPath($_REQUEST)) {
|
||||||
case 'api/statuses/followers.json':
|
case 'api/statuses/followers.json':
|
||||||
case 'api/statuses/friends.json':
|
case 'api/statuses/friends.json':
|
||||||
|
@ -270,42 +270,42 @@ class QvitterPlugin extends Plugin {
|
||||||
case 'api/favorites.json':
|
case 'api/favorites.json':
|
||||||
case 'api/statuses/friends_timeline.json':
|
case 'api/statuses/friends_timeline.json':
|
||||||
case 'api/statuses/user_timeline.json':
|
case 'api/statuses/user_timeline.json':
|
||||||
|
|
||||||
// add logged in user's user array
|
// add logged in user's user array
|
||||||
if (common_logged_in() && !isset($_GET['screen_name'])) {
|
if (common_logged_in() && !isset($_GET['screen_name'])) {
|
||||||
$profilecurrent = Profile::current();
|
$profilecurrent = Profile::current();
|
||||||
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($profilecurrent)));
|
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($profilecurrent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add screen_name's user array
|
// add screen_name's user array
|
||||||
elseif(isset($_GET['screen_name'])){
|
elseif(isset($_GET['screen_name'])){
|
||||||
$screen_name_user = User::getKV('nickname', $_GET['screen_name']);
|
$screen_name_user = User::getKV('nickname', $_GET['screen_name']);
|
||||||
if($screen_name_user instanceof User) {
|
if($screen_name_user instanceof User) {
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
$profilecurrent = Profile::current();
|
$profilecurrent = Profile::current();
|
||||||
$currentuser = $profilecurrent->getUser();
|
$currentuser = $profilecurrent->getUser();
|
||||||
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($screen_name_user->getProfile(),$currentuser)));
|
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($screen_name_user->getProfile(),$currentuser)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($screen_name_user->getProfile())));
|
header('Qvitter-User-Array: '.json_encode($this->qvitterTwitterUserArray($screen_name_user->getProfile())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add script to default ui, to be able to toggle Qvitter with one click
|
* Add script to default ui, to be able to toggle Qvitter with one click
|
||||||
*
|
*
|
||||||
* @return boolean hook return
|
* @return boolean hook return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onEndShowScripts($action){
|
function onEndShowScripts($action){
|
||||||
|
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
@ -330,13 +330,13 @@ class QvitterPlugin extends Plugin {
|
||||||
var toggleText = \'New '.str_replace("'","\'",common_config('site','name')).'\';
|
var toggleText = \'New '.str_replace("'","\'",common_config('site','name')).'\';
|
||||||
var qvitterEnabled = '.$qvitter_enabled.';
|
var qvitterEnabled = '.$qvitter_enabled.';
|
||||||
var qvitterAllLink = \''.common_local_url('all', array('nickname' => $user->nickname)).'\';
|
var qvitterAllLink = \''.common_local_url('all', array('nickname' => $user->nickname)).'\';
|
||||||
');
|
');
|
||||||
$action->script($this->path('js/toggleqvitter.js').'?changed='.date('YmdHis',filemtime(QVITTERDIR.'/js/toggleqvitter.js')));
|
$action->script($this->path('js/toggleqvitter.js').'?changed='.date('YmdHis',filemtime(QVITTERDIR.'/js/toggleqvitter.js')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu item for Qvitter
|
* Menu item for Qvitter
|
||||||
*
|
*
|
||||||
|
@ -358,7 +358,7 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu item for admin panel
|
* Menu item for admin panel
|
||||||
*
|
*
|
||||||
|
@ -369,7 +369,7 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
function onEndAdminPanelNav($action)
|
function onEndAdminPanelNav($action)
|
||||||
{
|
{
|
||||||
|
|
||||||
$action_name = $action->trimmed('action');
|
$action_name = $action->trimmed('action');
|
||||||
|
|
||||||
$action->out->menuItem(common_local_url('qvitteradminsettings'),
|
$action->out->menuItem(common_local_url('qvitteradminsettings'),
|
||||||
|
@ -380,7 +380,7 @@ class QvitterPlugin extends Plugin {
|
||||||
$action_name === 'qvitteradminsettings');
|
$action_name === 'qvitteradminsettings');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -395,14 +395,14 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
|
function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
|
||||||
{
|
{
|
||||||
|
|
||||||
// groups
|
// groups
|
||||||
$notice_groups = $notice->getGroups();
|
$notice_groups = $notice->getGroups();
|
||||||
$group_addressees = false;
|
$group_addressees = false;
|
||||||
foreach($notice_groups as $g) {
|
foreach($notice_groups as $g) {
|
||||||
$group_addressees = array('nickname'=>$g->nickname,'url'=>$g->mainpage);
|
$group_addressees = array('nickname'=>$g->nickname,'url'=>$g->mainpage);
|
||||||
}
|
}
|
||||||
$twitter_status['statusnet_in_groups'] = $group_addressees;
|
$twitter_status['statusnet_in_groups'] = $group_addressees;
|
||||||
|
|
||||||
// include the repeat-id, which we need when unrepeating later
|
// include the repeat-id, which we need when unrepeating later
|
||||||
if(array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
|
if(array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
|
||||||
|
@ -412,22 +412,22 @@ class QvitterPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// thumb urls
|
// thumb urls
|
||||||
|
|
||||||
// find all thumbs
|
// find all thumbs
|
||||||
$attachments = $notice->attachments();
|
$attachments = $notice->attachments();
|
||||||
$attachment_url_to_id = array();
|
$attachment_url_to_id = array();
|
||||||
if (!empty($attachments)) {
|
if (!empty($attachments)) {
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
if(is_object($attachment)) {
|
if(is_object($attachment)) {
|
||||||
try {
|
try {
|
||||||
$enclosure_o = $attachment->getEnclosure();
|
$enclosure_o = $attachment->getEnclosure();
|
||||||
$thumb = $attachment->getThumbnail();
|
$thumb = $attachment->getThumbnail();
|
||||||
|
|
||||||
$attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
|
$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]['thumb_url'] = $thumb->getUrl();
|
||||||
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
|
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
|
||||||
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
|
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
|
||||||
|
|
||||||
// animated gif?
|
// animated gif?
|
||||||
if($attachment->mimetype == 'image/gif') {
|
if($attachment->mimetype == 'image/gif') {
|
||||||
$image = ImageFile::fromFileObject($attachment);
|
$image = ImageFile::fromFileObject($attachment);
|
||||||
|
@ -435,18 +435,18 @@ class QvitterPlugin extends Plugin {
|
||||||
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ServerException $e) {
|
} catch (ServerException $e) {
|
||||||
$thumb = File_thumbnail::getKV('file_id', $attachment->id);
|
$thumb = File_thumbnail::getKV('file_id', $attachment->id);
|
||||||
if ($thumb instanceof File_thumbnail) {
|
if ($thumb instanceof File_thumbnail) {
|
||||||
$attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
|
$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]['thumb_url'] = $thumb->getUrl();
|
||||||
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
|
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
|
||||||
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
|
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
|
||||||
|
|
||||||
// animated gif?
|
// animated gif?
|
||||||
if($attachment->mimetype == 'image/gif') {
|
if($attachment->mimetype == 'image/gif') {
|
||||||
$image = ImageFile::fromFileObject($attachment);
|
$image = ImageFile::fromFileObject($attachment);
|
||||||
|
@ -454,30 +454,30 @@ class QvitterPlugin extends Plugin {
|
||||||
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
|
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add thumbs to $twitter_status
|
// add thumbs to $twitter_status
|
||||||
if (!empty($twitter_status['attachments'])) {
|
if (!empty($twitter_status['attachments'])) {
|
||||||
foreach ($twitter_status['attachments'] as &$attachment) {
|
foreach ($twitter_status['attachments'] as &$attachment) {
|
||||||
if (!empty($attachment_url_to_id[$attachment['url']])) {
|
if (!empty($attachment_url_to_id[$attachment['url']])) {
|
||||||
$attachment['id'] = $attachment_url_to_id[$attachment['url']]['id'];
|
$attachment['id'] = $attachment_url_to_id[$attachment['url']]['id'];
|
||||||
$attachment['width'] = $attachment_url_to_id[$attachment['url']]['width'];
|
$attachment['width'] = $attachment_url_to_id[$attachment['url']]['width'];
|
||||||
$attachment['height'] = $attachment_url_to_id[$attachment['url']]['height'];
|
$attachment['height'] = $attachment_url_to_id[$attachment['url']]['height'];
|
||||||
$attachment['thumb_url'] = $attachment_url_to_id[$attachment['url']]['thumb_url'];
|
$attachment['thumb_url'] = $attachment_url_to_id[$attachment['url']]['thumb_url'];
|
||||||
if(isset($attachment_url_to_id[$attachment['url']]['animated'])) {
|
if(isset($attachment_url_to_id[$attachment['url']]['animated'])) {
|
||||||
$attachment['animated'] = $attachment_url_to_id[$attachment['url']]['animated'];
|
$attachment['animated'] = $attachment_url_to_id[$attachment['url']]['animated'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reply-to profile url
|
// reply-to profile url
|
||||||
try {
|
try {
|
||||||
$reply = $notice->getParent();
|
$reply = $notice->getParent();
|
||||||
|
@ -490,41 +490,41 @@ class QvitterPlugin extends Plugin {
|
||||||
$faves = Fave::byNotice($notice);
|
$faves = Fave::byNotice($notice);
|
||||||
$favenum = count($faves);
|
$favenum = count($faves);
|
||||||
$twitter_status['fave_num'] = $favenum;
|
$twitter_status['fave_num'] = $favenum;
|
||||||
|
|
||||||
// repeat number
|
// repeat number
|
||||||
$repeats = $notice->repeatStream();
|
$repeats = $notice->repeatStream();
|
||||||
$repeatnum=0;
|
$repeatnum=0;
|
||||||
while ($repeats->fetch()) {
|
while ($repeats->fetch()) {
|
||||||
$repeatnum++;
|
$repeatnum++;
|
||||||
}
|
}
|
||||||
$twitter_status['repeat_num'] = $repeatnum;
|
$twitter_status['repeat_num'] = $repeatnum;
|
||||||
|
|
||||||
// some more metadata about notice
|
// some more metadata about notice
|
||||||
if($notice->is_local == '1') {
|
if($notice->is_local == '1') {
|
||||||
$twitter_status['is_local'] = true;
|
$twitter_status['is_local'] = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$twitter_status['is_local'] = false;
|
$twitter_status['is_local'] = false;
|
||||||
if($notice->object_type != 'activity') {
|
if($notice->object_type != 'activity') {
|
||||||
$twitter_status['external_url'] = $notice->getUrl(true);
|
$twitter_status['external_url'] = $notice->getUrl(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($notice->object_type == 'activity' || $notice->object_type == 'http://activitystrea.ms/schema/1.0/activity') {
|
if($notice->object_type == 'activity' || $notice->object_type == 'http://activitystrea.ms/schema/1.0/activity') {
|
||||||
$twitter_status['is_activity'] = true;
|
$twitter_status['is_activity'] = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$twitter_status['is_activity'] = false;
|
$twitter_status['is_activity'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($notice->verb == 'qvitter-delete-notice') {
|
if($notice->verb == 'qvitter-delete-notice') {
|
||||||
$twitter_status['qvitter_delete_notice'] = true;
|
$twitter_status['qvitter_delete_notice'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cover photo in API response, also follows_you, etc
|
* Cover photo in API response, also follows_you, etc
|
||||||
*
|
*
|
||||||
|
@ -534,22 +534,22 @@ class QvitterPlugin extends Plugin {
|
||||||
function onTwitterUserArray($profile, &$twitter_user, $scoped)
|
function onTwitterUserArray($profile, &$twitter_user, $scoped)
|
||||||
{
|
{
|
||||||
|
|
||||||
$twitter_user['cover_photo'] = Profile_prefs::getConfigData($profile, 'qvitter', 'cover_photo');
|
$twitter_user['cover_photo'] = Profile_prefs::getConfigData($profile, 'qvitter', 'cover_photo');
|
||||||
$twitter_user['background_image'] = Profile_prefs::getConfigData($profile, 'qvitter', 'background_image');
|
$twitter_user['background_image'] = Profile_prefs::getConfigData($profile, 'qvitter', 'background_image');
|
||||||
|
|
||||||
|
|
||||||
// follows me?
|
// follows me?
|
||||||
if ($scoped) {
|
if ($scoped) {
|
||||||
$twitter_user['follows_you'] = $profile->isSubscribed($scoped);
|
$twitter_user['follows_you'] = $profile->isSubscribed($scoped);
|
||||||
}
|
}
|
||||||
|
|
||||||
// local user?
|
// local user?
|
||||||
$twitter_user['is_local'] = $profile->isLocal();
|
$twitter_user['is_local'] = $profile->isLocal();
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -557,7 +557,7 @@ class QvitterPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
function insertNotification($to_profile_id, $from_profile_id, $ntype, $notice_id=false)
|
function insertNotification($to_profile_id, $from_profile_id, $ntype, $notice_id=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$to_user = User::getKV('id', $to_profile_id);
|
$to_user = User::getKV('id', $to_profile_id);
|
||||||
$from_profile = Profile::getKV($from_profile_id);
|
$from_profile = Profile::getKV($from_profile_id);
|
||||||
|
|
||||||
|
@ -570,56 +570,56 @@ class QvitterPlugin extends Plugin {
|
||||||
if ($to_user->hasBlocked($from_profile)) {
|
if ($to_user->hasBlocked($from_profile)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// never notify myself
|
// never notify myself
|
||||||
if($to_profile_id == $from_profile_id) {
|
if($to_profile_id == $from_profile_id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert
|
// insert
|
||||||
$notif = new QvitterNotification();
|
$notif = new QvitterNotification();
|
||||||
$notif->to_profile_id = $to_profile_id;
|
$notif->to_profile_id = $to_profile_id;
|
||||||
$notif->from_profile_id = $from_profile_id;
|
$notif->from_profile_id = $from_profile_id;
|
||||||
$notif->ntype = $ntype;
|
$notif->ntype = $ntype;
|
||||||
$notif->notice_id = $notice_id;
|
$notif->notice_id = $notice_id;
|
||||||
$notif->created = common_sql_now();
|
$notif->created = common_sql_now();
|
||||||
if (!$notif->insert()) {
|
if (!$notif->insert()) {
|
||||||
common_log_db_error($notif, 'INSERT', __FILE__);
|
common_log_db_error($notif, 'INSERT', __FILE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert likes in notification table
|
* Insert likes in notification table
|
||||||
*/
|
*/
|
||||||
public function onEndFavorNotice($profile, $notice)
|
public function onEndFavorNotice($profile, $notice)
|
||||||
{
|
{
|
||||||
|
|
||||||
// don't notify people favoriting their own notices
|
// don't notify people favoriting their own notices
|
||||||
if($notice->profile_id != $profile->id) {
|
if($notice->profile_id != $profile->id) {
|
||||||
$this->insertNotification($notice->profile_id, $profile->id, 'like', $notice->id);
|
$this->insertNotification($notice->profile_id, $profile->id, 'like', $notice->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove likes in notification table on dislike
|
* Remove likes in notification table on dislike
|
||||||
*/
|
*/
|
||||||
public function onEndDisfavorNotice($profile, $notice)
|
public function onEndDisfavorNotice($profile, $notice)
|
||||||
{
|
{
|
||||||
$notif = new QvitterNotification();
|
$notif = new QvitterNotification();
|
||||||
$notif->from_profile_id = $profile->id;
|
$notif->from_profile_id = $profile->id;
|
||||||
$notif->notice_id = $notice->id;
|
$notif->notice_id = $notice->id;
|
||||||
$notif->ntype = 'like';
|
$notif->ntype = 'like';
|
||||||
$notif->delete();
|
$notif->delete();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert notifications for replies, mentions and repeats
|
* Insert notifications for replies, mentions and repeats
|
||||||
*
|
*
|
||||||
|
@ -631,7 +631,7 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
// don't add notifications for activity type notices
|
// don't add notifications for activity type notices
|
||||||
if($notice->object_type == 'activity') {
|
if($notice->object_type == 'activity') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark reply/mention-notifications as read if we're replying to a notice we're notified about
|
// mark reply/mention-notifications as read if we're replying to a notice we're notified about
|
||||||
|
@ -644,21 +644,21 @@ class QvitterPlugin extends Plugin {
|
||||||
&& ($notification_to_mark_as_seen->ntype == 'mention' || $notification_to_mark_as_seen->ntype == 'reply')) {
|
&& ($notification_to_mark_as_seen->ntype == 'mention' || $notification_to_mark_as_seen->ntype == 'reply')) {
|
||||||
$orig = clone($notification_to_mark_as_seen);
|
$orig = clone($notification_to_mark_as_seen);
|
||||||
$notification_to_mark_as_seen->is_seen = 1;
|
$notification_to_mark_as_seen->is_seen = 1;
|
||||||
$notification_to_mark_as_seen->update($orig);
|
$notification_to_mark_as_seen->update($orig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// repeats
|
// repeats
|
||||||
if ($notice->isRepeat()) {
|
if ($notice->isRepeat()) {
|
||||||
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
||||||
if ($repeated_notice instanceof Notice) {
|
if ($repeated_notice instanceof Notice) {
|
||||||
$this->insertNotification($repeated_notice->profile_id, $notice->profile_id, 'repeat', $repeated_notice->id);
|
$this->insertNotification($repeated_notice->profile_id, $notice->profile_id, 'repeat', $repeated_notice->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// replies and mentions (no notifications for these if this is a repeat)
|
// replies and mentions (no notifications for these if this is a repeat)
|
||||||
else {
|
else {
|
||||||
$reply_notification_to = false;
|
$reply_notification_to = false;
|
||||||
// check for reply to insert in notifications
|
// check for reply to insert in notifications
|
||||||
if($notice->reply_to) {
|
if($notice->reply_to) {
|
||||||
try {
|
try {
|
||||||
|
@ -673,28 +673,28 @@ class QvitterPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for mentions to insert in notifications
|
// check for mentions to insert in notifications
|
||||||
$mentions = $notice->getReplies();
|
$mentions = $notice->getReplies();
|
||||||
$sender = Profile::getKV($notice->profile_id);
|
$sender = Profile::getKV($notice->profile_id);
|
||||||
$all_mentioned_user_ids = array();
|
$all_mentioned_user_ids = array();
|
||||||
foreach ($mentions as $mentioned) {
|
foreach ($mentions as $mentioned) {
|
||||||
|
|
||||||
// no duplicate mentions
|
// no duplicate mentions
|
||||||
if(in_array($mentioned, $all_mentioned_user_ids)) {
|
if(in_array($mentioned, $all_mentioned_user_ids)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$all_mentioned_user_ids[] = $mentioned;
|
$all_mentioned_user_ids[] = $mentioned;
|
||||||
|
|
||||||
// only notify if mentioned user is not already notified for reply
|
// only notify if mentioned user is not already notified for reply
|
||||||
if($reply_notification_to != $mentioned) {
|
if($reply_notification_to != $mentioned) {
|
||||||
$this->insertNotification($mentioned, $notice->profile_id, 'mention', $notice->id);
|
$this->insertNotification($mentioned, $notice->profile_id, 'mention', $notice->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete any notifications tied to deleted notices and un-repeats
|
* Delete any notifications tied to deleted notices and un-repeats
|
||||||
|
@ -709,16 +709,16 @@ class QvitterPlugin extends Plugin {
|
||||||
// unrepeats
|
// unrepeats
|
||||||
if ($notice->isRepeat()) {
|
if ($notice->isRepeat()) {
|
||||||
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
$repeated_notice = Notice::getKV('id', $notice->repeat_of);
|
||||||
$notif->notice_id = $repeated_notice->id;
|
$notif->notice_id = $repeated_notice->id;
|
||||||
$notif->from_profile_id = $notice->profile_id;
|
$notif->from_profile_id = $notice->profile_id;
|
||||||
}
|
}
|
||||||
// notices
|
// notices
|
||||||
else {
|
else {
|
||||||
$notif->notice_id = $notice->id;
|
$notif->notice_id = $notice->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notif->delete();
|
$notif->delete();
|
||||||
|
|
||||||
// outputs an activity notice that this notice was deleted
|
// outputs an activity notice that this notice was deleted
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
|
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
|
||||||
|
@ -726,22 +726,25 @@ class QvitterPlugin extends Plugin {
|
||||||
$profile->getBestName(),
|
$profile->getBestName(),
|
||||||
$notice->getUrl(),
|
$notice->getUrl(),
|
||||||
$notice->uri);
|
$notice->uri);
|
||||||
|
$text = sprintf(_m('%1$s deleted notice {{%2$s}}.'),
|
||||||
|
$profile->getBestName(),
|
||||||
|
$notice->uri);
|
||||||
$uri = TagURI::mint('delete-notice:%d:%d:%s',
|
$uri = TagURI::mint('delete-notice:%d:%d:%s',
|
||||||
$notice->profile_id,
|
$notice->profile_id,
|
||||||
$notice->id,
|
$notice->id,
|
||||||
common_date_iso8601(common_sql_now()));
|
common_date_iso8601(common_sql_now()));
|
||||||
$notice = Notice::saveNew($notice->profile_id,
|
$notice = Notice::saveNew($notice->profile_id,
|
||||||
$notice->uri,
|
$text,
|
||||||
ActivityPlugin::SOURCE,
|
ActivityPlugin::SOURCE,
|
||||||
array('rendered' => $rendered,
|
array('rendered' => $rendered,
|
||||||
'urls' => array(),
|
'urls' => array(),
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'verb' => 'qvitter-delete-notice',
|
'verb' => 'qvitter-delete-notice',
|
||||||
'object_type' => ActivityObject::ACTIVITY));
|
'object_type' => ActivityObject::ACTIVITY));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -750,7 +753,7 @@ class QvitterPlugin extends Plugin {
|
||||||
*
|
*
|
||||||
* @return boolean hook flag
|
* @return boolean hook flag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function onEndHandleFeedEntry($activity) {
|
public function onEndHandleFeedEntry($activity) {
|
||||||
|
|
||||||
if($activity->verb == 'qvitter-delete-notice') {
|
if($activity->verb == 'qvitter-delete-notice') {
|
||||||
|
@ -768,23 +771,23 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
$deleter_profile = Profile::getKV('id', $deleter_ostatus_profile->profile_id);
|
$deleter_profile = Profile::getKV('id', $deleter_ostatus_profile->profile_id);
|
||||||
$deleted_notice = Notice::getKV('uri', $deleted_notice_uri);
|
$deleted_notice = Notice::getKV('uri', $deleted_notice_uri);
|
||||||
|
|
||||||
if(!($deleter_profile instanceof Profile) || !($deleted_notice instanceof Notice)) {
|
if(!($deleter_profile instanceof Profile) || !($deleted_notice instanceof Notice)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($deleter_profile->id != $deleted_notice->profile_id) {
|
if($deleter_profile->id != $deleted_notice->profile_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleted_notice->delete();
|
$deleted_notice->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add notification on subscription, remove on unsubscribe
|
* Add notification on subscription, remove on unsubscribe
|
||||||
*
|
*
|
||||||
|
@ -793,23 +796,23 @@ class QvitterPlugin extends Plugin {
|
||||||
public function onEndSubscribe($subscriber, $other)
|
public function onEndSubscribe($subscriber, $other)
|
||||||
{
|
{
|
||||||
if(Subscription::exists($subscriber, $other)) {
|
if(Subscription::exists($subscriber, $other)) {
|
||||||
$this->insertNotification($other->id, $subscriber->id, 'follow', 1);
|
$this->insertNotification($other->id, $subscriber->id, 'follow', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function onEndUnsubscribe($subscriber, $other)
|
public function onEndUnsubscribe($subscriber, $other)
|
||||||
{
|
{
|
||||||
if(!Subscription::exists($subscriber, $other)) {
|
if(!Subscription::exists($subscriber, $other)) {
|
||||||
$notif = new QvitterNotification();
|
$notif = new QvitterNotification();
|
||||||
$notif->to_profile_id = $other->id;
|
$notif->to_profile_id = $other->id;
|
||||||
$notif->from_profile_id = $subscriber->id;
|
$notif->from_profile_id = $subscriber->id;
|
||||||
$notif->ntype = 'follow';
|
$notif->ntype = 'follow';
|
||||||
$notif->delete();
|
$notif->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace GNU Social's default FAQ with Qvitter's
|
* Replace GNU Social's default FAQ with Qvitter's
|
||||||
|
@ -818,24 +821,24 @@ class QvitterPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public function onEndLoadDoc($title, &$output)
|
public function onEndLoadDoc($title, &$output)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($title == 'faq') {
|
if($title == 'faq') {
|
||||||
|
|
||||||
$faq = file_get_contents(QVITTERDIR.'/doc/en/faq.html');
|
$faq = file_get_contents(QVITTERDIR.'/doc/en/faq.html');
|
||||||
$faq = str_replace('{instance-name}',common_config('site','name'),$faq);
|
$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}',common_config('site','server'),$faq);
|
||||||
$faq = str_replace('{instance-url-with-protocol}',common_path('', true),$faq);
|
$faq = str_replace('{instance-url-with-protocol}',common_path('', true),$faq);
|
||||||
|
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$faq = str_replace('{nickname}',$user->nickname,$faq);
|
$faq = str_replace('{nickname}',$user->nickname,$faq);
|
||||||
}
|
}
|
||||||
$output = $faq;
|
$output = $faq;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add menu items to top header in Classic
|
* Add menu items to top header in Classic
|
||||||
*
|
*
|
||||||
|
@ -843,7 +846,7 @@ class QvitterPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public function onStartPrimaryNav($action)
|
public function onStartPrimaryNav($action)
|
||||||
{
|
{
|
||||||
|
|
||||||
$action->menuItem(common_local_url('doc', array('title' => 'faq')),
|
$action->menuItem(common_local_url('doc', array('title' => 'faq')),
|
||||||
// TRANS: Menu item in primary navigation panel.
|
// TRANS: Menu item in primary navigation panel.
|
||||||
_m('MENU','FAQ'),
|
_m('MENU','FAQ'),
|
||||||
|
@ -851,9 +854,9 @@ class QvitterPlugin extends Plugin {
|
||||||
_('Frequently asked questions'),
|
_('Frequently asked questions'),
|
||||||
false,
|
false,
|
||||||
'top_nav_doc_faq');
|
'top_nav_doc_faq');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -863,23 +866,23 @@ class QvitterPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public function onStartUserRegister($profile)
|
public function onStartUserRegister($profile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(is_array(self::settings("blocked_ips"))) {
|
if(is_array(self::settings("blocked_ips"))) {
|
||||||
if(in_array($_SERVER['REMOTE_ADDR'], self::settings("blocked_ips"))) {
|
if(in_array($_SERVER['REMOTE_ADDR'], self::settings("blocked_ips"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add unread notification count to all API responses, when logged in
|
* Add unread notification count to all API responses, when logged in
|
||||||
*
|
*
|
||||||
* @return boolean hook flag
|
* @return boolean hook flag
|
||||||
*/
|
*/
|
||||||
public function onEndSetApiUser($user) {
|
public function onEndSetApiUser($user) {
|
||||||
if (!$user instanceof User) {
|
if (!$user instanceof User) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -890,24 +893,24 @@ class QvitterPlugin extends Plugin {
|
||||||
|
|
||||||
$notification->selectAdd();
|
$notification->selectAdd();
|
||||||
$notification->selectAdd('ntype');
|
$notification->selectAdd('ntype');
|
||||||
$notification->selectAdd('count(id) as count');
|
$notification->selectAdd('count(id) as count');
|
||||||
$notification->whereAdd("(to_profile_id = '".$user_id."')");
|
$notification->whereAdd("(to_profile_id = '".$user_id."')");
|
||||||
$notification->groupBy('ntype');
|
$notification->groupBy('ntype');
|
||||||
$notification->whereAdd("(is_seen = '0')");
|
$notification->whereAdd("(is_seen = '0')");
|
||||||
$notification->whereAdd("(notice_id IS NOT NULL)"); // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
|
$notification->whereAdd("(notice_id IS NOT NULL)"); // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
|
||||||
$notification->find();
|
$notification->find();
|
||||||
|
|
||||||
$new_notifications = array();
|
$new_notifications = array();
|
||||||
while ($notification->fetch()) {
|
while ($notification->fetch()) {
|
||||||
$new_notifications[$notification->ntype] = $notification->count;
|
$new_notifications[$notification->ntype] = $notification->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Qvitter-Notifications: '.json_encode($new_notifications));
|
header('Qvitter-Notifications: '.json_encode($new_notifications));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onPluginVersion(array &$versions)
|
function onPluginVersion(array &$versions)
|
||||||
{
|
{
|
||||||
$versions[] = array('name' => 'Qvitter',
|
$versions[] = array('name' => 'Qvitter',
|
||||||
|
@ -981,7 +984,7 @@ class QvitterPlugin extends Plugin {
|
||||||
// Is the requesting user following this user?
|
// Is the requesting user following this user?
|
||||||
$twitter_user['following'] = false;
|
$twitter_user['following'] = false;
|
||||||
$twitter_user['statusnet_blocking'] = false;
|
$twitter_user['statusnet_blocking'] = false;
|
||||||
|
|
||||||
$logged_in_profile = Profile::current();
|
$logged_in_profile = Profile::current();
|
||||||
|
|
||||||
if ($logged_in) {
|
if ($logged_in) {
|
||||||
|
@ -998,7 +1001,7 @@ class QvitterPlugin extends Plugin {
|
||||||
$twitter_user['statusnet_profile_url'] = $profile->profileurl;
|
$twitter_user['statusnet_profile_url'] = $profile->profileurl;
|
||||||
|
|
||||||
// The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
|
// The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
|
||||||
|
|
||||||
Event::handle('TwitterUserArray', array($profile, &$twitter_user, $logged_in_profile, array()));
|
Event::handle('TwitterUserArray', array($profile, &$twitter_user, $logged_in_profile, array()));
|
||||||
|
|
||||||
return $twitter_user;
|
return $twitter_user;
|
||||||
|
@ -1018,13 +1021,13 @@ class URLMapperOverwrite extends URLMapper
|
||||||
{
|
{
|
||||||
static function overwrite_variable($m, $path, $args, $paramPatterns, $newaction)
|
static function overwrite_variable($m, $path, $args, $paramPatterns, $newaction)
|
||||||
{
|
{
|
||||||
|
|
||||||
$m->connect($path, array('action' => $newaction), $paramPatterns);
|
$m->connect($path, array('action' => $newaction), $paramPatterns);
|
||||||
|
|
||||||
$regex = self::makeRegex($path, $paramPatterns);
|
$regex = self::makeRegex($path, $paramPatterns);
|
||||||
|
|
||||||
foreach($m->variables as $n=>$v)
|
foreach($m->variables as $n=>$v)
|
||||||
if($v[1] == $regex)
|
if($v[1] == $regex)
|
||||||
$m->variables[$n][0]['action'] = $newaction;
|
$m->variables[$n][0]['action'] = $newaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1673,6 +1673,16 @@ body.rtl .queet.rtl .expanded-content {
|
||||||
color:#999999;
|
color:#999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* only show activity notices if they are conversation starters
|
||||||
|
we never need to see these, but sometimes someone replies to
|
||||||
|
an activity notice, and then it can be good to know what the
|
||||||
|
user is replying to... */
|
||||||
|
#feed-body > .stream-item.activity {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
.stream-item > .stream-item.activity:first-child {
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
.queet .queet-thumbs {
|
.queet .queet-thumbs {
|
||||||
-webkit-transition: max-height 0s linear;
|
-webkit-transition: max-height 0s linear;
|
||||||
|
|
|
@ -1769,8 +1769,10 @@ function addToFeed(feed, after, extraClasses, isReply) {
|
||||||
|
|
||||||
// if this is a special qvitter-delete-notice activity notice it means we try to hide
|
// if this is a special qvitter-delete-notice activity notice it means we try to hide
|
||||||
// the deleted notice from our stream
|
// the deleted notice from our stream
|
||||||
|
// the uri is in the obj.text var, between the double curly brackets
|
||||||
if(typeof obj.qvitter_delete_notice != 'undefined' && obj.qvitter_delete_notice == true) {
|
if(typeof obj.qvitter_delete_notice != 'undefined' && obj.qvitter_delete_notice == true) {
|
||||||
var streamItemToHide = $('.stream-item[data-uri="' + obj.text + '"]');
|
var uriToHide = obj.text.substring(obj.text.indexOf('{{')+2,obj.text.indexOf('}}'));
|
||||||
|
var streamItemToHide = $('.stream-item[data-uri="' + uriToHide + '"]');
|
||||||
streamItemToHide.animate({opacity:'0.2'},1000,'linear',function(){
|
streamItemToHide.animate({opacity:'0.2'},1000,'linear',function(){
|
||||||
$(this).css('height',$(this).height() + 'px');
|
$(this).css('height',$(this).height() + 'px');
|
||||||
$(this).animate({height:'0px'},500,'linear',function(){
|
$(this).animate({height:'0px'},500,'linear',function(){
|
||||||
|
@ -1779,11 +1781,6 @@ function addToFeed(feed, after, extraClasses, isReply) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't show any notices with object_type "activity"
|
|
||||||
if(typeof obj.is_activity != 'undefined' && obj.is_activity === true) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// only if not already exist
|
// only if not already exist
|
||||||
if($('#q-' + obj.id).length == 0) {
|
if($('#q-' + obj.id).length == 0) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user