aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Admin/Dbsync.php
diff options
context:
space:
mode:
authorredmatrix <mike@macgirvin.com>2016-09-05 21:00:00 -0700
committerredmatrix <mike@macgirvin.com>2016-09-05 21:00:00 -0700
commitdbb4ccbcc02325c79c1b660d4d636f8638e35e06 (patch)
tree05b84d7c9fcbe0b575c6a560e1ed165aca42aee8 /Zotlabs/Module/Admin/Dbsync.php
parented213c4d6da06e39fa4177030044395ae22783ac (diff)
downloadvolse-hubzilla-dbb4ccbcc02325c79c1b660d4d636f8638e35e06.tar.gz
volse-hubzilla-dbb4ccbcc02325c79c1b660d4d636f8638e35e06.tar.bz2
volse-hubzilla-dbb4ccbcc02325c79c1b660d4d636f8638e35e06.zip
move the rest of mod_admin to sub modules
Diffstat (limited to 'Zotlabs/Module/Admin/Dbsync.php')
-rw-r--r--Zotlabs/Module/Admin/Dbsync.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/Zotlabs/Module/Admin/Dbsync.php b/Zotlabs/Module/Admin/Dbsync.php
new file mode 100644
index 000000000..305126c7d
--- /dev/null
+++ b/Zotlabs/Module/Admin/Dbsync.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Zotlabs\Module\Admin;
+
+
+
+class Dbsync {
+
+
+
+
+ function get() {
+ $o = '';
+
+ if(argc() > 3 && intval(argv(3)) && argv(2) === 'mark') {
+ set_config('database', 'update_r' . intval(argv(3)), 'success');
+ if(intval(get_config('system','db_version')) <= intval(argv(3)))
+ set_config('system','db_version',intval(argv(3)) + 1);
+ info( t('Update has been marked successful') . EOL);
+ goaway(z_root() . '/admin/dbsync');
+ }
+
+ if(argc() > 2 && intval(argv(2))) {
+ require_once('install/update.php');
+ $func = 'update_r' . intval(argv(2));
+ if(function_exists($func)) {
+ $retval = $func();
+ if($retval === UPDATE_FAILED) {
+ $o .= sprintf( t('Executing %s failed. Check system logs.'), $func);
+ }
+ elseif($retval === UPDATE_SUCCESS) {
+ $o .= sprintf( t('Update %s was successfully applied.'), $func);
+ set_config('database',$func, 'success');
+ }
+ else
+ $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func);
+ }
+ else
+ $o .= sprintf( t('Update function %s could not be found.'), $func);
+
+ return $o;
+ }
+
+ $failed = array();
+ $r = q("select * from config where `cat` = 'database' ");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $upd = intval(substr($rr['k'],8));
+ if($rr['v'] === 'success')
+ continue;
+ $failed[] = $upd;
+ }
+ }
+ if(! count($failed))
+ return '<div class="generic-content-wrapper-styled"><h3>' . t('No failed updates.') . '</h3></div>';
+
+ $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
+ '$base' => z_root(),
+ '$banner' => t('Failed Updates'),
+ '$desc' => '',
+ '$mark' => t('Mark success (if update was manually applied)'),
+ '$apply' => t('Attempt to execute this update step automatically'),
+ '$failed' => $failed
+ ));
+
+ return $o;
+ }
+} \ No newline at end of file