diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 52c276590..909dcffa3 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -23,6 +23,8 @@ $e_sub_cat = 'plug_manage'; define('PLUGIN_SHOW_REFRESH', FALSE); define('PLUGIN_SCAN_INTERVAL', !empty($_SERVER['E_DEV']) ? 0 : 360); +define("ADMIN_GITSYNC_ICON", $tp->toGlyph('fa-refresh', array('size'=>'2x', 'fw'=>1))); + global $user_pref; @@ -151,7 +153,7 @@ class pluginmanager_form extends e_form $text .= EPL_NOINSTALL_1.str_replace("..", "", e_PLUGIN.$this->plug['plugin_path'])."/ ".EPL_DIRECTORY; if($this->plug['plugin_installflag'] == false) { - e107::getDb()->db_Delete('plugin', "plugin_installflag=0 AND (plugin_path='{$this->plug['plugin_path']}' OR plugin_path='{$this->plug['plugin_path']}/' ) "); + e107::getDb()->delete('plugin', "plugin_installflag=0 AND (plugin_path='{$this->plug['plugin_path']}' OR plugin_path='{$this->plug['plugin_path']}/' ) "); } } } @@ -164,9 +166,13 @@ class pluginmanager_form extends e_form if ($this->plug['plugin_installflag'] && e_DEBUG == true) { - $text .= " ".ADMIN_REPAIRPLUGIN_ICON.""; + $text .= " ".ADMIN_REPAIRPLUGIN_ICON.""; } + if($this->plug['plugin_installflag'] && is_dir($_path.".git")) + { + $text .= " ".ADMIN_GITSYNC_ICON.""; + } $text .=" "; @@ -246,8 +252,9 @@ class pluginManager{ global $user_pref,$admin_log; $tmp = explode('.', e_QUERY); - $this -> action = ($tmp[0]) ? $tmp[0] : "installed"; - $this -> id = varset($tmp[1]) ? intval($tmp[1]) : ""; + + $this -> action = ($tmp[0]) ? $tmp[0] : "installed"; + $this -> id = !empty($tmp[1]) ? intval($tmp[1]) : ""; $this -> titlearray = array('installed'=>EPL_ADLAN_22,'avail'=>EPL_ADLAN_23, 'upload'=>EPL_ADLAN_38); if(isset($_GET['mode'])) @@ -332,7 +339,26 @@ class pluginManager{ return; } - + + + if($this->action == 'pull' && !empty($this->id)) + { + $info = e107::getPlugin()->getInfo($this->id); + + if(!empty($info['plugin_path'])) + { + $return = e107::getFile()->gitPull($info['plugin_path'], 'plugin'); + e107::getMessage()->addSuccess($return); + $this->action = 'refresh'; + } + else + { + $this->action = 'avail'; + } + + } + + if($this->action == 'avail' || $this->action == 'installed') // Plugin Check is done during upgrade_routine. { @@ -345,11 +371,15 @@ class pluginManager{ $this -> pluginCheck(true); // forced } + + if($this->action == "repair") { $this -> pluginRepair(); $this->action = 'refresh'; } + + if($this->action == "refresh") { diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php index 01de7f1e1..ef34fa038 100644 --- a/e107_handlers/cron_class.php +++ b/e107_handlers/cron_class.php @@ -41,25 +41,8 @@ class _system_cron if(is_dir(e_BASE.".git")) // Check it's a Git Repo { + $return = $fl->gitPull(); - $gitPath = defset('e_GIT','git'); // addo to e107_config.php to - - // Change Dir. - $cmd = 'cd '.e_ROOT; - $mes->addDebug($cmd); - $text = `$cmd 2>&1`; - - // Remove any local changes. - $cmd = $gitPath.' reset --hard'; - $mes->addDebug($cmd); - $text .= `$cmd 2>&1`; - - // Run Pull request - $cmd = $gitPath.' pull'; - $mes->addDebug($cmd); - $text .= `$cmd 2>&1`; - - $return = print_a($text,true); $mes->addSuccess($return); if(unlink(e_BASE."install.php")) diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index a4fee3a4f..0c860fb08 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -1245,6 +1245,54 @@ class e_file } + + public function gitPull($folder='', $type=null) + { + $gitPath = defset('e_GIT','git'); // addo to e107_config.php to + $mes = e107::getMessage(); + + // Change Dir. + + switch($type) + { + case "plugin": + $dir = realpath(e_PLUGIN.basename($folder)); + break; + + case "theme": + $dir = realpath(e_THEME.basename($folder)); + break; + + default: + $dir = e_ROOT; + + } + + $cmd = 'cd '.$dir; + + // return $cmd; + + $mes->addDebug($cmd); + + $mes->addDebug($cmd); + $text = `$cmd 2>&1`; + + // Remove any local changes. + $cmd = $gitPath.' reset --hard'; + $mes->addDebug($cmd); + $text .= `$cmd 2>&1`; + + // Run Pull request + $cmd = $gitPath.' pull'; + $mes->addDebug($cmd); + $text .= `$cmd 2>&1`; + + return print_a($text,true); + + } + + + /** * Returns true is the URL is valid and false if it is not. * @param $url diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 67024a89a..985e3bb9f 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -158,6 +158,12 @@ class themeHandler e107::getConfig()->save(true); } + + if(!empty($_POST['git_pull'])) + { + $return = e107::getFile()->gitPull($_POST['curTheme'], 'theme'); + $mes->addSuccess($return); + } if(isset($_POST['installplugin'])) { @@ -1217,7 +1223,7 @@ class themeHandler