ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionStandardField.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Modules/DataCollection/classes/class.ilDataCollectionField.php';
5include_once './Modules/DataCollection/classes/class.ilDataCollectionDatatype.php';
6
19{
20 /*
21 * doRead
22 */
23 public function doRead()
24 {
25 global $ilLog;
26 $message = "Standard fields cannot be read from DB";
27 ilUtil::sendFailure($message);
28 $ilLog->write("[ilDataCollectionStandardField] ".$message);
29 }
30
31 /*
32 * doCreate
33 */
34 public function doCreate()
35 {
36 global $ilLog;
37 $message = "Standard fields cannot be written to DB";
38 ilUtil::sendFailure($message);
39 $ilLog->write("[ilDataCollectionStandardField] ".$message);
40 }
41
42 /*
43 * doUpdate
44 */
45 public function doUpdate()
46 {
47 $this->updateVisibility();
48 $this->updateFilterability();
49 $this->updateExportability();
50 }
51
52
56 public function cloneStructure(ilDataCollectionStandardField $original_record) {
57 $this->setEditable($original_record->isEditable());
58 $this->setLocked($original_record->getLocked());
59 $this->setFilterable($original_record->isFilterable());
60 $this->setVisible($original_record->isVisible());
61 $this->setOrder($original_record->getOrder());
62 $this->setRequired($original_record->getRequired());
63 $this->setUnique($original_record->isUnique());
64 $this->setExportable($original_record->getExportable());
65
66 $this->doUpdate();
67 }
68
69 /*
70 * getLocked
71 */
72 public function getLocked()
73 {
74 return true;
75 }
76
77 /*
78 * _getStandardFieldsAsArray
79 */
80 static function _getStandardFieldsAsArray()
81 {
82
83 //TODO: this isn't particularly pretty especially as $lng is used in the model. On the long run the standard fields should be refactored into "normal" fields.
84 global $lng;
85 $stdfields = array(
86 array("id"=>"id", "title" => $lng->txt("dcl_id"), "description" => $lng->txt("dcl_id_description"), "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_NUMBER, "required" => true),
87 array("id"=>"create_date", "title" => $lng->txt("dcl_creation_date"), "description" => $lng->txt("dcl_creation_date_description"), "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_DATETIME, "required" => true),
88 array("id"=>"last_update", "title" => $lng->txt("dcl_last_update"), "description" => $lng->txt("dcl_last_update_description"), "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_DATETIME, "required" => true),
89 array("id"=>"owner", "title" => $lng->txt("dcl_owner"), "description" => $lng->txt("dcl_owner_description"), "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_TEXT, "required" => true),
90 array("id"=>"last_edit_by", "title" => $lng->txt("dcl_last_edited_by"), "description" => $lng->txt("dcl_last_edited_by_description"), "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_TEXT, "required" => true),
91 array('id' => 'comments', 'title' => $lng->txt('dcl_comments'), 'description' => $lng->txt('dcl_comments_description'), 'datatype_id' => ilDataCollectionDatatype::INPUTFORMAT_NONE, 'required' => false),
92 );
93 return $stdfields;
94 }
95
96 /*
97 * _getStandardFields
98 */
100 {
101 $stdFields = array();
102 foreach(self::_getStandardFieldsAsArray() as $array)
103 {
104 $array["table_id"] = $table_id;
105 //$array["datatype_id"] = self::_getDatatypeForId($array["id"]);
106 $field = new ilDataCollectionStandardField();
107 $field->buildFromDBRecord($array);
108 $stdFields[] = $field;
109 }
110 return $stdFields;
111 }
112
113
117 static function _getAllStandardFieldTitles() {
118 global $ilDB;
119 $identifiers = '';
120 foreach (array('dcl_id', 'dcl_creation_date', 'dcl_last_update', 'dcl_owner', 'dcl_last_edited_by', 'dcl_comments') as $id) {
121 $identifiers .= $ilDB->quote($id, 'text') . ',';
122 }
123 $identifiers = rtrim($identifiers, ',');
124 $sql = $ilDB->query('SELECT value FROM lng_data WHERE identifier IN (' . $identifiers . ')');
125 $titles = array();
126 while ($rec = $ilDB->fetchAssoc($sql)) {
127 $titles[] = $rec['value'];
128 }
129 return $titles;
130 }
131
132 /*
133 * _isStandardField
134 */
135 static function _isStandardField($field_id)
136 {
137 $return = false;
138 foreach(self::_getStandardFieldsAsArray() as $field)
139 {
140 if($field["id"] == $field_id)
141 {
142 $return = true;
143 }
144 }
145
146 return $return;
147 }
148
153 public static function _getDatatypeForId($id)
154 {
155 $datatype = null;
156 foreach (self::_getStandardFieldsAsArray() as $fields_data) {
157 if ($id == $fields_data['id']) {
158 $datatype = $fields_data['datatype_id'];
159 break;
160 }
161 }
162 return $datatype;
163 }
164
165 /*
166 * isStandardField
167 */
168 public function isStandardField()
169 {
170 return true;
171 }
172
173 /*
174 * isUnique
175 */
176 public function isUnique()
177 {
178 return false;
179 }
180}
181
182?>
Class ilDataCollectionField.
setFilterable($filterable)
setFilterable
getRequired()
Get Required Required.
setRequired($a_required)
Set Required.
cloneStructure(ilDataCollectionStandardField $original_record)
static _getDatatypeForId($id)
gives you the datatype id of a specified standard field.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:40
global $ilDB