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


PHP company::add_course方法代码示例

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


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

示例1: company

                                 if ($instance->enrol == 'manual') {
                                     $updateinstance['status'] = 1;
                                 }
                             }
                         }
                         $DB->update_record('enrol', $updateinstance);
                     }
                 }
             }
         }
     }
     // Associate the company with the course.
     $company = new company($companyid);
     // Check if we are a company manager.
     if ($data->selfenrol != 2 && $DB->get_record('company_users', array('companyid' => $companyid, 'userid' => $USER->id, 'managertype' => 1))) {
         $company->add_course($course, 0, true);
     } else {
         if ($data->selfenrol == 2) {
             $company->add_course($course, 0, false, true);
         } else {
             $company->add_course($course);
         }
     }
     if (isset($data->submitandviewbutton)) {
         // We are going to the course instead.
         redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
     } else {
         redirect($returnurl);
     }
 } else {
     $blockpage->display_header();
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:company_course_create_form.php

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