Added feature to use data fillers from the admin interface in non-packaged (=development/test) versions of the platform.

skala
Yannick Warnier 15 years ago
parent 4e3aabc561
commit b71fbaab80
  1. 64
      main/admin/filler.php
  2. 8
      main/admin/index.php
  3. 10
      tests/datafiller/fill_users.php

@ -0,0 +1,64 @@
<?php // $Id: index.php 22269 2009-07-21 15:06:15Z juliomontoya $
/* For licensing terms, see /license.txt */
/**
* Index of the admin tools
*
* @package chamilo.admin
*/
// name of the language file that needs to be included <br />
$language_file=array('admin','tracking');
// resetting the course id
$cidReset=true;
// including some necessary chamilo files
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'security.lib.php';
// setting the section (for the tabs)
$this_section=SECTION_PLATFORM_ADMIN;
// Access restrictions
api_protect_admin_script(true);
$nameTools = get_lang('PlatformAdmin');
// setting breadcrumbs
$interbreadcrumb[] = array ("url" => 'index.php', "name" => $nameTools);
// setting the name of the tool
$nameTools = get_lang('DataFiller');
$output = array();
if (!empty($_GET['fill'])) {
require api_get_path('SYS_TEST_PATH').'datafiller/fill_users.php';
$output = fill_users();
}
// Displaying the header
Display::display_header($nameTools);
$result = '';
if (count($output)>0) {
$result = '<div class="filler-report">'."\n";
$result .= '<div class="filler-report-title">'.$output[0]['title'].'</div>'."\n";
$result .= '<table>';
foreach ($output as $line) {
$result .= '<tr>';
$result .= '<td class="filler-report-data-init">'.$line['line-init'].'</td><td class="filler-report-data">'.$line['line-info'].'</td>';
$result .= '</tr>'."\n";
}
$result .= '</table>';
$result .= '</div>';
Display::display_normal_message($result);
}
?>
<div class="admin_section">
<h4><?php Display::display_icon('bug.gif', 'DataFiller'); echo ' '.api_ucfirst(get_lang('DataFiller'));?></h4>
<div><?php echo get_lang('ThisSectionIsOnlyVisibleOnSourceInstalls');?></div>
<ul>
<li><a href="filler.php?fill=users"><?php echo get_lang('FillUsers');?></a></li>
</ul>
</div>
<?php
/* FOOTER */
Display::display_footer();

@ -176,8 +176,11 @@ if(api_is_platform_admin()) {
//@todo Translations needed in order to see a better explanation of issues
echo '<li><a href="system_status.php">'.get_lang('SystemStatus').'</a></li>';
if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
//do not show on production portals, where the tests directory doesn't exist
echo '<li><a href="filler.php">'.get_lang('DataFiller').'</a></li>';
}
?>
</ul>
</div>
@ -278,6 +281,7 @@ if(api_is_platform_admin()){
<?php
}*/
?>
<div class="admin_section">
<h4><?php Display::display_icon('logo.gif', 'Chamilo'); ?> Chamilo.org</h4>
<ul>
@ -294,7 +298,7 @@ if(api_is_platform_admin()){
?>
</ul>
</div>
<?php
<?php
}
/**

@ -15,15 +15,17 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
* @return array List of user IDs for the users that have just been inserted
*/
function fill_users() {
global $eol;
$eol = PHP_EOL;
$users = array(); //declare only to avoid parsing notice
require_once 'data_users.php'; //fill the $users array
$output = array();
echo $eol.'Users created:'.$eol.$eol;
$output[] = array('title'=>'UsersFillingReport:');
$i = 1;
foreach ($users as $i => $user) {
//first check that the first item doesn't exist already
echo $user['firstname'].$eol;
$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']);
$output[$i]['line-init'] = $user['firstname'];
$output[$i]['line-info'] = (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'])?$res:get_lang('NotInserted'));
$i++;
}
return $output;
}
Loading…
Cancel
Save