if ($departmentid) {
    $params['departmentid'] = $departmentid;
}
$systemcontext = context_system::instance();
require_login();
// Correct the navbar.
// Set the name for the page.
$linktext = get_string('edit_users_title', 'block_iomad_company_admin');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_company_admin/editusers.php');
// Build the nav bar.
//company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('managecompanyusersetting');
// Print the page header.
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'company_edit_users_title');
$blockpage->setup();
// Set the companyid
$companyid = iomad::get_my_companyid($systemcontext);
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
$baseurl = new moodle_url(basename(__FILE__), $params);
$returnurl = $baseurl;
$blockpage->display_header();
// GWL : Check the department is valid.
if (!empty($departmentid) && !company::check_valid_department($companyid, $departmentid)) {
    print_error('invaliddepartment', 'block_iomad_company_admin');
}
// Get the associated department id.
$company = new company($companyid);
$parentlevel = company::get_company_parentnode($company->id);
        }
    }
}
// Correct the navbar.
// Set the name for the page.
$linktext = get_string('course_list_title', 'block_iomad_commerce');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_commerce/courselist.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$title = 'edit_course_shopsettings';
if ($isadding) {
    $title = 'addnewcourse';
}
$PAGE->navbar->add(get_string($title, 'block_iomad_commerce'));
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_commerce', 'block', $title);
$blockpage->setup($urlparams);
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
/* next line copied from /course/edit.php */
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$mform = new course_edit_form($PAGE->url, $isadding, $shopsettingsid, $course, $priceblocks, $editoroptions);
$mform->set_data($shopsettings);
if ($mform->is_cancelled()) {
    redirect($companylist);
} else {
    if ($data = $mform->get_data()) {
        $data->userid = $USER->id;
        $transaction = $DB->start_delegated_transaction();
        if ($isadding) {
            $shopsettingsid = $DB->insert_record('course_shopsettings', $data);
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 30, PARAM_INT);
// How many per page.
$context = context_system::instance();
require_login();
// Set the companyid
$companyid = iomad::get_my_companyid($context);
$PAGE->set_context($context);
// Correct the navbar .
// Set the name for the page.
$linktext = get_string('company_list_title', 'block_iomad_company_admin');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_company_admin/company_list.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'company_list_title');
$blockpage->setup();
$baseurl = new moodle_url(basename(__FILE__), array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
$returnurl = $baseurl;
if ($delete and confirm_sesskey()) {
    // Delete a selected company, after confirmation.
    iomad::require_capability('block/iomad_company_admin:company_delete', $context);
    $company = $DB->get_record('company', array('id' => $delete), '*', MUST_EXIST);
    if ($confirm != md5($delete)) {
        echo $OUTPUT->header();
        $name = $company->name;
        echo $OUTPUT->heading(get_string('deletecompany', 'block_iomad_company_admin'), 2, 'headingblock header');
        $optionsyes = array('delete' => $delete, 'confirm' => md5($delete), 'sesskey' => sesskey());
        echo $OUTPUT->confirm(get_string('companydeletecheckfull', 'block_iomad_company_admin', "'{$name}'"), new moodle_url('company_list.php', $optionsyes), 'company_list.php');
        echo $OUTPUT->footer();
        die;
require_once '../../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once 'lib.php';
$format = optional_param('format', '', PARAM_ALPHA);
$companyid = optional_param('companyid', 0, PARAM_INTEGER);
$context = context_system::instance();
require_login();
iomad::require_capability('block/iomad_company_admin:user_upload', $context);
// Correct the navbar.
// Set the name for the page.
$linktext = get_string('users_download', 'block_iomad_company_admin');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_company_admin/user_bulk_download.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'user_bulk_download_title');
$blockpage->setup();
// Set the companyid
$companyid = iomad::get_my_companyid($context);
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
// If company user override the companyid parameter - they can only download their own.
if (company_user::is_company_user()) {
    $companyid = company_user::companyid();
}
// Deal with the departments.
$parentlevel = company::get_company_parentnode($companyid);
$companydepartment = $parentlevel->id;
if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) {
    $userhierarchylevel = $parentlevel->id;
} else {
    $userlevel = company::get_userlevel($USER);
define('UU_ADD_UPDATE', 2);
define('UU_UPDATE', 3);
$choices = array(UU_ADDNEW => get_string('uuoptype_addnew', 'tool_uploaduser'), UU_ADDINC => get_string('uuoptype_addinc', 'tool_uploaduser'), UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'tool_uploaduser'), UU_UPDATE => get_string('uuoptype_update', 'tool_uploaduser'));
@set_time_limit(3600);
// 1 hour should be enough.
raise_memory_limit(MEMORY_EXTRA);
require_login();
iomad::require_capability('block/iomad_company_admin:user_upload', context_system::instance());
// Correct the navbar .
// Set the name for the page.
$linktext = get_string('user_upload_title', 'block_iomad_company_admin');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_company_admin/uploaduser.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'user_upload_title');
$blockpage->setup();
// Set the companyid
$companyid = iomad::get_my_companyid($context);
$companyshortname = '';
if ($companyid) {
    $company = new company($companyid);
    $companyshortname = $company->get_shortname();
}
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
$systemcontext = context_system::instance();
$struserrenamed = get_string('userrenamed', 'tool_uploaduser');
$strusernotrenamedexists = get_string('usernotrenamedexists', 'error');
$strusernotrenamedmissing = get_string('usernotrenamedmissing', 'error');
$strusernotrenamedoff = get_string('usernotrenamedoff', 'error');