コード例 #1
0
ファイル: user_bulk_download.php プロジェクト: nmicha/moodle
admin_externalpage_setup('userbulk');
require_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM));
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
if (empty($SESSION->bulk_users)) {
    redirect($return);
}
if ($format) {
    $fields = array('id' => 'id', 'username' => 'username', 'email' => 'email', 'firstname' => 'firstname', 'lastname' => 'lastname', 'idnumber' => 'idnumber', 'institution' => 'institution', 'department' => 'department', 'phone1' => 'phone1', 'phone2' => 'phone2', 'city' => 'city', 'url' => 'url', 'icq' => 'icq', 'skype' => 'skype', 'aim' => 'aim', 'yahoo' => 'yahoo', 'msn' => 'msn', 'country' => 'country');
    if ($extrafields = $DB->get_records('user_info_field')) {
        foreach ($extrafields as $n => $v) {
            $fields['profile_field_' . $v->shortname] = 'profile_field_' . $v->shortname;
        }
    }
    switch ($format) {
        case 'csv':
            user_download_csv($fields);
        case 'ods':
            user_download_ods($fields);
        case 'xls':
            user_download_xls($fields);
    }
    die;
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
echo $OUTPUT->box_start();
echo '<ul>';
echo '<li><a href="user_bulk_download.php?format=csv">' . get_string('downloadtext') . '</a></li>';
echo '<li><a href="user_bulk_download.php?format=ods">' . get_string('downloadods') . '</a></li>';
echo '<li><a href="user_bulk_download.php?format=xls">' . get_string('downloadexcel') . '</a></li>';
echo '</ul>';
コード例 #2
0
ファイル: sample.php プロジェクト: narasimhaeabyas/tataaiapro
 * script for downloading costcenters
 */
require_once(dirname(__FILE__) . '/../../config.php');
$format = optional_param('format', '', PARAM_ALPHA);

if ($format) {
    $fields = array(
        'fullname' => 'fullname',
        'parentid' => 'parentid',
        'type' => 'type',
        'description' => 'description',
        'visible' => 'visible',
        'childpermissions' => 'childpermissions'
    );
    switch ($format) {
        case 'csv' : user_download_csv($fields);
    }
    die;
}

function user_download_csv($fields) {
    global $CFG;
    require_once($CFG->libdir . '/csvlib.class.php');
    $filename = clean_filename('Departments');
    $csvexport = new csv_export_writer();
    $csvexport->set_filename($filename);
    $csvexport->add_data($fields);
    $userprofiledata = array();
    $csvexport->add_data($userprofiledata);
    $csvexport->download_file();
    die;
コード例 #3
0
        $departmentids = "";
        foreach ($departmentusers as $departmentuser) {
            if (!empty($departmentids)) {
                $departmentids .= "," . $departmentuser->userid;
            } else {
                $departmentids .= $departmentuser->userid;
            }
        }
        $sqlsearch = " AND userid in ({$departmentids}) ";
    } else {
        $sqlsearch = "AND 1 = 0";
    }
    $userids = $DB->get_records_sql_menu("SELECT userid, userid as id\n        FROM\n            {company_users}\n        WHERE\n            companyid = :companyid\n            " . $sqlsearch, $params);
    switch ($format) {
        case 'csv':
            user_download_csv($userids, $fields, !$companyid);
        case 'ods':
            user_download_ods($userids, $fields, !$companyid);
        case 'xls':
            user_download_xls($userids, $fields, !$companyid);
    }
    die;
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
// Get url of ourselves.
$url = new moodle_url('/blocks/iomad_company_admin/user_bulk_download.php', array('companyid' => $companyid));
// Show download options menu.
echo $OUTPUT->box_start();
echo '<ul>';
echo '<li><a href="' . $url->out(true, array('format' => 'csv')) . '">' . get_string('downloadtext') . '</a></li>';
コード例 #4
0
admin_externalpage_setup('userbulk');
require_capability('moodle/user:update', context_system::instance());
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
// if (empty($SESSION->bulk_users)) {
// redirect($return);
// }
if ($format) {
    $fields = array('id' => 'id', 'username' => 'username', 'email' => 'email', 'firstname' => 'firstname', 'lastname' => 'lastname', 'idnumber' => 'idnumber', 'institution' => 'institution', 'phone1' => 'phone1', 'phone2' => 'phone2', 'city' => 'city', 'url' => 'url', 'icq' => 'icq', 'skype' => 'skype', 'aim' => 'aim', 'yahoo' => 'yahoo', 'msn' => 'msn', 'country' => 'country');
    if ($extrafields = $DB->get_records('user_info_field')) {
        foreach ($extrafields as $n => $v) {
            $fields['profile_field_' . $v->shortname] = 'profile_field_' . $v->shortname;
        }
    }
    switch ($format) {
        case 'csv':
            user_download_csv($fields, $extrafields);
        case 'ods':
            user_download_ods($fields, $extrafields);
        case 'xls':
            user_download_xls($fields, $extrafields);
    }
    die;
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
echo $OUTPUT->box_start();
echo '<ul>';
echo '<li><a href="user_bulk_download_list.php?format=csv">' . get_string('downloadtext') . '</a></li>';
echo '<li><a href="user_bulk_download_list.php?format=ods">' . get_string('downloadods') . '</a></li>';
echo '<li><a href="user_bulk_download_list.php?format=xls">' . get_string('downloadexcel') . '</a></li>';
echo '</ul>';