Esempio n. 1
0
 function addItem($idParent, $title, $objectType, $idResource, $idCategory, $idUser, $idAuthor, $version, $difficult, $description, $language, $resource, $objective, $dateInsert, $otherData = NULL, $idCourse = FALSE)
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.param.php';
     $this->org_title = $title;
     $this->org_objectType = $objectType;
     $this->org_idResource = $idResource;
     $this->org_idCategory = $idCategory;
     $this->org_idUser = $idUser;
     $this->org_idAuthor = $idAuthor;
     $this->org_version = $version;
     $this->org_difficult = $difficult;
     $this->org_description = $description;
     $this->org_language = $language;
     $this->org_resource = $resource;
     $this->org_objective = $objective;
     $this->org_dateInsert = $dateInsert;
     $this->org_prerequisites = '';
     $this->org_isTerminator = 0;
     $this->org_visible = 1;
     if ($idCourse === FALSE) {
         $this->org_idCourse = $this->idCourse;
     } else {
         $this->org_idCourse = $idCourse;
     }
     require_once _lms_ . '/lib/lib.module.php';
     $lo = createLO($objectType);
     if ($lo) {
         // Add object to the uncategorized resources
         require_once _lms_ . '/lib/lib.kbres.php';
         $kbres = new KbRes();
         $lang = isset($_SESSION['idCourse']) && defined("LMS") ? Docebo::course()->getValue('lang_code') : false;
         $kbres->saveUncategorizedResource($title, $idResource, $objectType, 'course_lo', $this->org_idCourse, false, $lang);
     }
     $arrParamsInfo = $lo->getParamInfo();
     if ($arrParamsInfo !== FALSE) {
         $param = current($arrParamsInfo);
         $this->org_idParam = setLOParam(NULL, $param['param_name'], '');
         next($arrParamsInfo);
         while ($param = current($arrParamsInfo)) {
             setLOParam($this->org_idParam, $param['param_name'], '');
             next($arrParamsInfo);
         }
         reset($arrParamsInfo);
     } else {
         $this->org_idParam = setLOParam(NULL, 'idReference', '');
     }
     $idReference = TreeDb::addFolderById($idParent, $this->getNewPos($idParent));
     setLOParam($this->org_idParam, 'idReference', $idReference);
     return $idReference;
 }
 protected function insert_obj()
 {
     if (!$this->permissions['add']) {
         $this->render('invalid', array('message' => $this->_getMessage('no permission'), 'back_url' => 'index.php?r=alms/games/show'));
         return;
     }
     $data['id_game'] = Get::req('id_game', DOTY_INT, 0);
     $data['id_resource'] = Get::req('id_lo', DOTY_INT, 0);
     $create_result = Get::req('create_result', DOTY_INT, 0);
     if ($create_result >= 1) {
         if ($this->model->save($data)) {
             $data = $this->model->findByPk($data['id_game']);
             if ($data['type_of'] == 'file' || $data['type_of'] == 'scorm') {
                 // Save resource as uncategorized
                 require_once _lms_ . '/lib/lib.kbres.php';
                 $kbres = new KbRes();
                 $kbres->saveUncategorizedResource($data['title'], $data['id_resource'], $data['type_of'], 'games', $data['id_game']);
             }
             Util::jump_to('index.php?r=alms/games/show&success=1');
         }
     } else {
         // destroy the empty game
         $this->model->delByPk($data['id_game']);
     }
     Util::jump_to('index.php?r=alms/games/show&error=1');
 }