本文整理汇总了PHP中company::get_userlevel方法的典型用法代码示例。如果您正苦于以下问题:PHP company::get_userlevel方法的具体用法?PHP company::get_userlevel怎么用?PHP company::get_userlevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类company
的用法示例。
在下文中一共展示了company::get_userlevel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition_after_data
/**
* 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'));
}
示例2: __construct
public function __construct($actionurl, $companyid, $departmentid)
{
global $CFG, $USER;
$this->selectedcompany = $companyid;
$this->departmentid = $departmentid;
$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', 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;
}
$this->userdepartment = $userhierarchylevel;
$options = array('context' => $this->context, 'multiselect' => true, 'companyid' => $this->selectedcompany, 'departmentid' => $departmentid, 'subdepartments' => $this->subhierarchieslist, 'parentdepartmentid' => $parentlevel, 'showopenshared' => true, 'license' => false);
$this->currentcourses = new potential_subdepartment_course_selector('currentcourses', $options);
$this->currentcourses->set_rows(20);
$this->context = context_coursecat::instance($CFG->defaultrequestcategory);
parent::moodleform($actionurl);
}
示例3: __construct
public function __construct($actionurl, $context, $companyid, $deptid, $roleid, $showothermanagers)
{
global $USER;
$this->selectedcompany = $companyid;
$this->context = $context;
$this->departmentid = $deptid;
$this->roletype = $roleid;
/* GWL : */
if (!iomad::has_capability('block/iomad_company_admin:company_add', context_system::instance())) {
$this->showothermanagers = false;
} else {
$this->showothermanagers = $showothermanagers;
}
$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', 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, 'companyid' => $this->selectedcompany, 'departmentid' => $departmentid, 'roletype' => $this->roletype, 'subdepartments' => $this->subhierarchieslist, 'parentdepartmentid' => $parentlevel, 'showothermanagers' => $this->showothermanagers);
$this->potentialusers = new potential_department_user_selector('potentialmanagers', $options);
$this->currentusers = new current_department_user_selector('currentmanagers', $options);
parent::__construct($actionurl);
}
示例4: __construct
public function __construct($actionurl, $context, $companyid, $departmentid)
{
global $USER;
$this->selectedcompany = $companyid;
$this->context = $context;
$this->departmentid = $departmentid;
$company = new company($this->selectedcompany);
$parentlevel = company::get_company_parentnode($company->id);
$this->companydepartment = $parentlevel->id;
$syscontext = context_system::instance();
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->subhierarchieslist = company::get_all_subdepartments($userhierarchylevel);
if ($this->departmentid == 0) {
$departmentid = $userhierarchylevel;
} else {
$departmentid = $this->departmentid;
}
$options = array('context' => $this->context, 'companyid' => $this->selectedcompany, 'departmentid' => $departmentid, 'subdepartments' => $this->subhierarchieslist, 'parentdepartmentid' => $parentlevel, 'shared' => false, 'partialshared' => true);
$this->potentialcourses = new potential_company_course_selector('potentialcourses', $options);
$this->currentcourses = new current_company_course_selector('currentcourses', $options);
parent::__construct($actionurl);
}
示例5: __construct
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);
}
示例6: __construct
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);
}
示例7: __construct
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);
}
示例8: moodle_url
// 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;
}
// Get the appropriate list of departments.
$subhierarchieslist = company::get_all_subdepartments($userhierarchylevel);
$select = new single_select($baseurl, 'departmentid', $subhierarchieslist, $departmentid);
//GWL $select->label = get_string('department', 'block_iomad_company_admin');
$select->label = get_string('regionlocation', 'block_iomad_company_admin');
$select->formid = 'choosedepartment';
echo html_writer::tag('div', $OUTPUT->render($select), array('id' => 'iomad_department_selector'));
$fwselectoutput = html_writer::tag('div', $OUTPUT->render($select), array('id' => 'iomad_company_selector'));
if (!(iomad::has_capability('block/iomad_company_admin:editusers', $systemcontext) or iomad::has_capability('block/iomad_company_admin:editallusers', $systemcontext))) {
print_error('nopermissions', 'error', '', 'edit/delete users');
示例9: find_courses
public function find_courses($search)
{
global $CFG, $DB, $SITE;
require_once $CFG->dirroot . '/local/iomad/lib/company.php';
// By default wherecondition retrieves all courses except the deleted, not confirmed and guest.
list($wherecondition, $params) = $this->search_sql($search, 'c');
$params['companyid'] = $this->companyid;
$params['siteid'] = $SITE->id;
$userdepartment = company::get_userlevel($this->user);
if (!($companycourses = $DB->get_records('company_course', array('companyid' => $this->companyid), null, 'courseid'))) {
$companysql = " AND 1=0";
} else {
$companysql = " AND c.id in (" . implode(',', array_keys($companycourses)) . ") ";
}
$deptids = company::get_recursive_department_courses($userdepartment->id);
$departmentcondition = "";
if (!empty($deptids)) {
foreach ($deptids as $deptid) {
if (empty($departmentcondition)) {
$departmentcondition = " AND cc.courseid in (" . $deptid->courseid;
} else {
$departmentcondition .= "," . $deptid->courseid;
}
}
$departmentcondition .= ") ";
}
$currentcourses = enrol_get_users_courses($this->user->id, true, null, 'visible DESC, sortorder ASC');
if (!empty($currentcourses)) {
$currentcoursesql = "AND c.id not in (" . implode(',', array_keys($currentcourses)) . ")";
} else {
$currentcoursesql = "";
}
if ($licensecourses = $DB->get_records('iomad_courses', array('licensed' => 1), null, 'courseid')) {
$licensesql = " AND c.id not in (" . implode(',', array_keys($licensecourses)) . ")";
} else {
$licensesql = "";
}
$fields = 'SELECT ' . $this->required_fields_sql('c');
$countfields = 'SELECT COUNT(1)';
$distinctfields = 'SELECT DISTINCT ' . $this->required_fields_sql('c');
$distinctcountfields = 'SELECT COUNT(DISTINCT c.id) ';
$sql = " FROM {course} c,\n {company_course} cc\n WHERE cc.courseid = c.id\n AND {$wherecondition}\n {$companysql}\n {$departmentcondition}\n {$currentcoursesql}\n {$licensesql}";
// Deal with shared courses.
if ($this->shared) {
if ($this->licenses) {
$sharedsql = " FROM {course} c\n INNER JOIN {iomad_courses} pc\n ON c.id=pc.courseid\n WHERE pc.shared=1\n AND pc.licensed != 1";
$partialsharedsql = " FROM {course} c\n WHERE c.id IN (SELECT pc.courseid from {iomad_courses} pc\n INNER JOIN {company_shared_courses} csc ON pc.courseid=csc.courseid\n where pc.shared=2 AND pc.licensed !=1 AND csc.companyid = :companyid)";
} else {
$sharedsql = " FROM {course} c INNER JOIN {iomad_courses} pc ON c.id=pc.courseid WHERE pc.shared=1";
$partialsharedsql = " FROM {course} c\n WHERE c.id IN (SELECT pc.courseid from {iomad_courses} pc\n INNER JOIN {company_shared_courses} csc ON pc.courseid=csc.courseid\n where pc.shared=2 AND csc.companyid = :companyid)";
}
} else {
$sharedsql = " FROM {course} c WHERE 1 = 2";
$partialsharedsql = " FROM {course} c WHERE 1 = 2";
}
$order = ' ORDER BY c.fullname ASC';
if (!$this->is_validating()) {
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params) + $DB->count_records_sql($countfields . $sharedsql, $params) + $DB->count_records_sql($countfields . $partialsharedsql, $params);
if ($potentialmemberscount > company_course_selector_base::MAX_COURSES_PER_PAGE) {
return $this->too_many_results($search, $potentialmemberscount);
}
}
$availablecourses = $DB->get_records_sql($fields . $sql . $order, $params) + $DB->get_records_sql($fields . $sharedsql . $order, $params) + $DB->get_records_sql($fields . $partialsharedsql . $order, $params);
if (empty($availablecourses)) {
return array();
}
if ($search) {
$groupname = get_string('potcoursesmatching', 'block_iomad_company_admin', $search);
} else {
$groupname = get_string('potcourses', 'block_iomad_company_admin');
}
return array($groupname => $availablecourses);
}
示例10: get_license_department_ids
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);
}
}
}
示例11: tag_get_tags_array
// User interests.
if (!empty($CFG->usetags)) {
require_once $CFG->dirroot . '/tag/lib.php';
$user->interests = tag_get_tags_array('user', $id);
}
if ($user->id !== -1) {
$usercontext = context_user::instance($user->id);
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'forcehttps' => false, 'context' => $usercontext);
$user = file_prepare_standard_editor($user, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
} else {
$usercontext = null;
// This is a new user, we don't want to add files here.
$editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false, 'context' => $coursecontext);
}
// Code by sumit
$userregionlocation = company::get_userlevel($user);
if ($userregionlocation && $userregionlocation->level) {
// if user is assigned at location, need to identify his region also.
// Check the user level i.e. region or location
$user->userregion = $userregionlocation->parent;
$user->userlocation = $userregionlocation->id;
} else {
// user is assigned at region level don't need to identify location.
$user->userregion = $userregionlocation->id;
$user->userlocation = '';
}
// Get user role in region or location
// Code by sumit
$userrole = $DB->get_record('company_users', array('userid' => $user->id), 'managertype');
$user->managertype = $userrole->managertype ? $userrole->managertype : 0;
if ($userdepartmenttitle = get_user_department_title($user->id, $companyid)) {
示例12: definition
public function definition()
{
global $CFG, $USER;
$mform =& $this->_form;
$company = new company($this->selectedcompany);
//$departmentslist = company::get_all_departments($company->id);
$departmentlist = array();
if ($this->deptid) {
$departmentlist = array();
if ($this->locationid) {
$department = company::get_departmentbyid($this->locationid);
$departmenttree = company::get_subdepartments($department);
$parentlist[$department->id] = array($department->id => '/' . $department->name);
$departmentlist = company::array_flatten($parentlist + company::get_subdepartments_list($departmenttree));
}
}
// Then show the fields about where this block appears.
if ($this->action == 0) {
$mform->addElement('header', 'header', get_string('createdepartment', 'block_iomad_company_admin'));
} else {
$mform->addElement('header', 'header', get_string('editdepartments', 'block_iomad_company_admin'));
}
$regionlist = company::get_all_regions($company->id);
$regionlistarr = array('' => get_string('choose'));
foreach ($regionlist as $region) {
$regionlistarr[$region->id] = $region->name;
}
$parentnode = company::get_company_parentnode($this->selectedcompany);
$context = context_system::instance();
if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $context)) {
$userhierarchylevel = $parentnode->id;
} else {
$userlevel = company::get_userlevel($USER);
$userhierarchylevel = $userlevel->id;
}
$showregion = 1;
$showlocation = 1;
if ($parentnode->id != $userhierarchylevel) {
$myregion = company::get_my_region($userhierarchylevel);
if (!$myregion) {
$showregion = 0;
}
$mylocation = company::get_my_location($userhierarchylevel);
if (!$mylocation) {
$showlocation = 0;
}
}
$locationlist = array();
if ($this->locationid) {
$locationdetail = company::get_departmentbyid($this->locationid);
$locationlist[$locationdetail->id] = $locationdetail->name;
}
$mform->addElement('hidden', 'departmentid', $this->deptid);
$mform->setType('departmentid', PARAM_INT);
$mform->addElement('hidden', 'deptlocation', $this->locationid);
$mform->setType('deptlocation', PARAM_INT);
$mform->addElement('hidden', 'action', $this->action);
$mform->setType('action', PARAM_INT);
if ($showregion) {
$mform->addElement('select', 'regionid', get_string('region', 'block_iomad_company_admin'), $regionlistarr);
$mform->disabledIf('regionid', 'action', 'eq', 1);
}
if ($showlocation) {
$mform->addElement('select', 'locationid', get_string('location', 'block_iomad_company_admin'), $locationlist);
$mform->disabledIf('locationid', 'action', 'eq', 1);
}
if ($departmentlist) {
$attr = array('class' => 'dept_container');
if ($this->disabledeptlist) {
$attr['disabled'] = 'disabled';
}
$mform->addElement('select', 'deptid', get_string('department', 'block_iomad_company_admin'), $departmentlist, $attr);
}
$mform->addElement('text', 'fullname', get_string('fullnamedepartment', 'block_iomad_company_admin'), 'maxlength = "254" size = "50"');
$mform->addHelpButton('fullname', 'fullnamedepartment', 'block_iomad_company_admin');
$mform->addRule('fullname', get_string('missingfullnamedepartment', 'block_iomad_company_admin'), 'required', null, 'client');
$mform->setType('fullname', PARAM_MULTILANG);
$mform->addElement('text', 'shortname', get_string('shortnamedepartment', 'block_iomad_company_admin'), 'maxlength = "100" size = "20"');
$mform->addHelpButton('shortname', 'shortnamedepartment', 'block_iomad_company_admin');
$mform->addRule('shortname', get_string('missingshortnamedepartment', 'block_iomad_company_admin'), 'required', null, 'client');
$mform->setType('shortname', PARAM_MULTILANG);
$mform->addElement('hidden', 'chosenid', $this->chosenid);
$mform->setType('chosenid', PARAM_INT);
$this->add_action_buttons();
}