public function scaffold($table_name, $class_name = '', $prefix = '_')
 {
     $db_name = Database::get_main_database();
     $sql = "SELECT * FROM `{$db_name}`.`{$table_name}` LIMIT 1";
     $fields = array();
     $unique_fields = array();
     $rs = Database::query($sql, null, __FILE__);
     while ($field = mysql_fetch_field($rs)) {
         $fields[] = $field;
         if ($field->primary_key) {
             /**
              * Could move that to an array to support multiple keys
              */
             $id_name = $field->name;
         }
         if ($field->unique_key | $field->primary_key) {
             $keys[] = $field->name;
         }
     }
     $name = $table_name;
     $class_name = ucfirst($table_name);
     ob_start();
     include dirname(__FILE__) . '/template/model.php';
     $result = ob_get_clean();
     return $result;
 }
Example #2
0
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath . 'fileManage.lib.php';
require_once $libpath . 'fileUpload.lib.php';
// user permissions
api_block_anonymous_users();
if (!api_is_platform_admin()) {
    if (!api_is_drh()) {
        api_not_allowed(true);
    }
} else {
    api_protect_admin_script();
}
// Database table definitions
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$database = Database::get_main_database();
$userId = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : '';
$userInfo = api_get_user_info($userId);
if (empty($userInfo)) {
    api_not_allowed(true);
}
$userIsFollowed = UserManager::is_user_followed_by_drh($userId, api_get_user_id());
if (api_drh_can_access_all_session_content()) {
    $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, 0, null, null, 'desc', null, null, null, null, null, STUDENT);
    if (empty($students)) {
        api_not_allowed(true);
    }
    $userIdList = array();
    foreach ($students as $student) {
        $userIdList[] = $student['user_id'];
    }
Example #3
0
    echo "  This script needs to be run from the tests/ directory inside a Chamilo\n", "  installation. Please make sure main/inc/global.inc.php exists, then run this\n", "  script again.\n";
    exit;
}
if (!is_file(dirname(__FILE__) . '/../main/inc/conf/configuration.php')) {
    echo "  This script will only work on an already installed version of Chamilo. The \n", "main/inc/conf/configuration.php file could not be found, which is understood\n", "as Chamilo not being installed.\n";
    exit;
}
/**
 * Preparing vars
 */
ini_set('track_errors', 1);
$_SERVER['SERVER_NAME'] = '';
$_SERVER['HTTP_HOST'] = 'localhost';
$root = dirname(__FILE__) . '/../';
require $root . 'main/inc/global.inc.php';
$global_db = Database::get_main_database();
$webpath = api_get_path(WEB_PATH);
$homepath = api_get_path(SYS_PATH) . 'home';
$clean_dirs = array(api_get_path(SYS_COURSE_PATH), api_get_path(SYS_CODE_PATH) . 'inc/conf/', api_get_path(SYS_CODE_PATH) . 'upload/users/', api_get_path(SYS_ARCHIVE_PATH));
// With all this, we will still be missing custom languages and CSS dirs
/**
 * Running the cleanup
 */
echo "Assuming " . api_get_path(SYS_PATH) . " as Chamilo directory\n";
foreach ($clean_dirs as $dir) {
    $list = scandir($dir);
    echo "Cleaning {$dir}\n";
    foreach ($list as $entry) {
        if (substr($entry, 0, 1) == '.' or strcmp($entry, 'htaccess') === 0 or strcmp($entry, 'index.html') === 0 or substr($entry, -9, 9) == '.dist.php') {
            //skip files that are part of the Chamilo installation
        } else {