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

Bit of work on admin -> crons

This commit is contained in:
CaMer0n
2009-07-08 12:01:06 +00:00
parent 6c0bd1e16a
commit 0a40da5242

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/cron.php,v $
| $Revision: 1.1 $
| $Date: 2008-06-17 05:39:22 $
| $Revision: 1.2 $
| $Date: 2009-07-08 12:01:06 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -25,9 +25,63 @@ if (!getperms('U'))
$e_sub_cat = 'cron';
require_once('auth.php');
require_once (e_HANDLER.'message_handler.php');
require_once(e_HANDLER."form_handler.php");
$frm = new e_form(true);
$cron = new cron;
if(isset($_POST['submit']))
require_once(e_ADMIN."footer.php");
exit;
class cron
{
var $coreCrons = array();
var $cronAction;
function cron()
{
$this->cronAction = e_QUERY;
if(isset($_POST['submit']))
{
$this -> cronSave();
}
if(isset($_POST['save_prefs']))
{
$this -> cronSavePrefs();
}
// Set Core Cron Options.
$this->coreCrons[] = array('name'=>'User Purge','function' => 'user_purge', 'description'=>'Purge Unactivated Users');
$this->coreCrons[] = array('name'=>'User UnActivated','function' => 'user_unactivated', 'description'=>'Resend activation email to unactivated users.');
$this->coreCrons[] = array('name'=>'News Sticky','function' => 'news_purge', 'description'=>'Remove Sticky News Items');
// These core functions need to be put into e_BASE/cron.php ie. news_purge()
if($this->cronAction == "" || $this->cronAction == "main")
{
$this -> cronRenderPage();
}
if($this->cronAction == "pref")
{
$this -> cronRenderPrefs();
}
}
function cronSavePref()
{
// Store the USERID with the password.
// This way only the one password is needed, and the user login can be looked up in e_base/cron.php
}
function cronSave()
{
global $pref;
foreach($_POST['cron'] as $key=>$val)
{
if(!$val['active'])
@@ -47,18 +101,70 @@ if(isset($_POST['submit']))
}
$pref['e_cron_pref'] = $cron;
save_prefs();
$ns -> tablerender(LAN_SAVED,"<div style='text-align:center'>".LAN_SETSAVED."</div>");
}
$emessage = &eMessage::getInstance();
if(save_prefs())
{
$emessage->add(LAN_SETSAVED, E_MESSAGE_SUCCESS);
}
else
{
$emessage->add("There was a problem saving your settings.", E_MESSAGE_ERROR);
}
}
// --------------------------------------------------------------------------
function cronRenderPrefs()
{
global $frm,$ns;
$text = "<div style='text-align:center'>
<form method='post' action='".e_SELF."' id='linkform'>
<table class='adminlist'>
<tr>
<td style='width:30%'>Cron Password</td>
<td style='width:70%'>
".$frm->password('cron_password',100)."
</td>
</tr>
<tr>
<td style='width:30%'>bcc: </td>
<td style='width:70%'>
<input type='text' name='name2' class='tbox' style='width:80%' value='' />
</td>
</tr>
<tr style='vertical-align:top'>
<td colspan='2' class='center buttons-bar'>";
$text .= $frm->admin_button('save_prefs',LAN_SAVE, 'update');
$text .= "</td>
</tr>
</table>
</form>
</div>";
$ns -> tablerender(LAN_PREFS, $text);
}
$cronpref = $pref['e_cron_pref'];
// ----------- Grab All e_cron parameters -----------------------------------
$count = 0;
foreach($pref['e_cron_list'] as $key=>$val)
{
function cronRenderPage()
{
global $pref,$ns,$frm;
$cronpref = $pref['e_cron_pref'];
// $count = 0;
$e_cron = $this->coreCrons;
$count = count($this->coreCrons);
foreach($pref['e_cron_list'] as $key=>$val)
{
$eplug_cron = array();
if(is_readable(e_PLUGIN.$key."/e_cron.php"))
{
@@ -73,27 +179,40 @@ foreach($pref['e_cron_list'] as $key=>$val)
}
}
}
}
// ---------------------- List All Functions -----------------------------
// ---------------------- List All Functions -----------------------------
$text = "<div style='text-align:center'>
<form method='post' action='".e_SELF."' id='linkform'>
<table style='".ADMIN_WIDTH."' class='fborder'>
$text = "<div style='text-align:center'>
<form method='post' action='".e_SELF."' id='cronform'>
<table class='adminlist'>
<colgroup span='8'>
<col></col>
<col></col>
<col></col>
<col></col>
<col></col>
<col></col>
<col></col>
<col></col>
</colgroup>
<thead>
<tr>
<td class='fcaption'>".LAN_CRON_1."</td>
<td class='fcaption'>".LAN_CRON_2."</td>
<td class='fcaption'>".LAN_CRON_3."</td>
<td class='fcaption'>".LAN_CRON_4."</td>
<td class='fcaption'>".LAN_CRON_5."</td>
<td class='fcaption'>".LAN_CRON_6."</td>
<td class='fcaption'>".LAN_CRON_7."</td>
<td class='fcaption'>".LAN_CRON_8."</td>
</tr>";
<th>".LAN_CRON_1."</th>
<th>".LAN_CRON_2."</th>
<th>".LAN_CRON_3."</th>
<th>".LAN_CRON_4."</th>
<th>".LAN_CRON_5."</th>
<th>".LAN_CRON_6."</th>
<th>".LAN_CRON_7."</th>
<th>".LAN_CRON_8."</th>
</tr>
</thead>
<tbody>";
foreach($e_cron as $cron)
{
foreach($e_cron as $cron)
{
$c = $cron['function'];
$sep = array();
@@ -129,9 +248,9 @@ foreach($e_cron as $cron)
);
$text .= "<tr>
<td class='forumheader3'>".$cron['name']."</td>
<td class='forumheader3'>".$cron['description']."</td>
<td class='forumheader3'>
<td>".$cron['name']."</td>
<td>".$cron['description']."</td>
<td>
<input type='hidden' name='cron[$c][path]' value='".$cron['path']."' />
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][minute][]'>\n";
@@ -157,7 +276,7 @@ foreach($e_cron as $cron)
}
$text .= "</select>
</td>
<td class='forumheader3'>
<td>
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][hour][]'>
\n";
@@ -183,7 +302,7 @@ foreach($e_cron as $cron)
}
$text .= "</select>
</td>
<td class='forumheader3'>
<td>
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][day][]'>\n";
$sel_day = ($day[0] == "*") ? "selected='selected'" : "";
@@ -196,7 +315,7 @@ foreach($e_cron as $cron)
}
$text .= "</select>
</td>
<td class='forumheader3'>
<td>
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][month][]'>\n";
$sel_month = ($month[0] == "*") ? "selected='selected'" : "";
@@ -210,7 +329,7 @@ foreach($e_cron as $cron)
}
$text .= "</select>
</td>
<td class='forumheader3'>
<td>
<select class='tbox' style='height:70px' multiple='multiple' name='tab[$c][weekday][]'>\n";
$sel_weekday = ($weekday[0] == "*") ? "selected='selected'" : "";
@@ -224,28 +343,54 @@ foreach($e_cron as $cron)
}
$text .= "</select>
</td>
<td class='forumheader3' style='text-align:center'>";
<td style='text-align:center'>";
$checked = ($cronpref[$c]['active'] == 1) ? "checked='checked'" : "";
$text .= "<input type='checkbox' name='cron[$c][active]' value='1' $checked />
</td>
</tr>";
}
}
$text .= "
$text .= "
<tr style='vertical-align:top'>
<td colspan='8' style='text-align:center' class='forumheader'>";
$text .= "<input class='button' type='submit' name='submit' value='".LAN_SAVE."' />";
$text .= "</td>
<tr >
<td colspan='8' class='center'>
<div class='center buttons-bar'>";
// $text .= "<input class='button' type='submit' name='submit' value='".LAN_SAVE."' />";
$text .= $frm->admin_button('submit', LAN_SAVE, $action = 'update');
$text .= "</div></td>
</tr>
</tbody>
</table>
</form>
</div>";
$ns -> tablerender(PAGE_NAME, $text);
$emessage = &eMessage::getInstance();
$ns -> tablerender(PAGE_NAME, $emessage->render() . $text);
}
function cronOptions()
{
$e107 = &e107::getInstance();
$var['main']['text'] = PAGE_NAME;
$var['main']['link'] = e_SELF;
$var['pref']['text'] = LAN_PREFS;
$var['pref']['link'] = e_SELF."?pref";
$var['pref']['perm'] = "N";
$action = ($this->cronAction) ? $this->cronAction : "main";
e_admin_menu(PAGE_NAME, $action, $var);
}
}
require_once(e_ADMIN."footer.php");
exit;
function cron_adminmenu()
{
global $cron;
$cron->cronOptions();
}
?>