ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilStudyProgrammeAssignment.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 require_once(dirname(__FILE__)."/../../../../Services/ActiveRecord/class.ActiveRecord.php");
6 
23  static function returnDbTableName() {
24  return "prg_usr_assignments";
25  }
26 
39  protected $id;
40 
51  protected $usr_id;
52 
64  protected $root_prg_id;
65 
66 
76  protected $last_change;
77 
88  protected $last_change_by;
89 
90 
101  static public function createFor(ilStudyProgramme $a_prg, $a_usr_id, $a_assigning_usr_id) {
102  if (ilObject::_lookupType($a_usr_id) != "usr") {
103  throw new ilException("ilStudyProgrammeAssignment::createFor: '$a_usr_id' "
104  ."is no id of a user.");
105  }
106 
107  $ass = new ilStudyProgrammeAssignment();
108  $ass->setRootId($a_prg->getObjId())
109  ->setUserId($a_usr_id)
110  ->setLastChangeBy($a_assigning_usr_id)
111  ->updateLastChange()
112  ->create();
113  return $ass;
114  }
115 
121  public function getId() {
122  return $this->id;
123  }
124 
130  public function getRootId() {
131  return $this->root_prg_id;
132  }
133 
134  protected function setRootId($a_id) {
135  $this->root_prg_id = $a_id;
136  return $this;
137  }
138 
144  public function getUserId() {
145  return $this->usr_id;
146  }
147 
148  protected function setUserId($a_usr_id) {
149  $this->usr_id = $a_usr_id;
150  return $this;
151  }
152 
158  public function getLastChangeBy() {
159  return $this->last_change_by;
160  }
161 
170  public function setLastChangeBy($a_usr_id) {
171  if (ilObject::_lookupType($a_usr_id) != "usr") {
172  throw new ilException("ilStudyProgrammeAssignment::setLastChangeBy: '$a_usr_id' "
173  ."is no id of a user.");
174  }
175  $this->last_change_by = $a_usr_id;
176  return $this;
177  }
178 
184  public function getLastChange() {
185  return new ilDateTime($this->last_change, IL_CAL_DATETIME);
186  }
187 
193  public function updateLastChange() {
195  return $this;
196  }
197 
207  public function setLastChange(ilDateTime $a_timestamp) {
208  if (ilDateTime::_before($a_timestamp, $this->getLastChange())) {
209  throw new ilException("ilStudyProgrammeAssignment::setLastChange: Given "
210  ."timestamp is before current timestamp. That "
211  ."is logically impossible.");
212  }
213 
214  $this->last_change = $a_timestamp->get(IL_CAL_DATETIME);
215  return $this;
216  }
217 }
218 
219 ?>
Base class for ILIAS Exception handling.
const IL_CAL_DATETIME
getUserId()
Get the id of the user who is assigned.
Class ActiveRecord.
setLastChange(ilDateTime $a_timestamp)
Set the last change timestamp to the given time.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
setLastChangeBy($a_usr_id)
Set the id of the user who did the last change on this assignment.
Class ilStudyProgramme.
static now()
Return current timestamp in Y-m-d H:i:s format.
getLastChange()
Get the timestamp of the last change on this program or a sub program.
getObjId()
Get the id of the study program.
updateLastChange()
Update the last change timestamp to the current time.
Date and time handling
Class ilStudyProgrammeAssignment.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
static _lookupType($a_id, $a_reference=false)
lookup object type
getLastChangeBy()
Get the id of the user who did the last change on this assignment.
static createFor(ilStudyProgramme $a_prg, $a_usr_id, $a_assigning_usr_id)
Create new assignment object for study program and user.
getRootId()
Get the object id of the program the user was assigned to.
getId()
Get the id of the assignment.