コード例 #1
0
 public function __construct($obj, $eschool)
 {
     parent::__construct($obj, $eschool);
     $this->mdl_enrol = $this->app->selectFromMdlTable('enrol', 'id', $this->obj->enrolid, true);
     $this->course = $this->app->getCourse($this->mdl_enrol->courseid);
     $mdl_user_obj = $this->app->selectFromMdlTable('user', 'id', $this->obj->userid, true);
     $mdl_user = new GcrMdlUser($mdl_user_obj, $this->app);
     $this->user = $mdl_user->getUserOnInstitution();
     $short_name = $this->app->getShortName();
     $sql = 'select * from ' . $short_name . '.mdl_grade_items gi, ' . $short_name . '.mdl_grade_grades gg where gg.userid = ? ' . 'and gi.courseid = ? and gi.itemtype = ? and gg.itemid = gi.id order by gg.timecreated';
     $this->grade_data = $this->app->gcQuery($sql, array($mdl_user->getObject()->id, $this->course->getObject()->id, 'course'), true);
 }
コード例 #2
0
 public function sendEnrolmentEmails($plugin, $mdl_course, $mdl_user_obj)
 {
     $mailstudents = $plugin->get_config('mailstudents');
     $mailteachers = $plugin->get_config('mailteachers');
     $mailadmins = $plugin->get_config('mailadmins');
     $course = new GcrMdlCourse($mdl_course, $this);
     $mdl_user = new GcrMdlUser($mdl_user_obj, $this);
     if (!($mhr_user = $mdl_user->getUserOnInstitution())) {
         return false;
     }
     $mhr_teacher = $course->getInstructor();
     if ($mhr_teacher) {
         $mhr_teacher = $mhr_teacher->getUserOnInstitution();
     }
     $mhr_owner = $this->getOwnerUser();
     if ($mhr_owner) {
         $mhr_owner = $mhr_owner->getUserOnInstitution();
     }
     if (!empty($mailstudents)) {
         $mhr_user_to = $mhr_user;
         if (!($mhr_user_from = $mhr_teacher)) {
             $mhr_user_from = $mhr_owner;
         }
         if ($mhr_user_from) {
             $message_type = 'maharamessage';
             $a = new StdClass();
             $a->coursename = $course->getObject()->fullname;
             $subject = get_string("enrolmentnew", 'enrol_globalclassroom', $course->getObject()->shortname);
             $body = get_string('welcometocoursetext', 'enrol_globalclassroom', $a);
             $this->sendEnrolmentEmailsHelper($subject, $body, $mhr_user_to, $mhr_user_from, $message_type);
         }
     }
     if (!empty($mailteachers)) {
         if ($mhr_user_to = $mhr_teacher) {
             $mhr_user_from = $mhr_user;
             $message_type = 'moodlemessage';
             $a = new StdClass();
             $a->user = $mdl_user->getObject()->firstname . ' ' . $mdl_user->getObject->lastname;
             $a->course = $course->getObject()->fullname;
             $subject = get_string("enrolmentnew", 'enrol_globalclassroom', $course->getObject()->shortname);
             $body = get_string('enrolmentnewuser', 'enrol_globalclassroom', $a);
             $this->sendEnrolmentEmailsHelper($subject, $body, $mhr_user_to, $mhr_user_from, $message_type);
         }
     }
     if (!empty($mailadmins)) {
         $mhr_user_from = $mhr_user;
         if ($mhr_user_to = $mhr_owner) {
             $message_type = 'moodlemessage';
             $a = new StdClass();
             $a->user = $mdl_user->getObject()->firstname . ' ' . $mdl_user->getObject->lastname;
             $a->course = $course->getObject()->fullname;
             $subject = get_string("enrolmentnew", 'enrol_globalclassroom', $course->getObject()->shortname);
             $body = get_string('enrolmentnewuser', 'enrol_globalclassroom', $a);
             $this->sendEnrolmentEmailsHelper($subject, $body, $mhr_user_to, $mhr_user_from, $message_type);
         }
     }
 }
コード例 #3
0
 public function setUser($mhr_user, $system_roles = array())
 {
     if (!($host_id = $this->getMnetHostId($mhr_user->getApp()))) {
         global $CFG;
         $CFG->current_app->gcError('User from unknown host ' . $mhr_user->getApp()->getShortName() . ', cannot add.', 'gcdatabaseerror');
     }
     $mhr_user_object = $mhr_user->getObject();
     if (!($mdl_user = $this->getUser($mhr_user))) {
         $params = array('auth' => 'mnet', 'confirmed' => 1, 'mnethostid' => $host_id, 'username' => $mhr_user_object->username, 'firstname' => $mhr_user_object->firstname, 'lastname' => $mhr_user_object->lastname, 'email' => $mhr_user_object->email);
         $mdl_user_object = $this->insertIntoMdlTable('user', $params);
         $mdl_user = new GcrMdlUser($mdl_user_object, $this);
     }
     foreach ($system_roles as $system_role) {
         $this->setMdlRoleAssignment($system_role, 1, $mdl_user->getObject()->id);
     }
     return $mdl_user;
 }
コード例 #4
0
 public function isInstructor(GcrMdlUser $user)
 {
     foreach ($this->getMdlInstructors() as $mdl_user) {
         if ($mdl_user->id == $user->getObject()->instructorid) {
             return true;
         }
     }
     return false;
 }