ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStartingPoint Class Reference

Class ilStartingPoint. More...

+ Collaboration diagram for ilStartingPoint:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setStartingPoint ($a_starting_point)
 Sets the starting point. More...
 
 getStartingPoint ()
 Gets the starting point. More...
 
 setStartingObject ($a_starting_object)
 Sets the starting object. More...
 
 getStartingObject ()
 Gets the starting object. More...
 
 setPosition ($a_starting_position)
 Sets the starting position. More...
 
 getPosition ()
 Gets the starting point position. More...
 
 setRuleType ($a_rule_type)
 Sets rule type. More...
 
 getRuleType ()
 Gets the rule type. More...
 
 setRuleOptions ($a_rule_options)
 Sets rule type options. More...
 
 getCalendarView ()
 Gets calendar view. More...
 
 setCalendarView (int $calendar_view)
 Sets calendar view. More...
 
 getCalendarPeriod ()
 Gets calendar Period. More...
 
 setCalendarPeriod (int $calendar_period)
 Sets calendar Period. More...
 
 getRuleOptions ()
 Gets the rule options. More...
 
 save ()
 insert starting point into database More...
 
 update ()
 update starting point More...
 
 delete ()
 delete starting point More...
 
 getMaxPosition ()
 
 saveOrder ($a_items)
 Save all starting point positions. More...
 

Static Public Member Functions

static getStartingPoints ()
 Get all the starting points in database. More...
 
static onRoleDeleted (ilObjRole $role)
 
static getRolesWithStartingPoint ()
 get array with all roles which have starting point defined. More...
 
static getGlobalRolesWithoutStartingPoint ()
 Get id and title of the roles without starting points. More...
 
static reArrangePositions ($a_items)
 

Data Fields

const ORDER_POSITION_MIN = 0
 
const ORDER_POSITION_MAX = 9999
 
const FALLBACK_RULE = 1
 
const ROLE_BASED = 2
 
const USER_SELECTION_RULE = 3
 

Protected Attributes

 $starting_point
 
 $starting_object
 
 $starting_position
 
 $rule_type
 
 $rule_options
 
 $id
 
 $calendar_view
 
 $calendar_period
 

Private Member Functions

 setData ($a_id)
 Set data for the starting point. More...
 

Detailed Description

Class ilStartingPoint.

Author
Jesús López lopez.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 11 of file class.ilStartingPoint.php.

Constructor & Destructor Documentation

◆ __construct()

ilStartingPoint::__construct (   $a_id = 0)

Constructor.

Parameters
a_idpublic

Definition at line 36 of file class.ilStartingPoint.php.

References setData().

37  {
38  if ($a_id > 0) {
39  $this->id = $a_id;
40  $this->setData($a_id);
41  }
42  }
setData($a_id)
Set data for the starting point.
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilStartingPoint::delete ( )

delete starting point

Definition at line 397 of file class.ilStartingPoint.php.

References $DIC, $ilDB, and $query.

398  {
399  global $DIC;
400 
401  $ilDB = $DIC['ilDB'];
402 
403  $query = "DELETE FROM usr_starting_point WHERE id = " . $ilDB->quote($this->id, "integer");
404  $ilDB->manipulate($query);
405  }
global $DIC
Definition: goto.php:24
$query
global $ilDB

◆ getCalendarPeriod()

ilStartingPoint::getCalendarPeriod ( )

Gets calendar Period.

Returns
int

Definition at line 193 of file class.ilStartingPoint.php.

References $calendar_period.

Referenced by save(), and update().

193  : int
194  {
195  return $this->calendar_period;
196  }
+ Here is the caller graph for this function:

◆ getCalendarView()

ilStartingPoint::getCalendarView ( )

Gets calendar view.

Returns
int

Definition at line 173 of file class.ilStartingPoint.php.

References $calendar_view.

Referenced by save(), and update().

173  : int
174  {
175  return $this->calendar_view;
176  }
+ Here is the caller graph for this function:

◆ getGlobalRolesWithoutStartingPoint()

static ilStartingPoint::getGlobalRolesWithoutStartingPoint ( )
static

Get id and title of the roles without starting points.

Returns
array

Definition at line 303 of file class.ilStartingPoint.php.

References $DIC, and ANONYMOUS_ROLE_ID.

Referenced by ilUserStartingPointGUI\getRoleStartingPointForm(), and ilUserStartingPointGUI\startingPoints().

304  {
305  global $DIC;
306 
307  $rbacreview = $DIC['rbacreview'];
308 
309  require_once "./Services/AccessControl/classes/class.ilObjRole.php";
310 
311  $global_roles = $rbacreview->getGlobalRoles();
312 
313  $roles_with_starting_point = self::getRolesWithStartingPoint();
314 
315  $ids_roles_with_sp = array();
316  foreach ($roles_with_starting_point as $role) {
317  array_push($ids_roles_with_sp, $role['role_id']);
318  }
319 
320  $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
321 
322  $roles = array();
323  foreach ($ids_roles_without_sp as $roleid) {
324  if ($roleid === ANONYMOUS_ROLE_ID) {
325  continue;
326  }
327  $role_obj = new ilObjRole($roleid);
328  $roles[] = array(
329  "id" => $role_obj->getId(),
330  "title" => $role_obj->getTitle(),
331  );
332  }
333 
334  return $roles;
335  }
Class ilObjRole.
global $DIC
Definition: goto.php:24
const ANONYMOUS_ROLE_ID
Definition: constants.php:26
+ Here is the caller graph for this function:

◆ getMaxPosition()

ilStartingPoint::getMaxPosition ( )
Parameters
int$a_ass_idassignment id
Returns
int

Definition at line 412 of file class.ilStartingPoint.php.

References $DIC, $ilDB, and $result.

Referenced by save().

413  {
414  global $DIC;
415 
416  $ilDB = $DIC['ilDB'];
417 
418  //get max order number
419  $result = $ilDB->query("SELECT max(position) as max_order FROM usr_starting_point");
420 
421  while ($row = $ilDB->fetchAssoc($result)) {
422  $order_val = (int) $row['max_order'];
423  }
424  return $order_val;
425  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ getPosition()

ilStartingPoint::getPosition ( )

Gets the starting point position.

public

Returns
int

Definition at line 130 of file class.ilStartingPoint.php.

References $starting_position.

Referenced by update().

131  {
133  }
+ Here is the caller graph for this function:

◆ getRolesWithStartingPoint()

static ilStartingPoint::getRolesWithStartingPoint ( )
static

get array with all roles which have starting point defined.

Returns
array

Definition at line 272 of file class.ilStartingPoint.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilUserUtil\getStartingPoint().

273  {
274  global $DIC;
275 
276  $ilDB = $DIC['ilDB'];
277 
278  $query = "SELECT * FROM usr_starting_point WHERE rule_options LIKE %s";
279  $res = $ilDB->queryF($query, array('text'), array("%role_id%"));
280 
281  $roles = array();
282  while ($sp = $ilDB->fetchAssoc($res)) {
283  $options = unserialize($sp['rule_options']);
284 
285  $roles[$options['role_id']] = array(
286  "id" => $sp['id'],
287  "starting_point" => $sp['starting_point'],
288  "starting_object" => $sp['starting_object'],
289  "calendar_view" => $sp['calendar_view'],
290  "calendar_period" => $sp['calendar_period'],
291  "position" => $sp['position'],
292  "role_id" => $options['role_id'],
293 
294  );
295  }
296  return $roles;
297  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getRuleOptions()

ilStartingPoint::getRuleOptions ( )

Gets the rule options.

public

Returns
int

Definition at line 214 of file class.ilStartingPoint.php.

References $rule_options.

Referenced by save(), and update().

215  {
216  return $this->rule_options;
217  }
+ Here is the caller graph for this function:

◆ getRuleType()

ilStartingPoint::getRuleType ( )

Gets the rule type.

public

Returns
int

Definition at line 152 of file class.ilStartingPoint.php.

References $rule_type.

Referenced by save(), and update().

153  {
154  return $this->rule_type;
155  }
+ Here is the caller graph for this function:

◆ getStartingObject()

ilStartingPoint::getStartingObject ( )

Gets the starting object.

public

Returns
int

Definition at line 108 of file class.ilStartingPoint.php.

References $starting_object.

Referenced by save(), and update().

109  {
110  return $this->starting_object;
111  }
+ Here is the caller graph for this function:

◆ getStartingPoint()

ilStartingPoint::getStartingPoint ( )

Gets the starting point.

public

Returns
int

Definition at line 86 of file class.ilStartingPoint.php.

References $starting_point.

Referenced by save(), and update().

87  {
88  return $this->starting_point;
89  }
+ Here is the caller graph for this function:

◆ getStartingPoints()

static ilStartingPoint::getStartingPoints ( )
static

Get all the starting points in database.

Returns
array

Definition at line 223 of file class.ilStartingPoint.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilUserRoleStartingPointTableGUI\getItems().

224  {
225  global $DIC;
226 
227  $ilDB = $DIC['ilDB'];
228 
229  $query = "SELECT * FROM usr_starting_point";
230  $res = $ilDB->query($query);
231  $points = array();
232  while ($point = $ilDB->fetchAssoc($res)) {
233  $points[] = array(
234  "id" => $point["id"],
235  "position" => $point["position"],
236  "starting_point" => $point['starting_point'],
237  "starting_object" => $point['starting_object'],
238  "calendar_view" => $point['calendar_view'],
239  "calendar_period" => $point['calendar_period'],
240  "rule_type" => $point['rule_type'],
241  "rule_options" => $point['rule_options']
242  );
243  }
244 
245  return $points;
246  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ onRoleDeleted()

static ilStartingPoint::onRoleDeleted ( ilObjRole  $role)
static
Parameters
ilObjRole$role
Returns
void

Definition at line 252 of file class.ilStartingPoint.php.

References $data, ilObject\getId(), and ilObjectFactory\getInstanceByObjId().

253  {
254  foreach (self::getRolesWithStartingPoint() as $roleId => $data) {
255  if ((int) $roleId === (int) $role->getId()) {
256  $sp = new self((int) $data['id']);
257  $sp->delete();
258  } elseif (
259  false === ($maybeDeletedRole = ilObjectFactory::getInstanceByObjId((int) $roleId, false)) ||
260  !($maybeDeletedRole instanceof ilObjRole)
261  ) {
262  $sp = new self((int) $data['id']);
263  $sp->delete();
264  }
265  }
266  }
Class ilObjRole.
$data
Definition: storeScorm.php:23
getId()
get object id public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ reArrangePositions()

static ilStartingPoint::reArrangePositions (   $a_items)
static
Parameters
$a_items
Returns
mixed

Definition at line 431 of file class.ilStartingPoint.php.

Referenced by ilUserRoleStartingPointTableGUI\getItems().

432  {
433  $ord_const = 0;
434  $rearranged = [];
435  foreach ($a_items as $k => $v) {
436  $v['starting_position'] = $ord_const;
437  $rearranged[$ord_const] = $v;
438  $ord_const = $ord_const + 10;
439  }
440  return $rearranged;
441  }
+ Here is the caller graph for this function:

◆ save()

ilStartingPoint::save ( )

insert starting point into database

Definition at line 340 of file class.ilStartingPoint.php.

References $DIC, $ilDB, getCalendarPeriod(), getCalendarView(), getMaxPosition(), getRuleOptions(), getRuleType(), getStartingObject(), getStartingPoint(), ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

341  {
342  global $DIC;
343 
344  $ilDB = $DIC['ilDB'];
345 
346  //get position
347  $max_position = $this->getMaxPosition();
348  $position = $max_position + 10;
349 
350  $next_id = $ilDB->nextId('usr_starting_point');
351  $values = array(
352  $next_id,
353  $this->getStartingPoint(),
354  $this->getStartingObject(),
355  $position,
356  $this->getRuleType(),
357  $this->getRuleOptions(),
358  $this->getCalendarView(),
359  $this->getCalendarPeriod()
360  );
361 
362  $ilDB->manipulateF(
363  "INSERT INTO usr_starting_point (id, starting_point, starting_object, position, rule_type, rule_options, calendar_view, calendar_period) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
365  $values
366  );
367  }
getRuleOptions()
Gets the rule options.
getCalendarView()
Gets calendar view.
getStartingObject()
Gets the starting object.
global $DIC
Definition: goto.php:24
getRuleType()
Gets the rule type.
global $ilDB
getStartingPoint()
Gets the starting point.
getCalendarPeriod()
Gets calendar Period.
+ Here is the call graph for this function:

◆ saveOrder()

ilStartingPoint::saveOrder (   $a_items)

Save all starting point positions.

Ordering values with increment +10

Parameters
$a_items

Definition at line 447 of file class.ilStartingPoint.php.

References $DIC, $id, and $ilDB.

448  {
449  global $DIC;
450 
451  $ilDB = $DIC['ilDB'];
452 
453  asort($a_items);
454  $nr = 10;
455  foreach ($a_items as $id => $position) {
456  if ($position > self::ORDER_POSITION_MIN && $position < self::ORDER_POSITION_MAX) {
457  $ilDB->manipulate(
458  "UPDATE usr_starting_point SET" .
459  " position = " . $ilDB->quote($nr, 'integer') .
460  " WHERE id = " . $ilDB->quote($id, 'integer')
461  );
462  $nr += 10;
463  }
464  }
465  }
global $DIC
Definition: goto.php:24
global $ilDB

◆ setCalendarPeriod()

ilStartingPoint::setCalendarPeriod ( int  $calendar_period)

Sets calendar Period.

Parameters
int$calendar_period

Definition at line 203 of file class.ilStartingPoint.php.

References $calendar_period.

Referenced by setData().

203  : void
204  {
205  $this->calendar_period = $calendar_period;
206  }
+ Here is the caller graph for this function:

◆ setCalendarView()

ilStartingPoint::setCalendarView ( int  $calendar_view)

Sets calendar view.

Parameters
int$calendar_view

Definition at line 183 of file class.ilStartingPoint.php.

References $calendar_view.

Referenced by setData().

183  : void
184  {
185  $this->calendar_view = $calendar_view;
186  }
+ Here is the caller graph for this function:

◆ setData()

ilStartingPoint::setData (   $a_id)
private

Set data for the starting point.

Parameters
$a_idinteger starting point id

Definition at line 49 of file class.ilStartingPoint.php.

References $DIC, $ilDB, $query, $res, setCalendarPeriod(), setCalendarView(), setPosition(), setRuleOptions(), setRuleType(), setStartingObject(), and setStartingPoint().

Referenced by __construct().

50  {
51  global $DIC;
52 
53  $ilDB = $DIC['ilDB'];
54 
55  $query = "SELECT * FROM usr_starting_point WHERE id = " . $ilDB->quote($a_id, 'integer');
56  $res = $ilDB->query($query);
57 
58  while ($point = $ilDB->fetchAssoc($res)) {
59  $this->setStartingPoint($point['starting_point']);
60  $this->setRuleOptions($point['rule_options']);
61  $this->setPosition($point['position']);
62  $this->setStartingObject($point['starting_object']);
63  $this->setRuleType($point['rule_type']);
64  $this->setCalendarView($point['calendar_view']);
65  $this->setCalendarPeriod($point['calendar_period']);
66  }
67  }
setRuleOptions($a_rule_options)
Sets rule type options.
setStartingObject($a_starting_object)
Sets the starting object.
setCalendarView(int $calendar_view)
Sets calendar view.
foreach($_POST as $key=> $value) $res
setPosition($a_starting_position)
Sets the starting position.
global $DIC
Definition: goto.php:24
setStartingPoint($a_starting_point)
Sets the starting point.
$query
setCalendarPeriod(int $calendar_period)
Sets calendar Period.
global $ilDB
setRuleType($a_rule_type)
Sets rule type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPosition()

ilStartingPoint::setPosition (   $a_starting_position)

Sets the starting position.

public

Parameters
int

Definition at line 119 of file class.ilStartingPoint.php.

Referenced by setData().

120  {
121  $this->starting_position = $a_starting_position;
122  }
+ Here is the caller graph for this function:

◆ setRuleOptions()

ilStartingPoint::setRuleOptions (   $a_rule_options)

Sets rule type options.

public

Parameters
int

Definition at line 163 of file class.ilStartingPoint.php.

Referenced by setData().

164  {
165  $this->rule_options = $a_rule_options;
166  }
+ Here is the caller graph for this function:

◆ setRuleType()

ilStartingPoint::setRuleType (   $a_rule_type)

Sets rule type.

public

Parameters
int

Definition at line 141 of file class.ilStartingPoint.php.

Referenced by setData().

142  {
143  $this->rule_type = $a_rule_type;
144  }
+ Here is the caller graph for this function:

◆ setStartingObject()

ilStartingPoint::setStartingObject (   $a_starting_object)

Sets the starting object.

public

Parameters
int

Definition at line 97 of file class.ilStartingPoint.php.

Referenced by setData().

98  {
99  $this->starting_object = $a_starting_object;
100  }
+ Here is the caller graph for this function:

◆ setStartingPoint()

ilStartingPoint::setStartingPoint (   $a_starting_point)

Sets the starting point.

public

Parameters
int

Definition at line 75 of file class.ilStartingPoint.php.

Referenced by setData().

76  {
77  $this->starting_point = $a_starting_point;
78  }
+ Here is the caller graph for this function:

◆ update()

ilStartingPoint::update ( )

update starting point

Definition at line 372 of file class.ilStartingPoint.php.

References $DIC, $ilDB, getCalendarPeriod(), getCalendarView(), getPosition(), getRuleOptions(), getRuleType(), getStartingObject(), getStartingPoint(), ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

373  {
374  global $DIC;
375 
376  $ilDB = $DIC['ilDB'];
377 
378  $ilDB->manipulateF(
379  'UPDATE usr_starting_point
380  SET starting_point = %s,
381  starting_object = %s,
382  position = %s,
383  rule_type = %s,
384  rule_options = %s,
385  calendar_view = %s,
386  calendar_period = %s
387  WHERE id = %s',
389  array($this->getStartingPoint(), $this->getStartingObject(), $this->getPosition(),
390  $this->getRuleType(), $this->getRuleOptions(), $this->getCalendarView(), $this->getCalendarPeriod(), $this->id)
391  );
392  }
getRuleOptions()
Gets the rule options.
getCalendarView()
Gets calendar view.
getStartingObject()
Gets the starting object.
getPosition()
Gets the starting point position.
global $DIC
Definition: goto.php:24
getRuleType()
Gets the rule type.
global $ilDB
getStartingPoint()
Gets the starting point.
getCalendarPeriod()
Gets calendar Period.
+ Here is the call graph for this function:

Field Documentation

◆ $calendar_period

ilStartingPoint::$calendar_period
protected

Definition at line 29 of file class.ilStartingPoint.php.

Referenced by getCalendarPeriod(), and setCalendarPeriod().

◆ $calendar_view

ilStartingPoint::$calendar_view
protected

Definition at line 28 of file class.ilStartingPoint.php.

Referenced by getCalendarView(), and setCalendarView().

◆ $id

ilStartingPoint::$id
protected

Definition at line 27 of file class.ilStartingPoint.php.

Referenced by saveOrder().

◆ $rule_options

ilStartingPoint::$rule_options
protected

Definition at line 26 of file class.ilStartingPoint.php.

Referenced by getRuleOptions().

◆ $rule_type

ilStartingPoint::$rule_type
protected

Definition at line 25 of file class.ilStartingPoint.php.

Referenced by getRuleType().

◆ $starting_object

ilStartingPoint::$starting_object
protected

Definition at line 23 of file class.ilStartingPoint.php.

Referenced by getStartingObject().

◆ $starting_point

ilStartingPoint::$starting_point
protected

Definition at line 22 of file class.ilStartingPoint.php.

Referenced by getStartingPoint().

◆ $starting_position

ilStartingPoint::$starting_position
protected

Definition at line 24 of file class.ilStartingPoint.php.

Referenced by getPosition().

◆ FALLBACK_RULE

const ilStartingPoint::FALLBACK_RULE = 1

Definition at line 18 of file class.ilStartingPoint.php.

◆ ORDER_POSITION_MAX

const ilStartingPoint::ORDER_POSITION_MAX = 9999

Definition at line 15 of file class.ilStartingPoint.php.

◆ ORDER_POSITION_MIN

const ilStartingPoint::ORDER_POSITION_MIN = 0

Definition at line 14 of file class.ilStartingPoint.php.

◆ ROLE_BASED

◆ USER_SELECTION_RULE

const ilStartingPoint::USER_SELECTION_RULE = 3

Definition at line 20 of file class.ilStartingPoint.php.


The documentation for this class was generated from the following file: