N°478 - Customizable access to the 'Admin Tools'

SVN:trunk[5364]
This commit is contained in:
Eric Espié
2018-02-23 11:13:07 +00:00
parent b952f9da4a
commit d65bd97956
29 changed files with 738 additions and 264 deletions

View File

@@ -40,8 +40,8 @@ try
case 'backup':
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
ApplicationMenu::CheckMenuIdEnabled('BackupStatus');
$oPage = new ajax_page("");
$oPage->no_cache();
$oPage->SetContentType('text/html');
@@ -70,7 +70,8 @@ try
case 'restore_get_token':
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
ApplicationMenu::CheckMenuIdEnabled('BackupStatus');
$oPage = new ajax_page("");
$oPage->no_cache();
@@ -166,7 +167,8 @@ EOF
case 'download':
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
ApplicationMenu::CheckMenuIdEnabled('BackupStatus');
if (utils::GetConfig()->Get('demo_mode'))
{

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.5">
<menus>
<menu id="BackupStatus" xsi:type="WebPageMenuNode" _delta="define">
<rank>15</rank>
<parent>AdminTools</parent>
<url>status.php</url>
<enable_class>ResourceAdminMenu</enable_class>
<enable_action>UR_ACTION_MODIFY</enable_action>
</menu>
</menus>
</itop_design>

View File

@@ -75,9 +75,11 @@ class DBBackupScheduled extends DBBackup
}
/**
* List and order by date the backups in the given directory
* List and order by date the backups in the given directory
* Note: the algorithm is currently based on the file modification date... because there is no "creation date" in general
*/
* @param string $sBackupDir
* @return array
*/
public function ListFiles($sBackupDir)
{
$aFiles = array();
@@ -130,6 +132,11 @@ class BackupExec implements iScheduledProcess
}
}
/**
* @param int $iUnixTimeLimit
* @return string
* @throws Exception
*/
public function Process($iUnixTimeLimit)
{
$oMutex = new iTopMutex('backup.'.utils::GetCurrentEnvironment());
@@ -182,10 +189,11 @@ class BackupExec implements iScheduledProcess
return "Created the backup: $sBackupFile";
}
/*
Interpret current setting for the week days
@returns array of int (monday = 1)
*/
/**
* Interpret current setting for the week days
* @returns array of int (monday = 1)
* @throws Exception
*/
public function InterpretWeekDays()
{
static $aWEEKDAYTON = array('monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6, 'sunday' => 7);
@@ -216,10 +224,10 @@ class BackupExec implements iScheduledProcess
return $aDays;
}
/*
Gives the exact time at which the process must be run next time
@returns DateTime
*/
/** Gives the exact time at which the process must be run next time
* @return DateTime
* @throws Exception
*/
public function GetNextOccurrence()
{
$bEnabled = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'enabled', true);
@@ -279,15 +287,3 @@ class BackupExec implements iScheduledProcess
return $oRet;
}
}
class ItopBackup extends ModuleHandlerAPI
{
public static function OnMenuCreation()
{
if (UserRights::IsAdministrator())
{
$oAdminMenu = new MenuGroup('AdminTools', 80 /* fRank */);
new WebPageMenuNode('BackupStatus', utils::GetAbsoluteUrlModulePage('itop-backup', 'status.php'), $oAdminMenu->GetIndex(), 15 /* fRank */);
}
}
}

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-backup/2.4.0',
'itop-backup/2.4.1',
array(
// Identification
//
@@ -21,7 +21,7 @@ SetupWebPage::AddModule(
//
'datamodel' => array(
'main.itop-backup.php',
//'model.itop-backup.php',
'model.itop-backup.php',
),
'webservice' => array(
//'webservices.itop-backup.php',

View File

@@ -37,17 +37,19 @@ require_once(APPROOT.'application/loginwebpage.class.inc.php');
/////////////////////////////////////////////////////////////////////
// Main program
//
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
ApplicationMenu::CheckMenuIdEnabled('BackupStatus');
//$sOperation = utils::ReadParam('operation', 'menu');
//$oAppContext = new ApplicationContext();
$oP = new iTopWebPage(Dict::S('bkp-status-title'));
$oP->set_base(utils::GetAbsoluteUrlAppRoot().'pages/');
try
{
$oP = new iTopWebPage(Dict::S('bkp-status-title'));
$oP->set_base(utils::GetAbsoluteUrlAppRoot().'pages/');
$oP->add("<h1>".Dict::S('bkp-status-title')."</h1>");
if (MetaModel::GetConfig()->Get('demo_mode'))
@@ -93,7 +95,7 @@ try
}
foreach($aOutput as $sLine)
{
//echo 'Info - mysqldump -V said: '.$sLine;
IssueLog::Info("$sCommand said: $sLine");
}
$oP->p($sMySqlDump);
@@ -394,6 +396,7 @@ EOF
}
catch(Exception $e)
{
$oP = new iTopWebPage(Dict::S('bkp-status-title'));
$oP->p('<b>'.$e->getMessage().'</b>');
}