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';
160 $ilDB = $DIC[
'ilDB'];
162 $query =
"SELECT * FROM il_dcl_table WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
164 $rec =
$ilDB->fetchAssoc($set);
185 $this->
setOrder($rec[
'table_order']);
196 public function doDelete($delete_only_content =
false, $omit_notification =
false)
199 $ilDB = $DIC[
'ilDB'];
203 $record->doDelete($omit_notification);
220 if (!$delete_only_content) {
221 $query =
"DELETE FROM il_dcl_table WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
230 public function doCreate($create_tablefield_setting =
true, $create_standardview =
true)
233 $ilDB = $DIC[
'ilDB'];
235 $id =
$ilDB->nextId(
"il_dcl_table");
237 $query =
"INSERT INTO il_dcl_table (" .
"id" .
", obj_id" .
", title" .
", add_perm" .
", edit_perm" .
", delete_perm" .
", edit_by_owner" 238 .
", limited" .
", limit_start" .
", limit_end" .
", is_visible" .
", export_enabled" .
", import_enabled" .
", default_sort_field_id" 239 .
", default_sort_field_order" .
", description" .
", public_comments" .
", view_own_records_perm" 240 .
", delete_by_owner, save_confirmation , table_order ) VALUES (" .
$ilDB->quote($this->
getId(),
"integer") .
"," 254 if ($create_standardview) {
259 if ($create_tablefield_setting) {
270 $ilDB = $DIC[
'ilDB'];
326 $this->objId = $a_id;
344 $this->title = $a_title;
370 if ($this->obj == null) {
381 if ($this->records == null) {
391 $ilDB = $DIC[
'ilDB'];
394 $query =
"SELECT id FROM il_dcl_record WHERE table_id = " .
$ilDB->quote($this->
id,
"integer");
397 while ($rec =
$ilDB->fetchAssoc($set)) {
413 $record->deleteField($field_id);
429 foreach (
$fields as $field_1) {
430 if ($field_1->getId() == $field_id) {
444 $field_ids =
array();
446 if ($field->getId()) {
447 $field_ids[] = $field->getId();
454 protected function loadCustomFields()
458 $ilDB = $DIC[
'ilDB'];
462 $query =
"SELECT DISTINCT il_dcl_field.*, il_dcl_tfield_set.field_order 464 INNER JOIN il_dcl_tfield_set 465 ON ( il_dcl_tfield_set.field NOT IN ('owner', 470 AND il_dcl_tfield_set.table_id = il_dcl_field.table_id 471 AND il_dcl_tfield_set.field = " .
$ilDB->cast(
"il_dcl_field.id",
"text") .
") 472 WHERE il_dcl_field.table_id = %s 473 ORDER BY il_dcl_tfield_set.field_order ASC";
477 while ($rec =
$ilDB->fetchAssoc($set)) {
490 $this->loadCustomFields();
506 if (!$field->isStandardField()) {
507 $place = $field->getOrder() + 1;
527 if ($tableviews == null) {
532 foreach ($tableviews as $tableview) {
533 $tableview->setTableviewOrder($order);
534 $tableview->update();
548 if ($this->all_fields == null) {
557 $this->loadCustomFields();
558 $this->stdFields = $this->getStandardFields();
587 $visible_views =
array();
591 $visible_views[] = $tableView;
595 return $visible_views;
608 return $tableview ? $tableview->getId() :
false;
616 public function getFieldsForFormula()
618 $unsupported =
array(
629 $this->loadCustomFields();
630 $return = $this->getStandardFields();
634 foreach ($this->
fields as $field) {
635 if (!in_array($field->getDatatypeId(), $unsupported)) {
650 public function getStandardFields()
652 if ($this->stdFields == null) {
657 foreach ($this->stdFields as $k => $field) {
658 if ($field->getId() ==
'comments') {
659 unset($this->stdFields[$k]);
677 $this->loadCustomFields();
688 $editableFields =
array();
691 if (!$field->getLocked()) {
692 $editableFields[] = $field;
696 return $editableFields;
707 $exportableFields =
array();
709 if ($field->getExportable()) {
710 $exportableFields[] = $field;
714 return $exportableFields;
849 return (
$from <= $now && $now <= $to);
877 $named[$field->getId()] = $field;
892 @usort($array,
array( $this,
"compareOrder" ));
907 if (!is_null($field->getOrder())) {
908 $field->setOrder($count);
909 $count = $count + $offset;
927 if ($field->getTitle() ==
$title) {
1194 $this->view_own_records_perm = (int) $view_own_perm;
1232 $this->loadCustomFields();
1234 return (count($this->
fields) > 0) ? true :
false;
1245 if (is_null($a->getOrder() == null) && is_null($b->getOrder() == null)) {
1248 if (is_null($a->getOrder())) {
1251 if (is_null($b->getOrder())) {
1255 return $a->getOrder() < $b->getOrder() ? -1 : 1;
1288 $org_std_fields = $original->getStandardFields();
1289 foreach ($this->getStandardFields() as $element_key => $std_field) {
1297 $new_fields =
array();
1298 foreach ($original->
getFields() as $orig_field) {
1299 if (!$orig_field->isStandardField()) {
1300 $class_name = get_class($orig_field);
1301 $new_field =
new $class_name();
1302 $new_field->setTableId($this->
getId());
1303 $new_field->cloneStructure($orig_field->getId());
1304 $new_fields[$orig_field->getId()] = $new_field;
1316 foreach ($original->
getRecords() as $orig_record) {
1318 $new_record->setTableId($this->
getId());
1319 $new_record->cloneStructure($orig_record->getId(), $new_fields);
1325 $new_tableview->setTableId($this->
getId());
1326 $new_tableview->cloneStructure($orig_tableview, $new_fields);
1339 foreach ($this->
getFields() as $field) {
1352 return (count($this->
getRecords()) > 0) ? true :
false;
1361 $this->all_fields[$field->getId()] = $field;
1373 $ilDB = $DIC[
'ilDB'];
1374 $query =
"SELECT * FROM il_dcl_table WHERE id = " . $table_id;
1377 return $result->numRows() != 0;
1390 $ilDB = $DIC[
'ilDB'];
1391 $result =
$ilDB->query(
'SELECT id FROM il_dcl_table WHERE title = ' .
$ilDB->quote(
$title,
'text') .
' AND obj_id = ' 1392 .
$ilDB->quote($obj_id,
'integer'));
1423 if (!$this->table_order) {
1435 $ilDB = $DIC[
'ilDB'];
1436 $result =
$ilDB->query(
'SELECT MAX(table_order) AS table_order FROM il_dcl_table WHERE obj_id = ' .
$ilDB->quote($this->getCollectionObject()->getId(),
'integer'));
1437 $this->table_order =
$ilDB->fetchObject(
$result)->table_order + 10;
1438 $ilDB->query(
'UPDATE il_dcl_table SET table_order = ' .
$ilDB->quote($this->table_order,
'integer') .
' WHERE id = ' .
$ilDB->quote($this->
getId(),
'integer'));
1479 $ilDB = $DIC[
'ilDB'];
1480 $result =
$ilDB->query(
'SELECT * FROM il_dcl_field WHERE table_id = ' .
$ilDB->quote($obj_id,
'integer') .
' AND title = ' 1498 public function getPartialRecords($sort, $direction, $limit, $offset,
array $filter =
array())
1501 $ilDB = $DIC[
'ilDB'];
1506 $rbacreview = $DIC[
'rbacreview'];
1509 $direction = strtolower($direction);
1510 $direction = (in_array($direction,
array(
'desc',
'asc' ))) ? $direction :
'asc';
1513 $sort_by_status =
false;
1514 if (substr($sort, 0, 8) ==
'_status_') {
1515 $sort_by_status =
true;
1519 if (is_null($sort_field)) {
1520 $sort_field = $this->
getField(
'id');
1523 $sort_query_object = $sort_field->getRecordQuerySortObject($direction, $sort_by_status);
1525 $select_str = ($sort_query_object != null) ? $sort_query_object->getSelectStatement() :
'';
1526 $join_str = ($sort_query_object != null) ? $sort_query_object->getJoinStatement() :
'';
1527 $where_str = ($sort_query_object != null) ? $sort_query_object->getWhereStatement() :
'';
1528 $order_str = ($sort_query_object != null) ? $sort_query_object->getOrderStatement() :
'';
1529 $group_str = ($sort_query_object != null) ? $sort_query_object->getGroupStatement() :
'';
1531 if (count($filter)) {
1532 foreach ($filter as
$key => $filter_value) {
1533 $filter_field_id = substr(
$key, 7);
1534 $filter_field = $this->
getField($filter_field_id);
1535 $filter_record_query_object = $filter_field->getRecordQueryFilterObject($filter_value, $sort_field);
1537 if ($filter_record_query_object) {
1538 $select_str .= $filter_record_query_object->getSelectStatement();
1539 $join_str .= $filter_record_query_object->getJoinStatement();
1540 $where_str .= $filter_record_query_object->getWhereStatement();
1541 $group_str .= $filter_record_query_object->getGroupStatement();
1547 $sql =
"SELECT DISTINCT record.id, record.owner";
1552 $as =
$ilDB->getDBType() ==
'oracle' ?
'' :
' AS ';
1554 $sql .= rtrim($select_str,
',') .
" FROM il_dcl_record {$as} record ";
1556 $sql .=
" WHERE record.table_id = " .
$ilDB->quote($this->
getId(),
'integer');
1558 if (strlen($where_str) > 0) {
1562 if (strlen($group_str) > 0) {
1563 $sql .=
" GROUP BY " . $group_str;
1566 if (strlen($order_str) > 0) {
1567 $sql .=
" ORDER BY " . $order_str;
1575 $set =
$ilDB->query($sql);
1576 $total_record_ids =
array();
1580 $ref = filter_input(INPUT_GET,
'ref_id');
1582 while ($rec =
$ilDB->fetchAssoc($set)) {
1587 $total_record_ids[] = $rec[
'id'];
1588 $_SESSION[
'dcl_record_ids'][] = $rec[
'id'];
1591 if ($sort_query_object != null) {
1592 $total_record_ids = $sort_query_object->applyCustomSorting($sort_field, $total_record_ids, $direction);
1596 $record_ids = array_slice($total_record_ids, $offset, $limit);
1599 foreach ($record_ids as
$id) {
1603 return array(
'records' =>
$records,
'total' => count($total_record_ids) );
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