Ejemplo n.º 1
0
    } */
 // Update mail bounces.
 //useredit_update_bounces($user, $usernew);
 // Update forum track preference.
 // useredit_update_trackforums($user, $usernew);
 // Save custom profile fields data.
 profile_save_data($usernew);
 // update user region and location as well as role type
 // print_object($usernew);
 // die;
 if (!$usercreated) {
     if (empty($usernew->userlocation) && $userlocation) {
         $usernew->userlocation = $userlocation;
     }
     $userdept = $usernew->userlocation ? $usernew->userlocation : $usernew->userregion;
     if (company::check_valid_department($companyid, $userdept)) {
         $userlevel = $DB->get_record('company_users', array('userid' => $usernew->id));
         $userlevel->managertype = $usernew->managertype;
         $userlevel->departmentid = $userdept;
         $DB->update_record('company_users', $userlevel);
     }
     if (isset($usernew->userdepartment) || isset($usernew->usertitle)) {
         $department = isset($usernew->userdepartment) ? $usernew->userdepartment : 0;
         $title = isset($usernew->usertitle) ? $usernew->usertitle : 0;
         assign_department_and_title_to_user($companyid, $department, $title, $usernew->id);
     }
 }
 // Reload from db.
 $usernew = $DB->get_record('user', array('id' => $usernew->id));
 // Trigger events.
 if ($usercreated) {
Ejemplo n.º 2
0
// 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);
$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);
    $userhierarchylevel = $userlevel->id;
}
if ($departmentid == 0) {
    $departmentid = $userhierarchylevel;
}
require_once 'lib.php';
global $SESSION, $PAGE;
$context = context_system::instance();
$region = required_param('regionid', PARAM_INT);
$resulttype = required_param('resulttype', PARAM_INT);
require_login();
$PAGE->set_context($context);
if (!empty($SESSION->currenteditingcompany)) {
    $companyid = $SESSION->currenteditingcompany;
} else {
    if (company_user::is_company_user()) {
        $companyid = company_user::companyid();
    }
}
$company = new company($companyid);
if (!empty($region) && !company::check_valid_department($company->id, $region)) {
    print_error('invalidregion', 'block_iomad_company_admin');
}
//iomad::require_capability('block/iomad_company_admin:edit_departments', $context);
$locationlist = company::get_all_locations($region);
$regiondropdownhtml = '<option value="">' . get_string('choose') . '</option>';
$regionlisthtml = '';
$enablebutton = 0;
if (!empty($locationlist)) {
    $regionlisthtml = "<p>" . get_string('locations', 'block_iomad_company_admin') . "</p>";
    $locationcount = 0;
    foreach ($locationlist as $location) {
        $locationcount++;
        if ($resulttype === 1) {
            // Return the checkbox list of locations
            $regionlisthtml .= '<input type = "checkbox" name = "locationids[]" value="' . $location->id . '" /> ' . $location->name . '</br>';