public function checkResourcePerm($res_id, $user_id = false, $course_filter = false) { $user_id = empty($user_id) ? Docebo::user()->getIdSt() : $user_id; $filter = $this->getSearchFilter(false, false, $course_filter, $res_id); $fields = "COUNT(*) as tot"; $qtxt = "SELECT " . $fields . " FROM %lms_kb_res as kr WHERE " . $filter['where']; $q = Docebo::db()->query($qtxt); $row = Docebo::db()->fetch_assoc($q); return $row['tot'] > 0 ? true : false; }
/** * Do the import operation. This function reads all row from source and puts * its on destination * @return array with input_row_index => error only for rows with error * in index 0 there are the total processed rows **/ function doImport() { $out = array(); // error list $dst_cols = $this->destination->get_cols_descripor(); $row = $this->source->get_first_row(); $i = 0; $open_transaction = false; while ($row !== FALSE) { $insrow = array(); for ($index = 0; $index < count($this->import_map); $index++) { if ($this->import_map[$index] != DOCEBOIMPORT_IGNORE) { $insrow[$this->import_map[$index]] = $row[$index]; } } if ($i == 0) { Docebo::db()->start_transaction(); $open_transaction = true; } foreach ($dst_cols as $col) { $col_name = isset($col[DOCEBOIMPORT_COLID]) ? $col[DOCEBOIMPORT_COLID] : $col[DOCEBOIMPORT_COLNAME]; if (!isset($insrow[$col_name])) { $insrow[$col_name] = isset($col[DOCEBOIMPORT_DEFAULT]) ? $col[DOCEBOIMPORT_DEFAULT] : ''; } } $this->destination->set_charset($this->source->get_charset()); if (!$this->destination->add_row($insrow)) { $out[$this->source->get_row_index()] = $this->destination->get_error(); } if ($i == 100) { $i = 0; Docebo::db()->commit(); $open_transaction = false; } else { $i++; } $row = $this->source->get_next_row(); } if ($open_transaction) { Docebo::db()->commit(); } $out[0] = $this->source->get_row_index() - 1; return $out; }