Merge pull request #1042 from annando/master
Workaround for likes from Diaspora, disabling of the automatic reload of the network page
This commit is contained in:
commit
829a92a10e
13 changed files with 197 additions and 312 deletions
|
@ -33,7 +33,7 @@ function admin_post(&$a){
|
|||
admin_page_users_post($a);
|
||||
break;
|
||||
case 'plugins':
|
||||
if ($a->argc > 2 &&
|
||||
if ($a->argc > 2 &&
|
||||
is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")){
|
||||
@include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
|
||||
if(function_exists($a->argv[2].'_plugin_admin_post')) {
|
||||
|
@ -122,7 +122,7 @@ function admin_content(&$a) {
|
|||
|
||||
$t = get_markup_template("admin_aside.tpl");
|
||||
$a->page['aside'] .= replace_macros( $t, array(
|
||||
'$admin' => $aside,
|
||||
'$admin' => $aside,
|
||||
'$admtxt' => t('Admin'),
|
||||
'$plugadmtxt' => t('Plugin Features'),
|
||||
'$logtxt' => t('Logs'),
|
||||
|
@ -168,13 +168,13 @@ function admin_content(&$a) {
|
|||
}
|
||||
|
||||
if(is_ajax()) {
|
||||
echo $o;
|
||||
echo $o;
|
||||
killme();
|
||||
return '';
|
||||
} else {
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -242,35 +242,35 @@ function admin_page_site_post(&$a){
|
|||
if (x($_POST,'relocate') && x($_POST,'relocate_url') && $_POST['relocate_url']!=""){
|
||||
$new_url = $_POST['relocate_url'];
|
||||
$new_url = rtrim($new_url,"/");
|
||||
|
||||
|
||||
$parsed = @parse_url($new_url);
|
||||
if (!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) {
|
||||
notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
|
||||
goaway($a->get_baseurl(true) . '/admin/site' );
|
||||
}
|
||||
|
||||
|
||||
/* steps:
|
||||
* replace all "baseurl" to "new_url" in config, profile, term, items and contacts
|
||||
* send relocate for every local user
|
||||
* */
|
||||
|
||||
|
||||
$old_url = $a->get_baseurl(true);
|
||||
|
||||
|
||||
function update_table($table_name, $fields, $old_url, $new_url) {
|
||||
global $db, $a;
|
||||
|
||||
|
||||
$dbold = dbesc($old_url);
|
||||
$dbnew = dbesc($new_url);
|
||||
|
||||
|
||||
$upd = array();
|
||||
foreach ($fields as $f) {
|
||||
$upd[] = "`$f` = REPLACE(`$f`, '$dbold', '$dbnew')";
|
||||
}
|
||||
|
||||
|
||||
$upds = implode(", ", $upd);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
|
||||
$r = q($q);
|
||||
if (!$r) {
|
||||
|
@ -278,30 +278,31 @@ function admin_page_site_post(&$a){
|
|||
goaway($a->get_baseurl(true) . '/admin/site' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update tables
|
||||
update_table("profile", array('photo', 'thumb'), $old_url, $new_url);
|
||||
update_table("term", array('url'), $old_url, $new_url);
|
||||
update_table("contact", array('photo','thumb','micro','url','nurl','request','notify','poll','confirm','poco'), $old_url, $new_url);
|
||||
update_table("unique_contacts", array('url'), $old_url, $new_url);
|
||||
update_table("item", array('owner-link','owner-avatar','author-name','author-link','author-avatar','body','plink','tag'), $old_url, $new_url);
|
||||
|
||||
// update config
|
||||
$a->set_baseurl($new_url);
|
||||
set_config('system','url',$new_url);
|
||||
|
||||
|
||||
// send relocate
|
||||
$users = q("SELECT uid FROM user WHERE account_removed = 0 AND account_expired = 0");
|
||||
|
||||
|
||||
foreach ($users as $user) {
|
||||
proc_run('php', 'include/notifier.php', 'relocate', $user['uid']);
|
||||
}
|
||||
|
||||
info("Relocation started. Could take a while to complete.");
|
||||
|
||||
|
||||
goaway($a->get_baseurl(true) . '/admin/site' );
|
||||
}
|
||||
// end relocate
|
||||
|
||||
|
||||
$sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
|
||||
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
|
||||
$info = ((x($_POST,'info')) ? trim($_POST['info']) : false);
|
||||
|
@ -374,14 +375,14 @@ function admin_page_site_post(&$a){
|
|||
`poco` = replace(`poco` , 'http:' , 'https:')
|
||||
where `self` = 1"
|
||||
);
|
||||
q("update `profile` set
|
||||
q("update `profile` set
|
||||
`photo` = replace(`photo` , 'http:' , 'https:'),
|
||||
`thumb` = replace(`thumb` , 'http:' , 'https:')
|
||||
where 1 "
|
||||
);
|
||||
}
|
||||
elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
|
||||
q("update `contact` set
|
||||
q("update `contact` set
|
||||
`url` = replace(`url` , 'https:' , 'http:'),
|
||||
`photo` = replace(`photo` , 'https:' , 'http:'),
|
||||
`thumb` = replace(`thumb` , 'https:' , 'http:'),
|
||||
|
@ -393,7 +394,7 @@ function admin_page_site_post(&$a){
|
|||
`poco` = replace(`poco` , 'https:' , 'http:')
|
||||
where `self` = 1"
|
||||
);
|
||||
q("update `profile` set
|
||||
q("update `profile` set
|
||||
`photo` = replace(`photo` , 'https:' , 'http:'),
|
||||
`thumb` = replace(`thumb` , 'https:' , 'http:')
|
||||
where 1 "
|
||||
|
@ -566,7 +567,7 @@ function admin_page_site(&$a) {
|
|||
REGISTER_CLOSED => t("Closed"),
|
||||
REGISTER_APPROVE => t("Requires approval"),
|
||||
REGISTER_OPEN => t("Open")
|
||||
);
|
||||
);
|
||||
|
||||
$ssl_choices = array(
|
||||
SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
|
||||
|
@ -670,7 +671,7 @@ function admin_page_dbsync(&$a) {
|
|||
if(function_exists($func)) {
|
||||
$retval = $func();
|
||||
if($retval === UPDATE_FAILED) {
|
||||
$o .= sprintf( t('Executing %s failed. Check system logs.'), $func);
|
||||
$o .= sprintf( t('Executing %s failed. Check system logs.'), $func);
|
||||
}
|
||||
elseif($retval === UPDATE_SUCCESS) {
|
||||
$o .= sprintf( t('Update %s was successfully applied.', $func));
|
||||
|
@ -918,9 +919,9 @@ function admin_page_users(&$a){
|
|||
'$delete' => t('Delete'),
|
||||
'$block' => t('Block'),
|
||||
'$unblock' => t('Unblock'),
|
||||
'$siteadmin' => t('Site admin'),
|
||||
'$accountexpired' => t('Account expired'),
|
||||
|
||||
'$siteadmin' => t('Site admin'),
|
||||
'$accountexpired' => t('Account expired'),
|
||||
|
||||
'$h_users' => t('Users'),
|
||||
'$h_newuser' => t('New User'),
|
||||
'$th_deleted' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since') ),
|
||||
|
@ -929,7 +930,7 @@ function admin_page_users(&$a){
|
|||
'$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'),
|
||||
'$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'),
|
||||
|
||||
'$form_security_token' => get_form_security_token("admin_users"),
|
||||
'$form_security_token' => get_form_security_token("admin_users"),
|
||||
|
||||
// values //
|
||||
'$baseurl' => $a->get_baseurl(true),
|
||||
|
@ -937,9 +938,9 @@ function admin_page_users(&$a){
|
|||
'$pending' => $pending,
|
||||
'deleted' => $deleted,
|
||||
'$users' => $users,
|
||||
'$newusername' => array('new_user_name', t("Name"), '', t("Name of the new user.")),
|
||||
'$newusernickname' => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")),
|
||||
'$newuseremail' => array('new_user_email', t("Email"), '', t("Email address of the new user.")),
|
||||
'$newusername' => array('new_user_name', t("Name"), '', t("Name of the new user.")),
|
||||
'$newusernickname' => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")),
|
||||
'$newuseremail' => array('new_user_email', t("Email"), '', t("Email address of the new user.")),
|
||||
));
|
||||
$o .= paginate($a);
|
||||
return $o;
|
||||
|
@ -1280,7 +1281,7 @@ function admin_page_themes(&$a){
|
|||
*
|
||||
* @param App $a
|
||||
*/
|
||||
|
||||
|
||||
function admin_page_logs_post(&$a) {
|
||||
if (x($_POST,"page_logs")) {
|
||||
check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
function display_init(&$a) {
|
||||
|
||||
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
|
||||
|
@ -8,6 +7,33 @@ function display_init(&$a) {
|
|||
}
|
||||
|
||||
$nick = (($a->argc > 1) ? $a->argv[1] : '');
|
||||
|
||||
// If there is only one parameter, then check if this parameter could be a guid
|
||||
if ($a->argc == 2) {
|
||||
$nick = "";
|
||||
|
||||
// Does the local user have this item?
|
||||
if (local_user()) {
|
||||
$r = q("SELECT `id` FROM `item`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `guid` = '%s' AND `uid` = %d", $a->argv[1], local_user());
|
||||
if (count($r))
|
||||
$nick = $a->user["nickname"];
|
||||
}
|
||||
|
||||
// Or is it anywhere on the server?
|
||||
if ($nick == "") {
|
||||
$r = q("SELECT `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
||||
AND `item`.`private` = 0 AND `item`.`wall` = 1
|
||||
AND `item`.`guid` = '%s'", $a->argv[1]);
|
||||
if (count($r))
|
||||
$nick = $r[0]["nickname"];
|
||||
}
|
||||
}
|
||||
|
||||
profile_load($a,$nick);
|
||||
|
||||
}
|
||||
|
@ -44,6 +70,33 @@ function display_content(&$a, $update = 0) {
|
|||
}
|
||||
else {
|
||||
$item_id = (($a->argc > 2) ? $a->argv[2] : 0);
|
||||
|
||||
if ($a->argc == 2) {
|
||||
$nick = "";
|
||||
|
||||
if (local_user()) {
|
||||
$r = q("SELECT `id` FROM `item`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `guid` = '%s' AND `uid` = %d", $a->argv[1], local_user());
|
||||
if (count($r)) {
|
||||
$item_id = $r[0]["id"];
|
||||
$nick = $a->user["nickname"];
|
||||
}
|
||||
}
|
||||
|
||||
if ($nick == "") {
|
||||
$r = q("SELECT `user`.`nickname`, `item`.`id` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
||||
AND `item`.`private` = 0 AND `item`.`wall` = 1
|
||||
AND `item`.`guid` = '%s'", $a->argv[1]);
|
||||
if (count($r)) {
|
||||
$item_id = $r[0]["id"];
|
||||
$nick = $r[0]["nickname"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(! $item_id) {
|
||||
|
|
|
@ -907,6 +907,10 @@ function item_post(&$a) {
|
|||
|
||||
call_hooks('post_local_end', $datarray);
|
||||
|
||||
// if no auto update is enabled, then disable it temporarily
|
||||
if (get_pconfig($profile_uid, "system", "no_auto_update") == 1)
|
||||
set_pconfig($profile_uid, "system", "no_auto_update", -1);
|
||||
|
||||
if(strlen($emailcc) && $profile_uid == local_user()) {
|
||||
$erecips = explode(',', $emailcc);
|
||||
if(count($erecips)) {
|
||||
|
|
|
@ -136,6 +136,9 @@ function like_content(&$a) {
|
|||
// Save the author information for the unlike in case we need to relay to Diaspora
|
||||
store_diaspora_like_retract_sig($activity, $item, $like_item, $contact);
|
||||
|
||||
// if no auto update is enabled, then disable it temporarily
|
||||
if (get_pconfig($owner_uid, "system", "no_auto_update") == 1)
|
||||
set_pconfig($owner_uid, "system", "no_auto_update", -1);
|
||||
|
||||
// proc_run('php',"include/notifier.php","like","$post_id"); // $post_id isn't defined here!
|
||||
$like_item_id = $like_item['id'];
|
||||
|
@ -148,7 +151,7 @@ function like_content(&$a) {
|
|||
$uri = item_new_uri($a->get_hostname(),$owner_uid);
|
||||
|
||||
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
|
||||
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
|
||||
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
|
||||
$link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
|
||||
$body = $item['body'];
|
||||
|
||||
|
@ -219,6 +222,9 @@ EOT;
|
|||
// Save the author information for the like in case we need to relay to Diaspora
|
||||
store_diaspora_like_sig($activity, $post_type, $contact, $post_id);
|
||||
|
||||
// if no auto update is enabled, then disable it temporarily
|
||||
if (get_pconfig($owner_uid, "system", "no_auto_update") == 1)
|
||||
set_pconfig($owner_uid, "system", "no_auto_update", -1);
|
||||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
|
|
|
@ -268,6 +268,7 @@ function settings_post(&$a) {
|
|||
$nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0);
|
||||
$noinfo = ((x($_POST,'noinfo')) ? intval($_POST['noinfo']) : 0);
|
||||
$infinite_scroll = ((x($_POST,'infinite_scroll')) ? intval($_POST['infinite_scroll']) : 0);
|
||||
$no_auto_update = ((x($_POST,'no_auto_update')) ? intval($_POST['no_auto_update']) : 0);
|
||||
$browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
|
||||
$browser_update = $browser_update * 1000;
|
||||
if($browser_update < 10000)
|
||||
|
@ -291,6 +292,7 @@ function settings_post(&$a) {
|
|||
set_pconfig(local_user(),'system','no_smilies',$nosmile);
|
||||
set_pconfig(local_user(),'system','ignore_info',$noinfo);
|
||||
set_pconfig(local_user(),'system','infinite_scroll',$infinite_scroll);
|
||||
set_pconfig(local_user(),'system','no_auto_update',$no_auto_update);
|
||||
|
||||
|
||||
if ($theme == $a->user['theme']){
|
||||
|
@ -859,6 +861,9 @@ function settings_content(&$a) {
|
|||
$infinite_scroll = get_pconfig(local_user(),'system','infinite_scroll');
|
||||
$infinite_scroll = (($infinite_scroll===false)? '0': $infinite_scroll); // default if not set: 0
|
||||
|
||||
$no_auto_update = get_pconfig(local_user(),'system','no_auto_update');
|
||||
$no_auto_update = (($no_auto_update===false)? '0': $no_auto_update); // default if not set: 0
|
||||
|
||||
$theme_config = "";
|
||||
if( ($themeconfigfile = get_theme_config_file($theme_selected)) != null){
|
||||
require_once($themeconfigfile);
|
||||
|
@ -881,6 +886,7 @@ function settings_content(&$a) {
|
|||
'$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''),
|
||||
'$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''),
|
||||
'$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''),
|
||||
'$no_auto_update' => array('no_auto_update', t("Disable automatic network update"), $no_auto_update, ''),
|
||||
|
||||
'$theme_config' => $theme_config,
|
||||
));
|
||||
|
|
|
@ -13,8 +13,14 @@ function update_network_content(&$a) {
|
|||
echo "<!DOCTYPE html><html><body>\r\n";
|
||||
echo (($_GET['msie'] == 1) ? '<div>' : '<section>');
|
||||
|
||||
$no_auto_update = get_pconfig($profile_uid, "system", "no_auto_update");
|
||||
if ($no_auto_update <= 0) {
|
||||
$text = network_content($a,$profile_uid);
|
||||
if ($no_auto_update < 0)
|
||||
set_pconfig($profile_uid, "system", "no_auto_update", 1);
|
||||
} else
|
||||
$text = "";
|
||||
|
||||
$text = network_content($a,$profile_uid);
|
||||
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
|
||||
$replace = "<img\${1} dst=\"\${2}\"";
|
||||
$text = preg_replace($pattern, $replace, $text);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue