ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once './Modules/DataCollection/classes/class.ilDataCollectionField.php';
5 include_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  */
99  static function _getStandardFields($table_id)
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  /*
114  * _isStandardField
115  */
116  static function _isStandardField($field_id)
117  {
118  $return = false;
119  foreach(self::_getStandardFieldsAsArray() as $field)
120  {
121  if($field["id"] == $field_id)
122  {
123  $return = true;
124  }
125  }
126 
127  return $return;
128  }
129 
134  public static function _getDatatypeForId($id)
135  {
136  $datatype = null;
137  foreach (self::_getStandardFieldsAsArray() as $fields_data) {
138  if ($id == $fields_data['id']) {
139  $datatype = $fields_data['datatype_id'];
140  break;
141  }
142  }
143  return $datatype;
144  }
145 
146  /*
147  * isStandardField
148  */
149  public function isStandardField()
150  {
151  return true;
152  }
153 
154  /*
155  * isUnique
156  */
157  public function isUnique()
158  {
159  return false;
160  }
161 }
162 
163 ?>