当前位置: 首页>>代码示例>>PHP>>正文


PHP company::assign_user_to_department方法代码示例

本文整理汇总了PHP中company::assign_user_to_department方法的典型用法代码示例。如果您正苦于以下问题:PHP company::assign_user_to_department方法的具体用法?PHP company::assign_user_to_department怎么用?PHP company::assign_user_to_department使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在company的用法示例。


在下文中一共展示了company::assign_user_to_department方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process


//.........这里部分代码省略.........
                                             // Deal with company course roles.
                                             if ($companycourses = $DB->get_records('company_course', array('companyid' => $this->selectedcompany))) {
                                                 foreach ($companycourses as $companycourse) {
                                                     if ($DB->record_exists('course', array('id' => $companycourse->courseid))) {
                                                         company_user::unenrol($adduser, array($companycourse->courseid), $companycourse->companyid);
                                                         company_user::enrol($adduser, array($companycourse->courseid), $companycourse->companyid, $companycoursenoneditorrole->id);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                             $userrecord->managertype = $roletype;
                             $DB->update_record('company_users', $userrecord);
                         } else {
                             if ($roletype == 1 && $DB->get_records_sql('SELECT id FROM {company_users}
                                                         WHERE
                                                         userid = :userid
                                                         AND managertype = :roletype
                                                         AND companyid != :companyid', array('userid' => $adduser->id, 'roletype' => 1, 'companyid' => $this->selectedcompany))) {
                                 // We have a company manager from another company.
                                 // We need to add another record.
                                 $company = new company($this->selectedcompany);
                                 $company->assign_user_to_company($adduser->id);
                                 $DB->set_field('company_users', 'managertype', 1, array('userid' => $adduser->id, 'companyid' => $this->selectedcompany));
                                 // Deal with company courses.
                                 if ($companycourses = $DB->get_records('company_course', array('companyid' => $this->selectedcompany))) {
                                     foreach ($companycourses as $companycourse) {
                                         if ($DB->record_exists('course', array('id' => $companycourse->courseid))) {
                                             if ($DB->record_exists('company_created_courses', array('companyid' => $companycourse->companyid, 'courseid' => $companycourse->courseid))) {
                                                 company_user::enrol($adduser, array($companycourse->courseid), $companycourse->companyid, $companycourseeditorrole->id);
                                             } else {
                                                 company_user::enrol($adduser, array($companycourse->courseid), $companycourse->companyid, $companycoursenoneditorrole->id);
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 // Assign the user to department as staff.
                                 company::assign_user_to_department($departmentid, $adduser->id);
                             }
                         }
                     } else {
                         // Assign the user to department as staff.
                         company::assign_user_to_department($departmentid, $adduser->id);
                     }
                 }
             }
             $this->potentialusers->invalidate_selected_users();
             $this->currentusers->invalidate_selected_users();
         }
     }
     // Process incoming unassignments.
     if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
         $userstounassign = $this->currentusers->get_selected_users();
         if (!empty($userstounassign)) {
             // Check if we are mearly removing the manager role.
             if ($roletype != 0) {
                 foreach ($userstounassign as $removeuser) {
                     // GWL : Check the userid is valid.
                     if (!company::check_valid_user($this->selectedcompany, $adduser->id, $this->departmentid)) {
                         print_error('invaliduserdepartment', 'block_iomad_company_management');
                     }
                     $userrecord = $DB->get_record('company_users', array('companyid' => $this->selectedcompany, 'userid' => $removeuser->id));
                     // Is this a manager from another company?
                     if ($DB->get_records_sql("SELECT id FROM {company_users}\n                                                  WHERE userid = :userid\n                                                  AND companyid != :companyid\n                                                  AND managertype = 1", array('userid' => $removeuser->id, 'companyid' => $this->selectedcompany))) {
                         // Remove the user from this company.
                         $DB->delete_records('company_users', (array) $userrecord);
                     } else {
                         // Remove the manager status from the user.
                         $userrecord->managertype = 0;
                         $DB->update_record('company_users', $userrecord);
                         role_unassign($companymanagerrole->id, $removeuser->id, $this->context->id);
                         role_unassign($departmentmanagerrole->id, $removeuser->id, $this->context->id);
                     }
                     // Remove their capabilities from the company courses.
                     if ($companycourses = $DB->get_records('company_course', array('companyid' => $this->selectedcompany))) {
                         foreach ($companycourses as $companycourse) {
                             if ($DB->record_exists('course', array('id' => $companycourse->courseid))) {
                                 company_user::unenrol($removeuser, array($companycourse->courseid), $companycourse->companyid);
                             }
                         }
                     }
                 }
             } else {
                 foreach ($userstounassign as $removeuser) {
                     // GWL : Check the userid is valid.
                     if (!company::check_valid_user($this->selectedcompany, $removeuser->id, $this->departmentid)) {
                         print_error('invaliduserdepartment', 'block_iomad_company_management');
                     }
                     // Assign the user to parent department as staff.
                     company::assign_user_to_department($this->companydepartment, $removeuser->id);
                 }
             }
             $this->potentialusers->invalidate_selected_users();
             $this->currentusers->invalidate_selected_users();
         }
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:company_managers_form.php

示例2: isset

     if (isset($data->userdepartment) || isset($data->usertitle)) {
         $department = isset($data->userdepartment) ? $data->userdepartment : 0;
         $title = isset($data->usertitle) ? $data->usertitle : 0;
         assign_department_and_title_to_user($companyid, $department, $title, $userid);
     }
     //
     // Code End
     // Code added by Sumit here we asign region or location to user and assign manager to company
     $data->userdepartment = $userlocation ? $userlocation : $data->userregion;
     $data->userdepartment = $data->managertype || !$data->userdepartment ? $parentnode->id : $data->userdepartment;
     company::assign_user_to_department($data->userdepartment, $userid);
     /* END -  GWL  : Assign user to department */
     // Code added by Sumit here we asign region or location to user and assign manager to company
     $data->userdepartment = $userlocation ? $userlocation : $data->userregion;
     $data->userdepartment = $data->managertype || !$data->userdepartment ? $parentnode->id : $data->userdepartment;
     company::assign_user_to_department($data->userdepartment, $userid);
     /* END -  GWL  : Assign user to department */
     // Enrol the user on the courses.
     if (!empty($createcourses)) {
         $userdata = $DB->get_record('user', array('id' => $userid));
         company_user::enrol($userdata, $createcourses, $companyid);
     }
     if (isset($data->submitandback)) {
         // redirect($returnurl);
         // Code by sumit
         redirect(new moodle_url('/blocks/iomad_company_admin/editusers.php'));
         // end of code
     } else {
         redirect($linkurl . "?createdok=1");
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:company_user_create_form.php

示例3: object

        company::initialise_departments($companyid);
        $company->id = $companyid;
        //  Set up a profiles field category for this company.
        $catdata = new object();
        $catdata->sortorder = $DB->count_records('user_info_category') + 1;
        $catdata->name = $company->shortname;
        $DB->insert_record('user_info_category', $catdata, false);
        // Set up course category for company.
        $coursecat = new object();
        $coursecat->name = $company->name;
        $coursecat->sortorder = 999;
        $coursecat->id = $DB->insert_record('course_categories', $coursecat);
        $coursecat->context = context_coursecat::instance($coursecat->id);
        $categorycontext = $coursecat->context;
        mark_context_dirty($coursecat->context->path);
        $DB->update_record('course_categories', $coursecat);
        fix_course_sortorder();
        $companydetails = $DB->get_record('company', array('id' => $company->id));
        $companydetails->category = $coursecat->id;
        $DB->update_record('company', $companydetails);
    }
    // Add user to default company department.
    $USER->profile_field_company = $company->shortname;
    profile_save_data($USER);
    $companydepartment = company::get_company_parentnode($company->id);
    company::assign_user_to_department($companydepartment->id, $USER->id);
}
if ($invoice->status == INVOICESTATUS_PAID) {
    processor::trigger_onordercomplete($invoice);
}
echo $OUTPUT->footer();
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:confirm.php

示例4: set_user_preference

             // Passwords will be created and sent out on cron.
             set_user_preference('create_password', 1, $user->id);
             set_user_preference('auth_forcepasswordchange', 1, $user->id);
             $upt->track('password', get_string('new'));
         } else {
             set_user_preference('auth_forcepasswordchange', 1, $user->id);
         }
     }
     // Save custom profile fields data.
     profile_save_data($user);
     // Make sure user context exists.
     context_user::instance($user->id);
     // Add the user to the company
     $company->assign_user_to_company($user->id);
     // Add the user to the company default hierarchy level.
     company::assign_user_to_department($formdata->userdepartment, $user->id);
     \core\event\user_created::create_from_userid($user->id)->trigger();
     if ($bulk == 1 or $bulk == 3) {
         if (!in_array($user->id, $SESSION->bulk_users)) {
             $SESSION->bulk_users[] = $user->id;
         }
     }
 }
 // Find course enrolments, groups, roles/types and enrol periods.
 foreach ($columns as $column) {
     if (preg_match('/^course\\d+$/', $column)) {
         $i = substr($column, 6);
         if (empty($user->{'course' . $i})) {
             continue;
         }
         $shortname = $user->{'course' . $i};
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:uploaduser.php


注:本文中的company::assign_user_to_department方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。