1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-09 09:13:25 +02:00

Added cron/function for updating from github. (Available only if the e107 installation is a cloned repo)

This commit is contained in:
Cameron
2014-05-23 21:59:01 -07:00
parent c0675ab6db
commit f428cc8041
4 changed files with 59 additions and 9 deletions

View File

@ -35,6 +35,7 @@ require_once(realpath(dirname(__FILE__)."/class2.php"));
if($pref['e_cron_pwd'] != $pwd) if($pref['e_cron_pwd'] != $pwd)
{ {
require_once(e_HANDLER."mail.php"); require_once(e_HANDLER."mail.php");
$message = "Your Cron Schedule is not configured correctly. Your passwords do not match. $message = "Your Cron Schedule is not configured correctly. Your passwords do not match.
<br /><br /> <br /><br />
Sent from cron: ".$pwd."<br /> Sent from cron: ".$pwd."<br />
@ -57,9 +58,9 @@ e107::getCache()->set('cronLastLoad',time(),TRUE,FALSE,TRUE);
$list = array(); $list = array();
$sql = e107::getDb(); $sql = e107::getDb();
if($sql->db_Select("cron",'cron_function,cron_tab','cron_active =1')) if($sql->select("cron",'cron_function,cron_tab','cron_active =1'))
{ {
while($row = $sql->db_Fetch(MYSQL_ASSOC)) while($row = $sql->fetch(MYSQL_ASSOC))
{ {
list($class,$function) = explode("::",$row['cron_function'],2); list($class,$function) = explode("::",$row['cron_function'],2);
$key = $class."__".$function; $key = $class."__".$function;

View File

@ -66,7 +66,7 @@ class cron_admin_ui extends e_admin_ui
protected $pluginName = 'core'; protected $pluginName = 'core';
protected $table = "cron"; protected $table = "cron";
protected $pid = "cron_id"; protected $pid = "cron_id";
protected $listOrder = 'cron_category'; protected $listOrder = 'cron_category desc'; // Show 'upgrades' on first page.
protected $perPage = 10; protected $perPage = 10;
protected $batchDelete = TRUE; protected $batchDelete = TRUE;
@ -108,8 +108,8 @@ class cron_admin_ui extends e_admin_ui
$pwd = $this->setCronPwd(); $pwd = $this->setCronPwd();
} }
$sql->db_Select_gen("SELECT cron_function,cron_active FROM #cron "); $sql->gen("SELECT cron_function,cron_active FROM #cron ");
while($row = $sql->db_Fetch(MYSQL_ASSOC)) while($row = $sql->fetch(MYSQL_ASSOC))
{ {
$this->curCrons[] = $row['cron_function']; $this->curCrons[] = $row['cron_function'];
if($row['cron_active']==1) if($row['cron_active']==1)
@ -164,13 +164,29 @@ class cron_admin_ui extends e_admin_ui
), ),
6 => array( 6 => array(
'name' => LAN_CRON_20_1, 'name' => LAN_CRON_20_1,
'category' => '', 'category' => 'update',
'function' => 'checkCoreUpdate', 'function' => 'checkCoreUpdate',
'description' => LAN_CRON_20_2 ."<br />". LAN_CRON_20_3, 'description' => LAN_CRON_20_2 ."<br />". LAN_CRON_20_3,
// 'available' => e107::getPref('ban_retrigger') // 'available' => e107::getPref('ban_retrigger')
), ),
); );
if(is_dir(e_BASE.".git"))
{
$cronDefaults['_system'][7] = array(
'name' => "Update this Git repository", //TODO LAN
'category' => 'update',
'function' => 'gitrepo',
'description' => "Update this e107 installation with the very latest files from github.<br />Recommended for developers only.<br /><span class='label label-warning'>Warning!</span> May cause site instability!", //TODO LAN
// 'available' => e107::getPref('ban_retrigger')
);
}
if(!vartrue($_GET['action']) || $_GET['action'] == 'refresh') if(!vartrue($_GET['action']) || $_GET['action'] == 'refresh')
{ {
@ -260,7 +276,7 @@ class cron_admin_ui extends e_admin_ui
return; return;
} }
if(!$sql->db_Insert('cron',$insert)) if(!$sql->insert('cron',$insert))
{ {
e107::getMessage()->add(LAN_CRON_6, E_MESSAGE_ERROR); e107::getMessage()->add(LAN_CRON_6, E_MESSAGE_ERROR);
} }
@ -285,7 +301,7 @@ class cron_admin_ui extends e_admin_ui
$cron_function = $insert['cron_function']; $cron_function = $insert['cron_function'];
unset($insert['cron_function']); unset($insert['cron_function']);
if($sql->db_Update('cron',$insert)===FALSE) if($sql->update('cron',$insert)===FALSE)
{ {
e107::getMessage()->add(LAN_CRON_7, E_MESSAGE_ERROR); e107::getMessage()->add(LAN_CRON_7, E_MESSAGE_ERROR);
} }
@ -475,7 +491,8 @@ class cron_admin_form_ui extends e_admin_form_ui
'mail' => ADLAN_136, 'mail' => ADLAN_136,
'notify' => ADLAN_149, 'notify' => ADLAN_149,
'user' => LAN_USER, 'user' => LAN_USER,
'plugin' => ADLAN_CL_7 'plugin' => ADLAN_CL_7,
'update' => LAN_UPDATE
); );
/** /**

View File

@ -30,6 +30,37 @@ class _system_cron
// Whatever code you wish. // Whatever code you wish.
} }
/**
* Update the current Repo. of this e107 installation. (eg. e107 on github)
*/
function gitrepo()
{
$mes = e107::getMessage();
if(is_dir(e_BASE.".git")) // Check it's a Git Repo
{
// Change Dir.
$cmd = 'cd '.e_ROOT;
$mes->addDebug($cmd);
$text .= `$cmd 2>&1`;
// Run Pull request
$cmd = 'git pull';
$mes->addDebug($cmd);
$text .= `$cmd 2>&1`;
$return = print_a($text,true);
$mes->addSuccess($return);
}
else
{
$mes->addError("No git repo found"); //TODO LAN
}
}
/** /**
* Burnsy - This is just a test * Burnsy - This is just a test
* *

View File

@ -3,6 +3,7 @@
$mes = e107::getMessage(); $mes = e107::getMessage();
$mes->setTitle(LAN_STATUS, 'info');
echo $mes->render('default','info',false); echo $mes->render('default','info',false);
?> ?>