5 include_once
'./Modules/DataCollection/classes/Fields/Base/class.ilDclStandardField.php';
6 include_once
'./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseRecordModel.php';
7 include_once
'./Modules/DataCollection/classes/TableView/class.ilDclTableView.php';
157 $ilDB = $DIC[
'ilDB'];
159 $query =
"SELECT * FROM il_dcl_table WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
161 $rec =
$ilDB->fetchAssoc($set);
182 $this->
setOrder($rec[
'table_order']);
193 public function doDelete($delete_only_content =
false, $omit_notification =
false) {
195 $ilDB = $DIC[
'ilDB'];
199 $record->doDelete($omit_notification);
216 if (!$delete_only_content) {
217 $query =
"DELETE FROM il_dcl_table WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
226 public function doCreate($create_tablefield_setting =
true, $create_standardview =
true) {
228 $ilDB = $DIC[
'ilDB'];
230 $id =
$ilDB->nextId(
"il_dcl_table");
232 $query =
"INSERT INTO il_dcl_table (" .
"id" .
", obj_id" .
", title" .
", add_perm" .
", edit_perm" .
", delete_perm" .
", edit_by_owner" 233 .
", limited" .
", limit_start" .
", limit_end" .
", is_visible" .
", export_enabled" .
", import_enabled" .
", default_sort_field_id" 234 .
", default_sort_field_order" .
", description" .
", public_comments" .
", view_own_records_perm" 235 .
", delete_by_owner, save_confirmation , table_order ) VALUES (" .
$ilDB->quote($this->
getId(),
"integer") .
"," 249 if ($create_standardview) {
254 if ($create_tablefield_setting) {
264 $ilDB = $DIC[
'ilDB'];
317 $this->objId = $a_id;
333 $this->title = $a_title;
356 if ($this->obj == NULL) {
366 if ($this->records == NULL) {
375 $ilDB = $DIC[
'ilDB'];
378 $query =
"SELECT id FROM il_dcl_record WHERE table_id = " .
$ilDB->quote($this->
id,
"integer");
381 while ($rec =
$ilDB->fetchAssoc($set)) {
396 $record->deleteField($field_id);
411 foreach (
$fields as $field_1) {
412 if ($field_1->getId() == $field_id) {
425 $field_ids =
array();
430 $field_ids[] = $field->getId();
437 protected function loadCustomFields() {
440 $ilDB = $DIC[
'ilDB'];
444 $query =
"SELECT DISTINCT il_dcl_field.*, il_dcl_tfield_set.field_order 446 INNER JOIN il_dcl_tfield_set 447 ON ( il_dcl_tfield_set.field NOT IN ('owner', 452 AND il_dcl_tfield_set.table_id = il_dcl_field.table_id 453 AND il_dcl_tfield_set.field = ".$ilDB->cast(
"il_dcl_field.id",
"text").
") 454 WHERE il_dcl_field.table_id = %s 455 ORDER BY il_dcl_tfield_set.field_order ASC";
459 while ($rec =
$ilDB->fetchAssoc($set)) {
471 $this->loadCustomFields();
486 if (!$field->isStandardField()) {
487 $place = $field->getOrder() + 1;
507 if ($tableviews == null)
513 foreach($tableviews as $tableview)
515 $tableview->setTableviewOrder($order);
516 $tableview->update();
530 if($this->all_fields == null) {
538 $this->loadCustomFields();
539 $this->stdFields = $this->getStandardFields();
567 $visible_views =
array();
574 $visible_views[] = $tableView;
578 return $visible_views;
590 return $tableview ? $tableview->getId() :
false;
598 public function getFieldsForFormula() {
599 $unsupported =
array(
610 $this->loadCustomFields();
611 $return = $this->getStandardFields();
615 foreach ($this->
fields as $field) {
616 if (!in_array($field->getDatatypeId(), $unsupported)) {
631 public function getStandardFields() {
632 if ($this->stdFields == NULL) {
637 foreach ($this->stdFields as $k => $field) {
638 if ($field->getId() ==
'comments') {
639 unset($this->stdFields[$k]);
656 $this->loadCustomFields();
666 $editableFields =
array();
669 if (!$field->getLocked()) {
670 $editableFields[] = $field;
674 return $editableFields;
684 $exportableFields =
array();
686 if ($field->getExportable()) {
687 $exportableFields[] = $field;
691 return $exportableFields;
820 return ($from <= $now && $now <= $to);
846 $named[$field->getId()] = $field;
860 @usort($array,
array( $this,
"compareOrder" ));
874 if (!is_null($field->getOrder())) {
875 $field->setOrder($count);
876 $count = $count + $offset;
893 if ($field->getTitle() ==
$title) {
1134 $this->view_own_records_perm = (int)$view_own_perm;
1168 $this->loadCustomFields();
1170 return (count($this->
fields) > 0) ? true :
false;
1180 if (is_null($a->getOrder() == NULL) && is_null($b->getOrder() == NULL)) {
1183 if (is_null($a->getOrder())) {
1186 if (is_null($b->getOrder())) {
1190 return $a->getOrder() < $b->getOrder() ? - 1 : 1;
1222 $org_std_fields = $original->getStandardFields();
1223 foreach ($this->getStandardFields() as $element_key => $std_field) {
1231 $new_fields =
array();
1232 foreach ($original->
getFields() as $orig_field) {
1233 if (!$orig_field->isStandardField()) {
1235 $new_field->setTableId($this->
getId());
1236 $new_field->cloneStructure($orig_field->getId());
1237 $new_fields[$orig_field->getId()] = $new_field;
1249 foreach($original->
getRecords() as $orig_record){
1251 $new_record->setTableId($this->
getId());
1252 $new_record->cloneStructure($orig_record->getId(), $new_fields);
1258 $new_tableview->setTableId($this->
getId());
1259 $new_tableview->cloneStructure($orig_tableview, $new_fields);
1272 foreach ($this->
getFields() as $field) {
1284 return (count($this->
getRecords()) > 0) ? true :
false;
1292 $this->all_fields[$field->getId()] = $field;
1303 $ilDB = $DIC[
'ilDB'];
1304 $query =
"SELECT * FROM il_dcl_table WHERE id = " . $table_id;
1307 return $result->numRows() != 0;
1319 $ilDB = $DIC[
'ilDB'];
1320 $result =
$ilDB->query(
'SELECT id FROM il_dcl_table WHERE title = ' .
$ilDB->quote(
$title,
'text') .
' AND obj_id = ' 1321 .
$ilDB->quote($obj_id,
'integer'));
1350 if (!$this->table_order) {
1361 $ilDB = $DIC[
'ilDB'];
1362 $result =
$ilDB->query(
'SELECT MAX(table_order) AS table_order FROM il_dcl_table WHERE obj_id = ' .
$ilDB->quote($this->getCollectionObject()->getId(),
'integer'));
1363 $this->table_order =
$ilDB->fetchObject(
$result)->table_order + 10;
1364 $ilDB->query(
'UPDATE il_dcl_table SET table_order = ' .
$ilDB->quote($this->table_order,
'integer') .
' WHERE id = ' .
$ilDB->quote($this->
getId(),
'integer'));
1402 $ilDB = $DIC[
'ilDB'];
1403 $result =
$ilDB->query(
'SELECT * FROM il_dcl_field WHERE table_id = ' .
$ilDB->quote($obj_id,
'integer') .
' AND title = ' 1421 public function getPartialRecords($sort, $direction, $limit, $offset,
array $filter =
array()) {
1423 $ilDB = $DIC[
'ilDB'];
1428 $rbacreview = $DIC[
'rbacreview'];
1431 $direction = strtolower($direction);
1432 $direction = (in_array($direction,
array(
'desc',
'asc' ))) ? $direction :
'asc';
1435 $sort_by_status =
false;
1436 if (substr($sort, 0, 8) ==
'_status_') {
1437 $sort_by_status =
true;
1441 if (is_null($sort_field)) {
1442 $sort_field = $this->
getField(
'id');
1445 $sort_query_object = $sort_field->getRecordQuerySortObject($direction, $sort_by_status);
1447 $select_str = ($sort_query_object != NULL) ? $sort_query_object->getSelectStatement() :
'';
1448 $join_str = ($sort_query_object != NULL) ? $sort_query_object->getJoinStatement() :
'';
1449 $where_str = ($sort_query_object != NULL) ? $sort_query_object->getWhereStatement() :
'';
1450 $order_str = ($sort_query_object != NULL) ? $sort_query_object->getOrderStatement() :
'';
1451 $group_str = ($sort_query_object != NULL) ? $sort_query_object->getGroupStatement() :
'';
1453 if (count($filter)) {
1454 foreach ($filter as $key => $filter_value) {
1455 $filter_field_id = substr($key, 7);
1456 $filter_field = $this->
getField($filter_field_id);
1457 $filter_record_query_object = $filter_field->getRecordQueryFilterObject($filter_value, $sort_field);
1459 if ($filter_record_query_object) {
1460 $select_str .= $filter_record_query_object->getSelectStatement();
1461 $join_str .= $filter_record_query_object->getJoinStatement();
1462 $where_str .= $filter_record_query_object->getWhereStatement();
1463 $group_str .= $filter_record_query_object->getGroupStatement();
1469 $sql =
"SELECT DISTINCT record.id, record.owner";
1474 $as =
$ilDB->getDBType() ==
'oracle' ?
'' :
' AS ';
1476 $sql .= rtrim($select_str,
',') .
" FROM il_dcl_record {$as} record ";
1478 $sql .=
" WHERE record.table_id = " .
$ilDB->quote($this->
getId(),
'integer');
1480 if (strlen($where_str) > 0) {
1484 if (strlen($group_str) > 0) {
1485 $sql .=
" GROUP BY " . $group_str;
1488 if (strlen($order_str) > 0) {
1489 $sql .=
" ORDER BY " . $order_str;
1497 $set =
$ilDB->query($sql);
1498 $total_record_ids =
array();
1502 $ref = filter_input(INPUT_GET,
'ref_id');
1504 while ($rec =
$ilDB->fetchAssoc($set)) {
1509 $total_record_ids[] = $rec[
'id'];
1510 $_SESSION[
'dcl_record_ids'][] = $rec[
'id'];
1513 if ($sort_query_object != NULL) {
1514 $total_record_ids = $sort_query_object->applyCustomSorting($sort_field, $total_record_ids, $direction);
1518 $record_ids = array_slice($total_record_ids, $offset, $limit);
1521 foreach ($record_ids as
$id) {
1525 return array(
'records' =>
$records,
'total' => count($total_record_ids) );
Class ilDclBaseFieldModel.
static setCloneOf($old, $new, $type)
static hasAddRecordAccess($ref, $user_id=0)
setId($a_id)
Set table id.
static buildFieldFromRecord($rec)
static _getTableIdByTitle($title, $obj_id)
getPublicCommentsEnabled()
$default_sort_field_order
getVisibleTableViews($ref_id, $with_active_detailedview=false, $user_id=0)
For current user.
getFirstTableViewId($ref_id, $user_id=0)
get id of first (for current user) available view
hasPermissionToViewRecord($ref_id, $record, $user_id=0)
sortTableViews(array $tableviews=null)
static _hasFieldByTitle($title, $obj_id)
Checks if a table has a field with the given title.
static preloadFieldProperties(array $fields)
Preloads field properties.
static hasReadAccess($ref, $user_id=0)
static getFieldCache($field_id=0)
const INPUTFORMAT_BOOLEAN
hasPermissionToDeleteRecord($ref_id, ilDclBaseRecordModel $record)
setEditByOwner($edit_by_owner)
static getAllForTableId($table_id)
static hasAccessToTableView($tableview, $user_id=0)
This only checks access to the tableview - if the full access check is required, use hasAccessTo($ref...
setPublicCommentsEnabled($public_comments)
setDefaultSortField($default_sort_field)
/**
const INPUTFORMAT_REFERENCELIST
static _lookupObjectId($a_ref_id)
getFields()
Returns all fields of this table including the standard fields.
hasPermissionToDeleteRecords($ref_id)
hasPermissionToEditRecord($ref_id, ilDclBaseRecordModel $record)
setDescription($description)
static getCountForTableId($table_id)
Class ilDclBaseFieldModel.
setExportEnabled($export_enabled)
doesRecordBelongToUser(ilDclBaseRecordModel $record)
updateFields()
Update fields.
static _getStandardFields($table_id)
getExportableFields()
Return all the fields that are marked as exportable.
static _tableExists($table_id)
cloneStructure(ilDclTable $original)
hasCustomFields()
hasCustomFields
setDeletePerm($delete_perm)
static hasEditAccess($ref, $user_id=0)
Has permission to view and edit all entries event when he is not the owner.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static hasWriteAccess($ref, $user_id=0)
static getRecordCache($record_id=0)
getRecordFields()
Returns all fields of this table which are NOT standard fields.
sortFields(&$fields)
sortFields
const INPUTFORMAT_ILIAS_REF
setSaveConfirmation($save_confirmation)
const INPUTFORMAT_FORMULA
getFieldByTitle($title)
Get a field by title.
Create styles array
The data for the language used.
getDefaultSortFieldOrder()
setLimitStart($limit_start)
static createOrGetStandardView($table_id, $create_default_settings=true)
const INPUTFORMAT_REFERENCE
setViewOwnRecordsPerm($view_own_perm)
Class ilDclBaseRecordModel.
setIsVisible($is_visible)
doCreate($create_tablefield_setting=true, $create_standardview=true)
setImportEnabled($import_enabled)
buildOrderFields()
buildOrderFields orders the fields.
Class ilObjDataCollection.
setDeleteByOwner($delete_by_owner)
setDefaultSortFieldOrder($default_sort_field_order)
getNewFieldOrder()
getNewOrder