public function run() { require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $data = false; if ($this->res_id > 0) { $data = $kbres->getResource($this->res_id, true, true); } else { if (!empty($this->r_item_id) && !empty($this->r_type)) { $data = $kbres->getResourceFromItem($this->r_item_id, $this->r_type, $this->r_env, true, true); } } if ($data == false) { $data = array('res_id' => 0, 'r_name' => '', 'original_name' => '', 'r_desc' => '', 'r_item_id' => $this->r_item_id, 'r_type' => $this->r_type, 'r_env' => $this->r_env, 'r_env_parent_id' => $this->r_env_parent_id, 'r_param' => $this->r_param, 'r_alt_desc' => '', 'r_lang' => !empty($this->language) ? $this->language : getLanguage(), 'force_visible' => 0, 'is_mobile' => 0, 'folders' => array(), 'tags' => array()); } if (!empty($this->original_name)) { $data['original_name'] = $this->original_name; } $c_folders = array_keys($data['folders']); unset($data['folders']); $c_tags = $data['tags']; unset($data['tags']); $json = new Services_JSON(); $this->render('kbcategorize', array('selected_node' => $this->_getSelectedNode(), 'back_url' => $this->back_url, 'form_url' => $this->form_url, 'form_extra_hidden' => $this->form_extra_hidden, 'data' => $data, 'c_folders' => $c_folders, 'c_tags_json' => $json->encode(array_values($c_tags)), 'all_tags_json' => $json->encode(array_values($kbres->getAllTags())))); }
public function getAllTagsForResources($res_id_arr) { require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); return $kbres->getAllTagsForResources($res_id_arr); }
public function play() { require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $kb_model = new KbAlms(); $from_adm = Get::req('from_adm', DOTY_INT, 0); $back_url = $from_adm ? Get::rel_path('adm') . '/index.php?r=alms/kb/show' : 'index.php?r=kb/show'; $res_id = Get::req('id', DOTY_INT, 0); if ($kb_model->checkResourcePerm($res_id)) { $kbres->playResource($res_id, $back_url); } else { echo "You can't access"; } }
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; }
function beforeDeleteItem(&$folder) { if ($folder->otherValues[REPOFIELDOBJECTTYPE] != '') { if ($folder->otherValues[REPOFIELDIDRESOURCE] != 0) { $lo = createLO($folder->otherValues[REPOFIELDOBJECTTYPE]); // delete categorized resource require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $kbres->deleteResourceFromItem($folder->otherValues[REPOFIELDIDRESOURCE], $folder->otherValues[REPOFIELDOBJECTTYPE], 'course_lo'); // --------------------------- $ret = $lo->del($folder->otherValues[REPOFIELDIDRESOURCE]); return $ret; } else { return TRUE; } } return parent::beforeDeleteItem($folder); }
public function getUncategorized() { require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $start_index = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_MIXED, Get::sett('visuItem', 25)); $sort = Get::req('sort', DOTY_MIXED, 'title'); $dir = Get::req('dir', DOTY_MIXED, 'asc'); $type = Get::req('type', DOTY_STRING, ""); $filter_text = Get::req('filter_text', DOTY_STRING, ""); $where = !empty($filter_text) ? "items.title LIKE '%" . $filter_text . "%'" : ''; $limit = $start_index . ', ' . $results; $data_arr = $kbres->getUnCategorizedResourcesByType($type, $where, $limit); $tot = $data_arr['tot']; $result = array('totalRecords' => $tot, 'startIndex' => $start_index, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $results, 'results' => count($data_arr), 'records' => $data_arr['data']); $data = $this->json->encode($result); echo $data; }
$i = 0; $data = array(); $sco_arr = array(); while ($row = mysql_fetch_assoc($q)) { $sco_id = $row["idscorm_item"]; $sco_arr[] = $sco_id; $data[$i]["idscorm_item"] = $sco_id; $data[$i]["title"] = $row['title']; $url = 'index.php?r=alms/communication/categorize&id_comm=' . $id_comm . ' &idResource=' . $id_resource . '&sco_id=' . $sco_id; //.'&comm_title='.$comm_data['title']; $data[$i]["url"] = $url; $i++; } require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $categorized_sco = $kbres->getCategorizedResources($sco_arr, "scoitem", "communication", true); $categorized_sco_id = !empty($categorized_sco) ? array_keys($categorized_sco) : array(); foreach ($data as $row) { $line = array(); $sco_id = $row["idscorm_item"]; $line[] = $row['title']; $categorized = false; if (in_array($sco_id, $categorized_sco_id)) { $res_id = $categorized_sco[$sco_id]['res_id']; $line[] = $categorized_sco[$sco_id]['r_type']; $line[] = $categorized_sco[$sco_id]['r_env']; $line[] = $categorized_sco[$sco_id]['r_lang']; $line[] = isset($categorized_sco['tags'][$res_id]) ? implode(',', $categorized_sco['tags'][$res_id]) : ''; $categorized = true; } else {
public function categorize() { if (!$this->permissions['mod']) { $this->render('invalid', array('message' => $this->_getMessage('no permission'), 'back_url' => 'index.php?r=alms/games/show')); return; } $id_game = Get::req('id_game', DOTY_INT, 0); require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); if ($id_game > 0) { $data = $this->model->findByPk($id_game); $r_data = $kbres->getResourceFromItem($data['id_resource'], $data['type_of'], 'games'); } if (isset($_POST['subcategorize_switch'])) { $cat_sub_items = Get::pReq('subcategorize_switch', DOTY_INT); $res_id = (int) $r_data['res_id']; $r_env_parent_id = (int) $r_data['r_env_parent_id']; $kbres->saveResourceSubCategorizePref($res_id, $cat_sub_items); Util::jump_to('index.php?r=alms/games/categorize&id_game=' . $r_env_parent_id); die; } else { if (isset($_POST['org_categorize_save'])) { require_once _lms_ . '/lib/lib.kbres.php'; $res_id = Get::req('res_id', DOTY_INT, 0); $name = Get::req('r_name', DOTY_STRING, ""); $original_name = ''; // won't update this field $desc = Get::req('r_desc', DOTY_STRING, ""); $r_item_id = Get::req('r_item_id', DOTY_INT, 0); $type = Get::req('r_type', DOTY_STRING, ""); $env = Get::req('r_env', DOTY_STRING, ""); $env_parent_id = Get::req('r_env_parent_id', DOTY_INT, 0); $param = Get::req('r_param', DOTY_STRING, ""); $alt_desc = ''; $lang_id = Get::req('r_lang', DOTY_INT, ""); $lang_arr = Docebo::langManager()->getAllLangCode(); $lang = $lang_arr[$lang_id]; $force_visible = Get::req('force_visible', DOTY_INT, 0); $is_mobile = Get::req('is_mobile', DOTY_INT, 0); $folders = Get::req('h_selected_folders', DOTY_STRING, ""); $json_tags = Util::strip_slashes(Get::req('tag_list', DOTY_STRING, "[]")); $kbres = new KbRes(); $res_id = $kbres->saveResource($res_id, $name, $original_name, $desc, $r_item_id, $type, $env, $env_parent_id, $param, $alt_desc, $lang, $force_visible, $is_mobile, $folders, $json_tags); Util::jump_to('index.php?r=alms/games/show'); } else { if (isset($_POST['org_categorize_cancel'])) { Util::jump_to('index.php?r=alms/games/show'); } else { if ($data['type_of'] == 'scorm' && $r_data && $r_data['sub_categorize'] == 1) { $this->categorize_sco($id_game, $data); } else { $data = $this->model->findByPk($id_game); $data['item_id'] = $id_game; $this->render('categorize', array('id_game' => $id_game, 'data' => $data, 'r_param' => '', 'back_url' => 'index.php?r=alms/games/show', 'form_url' => 'index.php?r=alms/games/categorize&id_game=' . $id_game)); } } } } }
$q = sql_query($qry); $i = 0; $data = array(); $sco_arr = array(); while ($row = mysql_fetch_assoc($q)) { $sco_id = $row["idscorm_item"]; $sco_arr[] = $sco_id; $data[$i]["idscorm_item"] = $sco_id; $data[$i]["title"] = $row['title']; $url = 'index.php?r=alms/games/categorize&id_game=' . $id_game . ' &idResource=' . $id_resource . '&sco_id=' . $sco_id; $data[$i]["url"] = $url; $i++; } require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $categorized_sco = $kbres->getCategorizedResources($sco_arr, "scoitem", "games", true); $categorized_sco_id = !empty($categorized_sco) ? array_keys($categorized_sco) : array(); foreach ($data as $row) { $line = array(); $sco_id = $row["idscorm_item"]; $line[] = $row['title']; $categorized = false; if (in_array($sco_id, $categorized_sco_id)) { $res_id = $categorized_sco[$sco_id]['res_id']; $line[] = $categorized_sco[$sco_id]['r_type']; $line[] = $categorized_sco[$sco_id]['r_env']; $line[] = $categorized_sco[$sco_id]['r_lang']; $line[] = isset($categorized_sco['tags'][$res_id]) ? implode(',', $categorized_sco['tags'][$res_id]) : ''; $categorized = true; } else {
function organization_categorize_switch_subcat(&$treeView, $idItem) { require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $folder = $treeView->tdb->getFolderById($idItem); $data = $folder->otherValues; $type = $data[REPOFIELDOBJECTTYPE]; $r_data = $kbres->getResourceFromItem($data[REPOFIELDIDRESOURCE], $type, 'course_lo'); $cat_sub_items = Get::pReq('subcategorize_switch', DOTY_INT); $res_id = (int) $r_data['res_id']; $r_env_parent_id = (int) $r_data['r_env_parent_id']; $kbres->saveResourceSubCategorizePref($res_id, $cat_sub_items); if ($cat_sub_items == 1) { organization_jump_select_sco($treeView, $idItem, $folder, $data, $type); die; } else { organization_categorize($treeView, $idItem); } }