public function get_content() { global $USER, $CFG, $DB, $OUTPUT, $SESSION; // Only display if you have the correct capability. if (!iomad::has_capability('block/iomad_company_admin:company_add', context_system::instance())) { return; } if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if (empty($this->instance)) { return $this->content; } if (!isloggedin()) { $this->content->text = get_string('pleaselogin', 'block_iomad_company_selector'); return $this->content; } // Check users session and profile settings to get the current editing company. if (!empty($SESSION->currenteditingcompany)) { $selectedcompany = $SESSION->currenteditingcompany; } else { if (!empty($USER->profile->company)) { $usercompany = company::by_userid($USER->id); $selectedcompany = $usercompany->id; } else { $selectedcompany = ""; } } // Get the company name if set. if (!empty($selectedcompany)) { $companyname = company::get_companyname_byid($selectedcompany); } else { $companyname = ""; } // Get a list of companies. $companylist = company::get_companies_select(); $select = new single_select(new moodle_url('/local/iomad_dashboard/index.php'), 'company', $companylist, $selectedcompany); $select->label = get_string('selectacompany', 'block_iomad_company_selector'); $select->formid = 'choosecompany'; $fwselectoutput = html_writer::tag('div', $OUTPUT->render($select), array('id' => 'iomad_company_selector')); $this->content->text = $OUTPUT->container_start('companyselect'); if (!empty($SESSION->currenteditingcompany)) { $this->content->text .= '<h3>' . get_string('currentcompany', 'block_iomad_company_selector') . ' - ' . $companyname . '</h3>'; } else { $this->content->text .= '<h3>' . get_string('nocurrentcompany', 'block_iomad_company_selector') . '</h3>'; } $this->content->text .= $fwselectoutput; $this->content->text .= $OUTPUT->container_end(); return $this->content; }
/** * Form tweaks that depend on current data. */ public function definition_after_data() { global $USER, $SESSION; $mform =& $this->_form; $columns =& $this->_customdata; foreach ($columns as $column) { if ($mform->elementExists($column)) { $mform->removeElement($column); } } // Set the companyid to bypass the company select form if possible. if (!empty($SESSION->currenteditingcompany)) { $companyid = $SESSION->currenteditingcompany; } else { $companyid = company_user::companyid(); } // Get the department list. $parentlevel = company::get_company_parentnode($companyid); 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; } $this->departmentid = $userhierarchylevel; $subhierarchieslist = company::get_all_subdepartments($userhierarchylevel); // Department drop down. $mform->insertElementBefore($mform->createElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $subhierarchieslist, $userhierarchylevel), 'uutypelabel'); $this->courseselector = $this->add_course_selector(); $this->add_action_buttons(true, get_string('uploadusers', 'tool_uploaduser')); }
public function __construct($actionurl, $context, $companyid, $departmentid, $licenseid, $courses = array()) { global $USER; $this->selectedcompany = $companyid; $this->context = $context; $this->departmentid = $departmentid; $this->licenseid = $licenseid; $this->selectedcourses = $courses; $company = new company($this->selectedcompany); $parentlevel = company::get_company_parentnode($company->id); $this->companydepartment = $parentlevel->id; if (iomad::has_capability('block/iomad_company_admin:edit_licenses', context_system::instance())) { $userhierarchylevel = $parentlevel->id; } else { $userlevel = company::get_userlevel($USER); $userhierarchylevel = $userlevel->id; } $this->subhierarchieslist = company::get_all_subdepartments($userhierarchylevel); if ($this->departmentid == 0) { $departmentid = $userhierarchylevel; } else { $departmentid = $this->departmentid; } $options = array('context' => $this->context, 'multiselect' => true, 'companyid' => $this->selectedcompany, 'departmentid' => $departmentid, 'subdepartments' => $this->subhierarchieslist, 'parentdepartmentid' => $parentlevel, 'selected' => $this->selectedcourses, 'license' => true); $this->currentcourses = new all_department_course_selector('currentcourselicense', $options); parent::moodleform($actionurl); }
public function __construct($actionurl, $context, $companyid, $departmentid, $userid, $licenseid) { global $USER, $DB; $this->selectedcompany = $companyid; $this->context = $context; $company = new company($this->selectedcompany); $this->parentlevel = company::get_company_parentnode($company->id); $this->companydepartment = $this->parentlevel->id; $this->licenseid = $licenseid; if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) { $userhierarchylevel = $this->parentlevel->id; } else { $userlevel = company::get_userlevel($USER); $userhierarchylevel = $userlevel->id; } $this->subhierarchieslist = company::get_all_subdepartments($userhierarchylevel); if ($departmentid == 0) { $this->departmentid = $userhierarchylevel; } else { $this->departmentid = $departmentid; } $this->userid = $userid; $this->user = $DB->get_record('user', array('id' => $this->userid)); parent::__construct($actionurl); }
public function definition_after_data() { global $USER; $mform =& $this->_form; // Adding the elements in the definition_after_data function rather than in the definition function // so that when the currentmanagers or potentialmanagers get changed in the process function, the // changes get displayed, rather than the lists as they are before processing. $company = new company($this->selectedcompany); $managertypes = $company->get_managertypes(); $mform->addElement('header', 'header', get_string('company_managers_for', 'block_iomad_company_admin', $company->get_name())); $mform->addElement('select', 'deptid', get_string('department', 'block_iomad_company_admin'), $this->subhierarchieslist); $mform->addHelpButton('deptid', 'department', 'block_iomad_company_admin'); $mform->addElement('select', 'managertype', get_string('managertype', 'block_iomad_company_admin'), $managertypes); $mform->addHelpButton('managertype', 'managertype', 'block_iomad_company_admin'); if (iomad::has_capability('block/iomad_company_admin:company_add', context_system::instance())) { // This user can add other managers to this company. $mform->addElement('selectyesno', 'showothermanagers', get_string('showothermanagers', 'block_iomad_company_admin')); $mform->disabledIf('showothermanagers', 'managertype', 'neq', '1'); $mform->addHelpButton('showothermanagers', 'showothermanagers', 'block_iomad_company_admin'); } else { $mform->addElement('hidden', 'showothermanagers', 0); } $mform->addElement('submit', 'updateselection', get_string('updatedepartmentusersselection', 'block_iomad_company_admin')); if (count($this->potentialusers->find_users('')) || count($this->currentusers->find_users(''))) { $mform->addElement('html', '<table summary="" class="companymanagertable addremovetable generaltable generalbox boxaligncenter" cellspacing="0"> <tr> <td id="existingcell">'); $mform->addElement('html', $this->currentusers->display(true)); $mform->addElement('html', ' </td> <td id="buttonscell"> <div id="addcontrols"> <input name="add" id="add" type="submit" value="◄ ' . get_string('add') . '" title="Add" /><br /> </div> <div id="removecontrols"> <input name="remove" id="remove" type="submit" value="' . get_string('remove') . ' ►" title="Remove" /> </div> </td> <td id="potentialcell">'); $mform->addElement('html', $this->potentialusers->display(true)); $mform->addElement('html', ' </td> </tr> </table>'); } else { $mform->addElement('html', get_string('nousers', 'block_iomad_company_admin') . ' <a href="' . new moodle_url('/blocks/iomad_company_admin/company_user_create_form.php?companyid=' . $this->selectedcompany) . '">Create one now</a>'); } }
public function get_content() { global $USER, $CFG, $DB, $OUTPUT; // Only display if you have the correct capability. if (!iomad::has_capability('block/iomad_link:view', context_system::instance())) { return; } if ($this->content !== null) { return $this->content; } $strlink = get_string('link', 'block_iomad_link'); $this->content = new stdClass(); $this->content->text = "<center><a href=\"{$CFG->wwwroot}/local/iomad_dashboard/index.php\">\n <img src=\"{$CFG->wwwroot}/blocks/iomad_link/image/iomad_logo.png\" /></a></center>"; $this->content->text .= "<center><b><a href=\"{$CFG->wwwroot}/local/iomad_dashboard/index.php\">{$strlink}</a></b></center>"; $this->content->footer = ''; return $this->content; }
public function get_content() { global $SITE, $CFG, $OUTPUT; if ($this->content !== null) { return $this->content; } if (!iomad::has_capability('block/iomad_reports:view', $this->context)) { return $this->content; } // Title. $this->content = new stdClass(); $this->content->text = '<h3>' . get_string('pluginname', 'block_iomad_reports') . "</h3>\n"; // Get all local/report_*. $reports = $this->getreportpaths(); // Loop over reports. $this->content->text .= '<div class="iomadlink_container clearfix">'; foreach ($reports as $report) { if (iomad::has_capability("local/{$report}:view", $this->context)) { $imgsrc = $OUTPUT->pix_url('logo', "local_{$report}"); $url = new moodle_url("/local/{$report}/index.php"); $name = get_string('pluginname', "local_{$report}"); $icon = '<img src="' . $imgsrc . '" alt="' . $name . '" /><br />'; // Report link html. // $this->content->text .= '<div class="iomadlink">'; // $this->content->text .= "<a href=\"$url\">" . $icon . $name. "</a>"; // $this->content->text .= '</div>'; // Put together link. $this->content->text .= "<a href=\"{$url}\">"; $this->content->text .= '<div class="iomadlink">'; if ($CFG->theme == 'bootstrap') { $this->content->text .= '<div class="iomadicon"><div class="fa fa-topic fa-bar-chart-o"> </div>'; } else { $this->content->text .= '<div class="iomadicon">' . $icon; } $this->content->text .= '<div class="actiondescription">' . $name . "</div>"; $this->content->text .= '</div>'; $this->content->text .= '</a>'; $this->content->text .= '</div>'; } } $this->content->text .= '</div>'; // A clearfix for the floated linked. $this->content->text .= '<div class="clearfix"></div>'; return $this->content; }
public function __construct($actionurl, $companyid, $departmentid) { global $CFG, $USER; $this->selectedcompany = $companyid; $this->context = context_coursecat::instance($CFG->defaultrequestcategory); $syscontext = context_system::instance(); $company = new company($this->selectedcompany); $parentlevel = company::get_company_parentnode($company->id); $this->companydepartment = $parentlevel->id; if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $syscontext)) { $userhierarchylevel = $parentlevel->id; } else { $userlevel = company::get_userlevel($USER); $userhierarchylevel = $userlevel->id; } $this->departmentid = $userhierarchylevel; parent::moodleform($actionurl); }
public function get_content() { global $USER, $CFG, $DB, $OUTPUT; // Only display if you have the correct capability. if (!iomad::has_capability('block/iomad_report_scheduler:view', context_system::instance())) { return; } if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = '<div id="iomad_report_scheduler" style="width: 100%; height: 200px; position:relative; margin: 0 auto; overflow: hidden">'; $this->content->text .= '<div id="iomad_report_scheduler_main1" style="width: 100%; height: 200px; position:relative; margin: 0 auto; "> <h3>Iomad Report Scheduler</h3></br>'; $this->content->text .= '<a id="ELDMSRS" href="' . new moodle_url('/blocks/iomad_report_scheduler/reports_view.php') . '"><img src="' . new moodle_url('/blocks/iomad_report_scheduler/images/report.png') . '"></br>View Reports</a>'; return $this->content; }
public function definition() { global $CFG; $mform =& $this->_form; // Then show the fields about where this block appears. // // code by sumit $returnurl = optional_param('returnurl', '', PARAM_LOCALURL); $mform->addElement('hidden', 'companyid', $this->selectedcompany); $mform->setType('companyid', PARAM_INT); $mform->addElement('hidden', 'returnurl', $returnurl); $mform->setType('returnurl', PARAM_LOCALURL); // code by sumit end $mform->addElement('header', 'header', get_string('companycourse', 'block_iomad_company_admin')); $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_MULTILANG); $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->addHelpButton('shortname', 'shortnamecourse'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_MULTILANG); // Create course as self enrolable. if (iomad::has_capability('block/iomad_company_admin:edit_licenses', context_system::instance())) { $selectarray = array(get_string('selfenrolled', 'block_iomad_company_admin'), get_string('enrolled', 'block_iomad_company_admin'), get_string('licensedcourse', 'block_iomad_company_admin')); } else { $selectarray = array(get_string('selfenrolled', 'block_iomad_company_admin'), get_string('enrolled', 'block_iomad_company_admin')); } $select =& $mform->addElement('select', 'selfenrol', get_string('enrolcoursetype', 'block_iomad_company_admin'), $selectarray); $mform->addHelpButton('selfenrol', 'enrolcourse', 'block_iomad_company_admin'); $select->setSelected('no'); $mform->addElement('editor', 'summary_editor', get_string('coursesummary'), null, $this->editoroptions); $mform->addHelpButton('summary_editor', 'coursesummary'); $mform->setType('summary_editor', PARAM_RAW); // Add action buttons. $buttonarray = array(); $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('createcourse', 'block_iomad_company_admin')); $buttonarray[] =& $mform->createElement('submit', 'submitandviewbutton', get_string('createandvisitcourse', 'block_iomad_company_admin')); $buttonarray[] =& $mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
public function __construct($actionurl, $companyid, $departmentid) { global $CFG, $USER; $this->selectedcompany = $companyid; $this->context = context_coursecat::instance($CFG->defaultrequestcategory); $syscontext = context_system::instance(); $company = new company($this->selectedcompany); $parentlevel = company::get_company_parentnode($company->id); $this->companydepartment = $parentlevel->id; if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $syscontext)) { $userhierarchylevel = $parentlevel->id; } else { $userlevel = company::get_userlevel($USER); $userhierarchylevel = $userlevel->id; } $this->departmentid = $userhierarchylevel; $region = company::get_my_region($userhierarchylevel); $mylocationlist = company::get_my_location($userhierarchylevel); if ($region || $mylocationlist || $userhierarchylevel == $parentlevel->id) { redirect(new moodle_url('/blocks/iomad_company_admin/company_department_create_form.php')); } parent::moodleform($actionurl); }
redirect(new moodle_url('mark_complete_user.php')); } echo $OUTPUT->header(); if (iomad::has_capability('block/iomad_company_admin:manageallcompanycourses', $context)) { $companyids = $DB->get_records_menu('company', array(), 'id, name'); //$companyids['none'] = get_string('nocompany', 'block_iomad_company_admin'); $companyids['all'] = get_string('allcourses', 'block_iomad_company_admin'); ksort($companyids); $companyselect = new single_select($linkurl, 'company', $companyids, $company); $companyselect->label = get_string('company', 'block_iomad_company_admin'); $companyselect->formid = 'choosecompany'; echo html_writer::tag('div', $OUTPUT->render($companyselect), array('id' => 'iomad_company_selector')) . '</br>'; } $companycourses = iomad_get_course_listing(0, $sort, $dir, $page * $perpage, $perpage); $countcourses = iomad_get_course_listing(1, $sort, $dir, $page * $perpage, $perpage); if (iomad::has_capability('block/iomad_company_admin:createcourse', $context)) { if ($company != 'all') { $newcourseurl = new moodle_url('/blocks/iomad_company_admin/company_course_create_form.php', array('returnurl' => new moodle_url('/blocks/iomad_company_admin/mark_complete_user.php'), 'companyid' => $company)); echo $OUTPUT->heading('<a class="anchor-1 pull-right" href="' . $newcourseurl . '"> <i class="fa fa-plus"></i>' . get_string('createcourse', 'block_iomad_company_admin') . '</a>'); echo html_writer::start_tag('div', array('class' => 'clearfix')); echo html_writer::end_tag('div'); } } if (!$companycourses) { echo $OUTPUT->heading(get_string('nocourses')); echo $OUTPUT->footer(); die; } $table = new html_table(); //$table->head = array($fullnamedisplay, $email, $department, $lastaccess, "", "", ""); $table->head = array($course, '', '', '', '', '');
$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); $userhierarchylevel = $userlevel->id; } 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'); // Get company category. if ($category = $DB->get_record_sql('SELECT uic.id, uic.name FROM {user_info_category} uic, {company} c WHERE c.id = ' . $companyid . ' AND c.shortname=uic.name')) { if ($extrafields = $DB->get_records('user_info_field', array('categoryid' => $category->id))) { foreach ($extrafields as $n => $v) { $fields['profile_field_' . $v->shortname] = 'profile_field_' . $v->shortname;
public function definition() { global $CFG, $DB; $mform =& $this->_form; // Then show the fields about where this block appears. $mform->addElement('header', 'header', get_string('companyuser', 'block_iomad_company_admin')); $mform->addElement('hidden', 'companyid', $this->selectedcompany); $mform->setType('companyid', PARAM_INT); // Code added by sumit $mform->addElement('hidden', 'returnurl', $this->returnurl); $mform->setType('returnurl', PARAM_LOCALURL); // end of code /* copied from /user/editlib.php */ $strrequired = get_string('required'); $mform->addElement('hidden', 'id', $this->userid); $mform->setType('id', PARAM_INT); // Deal with the name order sorting and required fields. $necessarynames = useredit_get_required_name_fields(); foreach ($necessarynames as $necessaryname) { $mform->addElement('text', $necessaryname, get_string($necessaryname), 'maxlength="100" size="30"'); $mform->addRule($necessaryname, $strrequired, 'required', null, 'client'); $mform->setType($necessaryname, PARAM_NOTAGS); } // Do not show email field if change confirmation is pending. if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) { $notice = get_string('auth_emailchangepending', 'auth_email', $user); $notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('auth_emailchangecancel', 'auth_email') . '</a>'; $mform->addElement('static', 'emailpending', get_string('email'), $notice); } else { $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"'); $mform->addRule('email', $strrequired, 'required', null, 'client'); $mform->setType('email', PARAM_EMAIL); } /* GWL : Add Field for Username while edit the user */ $mform->addElement('text', 'username', get_string('phone'), 'size="20"'); // GWL : Change get_string('username') to 'phone' $mform->addRule('username', $strrequired, 'required', null, 'client'); $mform->setType('username', PARAM_RAW); /* GWL : Add Field for Username while edit the user */ /* /copied from /user/editlib.php */ $mform->addElement('static', 'blankline', '', ''); if (!empty($CFG->passwordpolicy)) { $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy()); } $mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"'); $mform->addHelpButton('newpassword', 'newpassword'); $mform->setType('newpassword', PARAM_RAW); $mform->addElement('static', 'generatepassword', '', get_string('leavepasswordemptytogenerate', 'block_iomad_company_admin')); $mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange')); $mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange'); // $mform->setDefault('preference_auth_forcepasswordchange', 1); $mform->addElement('selectyesno', 'sendnewpasswordemails', get_string('sendnewpasswordemails', 'block_iomad_company_admin')); $mform->setDefault('sendnewpasswordemails', 1); $mform->disabledIf('sendnewpasswordemails', 'newpassword', 'eq', ''); // Deal with company optional fields. $mform->addElement('header', 'category_id', format_string(get_string('companyprofilefields', 'block_iomad_company_admin'))); // Department drop down. // $mform->addElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $this->subhierarchieslist, $this->userdepartment); // Add in company/department manager checkboxes. $departmentlist = company_department::get_department_list($this->selectedcompany); $titlelist = company_title::get_title_list($this->selectedcompany); if ($departmentlist) { $mform->addElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $departmentlist); } if ($titlelist) { $mform->addElement('select', 'usertitle', get_string('title', 'local_manage_company_dept_title'), $titlelist); } $managerarray = array(); if (iomad::has_capability('block/iomad_company_admin:assign_department_manager', context_system::instance())) { $managerarray['0'] = get_string('user', 'block_iomad_company_admin'); $managerarray['2'] = get_string('regionlocationmanager', 'block_iomad_company_admin'); } if (iomad::has_capability('block/iomad_company_admin:assign_company_manager', context_system::instance())) { if (empty($managearray)) { $managerarray['0'] = get_string('user', 'block_iomad_company_admin'); } $managerarray['1'] = get_string('companymanager', 'block_iomad_company_admin'); $managerarray['3'] = get_string('companyinstructor', 'block_iomad_company_admin'); //GWL : Add Instructor } if (!empty($managerarray)) { $mform->addElement('select', 'managertype', get_string('managertype', 'block_iomad_company_admin'), $managerarray, 0); $mform->addHelpButton('managertype', 'managertype', 'block_iomad_company_admin'); } else { $mform->addElement('hidden', 'managertype', 0); } // get region list $regionslistobj = company::get_all_regions($this->selectedcompany); $regionlist = array('' => get_string('regionnotselect', 'block_iomad_company_admin')); foreach ($regionslistobj as $region) { $regionlist[$region->id] = $region->name; } // Code added by sumit display region and location drop downs list $locationlist = array('' => get_string('choose')); if (!empty($this->regionid)) { $locationlistarr = company::get_all_locations($this->regionid); foreach ($locationlistarr as $location) { $locationlist[$location->id] = $location->name; } } $mform->addElement('select', 'userregion', get_string('region', 'block_iomad_company_admin'), $regionlist, array('class' => 'companyregion')); $mform->addElement('select', 'userlocation', get_string('location', 'block_iomad_company_admin'), $locationlist, array('id' => 'id_locationid')); $mform->disabledIf('userregion', 'managertype', 'eq', 1); $mform->disabledIf('userlocation', 'managertype', 'eq', 1); $mform->disabledIf('userregion', 'managertype', 'eq', 3); //GWL : Add Instructor $mform->disabledIf('userlocation', 'managertype', 'eq', 3); //GWL : Add Instructor // End of Code // Get global fields. // Get company category. if ($companyinfo = $DB->get_record('company', array('id' => $this->selectedcompany))) { // Get fields from company category. if ($fields = $DB->get_records('user_info_field', array('categoryid' => $companyinfo->profileid))) { // Display the header and the fields. foreach ($fields as $field) { require_once $CFG->dirroot . '/user/profile/field/' . $field->datatype . '/field.class.php'; $newfield = 'profile_field_' . $field->datatype; $formfield = new $newfield($field->id); $formfield->edit_field($mform); $mform->setDefault($formfield->inputname, $formfield->field->defaultdata); } } } /* $mform->addElement('header', 'courses', get_string('courses', 'block_iomad_company_admin')); $mform->addElement('html', "<div class='fitem'><div class='fitemtitle'>" . get_string('selectenrolmentcourse', 'block_iomad_company_admin') . "</div><div class='felement'>"); $mform->addElement('html', $this->currentcourses->display(true)); $mform->addElement('html', "</div></div>"); */ // add action buttons $buttonarray = array(); //$buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('createuseragain', 'block_iomad_company_admin')); $buttonarray[] =& $mform->createElement('submit', 'submitandback', get_string('createuserandback', 'block_iomad_company_admin')); $buttonarray[] =& $mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
$context = context_system::instance(); require_login(); $PAGE->set_context($context); $urlparams = array('templateid' => $templateid, 'templatename' => $templatename); if ($returnurl) { $urlparams['returnurl'] = $returnurl; } $templatelist = new moodle_url('/local/email/template_list.php', $urlparams); // Set the companyid to bypass the company select form if possible. if (!empty($SESSION->currenteditingcompany)) { $companyid = $SESSION->currenteditingcompany; } else { if (!empty($USER->company)) { $companyid = company_user::companyid(); } else { if (!iomad::has_capability('local/email:edit', context_system::instance())) { print_error('There has been a configuration error, please contact the site administrator'); } else { $blockpage->display_header(); redirect(new moodle_url('/local/iomad_dashboard/index.php'), 'Please select a company from the dropdown first'); } } } iomad::require_capability('local/email:send', $context); if ($templateid) { $templaterecord = $DB->get_record('email_template', array('id' => $templateid), '*', MUST_EXIST); } else { if ($templatename) { if (!($templaterecord = $DB->get_record('email_template', array('companyid' => $companyid, 'name' => $templatename), '*'))) { $templaterecord = (object) $email[$templatename]; $templaterecord->name = $templatename;
protected function get_license_department_ids() { global $DB, $USER; if (!isset($this->licenseid)) { return array(); } else { if (!$DB->get_record_sql("SELECT pc.id\n FROM {iomad_courses} pc\n INNER JOIN {companylicense_courses} clc\n ON clc.courseid = pc.courseid\n WHERE clc.licenseid={$this->licenseid}\n AND pc.shared=1")) { // Check if we are a shared course or not. $courses = $DB->get_records('companylicense_courses', array('licenseid' => $this->licenseid)); $shared = false; foreach ($courses as $course) { if ($DB->get_record_select('iomad_courses', "courseid='" . $course->courseid . "' AND shared!= 0")) { $shared = true; } } $sql = "SELECT DISTINCT d.id from {department} d, {company_course} cc, {companylicense_courses} clc\n WHERE\n d.id = cc.departmentid\n AND\n cc.courseid = clc.courseid\n AND\n clc.licenseid = " . $this->licenseid . "\n AND d.company = " . $this->companyid; $departments = $DB->get_records_sql($sql); $shareddepartment = array(); if ($shared) { if (iomad::has_capability('block/iomad_company_admin:edit_licenses', context_system::instance())) { // Need to add the top level department. $shareddepartment = company::get_company_parentnode($this->companyid); $departments = $departments + array($shareddepartment->id => $shareddepartment->id); } else { $shareddepartment = company::get_userlevel($USER); $departments = $departments + array($shareddepartment->id => $shareddepartment->id); } } if (!empty($departments)) { // Only return the keys (user ids). return array_keys($departments); } else { return array(); } } else { return array($this->departmentid); } } }
/** * Check if a user is a manger of this department. * * Parameters - * $departmentid = int; * * Return boolean; * */ public static function can_manage_department($departmentid, $preventdelete = 0) { global $DB, $USER; if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) { return true; } else { if (iomad::has_capability('block/iomad_company_admin:edit_departments', context_system::instance())) { return true; } else { // Get the list of departments at and below the user assignment. $userhierarchylevel = self::get_userlevel($USER); $subhierarchytree = self::get_all_subdepartments($userhierarchylevel->id); //$subhieracrhieslist = self::get_department_list($subhierarchytree); // Code by sumit, user is only allowed to edit the department where he is assigned as manager if ($preventdelete && (int) $userhierarchylevel->id == $departmentid) { return false; } if (isset($subhierarchytree[$departmentid])) { // Current department is a child of the users assignment. return true; } else { return false; } } } // We shouldn't get this far, return a default no. return false; }
$url = new moodle_url('/local/report_scorm_overview/index.php', array('departmentid' => $departmentid, 'courseid' => $courseid)); $dashboardurl = new moodle_url('/local/iomad_dashboard/index.php'); // Page stuff:. $strcompletion = get_string('pluginname', 'local_report_scorm_overview'); $PAGE->set_url($url); $PAGE->set_pagelayout('report'); $PAGE->set_title($strcompletion); $PAGE->set_heading($SITE->fullname); $PAGE->requires->css("/local/report_scorm_overvew/styles.css"); // Set the companyid $companyid = iomad::get_my_companyid($context); // 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) || !empty($SESSION->currenteditingcompany)) { $userhierarchylevel = $parentlevel->id; } else { $userlevel = company::get_userlevel($USER); $userhierarchylevel = $userlevel->id; } if ($departmentid == 0) { $departmentid = $userhierarchylevel; } // Set the url. //company_admin_fix_breadcrumb($PAGE, $strcompletion, $url); require_once $CFG->libdir . '/adminlib.php'; admin_externalpage_setup('userreportsettings'); // Navigation and header. if (empty($dodownload)) { echo $OUTPUT->header();
$strinstallation = get_string('installation', 'install'); $strprimaryadminsetup = get_string('primaryadminsetup'); $PAGE->navbar->add($strprimaryadminsetup); $PAGE->set_title($strinstallation); $PAGE->set_heading($strinstallation); $PAGE->set_cacheable(false); $blockpage->display_header(); echo $OUTPUT->box(get_string('configintroadmin', 'admin'), 'generalbox boxwidthnormal boxaligncenter'); echo '<br />'; } else { $streditmyprofile = get_string('editmyprofile'); $strparticipants = get_string('participants'); $strnewuser = get_string('newuser'); $userfullname = fullname($user, true); $link = null; if (iomad::has_capability('moodle/course:viewparticipants', $systemcontext) || iomad::has_capability('moodle/site:viewparticipants', $systemcontext)) { $link = new moodle_url("/user/index.php", array('id' => $course->id)); } $PAGE->navbar->add($strparticipants, $link); $link = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id)); $PAGE->navbar->add($userfullname, $link); $PAGE->navbar->add($streditmyprofile); $PAGE->set_title("{$course->shortname}: {$streditmyprofile}"); $PAGE->set_heading($course->fullname); $blockpage->display_header(); } } // Finally display THE form. $userform->display(); // And proper footer. echo $OUTPUT->footer();
iomad::require_capability('block/iomad_commerce:admin_view', $context); // Get the number of orders. $objectcount = $DB->count_records_sql("SELECT COUNT(*) FROM {invoice} WHERE Status != '" . INVOICESTATUS_BASKET . "'"); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); flush(); if ($orders = $DB->get_recordset_sql("SELECT\n i.*,\n (SELECT COUNT(*) FROM {invoiceitem} ii WHERE ii.invoiceid = i.id AND processed = 0)\n AS unprocesseditems\n FROM {invoice} i\n WHERE i.Status != '" . INVOICESTATUS_BASKET . "'\n ORDER BY i.Status DESC, i.id DESC", null, $page, $perpage)) { if (count($orders)) { $stredit = get_string('edit'); $strhide = get_string('hide', 'block_iomad_commerce'); $strshow = get_string('show', 'block_iomad_commerce'); $table = new html_table(); $table->head = array(get_string('reference', 'block_iomad_commerce'), get_string('paymentprovider', 'block_iomad_commerce'), get_string('status', 'block_iomad_commerce'), get_string('company', 'block_iomad_company_admin'), get_string('unprocesseditems', 'block_iomad_commerce'), ''); $table->align = array("left", "center", "center", "center"); $table->width = "95%"; foreach ($orders as $order) { if (iomad::has_capability('block/iomad_commerce:admin_view', $context)) { $editbutton = "<a href='" . new moodle_url('edit_order_form.php', array("id" => $order->id)) . "'>{$stredit}</a>"; } else { $editbutton = ""; } $table->data[] = array($order->reference, get_string('pp_' . $order->checkout_method . '_name', 'block_iomad_commerce'), get_string('status_' . $order->status, 'block_iomad_commerce'), $order->company, $order->unprocesseditems > 0 ? $order->unprocesseditems : "", $editbutton); } if (!empty($table)) { echo html_writer::table($table); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); } } else { echo "<p>" . get_string('noinvoices', 'block_iomad_commerce') . "</p>"; } $orders->close(); }
$strdisplay = $strshow; if ($course_shopsetting->enabled) { $strdisplay = $strhide; } $hidebutton = "<a href=\"courselist.php?hide={$course_shopsetting->id}&sesskey=" . sesskey() . "\">{$strdisplay}</a>"; } else { $hidebutton = ""; } if (iomad::has_capability('block/iomad_commerce:edit_course', $context)) { $editbutton = "<a href='" . new moodle_url('edit_course_shopsettings_form.php', array("shopsettingsid" => $course_shopsetting->id)) . "'>{$stredit}</a>"; } else { $editbutton = ""; } $table->data[] = array("{$course_shopsetting->fullname}", $editbutton, $hidebutton, $deletebutton); } if (!empty($table)) { echo html_writer::table($table); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); } } else { echo "<p>" . get_string('nocoursesontheshop', 'block_iomad_commerce') . "</p>"; } $courses->close(); } if (iomad::has_capability('block/iomad_commerce:add_course', $context)) { echo '<div class="buttons">'; echo $OUTPUT->single_button(new moodle_url('edit_course_shopsettings_form.php?createnew=1'), get_string('addnewcourse', 'block_iomad_commerce'), 'get'); echo $OUTPUT->single_button(new moodle_url('/local/iomad_dashboard/index.php'), get_string('cancel'), 'get'); echo '</div>'; } echo $OUTPUT->footer();
break; case "email": $sqlsearch .= " order by email {$dir} "; break; case "access": $sqlsearch .= " order by lastaccess {$dir} "; $sort = "lastaccess"; break; } // Get the user records. $userrecords = $DB->get_fieldset_select('user', 'id', $sqlsearch, $searchparams); } else { $userrecords = array(); } } else { if (iomad::has_capability('block/iomad_company_admin:editusers', $systemcontext)) { // Check if has role edit company users. // Check we havent looked and discounted everyone. if (empty($idlist) && !$foundfields || !empty($idlist) && $foundfields) { // Get users company association. $departmentusers = company::get_recursive_department_users($departmentid); $sqlsearch = "id!='-1'"; if (count($departmentusers) > 0) { $departmentids = ""; foreach ($departmentusers as $departmentuser) { if (!empty($departmentids)) { $departmentids .= "," . $departmentuser->userid; } else { $departmentids .= $departmentuser->userid; } }
$record = get_course($companycourse->id); $course = new course_in_list($record); $coursesuspendbutton = ''; if ($course->can_change_visibility()) { $action = $course->visible ? 'hidecourse' : 'showcourse'; $buttontext = $course->visible ? get_string('suspend', 'block_iomad_company_admin') : get_string('unsuspend', 'block_iomad_company_admin'); $coursesuspendbutton = html_writer::link(new moodle_url('companycourses.php', array('courseid' => $companycourse->id, 'action' => $action)), $buttontext); } $companycourse->fullname = '<a href=' . $courselink . '>' . $companycourse->fullname . '</a>'; $assigncourselink = ''; $companyrecord = $DB->get_record('company', array('id' => $companycourse->companyid)); if (iomad::has_capability('local/manage_company_dept_title:manage_courses', $context) && $companyrecord) { $assigncourselink = html_writer::link(new moodle_url('/local/manage_company_dept_title/addcoursetodepttitle.php', array('course' => $companycourse->id, 'companyid' => $companycourse->companyid)), get_string('assigncourse', 'local_manage_company_dept_title')); } $coursenotificationlink = ''; if (iomad::has_capability('local/course_notification:manage', $context) && $companyrecord) { $coursenotificationlink = html_writer::link(new moodle_url('/local/course_notification/manage_notification.php', array('courseid' => $companycourse->id, 'companyid' => $companycourse->companyid)), get_string('managenotification', 'block_iomad_company_admin')); } $columndata = array($companycourse->fullname, $editcoursebutton, $deletecoursebutton, $coursesuspendbutton, $assigncourselink, $coursenotificationlink); // code added by sumit if ($company == 'all') { // adding company column heading //echo $companycourse->companyid; $companyname = ''; if ($companyrecord) { $companyname = $companyrecord->name; } array_unshift($columndata, $companyname); } $table->data[] = $columndata; // end of code
public static function can_see_company($company) { global $USER; $context = context_system::instance(); if (!isset($company)) { return true; } if (!isset($USER->profile["company"]) or empty($USER->profile["company"]) or iomad::has_capability('block/iomad_company_admin:company_add', $context)) { return true; } // If companyid was passed in, retrieve the company object. if (is_integer($company)) { $company = new company($company); } // If company object, retrieve the shortname, otherwise assume the shortname was passed in. if (is_object($company)) { if (isset($company->shortname)) { $shortname = $company->shortname; } else { $shortname = $company->get_shortname(); } } else { $shortname = $company; } return $USER->profile["company"] == $shortname; }
public function definition() { global $CFG, $PAGE, $DB; $context = context_system::instance(); $mform =& $this->_form; $strrequired = get_string('required'); $mform->addElement('hidden', 'companyid', $this->companyid); $mform->setType('companyid', PARAM_INT); //GWL $mform->addElement('hidden', 'returnurl', $this->returnurl); $mform->setType('returnurl', PARAM_LOCALURL); // // // Then show the fields about where this block appears. $mform->addElement('header', 'header', get_string('company', 'block_iomad_company_admin')); $mform->addElement('text', 'name', get_string('companyname', 'block_iomad_company_admin'), array('size' => 50)); $mform->setType('name', PARAM_NOTAGS); $mform->addRule('name', $strrequired, 'required'); $mform->addElement('text', 'shortname', get_string('companyshortname', 'block_iomad_company_admin'), array('size' => 25)); $mform->setType('shortname', PARAM_NOTAGS); $mform->addRule('shortname', $strrequired, 'required'); $mform->addElement('text', 'city', get_string('companycity', 'block_iomad_company_admin'), array('size' => 50)); $mform->setType('city', PARAM_NOTAGS); $mform->addRule('city', $strrequired, 'required'); /* copied from user/editlib.php */ $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); $mform->addRule('country', $strrequired, 'required', null, 'client'); if (!empty($CFG->country)) { $mform->setDefault('country', $CFG->country); } $mform->addElement('text', 'companydomains', get_string('companydomains', 'block_iomad_company_admin'), array('display' => 'noofficial')); //GWL : Change textarea to text $mform->setType('companydomains', PARAM_NOTAGS); /* === User defaults === */ /*GWL : Remove User Default */ /* $mform->addElement('header', 'userdefaults', get_string('userdefaults', 'block_iomad_company_admin')); $choices = array(); $choices['0'] = get_string('emaildisplayno'); $choices['1'] = get_string('emaildisplayyes'); $choices['2'] = get_string('emaildisplaycourse'); $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); $mform->setDefault('maildisplay', 2); $choices = array(); $choices['0'] = get_string('textformat'); $choices['1'] = get_string('htmlformat'); $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices); $mform->setDefault('mailformat', 1); $choices = array(); $choices['0'] = get_string('emaildigestoff'); $choices['1'] = get_string('emaildigestcomplete'); $choices['2'] = get_string('emaildigestsubjects'); $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices); $mform->setDefault('maildigest', 0); $choices = array(); $choices['1'] = get_string('autosubscribeyes'); $choices['0'] = get_string('autosubscribeno'); $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); $mform->setDefault('autosubscribe', 1); if (!empty($CFG->forum_trackreadposts)) { $choices = array(); $choices['0'] = get_string('trackforumsno'); $choices['1'] = get_string('trackforumsyes'); $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices); $mform->setDefault('trackforums', 0); } $editors = editors_get_enabled(); if (count($editors) > 1) { $choices = array(); $choices['0'] = get_string('texteditor'); $choices['1'] = get_string('htmleditor'); $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices); $mform->setDefault('htmleditor', 1); } else { $mform->addElement('hidden', 'htmleditor'); $mform->setDefault('htmleditor', 1); $mform->setType('htmleditor', PARAM_INT); } $choices = get_list_of_timezones(); $choices['99'] = get_string('serverlocaltime'); if ($CFG->forcetimezone != 99) { $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]); } else { $mform->addElement('select', 'timezone', get_string('timezone'), $choices); $mform->setDefault('timezone', '99'); } $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); $mform->setDefault('lang', $CFG->lang); */ /*GWL : Remove User Default */ /* === end user defaults === */ // Only show the Appearence section if the theme is iomad or you have abilities // to change that. //GWL : To add company logo for each theme if (iomad::has_capability('block/iomad_company_admin:company_edit', $context)) { //|| //$this->companyrecord->theme == 'iomad' || $this->companyrecord->theme == 'bootstrap') { $mform->addElement('header', 'appearance', get_string('appearance', 'block_iomad_company_admin')); // If has the edit all companies capability we want to add a theme selector. if (iomad::has_capability('block/iomad_company_admin:company_edit', $context)) { // Get the list of themes. $themes = get_plugin_list('theme'); $themeselectarray = array(); foreach ($themes as $themename => $themedir) { // Load the theme config. try { $theme = theme_config::load($themename); } catch (Exception $e) { // Bad theme, just skip it for now. continue; } if ($themename !== $theme->name) { // Obsoleted or broken theme, just skip for now. continue; } if (!$CFG->themedesignermode && $theme->hidefromselector) { // The theme doesn't want to be shown in the theme selector and as theme // designer mode is switched off we will respect that decision. continue; } // Build the theme selection list. $themeselectarray[$themename] = $themename; } $mform->addElement('select', 'theme', get_string('selectatheme', 'block_iomad_company_admin'), $themeselectarray); $mform->disabledIf('theme', '', 'neq', '1'); /* GWL : Make Default Theme Field Disable */ } else { $mform->addElement('hidden', 'theme', $this->companyrecord->theme); $mform->setType('theme', PARAM_TEXT); } // If theme is already set to a real theme, dont show this. if (!isset($this->companyrecord->theme)) { $this->companyrecord->theme = 'gourmet'; /* GWL : Set Default theme Gourmet */ } /* GWL : Remove Message while setuping Company */ // if ($this->companyrecord->theme == 'iomad' || $this->companyrecord->theme == 'bootstrap') { /* $mform->addElement('HTML', get_string('theoptionsbelow', 'block_iomad_company_admin')); */ /* GWL : Remove Message while setuping Company */ $mform->addElement('filemanager', 'companylogo', get_string('companylogo', 'block_iomad_company_admin'), null, array('subdirs' => 0, 'maxbytes' => 150 * 1024, 'maxfiles' => 1, 'accepted_types' => array('*.jpg', '*.gif', '*.png'))); /* GWL : Remove Header Background Colour & Content Background Colour field while creating New Company */ /* $this->add_colour_picker('bgcolor_header', array('selector' => '.header,.navbar', 'style' => 'background')); $this->add_colour_picker('bgcolor_content', array('selector' => '.block .content', 'style' => 'background')); */ /* GWL : Remove Header Background Colour & Content Background Colour field while creating New Company */ $mform->disabledIf('id_bgcolor_header', 'usedefaulttheme', 'checked'); $mform->disabledIf('id_bgcolor_content', 'usedefaulttheme', 'checked'); /* } else { $mform->addElement('hidden', 'id_companylogo', $this->companyrecord->companylogo); $mform->addElement('hidden', 'companylogo', $this->companyrecord->companylogo); $mform->addElement('hidden', 'id_bgcolor_header', $this->companyrecord->bgcolor_header); $mform->addElement('hidden', 'id_bgcolor_content', $this->companyrecord->bgcolor_content); $mform->setType('companylogo', PARAM_CLEAN); $mform->setType('id_companylogo', PARAM_CLEAN); $mform->setType('id_bgcolor_header', PARAM_CLEAN); $mform->setType('id_bgcolor_content', PARAM_CLEAN); } */ } else { $mform->addElement('hidden', 'theme', $this->companyrecord->theme); $mform->setType('theme', PARAM_TEXT); $mform->addElement('hidden', 'companylogo', $this->companyrecord->companylogo); $mform->setType('companylogo', PARAM_CLEAN); $mform->addElement('hidden', 'bgcolor_header', $this->companyrecord->bgcolor_header); $mform->addElement('hidden', 'bgcolor_content', $this->companyrecord->bgcolor_content); } $mform->setType('bgcolor_header', PARAM_CLEAN); $mform->setType('bgcolor_content', PARAM_CLEAN); $submitlabel = null; // Default. if ($this->isadding) { $submitlabel = get_string('saveasnewcompany', 'block_iomad_company_admin'); $mform->addElement('hidden', 'createnew', 1); $mform->setType('createnew', PARAM_INT); } $this->add_action_buttons(true, $submitlabel); }
if (iomad::has_capability('block/iomad_company_admin:createcourse', $context)) { $createcoursebutton = "<a href='" . new moodle_url('company_course_create_form.php', array("companyid" => $company->id)) . "'>{$strcreatecourse}</a>"; } else { $createcoursebutton = ""; } if (iomad::has_capability('block/iomad_company_admin:company_course_users', $context)) { $courseusersbutton = "<a href='" . new moodle_url('company_course_users_form.php', array("companyid" => $company->id)) . "'>{$strcourseusers}</a>"; } else { $courseusersbutton = ""; } if (iomad::has_capability('block/iomad_company_admin:user_upload', $context)) { $downloadbutton = "<a href='" . new moodle_url('user_bulk_download.php', array("companyid" => $company->id)) . "'>{$strusersdownload}</a>"; } else { $downloadbutton = ""; } $table->data[] = array("{$company->name}", "{$company->shortname}", "{$company->city}", $editbutton, $usersbutton, $newuserbutton, $managersbutton, $coursesbutton, $createcoursebutton, $courseusersbutton, $downloadbutton, $deletebutton); } } if (!empty($table)) { echo html_writer::table($table); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); } $companies->close(); } if (iomad::has_capability('block/iomad_company_admin:company_add', $context)) { echo '<div class="buttons">'; echo $OUTPUT->single_button(new moodle_url('company_edit_form.php'), get_string('addnewcompany', 'block_iomad_company_admin'), 'get'); echo $OUTPUT->single_button(new moodle_url('/local/iomad_dashboard/index.php'), get_string('cancel'), 'get'); echo '</div>'; } echo $OUTPUT->footer();
public function get_content() { global $USER, $CFG, $DB, $OUTPUT; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if (empty($this->instance)) { return $this->content; } if (!isloggedin()) { $this->content->text = get_string('pleaselogin', 'block_iomad_online_users'); return $this->content; } $timetoshowusers = 300; // Seconds default. if (isset($CFG->block_iomad_online_users_timetosee)) { $timetoshowusers = $CFG->block_iomad_online_users_timetosee * 60; } $timefrom = 100 * floor((time() - $timetoshowusers) / 100); // Round to nearest 100 seconds for better query cache. $now = time(); // Calculate if we are in separate groups. $isseparategroups = $this->page->course->groupmode == SEPARATEGROUPS && $this->page->course->groupmodeforce && !iomad::has_capability('moodle/site:accessallgroups', $this->page->context); // Get the user current group. $currentgroup = $isseparategroups ? groups_get_course_group($this->page->course) : null; $groupmembers = ""; $groupselect = ""; $rafrom = ""; $rawhere = ""; $params = array(); $params['now'] = $now; $params['timefrom'] = $timefrom; // Add this to the SQL to show only group users. if ($currentgroup !== null) { $groupmembers = ", {groups_members} gm"; $groupselect = "AND u.id = gm.userid AND gm.groupid = :currentgroup"; $params['currentgroup'] = $currentgroup; } $companyselect = ""; $companyusersjoin = ""; if (company_user::is_company_user()) { company_user::load_company(); $companyusersjoin = ", {user_info_data} muid, {user_info_field} muif"; $companyselect = " AND muif.id = muid.fieldid\n AND u.id = muid.userid\n AND muif.shortname = 'company'\n AND muid.data = :companyshortname "; $params['companyshortname'] = $USER->company->shortname; } $userfields = user_picture::fields('u', array('username')); if ($this->page->course->id == SITEID) { // Site-level. $sql = "SELECT {$userfields}, MAX(u.lastaccess) AS lastaccess\n FROM {user} u {$groupmembers} {$companyusersjoin}\n WHERE u.lastaccess > {$timefrom}\n {$groupselect}\n {$companyselect}\n GROUP BY {$userfields}\n ORDER BY lastaccess DESC "; $csql = "SELECT COUNT(u.id), u.id\n FROM {user} u {$groupmembers} {$companyusersjoin}\n WHERE u.lastaccess > {$timefrom}\n {$groupselect}\n {$companyselect}\n GROUP BY u.id"; } else { // Course level - show only enrolled users for now. // TODO: add a new capability for viewing of all users (guests+enrolled+viewing). list($esqljoin, $eparams) = get_enrolled_sql($this->page->context); $params = array_merge($params, $eparams); $sql = "SELECT {$userfields}, MAX(ul.timeaccess) AS lastaccess\n FROM {user_lastaccess} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE ul.timeaccess > :timefrom\n AND u.id = ul.userid\n AND ul.courseid = :courseid\n AND ul.timeaccess <= :now\n AND u.deleted = 0\n {$groupselect}\n GROUP BY {$userfields}\n ORDER BY lastaccess DESC"; $csql = "SELECT COUNT(u.id)\n FROM {user_lastaccess} ul {$groupmembers}, {user} u\n JOIN ({$esqljoin}) euj ON euj.id = u.id\n WHERE ul.timeaccess > :timefrom\n AND u.id = ul.userid\n AND ul.courseid = :courseid\n AND ul.timeaccess <= :now\n AND u.deleted = 0\n {$groupselect}"; $params['courseid'] = $this->page->course->id; } // Calculate minutes. $minutes = floor($timetoshowusers / 60); // Verify if we can see the list of users, if not just print number of users. if (!iomad::has_capability('block/online_users:viewlist', $this->page->context)) { if (!($usercount = $DB->count_records_sql($csql, $params))) { $usercount = get_string("none"); } $this->content->text = "<div class=\"info\">" . get_string("periodnminutes", "block_iomad_online_users", $minutes) . ": {$usercount}</div>"; return $this->content; } if ($users = $DB->get_records_sql($sql, $params, 0, 50)) { // We'll just take the most recent 50 maximum. foreach ($users as $user) { $users[$user->id]->fullname = fullname($user); } } else { $users = array(); } if (count($users) < 50) { $usercount = ""; } else { $usercount = $DB->count_records_sql($csql, $params); $usercount = ": {$usercount}"; } $this->content->text = "<h3>Recent Online Company Users</h3><div class=\"info\">(" . get_string("periodnminutes", "block_iomad_online_users", $minutes) . "{$usercount})</div>"; // Now, we have in users, the list of users to show. // Because they are online. if (!empty($users)) { // Accessibility: Don't want 'Alt' text for the user picture; DO want it for the envelope/message link // (existing lang string). // Accessibility: Converted <div> to <ul>, inherit existing classes & styles. $this->content->text .= "<ul class='list'>\n"; if (isloggedin() && iomad::has_capability('moodle/site:sendmessage', $this->page->context) && !empty($CFG->messaging) && !isguestuser()) { $canshowicon = true; } else { $canshowicon = false; } foreach ($users as $user) { $this->content->text .= '<li class="listentry">'; $timeago = format_time(time() - $user->lastaccess); // Bruno to calculate correctly on frontpage. if (isguestuser($user)) { $this->content->text .= '<div class="user">' . $OUTPUT->user_picture($user, array('size' => 16)); $this->content->text .= get_string('guestuser') . '</div>'; } else { $this->content->text .= '<div class="user">' . $OUTPUT->user_picture($user, array('size' => 16)); $this->content->text .= '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $this->page->course->id . '" title="' . $timeago . '">' . $user->fullname . '</a></div>'; } if ($canshowicon and $USER->id != $user->id and !isguestuser($user)) { // Only when logged in and messaging active etc. $anchortagcontents = '<img class="iconsmall" src="' . $OUTPUT->pix_url('t/message') . '" alt="' . get_string('messageselectadd') . '" />'; $anchortag = '<a href="' . $CFG->wwwroot . '/message/index.php?id=' . $user->id . '" title="' . get_string('messageselectadd') . '">' . $anchortagcontents . '</a>'; $this->content->text .= '<div class="message">' . $anchortag . '</div>'; } $this->content->text .= "</li>\n"; } $this->content->text .= '</ul><div class="clearer"><!-- --></div>'; } else { $this->content->text .= "<div class=\"info\">" . get_string("none") . "</div>"; } return $this->content; }
if (empty($coursestring)) { $coursestring = "<a href='" . new moodle_url('/course/view.php', array('id' => $licensecourse->courseid)) . "'>" . $coursename->fullname . "</a>"; } else { $coursestring .= ",</br><a href='" . new moodle_url('/course/view.php', array('id' => $licensecourse->courseid)) . "'>" . $coursename->fullname . "</a>"; } } // Create the table data. $table->data[] = array("{$license->name}", $coursestring, date('d M Y', $license->expirydate), "{$license->validlength}", "{$license->allocation}", "{$license->used}", $editbutton, $deletebutton); } } else { if ($licenses = company::get_recursive_departments_licenses($companydepartment->id)) { foreach ($licenses as $licenseid) { // Get the license record. $license = $DB->get_record('companylicense', array('id' => $licenseid->licenseid)); // Set up the edit buttons. if (iomad::has_capability('block/iomad_company_admin:edit_licenses', $context)) { $deletebutton = "<a href=\"company_license_list.php?delete={$license->id}&sesskey=" . sesskey() . "\">{$strdelete}</a>"; $editbutton = "<a href='" . new moodle_url('company_license_edit_form.php', array("licenseid" => $license->id, 'departmentid' => $departmentid)) . "'>{$stredit}</a>"; } else { $deletebutton = ""; $editbutton = ""; } $table->data[] = array("{$license->name}", "{$license->expirydate}", "{$license->validlength}", "{$license->allocation}", "{$license->used}", $editbutton, $deletebutton); } } } if (!empty($table)) { echo html_writer::table($table); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); } echo '<div class="buttons">';
$strlastaccess = format_time(time() - $user->lastaccess); } else { $strlastaccess = get_string('never'); } $fullname = fullname($user, true); // Is this a suspended user? if (!empty($user->suspended)) { $fullname .= " (S)"; } // Get the users department. $userdepartment = $DB->get_record_sql("SELECT d.name\n FROM {department} d, {company_users} du\n WHERE du.userid = " . $user->id . "\n AND d.id = du.departmentid"); $user->department = $userdepartment->name; $table->data[] = array("{$fullname}", "{$user->email}", "{$user->department}", $strlastaccess, $editbutton, $suspendbutton, $deletebutton, $enrolmentbutton); } } if (iomad::has_capability('block/iomad_company_admin:user_create', $systemcontext)) { $returnurl = new moodle_url('/blocks/iomad_company_admin/editusers.php'); echo $OUTPUT->heading('<a class="anchor-1 pull-right" href="' . $CFG->wwwroot . '/blocks/iomad_company_admin/company_user_create_form.php?returnurl=' . $returnurl . '"> <i class="fa fa-plus"></i>' . get_string('createuser', 'block_iomad_company_admin') . '</a>'); echo html_writer::start_tag('div', array('class' => 'clearfix')); echo html_writer::end_tag('div'); } if (!empty($table)) { echo html_writer::table($table); echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl); } echo $OUTPUT->footer(); function iomad_get_users_listing($sort = 'lastaccess', $dir = 'ASC', $page = 0, $recordsperpage = 0, $search = '', $firstinitial = '', $lastinitial = '', $extraselect = '', array $extraparams = null) { global $DB; $fullname = $DB->sql_fullname(); $select = "u.deleted <> 1";
$selectparams['courseid'] = 0; $selecturl = new moodle_url('/local/report_completion/index.php', $selectparams); $subhierarchieslist = company::get_all_subdepartments($userhierarchylevel); $select = new single_select($selecturl, 'departmentid', $subhierarchieslist, $departmentid); $select->label = get_string('department', 'block_iomad_company_admin'); $select->formid = 'choosedepartment'; $fwselectoutput = html_writer::tag('div', $OUTPUT->render($select), array('id' => 'iomad_company_selector')); // Get the appropriate list of departments. $selectparams = $params; $selecturl = new moodle_url('/local/report_completion/index.php', $selectparams); $completiontypelist = array('0' => get_string('all'), '1' => get_string('notstartedusers', 'local_report_completion'), '2' => get_string('inprogressusers', 'local_report_completion'), '3' => get_string('completedusers', 'local_report_completion')); $select = new single_select($selecturl, 'completiontype', $completiontypelist, $completiontype); $select->label = get_string('choosecompletiontype', 'block_iomad_company_admin'); $select->formid = 'choosecompletiontype'; $completiontypeselectoutput = html_writer::tag('div', $OUTPUT->render($select), array('id' => 'iomad_completiontype_selector')); if (!(iomad::has_capability('block/iomad_company_admin:editusers', $context) or iomad::has_capability('block/iomad_company_admin:editallusers', $context))) { print_error('nopermissions', 'error', '', 'report on users'); } $searchinfo = iomad::get_user_sqlsearch($params, $idlist, $sort, $dir, $departmentid); // Create data for form. $customdata = null; $options = $params; $options['dodownload'] = 1; // Only print the header if we are not downloading. if (empty($dodownload) && empty($showchart)) { echo $OUTPUT->header(); } // Get the data. if (!empty($companyid)) { if (empty($dodownload) && empty($showchart)) { echo $fwselectoutput;