More "relocate":
button in user's setting to resend relocate message to contacts option in admin's site setting to relocate a server
This commit is contained in:
parent
dd7392d2c5
commit
0414e0a316
|
@ -38,6 +38,7 @@ require_once('include/html2plain.php');
|
||||||
* tgroup (in items.php)
|
* tgroup (in items.php)
|
||||||
* wall-new (in photos.php, item.php)
|
* wall-new (in photos.php, item.php)
|
||||||
* removeme (in Contact.php)
|
* removeme (in Contact.php)
|
||||||
|
* relocate (in uimport.php)
|
||||||
*
|
*
|
||||||
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
|
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -237,6 +237,70 @@ function admin_page_site_post(&$a){
|
||||||
|
|
||||||
check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
|
check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
|
||||||
|
|
||||||
|
// relocate
|
||||||
|
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) {
|
||||||
|
notice( "Falied updating '$table_name': " . $db->error );
|
||||||
|
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("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'])) : '');
|
$sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
|
||||||
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
|
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
|
||||||
$info = ((x($_POST,'info')) ? trim($_POST['info']) : false);
|
$info = ((x($_POST,'info')) ? trim($_POST['info']) : false);
|
||||||
|
@ -508,6 +572,7 @@ function admin_page_site(&$a) {
|
||||||
'$corporate' => t('Policies'),
|
'$corporate' => t('Policies'),
|
||||||
'$advanced' => t('Advanced'),
|
'$advanced' => t('Advanced'),
|
||||||
'$performance' => t('Performance'),
|
'$performance' => t('Performance'),
|
||||||
|
'$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
|
||||||
|
|
||||||
'$baseurl' => $a->get_baseurl(true),
|
'$baseurl' => $a->get_baseurl(true),
|
||||||
// name, label, value, help string, extra data...
|
// name, label, value, help string, extra data...
|
||||||
|
@ -564,6 +629,9 @@ function admin_page_site(&$a) {
|
||||||
'$lockpath' => array('lockpath', t("Path for lock file"), get_config('system','lockpath'), "The lock file is used to avoid multiple pollers at one time. Only define a folder here."),
|
'$lockpath' => array('lockpath', t("Path for lock file"), get_config('system','lockpath'), "The lock file is used to avoid multiple pollers at one time. Only define a folder here."),
|
||||||
'$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), "If you have a restricted system where the webserver can't access the system temp path, enter another path here."),
|
'$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), "If you have a restricted system where the webserver can't access the system temp path, enter another path here."),
|
||||||
'$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), "If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
|
'$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), "If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
|
||||||
|
|
||||||
|
'$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."),
|
||||||
|
|
||||||
'$form_security_token' => get_form_security_token("admin_site"),
|
'$form_security_token' => get_form_security_token("admin_site"),
|
||||||
|
|
||||||
));
|
));
|
||||||
|
|
|
@ -306,6 +306,12 @@ function settings_post(&$a) {
|
||||||
|
|
||||||
check_form_security_token_redirectOnErr('/settings', 'settings');
|
check_form_security_token_redirectOnErr('/settings', 'settings');
|
||||||
|
|
||||||
|
if (x($_POST,'resend_relocate')) {
|
||||||
|
proc_run('php', 'include/notifier.php', 'relocate', local_user());
|
||||||
|
info(t("Relocate message has been send to your contacts"));
|
||||||
|
goaway($a->get_baseurl(true) . '/settings');
|
||||||
|
}
|
||||||
|
|
||||||
call_hooks('settings_post', $_POST);
|
call_hooks('settings_post', $_POST);
|
||||||
|
|
||||||
if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
|
if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
|
||||||
|
@ -1148,6 +1154,10 @@ function settings_content(&$a) {
|
||||||
'$h_descadvn' => t('Change the behaviour of this account for special situations'),
|
'$h_descadvn' => t('Change the behaviour of this account for special situations'),
|
||||||
'$pagetype' => $pagetype,
|
'$pagetype' => $pagetype,
|
||||||
|
|
||||||
|
'$relocate' => t('Relocate'),
|
||||||
|
'$relocate_text' => t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."),
|
||||||
|
'$relocate_button' => t("Resend relocate message to contacts"),
|
||||||
|
|
||||||
));
|
));
|
||||||
|
|
||||||
call_hooks('settings_form',$o);
|
call_hooks('settings_form',$o);
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
{{*
|
|
||||||
* AUTOMATICALLY GENERATED TEMPLATE
|
|
||||||
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
|
|
||||||
*
|
|
||||||
*}}
|
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
||||||
|
@ -115,9 +110,17 @@
|
||||||
{{include file="field_checkbox.tpl" field=$use_fulltext_engine}}
|
{{include file="field_checkbox.tpl" field=$use_fulltext_engine}}
|
||||||
{{include file="field_input.tpl" field=$itemcache}}
|
{{include file="field_input.tpl" field=$itemcache}}
|
||||||
{{include file="field_input.tpl" field=$itemcache_duration}}
|
{{include file="field_input.tpl" field=$itemcache_duration}}
|
||||||
|
|
||||||
|
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{{* separate form for relocate... *}}
|
||||||
|
<form action="{{$baseurl}}/admin/site" method="post">
|
||||||
|
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
|
||||||
|
<h3>{{$relocate}}</h3>
|
||||||
|
{{include file="field_input.tpl" field=$relocate_url}}
|
||||||
|
<input type="hidden" name="page_site" value="{{$submit}}">
|
||||||
|
<div class="submit"><input type="submit" name="relocate" value="{{$submit}}" /></div>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
{{*
|
|
||||||
* AUTOMATICALLY GENERATED TEMPLATE
|
|
||||||
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
|
|
||||||
*
|
|
||||||
*}}
|
|
||||||
<h1>{{$ptitle}}</h1>
|
<h1>{{$ptitle}}</h1>
|
||||||
|
|
||||||
{{$nickname_block}}
|
{{$nickname_block}}
|
||||||
|
@ -149,4 +144,12 @@
|
||||||
<input type="submit" name="submit" class="settings-submit" value="{{$submit}}" />
|
<input type="submit" name="submit" class="settings-submit" value="{{$submit}}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h3 class="settings-heading">{{$relocate}}</h3>
|
||||||
|
<div id="settings-pagetype-desc">{{$relocate_text}}</div>
|
||||||
|
|
||||||
|
<div class="settings-submit-wrapper" >
|
||||||
|
<input type="submit" name="resend_relocate" class="settings-submit" value="{{$relocate_button}}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue