ILIAS  release_4-3 Revision
 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  }
50 
51  /*
52  * getLocked
53  */
54  public function getLocked()
55  {
56  return true;
57  }
58 
59  /*
60  * _getStandardFieldsAsArray
61  */
62  static function _getStandardFieldsAsArray()
63  {
64  $stdfields = array(
65  array("id"=>"id", "title" => "id", "Description" => "The internal ID", "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_NUMBER, "required" => true),
66  //array("id"=>"table_id", "title" => "Table id", "description" => "The internal ID of the table", "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_NUMBER, "required" => true),
67  array("id"=>"create_date", "title" => "Creation Date", "description" => "The date this record was created", "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_DATETIME, "required" => true),
68  array("id"=>"last_update", "title" => "Last Update", "description" => "The last time this record was updated", "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_DATETIME, "required" => true),
69  array("id"=>"owner", "title" => "Owner", "description" => "The owner of this record", "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_TEXT, "required" => true),
70  array("id"=>"last_edit_by", "title" => "Last edited by", "description" => "The user who did the last edit on this record", "datatype_id" => ilDataCollectionDatatype::INPUTFORMAT_TEXT, "required" => true)
71  );
72  return $stdfields;
73  }
74 
75  /*
76  * _getStandardFields
77  */
78  static function _getStandardFields($table_id)
79  {
80  $stdFields = array();
81  foreach(self::_getStandardFieldsAsArray() as $array)
82  {
83  $array["table_id"] = $table_id;
84  $array["datatype_id"] = self::_getDatatypeForId($array["id"]);
85  $field = new ilDataCollectionStandardField();
86  $field->buildFromDBRecord($array);
87  array_push($stdFields, $field);
88  }
89  return $stdFields;
90  }
91 
92  /*
93  * _isStandardField
94  */
95  static function _isStandardField($field_id)
96  {
97  $return = false;
98  foreach(self::_getStandardFieldsAsArray() as $field)
99  {
100  if($field["id"] == $field_id)
101  {
102  $return = true;
103  }
104  }
105 
106  return $return;
107  }
108 
113  public static function _getDatatypeForId($id)
114  {
115  switch($id)
116  {
117  case 'id':
119  case 'owner';
121  case 'create_date':
123  case 'last_edit_by':
125  case 'table_id':
127  case 'last_update':
129  }
130  return NULL;
131  }
132 
133  /*
134  * isStandardField
135  */
136  public function isStandardField()
137  {
138  return true;
139  }
140 
141  /*
142  * isUnique
143  */
144  public function isUnique()
145  {
146  return false;
147  }
148 }
149 
150 ?>