Skip to content
Snippets Groups Projects
Commit 16e3a3d2 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix datadir not defined

Fix can't use the cron script on cloud services since the admin user may
have different values.
parent d22ef4f3
No related branches found
No related tags found
No related merge requests found
......@@ -314,6 +314,7 @@ function NextButtonClick(CurPageID: Integer): Boolean;
var myResult: Integer;
var res: Boolean;
var paramok: Boolean;
var datadir: String;
var exedirold: String;
var exedirnew: String;
var themessage: String;
......
......@@ -80,6 +80,23 @@ if ($key != $conf->global->CRON_KEY)
exit(-1);
}
// If param userlogin is reserved word 'firstadmin'
if ($userlogin == 'firstadmin')
{
$sql='SELECT login from '.MAIN_DB_PREFIX.'user WHERE admin = 1 ORDER BY entity LIMIT 1';
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
if ($obj)
{
$userlogin = $obj->login;
echo "First admin user found is login '".$userlogin."'\n<br>";
}
}
else dol_print_error($db);
}
// Check user login
$user=new User($db);
$result=$user->fetch('',$userlogin);
......@@ -93,8 +110,8 @@ else
{
if (empty($user->id))
{
echo " User user login: ".$userlogin." do not exists";
dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR);
echo "User user login: ".$userlogin." does not exists";
dol_syslog("User user login:".$userlogin." does not exists", LOG_ERR);
exit(-1);
}
}
......@@ -178,7 +195,7 @@ function usage($path,$script_file)
{
global $conf;
print "Usage: ".$script_file." securitykey userlogin [cronjobid]\n";
print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid]\n";
print "The script return 0 when everything worked successfully.\n";
print "\n";
print "On Linux system, you can have cron jobs ran automatically by adding an entry into cron.\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment