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


PHP company::remove_course方法代码示例

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


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

示例1: process

 public function process()
 {
     global $DB;
     $context = context_system::instance();
     // Get process ok to unenroll confirmation.
     $oktounenroll = optional_param('oktounenroll', false, PARAM_BOOL);
     // Process incoming assignments.
     if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
         $coursestoassign = $this->potentialcourses->get_selected_courses();
         if (!empty($coursestoassign)) {
             $company = new company($this->selectedcompany);
             foreach ($coursestoassign as $addcourse) {
                 // Check if its a shared course.
                 if ($DB->get_record_sql("SELECT id FROM {iomad_courses}\n                                             WHERE courseid={$addcourse->id}\n                                             AND shared != 0")) {
                     if ($companycourserecord = $DB->get_record('company_course', array('companyid' => $this->selectedcompany, 'courseid' => $addcourse->id))) {
                         // Already assigned to the company so we are just moving it within it.
                         $companycourserecord->departmentid = $this->departmentid;
                         $DB->update_record('company_course', $companycourserecord);
                     } else {
                         $sharingrecord = new object();
                         $sharingrecord->courseid = $addcourse->id;
                         $sharingrecord->companyid = $company->id;
                         $DB->insert_record('company_shared_courses', $sharingrecord);
                         if ($this->departmentid != $this->companydepartment) {
                             $company->add_course($addcourse, $this->departmentid);
                         } else {
                             $company->add_course($addcourse, $this->companydepartment);
                         }
                     }
                 } else {
                     // If company has enrollment then we must have BOTH
                     // oktounenroll true and the company_course_unenrol capability.
                     if (!empty($addcourse->has_enrollments)) {
                         if (iomad::has_capability('block/iomad_company_admin:company_course_unenrol', $context) and $oktounenroll) {
                             $this->unenroll_all($addcourse->id);
                             $company->add_course($addcourse);
                         }
                     } else {
                         if ($companycourserecord = $DB->get_record('company_course', array('companyid' => $this->selectedcompany, 'courseid' => $addcourse->id))) {
                             $companycourserecord->departmentid = $this->departmentid;
                             $DB->update_record('company_course', $companycourserecord);
                         } else {
                             if ($this->departmentid != $this->companydepartment) {
                                 $company->add_course($addcourse, $this->departmentid);
                             } else {
                                 $company->add_course($addcourse, $this->companydepartment);
                             }
                         }
                     }
                 }
             }
             $this->potentialcourses->invalidate_selected_courses();
             $this->currentcourses->invalidate_selected_courses();
         }
     }
     // Process incoming unassignments.
     if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
         $coursestounassign = $this->currentcourses->get_selected_courses();
         if (!empty($coursestounassign)) {
             $company = new company($this->selectedcompany);
             foreach ($coursestounassign as $removecourse) {
                 // Check if its a shared course.
                 if ($DB->get_record_sql("SELECT id FROM {iomad_courses}\n                                             WHERE courseid=:removecourse\n                                             AND shared != 0", array('removecourse' => $removecourse->id))) {
                     $DB->delete_records('company_shared_courses', array('companyid' => $company->id, 'courseid' => $removecourse->id));
                     company::delete_company_course_group($company->id, $removecourse, $oktounenroll);
                 } else {
                     // If company has enrollment then we must have BOTH
                     // oktounenroll true and the company_course_unenrol capability.
                     if (!empty($removecourse->has_enrollments)) {
                         if (iomad::has_capability('block/iomad_company_admin:company_course_unenrol', $context) and $oktounenroll) {
                             $this->unenroll_all($removecourse->id);
                             if ($this->departmentid != $this->companydepartment) {
                                 // Dump it into the default company department.
                                 $company->remove_course($removecourse, $company->id, $this->companydepartment);
                             } else {
                                 // Remove it from the company.
                                 $company->remove_course($removecourse, $company->id);
                             }
                         }
                     } else {
                         if ($this->departmentid != $this->companydepartment) {
                             // Move the course to the company default department.
                             $company->remove_course($removecourse, $company->id, $this->companydepartment);
                         } else {
                             $company->remove_course($removecourse, $company->id);
                         }
                     }
                 }
             }
             $this->potentialcourses->invalidate_selected_courses();
             $this->currentcourses->invalidate_selected_courses();
         }
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:94,代码来源:company_courses_form.php


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