예제 #1
0
 public static function create(\stdClass $data)
 {
     if ($data->mode == 'youtube') {
         $data->galleryfocus = self::TYPE_VIDEO;
     }
     if (empty($data->groupid)) {
         $data->groupid = 0;
     }
     $result = parent::create($data);
     $params = array('context' => $result->get_collection()->context, 'objectid' => $result->id);
     if (!empty($data->nosync)) {
         $params['other']['nosync'] = true;
     }
     if (empty($data->noevent)) {
         $event = \mod_mediagallery\event\gallery_created::create($params);
         $event->add_record_snapshot('mediagallery_gallery', $result->get_record());
         $event->trigger();
     }
     return $result;
 }
예제 #2
0
 public static function create(\stdClass $data)
 {
     global $DB, $USER;
     foreach (static::$defaultvalues as $key => $val) {
         if (!isset($data->{$key})) {
             $data->{$key} = $val;
         }
     }
     $data->timecreated = time();
     if (!isset($data->userid)) {
         $data->userid = $USER->id;
     }
     $result = parent::create($data);
     if (!empty($data->thumbnail)) {
         $sql = "UPDATE {mediagallery_gallery}\n                    SET thumbnail = :item\n                    WHERE id = :galleryid";
         $DB->execute($sql, array('item' => $result->id, 'galleryid' => $result->galleryid));
     }
     $params = array('context' => $result->get_context(), 'objectid' => $result->id);
     if (!empty($data->nosync)) {
         $params['other']['nosync'] = true;
     }
     $event = \mod_mediagallery\event\item_created::create($params);
     $event->add_record_snapshot('mediagallery_item', $result->get_record());
     $event->trigger();
     return $result;
 }