parent
1e7184eed3
commit
5e0ffa8782
@ -0,0 +1,61 @@ |
|||||||
|
<?php //$id$
|
||||||
|
/** |
||||||
|
* This script contains the data to fill (or empty) the database with using |
||||||
|
* the fillers in this directory. |
||||||
|
* @author Yannick Warnier <yannick.warnier@dokeos.com> |
||||||
|
* |
||||||
|
*/ |
||||||
|
/** |
||||||
|
* Initialisation section |
||||||
|
*/ |
||||||
|
$users = array(); |
||||||
|
$users[] = array( |
||||||
|
'username' => 'ywarnier', |
||||||
|
'pass' => 'ywarnier', |
||||||
|
'firstname' => 'Yannick', |
||||||
|
'lastname' => 'Warnier', |
||||||
|
'status' => 1, |
||||||
|
'auth_source' => 'platform', |
||||||
|
'email' => 'yannick.warnier@testdokeos.com', |
||||||
|
'status' => 1, |
||||||
|
'creator_id' => 1, |
||||||
|
'active' => 1, |
||||||
|
); |
||||||
|
$users[] = array( |
||||||
|
'username' => 'mmosquera', |
||||||
|
'pass' => 'mmosquera', |
||||||
|
'firstname' => 'Michela', |
||||||
|
'lastname' => 'Mosquera Guardamino', |
||||||
|
'status' => 1, |
||||||
|
'auth_source' => 'platform', |
||||||
|
'email' => 'michela.mosquera@testdokeos.com', |
||||||
|
'status' => 1, |
||||||
|
'creator_id' => 1, |
||||||
|
'active' => 1, |
||||||
|
); |
||||||
|
$users[] = array( |
||||||
|
'username' => 'mlanoix', |
||||||
|
'pass' => 'mlanoix', |
||||||
|
'firstname' => 'Michel', |
||||||
|
'lastname' => 'Lanoix', |
||||||
|
'status' => 5, |
||||||
|
'auth_source' => 'platform', |
||||||
|
'email' => 'michel.lanoix@testdokeos.com', |
||||||
|
'status' => 1, |
||||||
|
'creator_id' => 1, |
||||||
|
'active' => 1, |
||||||
|
); |
||||||
|
/* |
||||||
|
$users[] = array( |
||||||
|
'username' => '', |
||||||
|
'pass' => '', |
||||||
|
'firstname' => '', |
||||||
|
'lastname' => '', |
||||||
|
'status' => 1, |
||||||
|
'auth_source' => 'platform', |
||||||
|
'email' => '', |
||||||
|
'status' => 1, |
||||||
|
'creator_id' => 1, |
||||||
|
'active' => 1, |
||||||
|
); |
||||||
|
*/ |
||||||
@ -0,0 +1,45 @@ |
|||||||
|
<?php //$id$
|
||||||
|
/** |
||||||
|
* This script contains calls to the various filling scripts that allow a |
||||||
|
* demo presenter to fill his Dokeos with demo data. |
||||||
|
* This script is locked against execution from the browser, to avoid malicious |
||||||
|
* insertion on production portals. |
||||||
|
* To execute, you need the PHP5 Command Line Interface (CLI) to be installed |
||||||
|
* on your system and t launch this script manually using: php5 fill_all.php |
||||||
|
* @author Yannick Warnier <yannick.warnier@dokeos.com> |
||||||
|
*/ |
||||||
|
/** |
||||||
|
* Initialisation section |
||||||
|
*/ |
||||||
|
require_once '../../main/inc/global.inc.php'; |
||||||
|
/** |
||||||
|
* Code logic |
||||||
|
*/ |
||||||
|
//Avoid execution if not from the command line |
||||||
|
if (PHP_SAPI != 'cli') { die('This demo-data filling script can only be run from the command line. Please launch it from the command line using: php5 fill_all.php. To enable it from your browser (very highly dangerous), remove the first line of code from the "logic" section of this file.'); } |
||||||
|
$eol = PHP_EOL; |
||||||
|
$output = ''; |
||||||
|
$files = scandir('.'); |
||||||
|
foreach ($files as $file) { |
||||||
|
if (substr($file,0,1) == '.' or substr($file,0,5) != 'fill_') { ; } //skip |
||||||
|
else { |
||||||
|
if ($file == basename(__FILE__)) { |
||||||
|
; //skip, this is the current file |
||||||
|
} else { |
||||||
|
$output .= $file.$eol; |
||||||
|
require_once $file; |
||||||
|
$function = basename($file,'.php'); |
||||||
|
if (function_exists($function)) { |
||||||
|
$output .= 'Executing function '.$function.$eol; |
||||||
|
$function(); |
||||||
|
} else { |
||||||
|
//function not found |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
/** |
||||||
|
* Display |
||||||
|
*/ |
||||||
|
echo $output.$eol; |
||||||
|
echo "Done all$eol"; |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
<?php //$id$
|
||||||
|
/** |
||||||
|
* This script contains a data filling procedure for users |
||||||
|
* @author Yannick Warnier <yannick.warnier@dokeos.com> |
||||||
|
* |
||||||
|
*/ |
||||||
|
/** |
||||||
|
* Initialisation section |
||||||
|
*/ |
||||||
|
require_once '../../main/inc/global.inc.php'; |
||||||
|
require_once '../../main/inc/lib/usermanager.lib.php'; |
||||||
|
/** |
||||||
|
* Loads the data and injects it into the Dokeos database, using the Dokeos |
||||||
|
* internal functions. |
||||||
|
* @return array List of user IDs for the users that have just been inserted |
||||||
|
*/ |
||||||
|
function fill_users() { |
||||||
|
$users = array(); //declare only to avoid parsing notice |
||||||
|
require_once 'data_users.php'; //fill the $users array |
||||||
|
$output = array(); |
||||||
|
foreach ($users as $i => $user) { |
||||||
|
//first check that the first item doesn't exist already |
||||||
|
echo $user['firstname']; |
||||||
|
$output[] = UserManager::create_user($user['firstname'],$user['lastname'],$user['status'],$user['email'],$user['username'],$user['pass'],null,null,null,null,$user['auth_source'],null,$user['active']); |
||||||
|
} |
||||||
|
return $output; |
||||||
|
} |
||||||
Loading…
Reference in new issue