ILIAS  release_7 Revision v7.30-3-g800a261c036
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_id@access public

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

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.

References setData().

+ 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.

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

References $DIC, $ilDB, and $query.

◆ getCalendarPeriod()

ilStartingPoint::getCalendarPeriod ( )

Gets calendar Period.

Returns
int

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

193 : int
194 {
196 }

References $calendar_period.

Referenced by save(), and update().

+ 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.

173 : int
174 {
176 }

References $calendar_view.

Referenced by save(), and update().

+ 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.

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.
static getRolesWithStartingPoint()
get array with all roles which have starting point defined.
const ANONYMOUS_ROLE_ID
Definition: constants.php:26

References $DIC, ANONYMOUS_ROLE_ID, and getRolesWithStartingPoint().

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

+ Here is the call graph for this function:
+ 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.

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

References $DIC, $ilDB, and $result.

Referenced by save().

+ Here is the caller graph for this function:

◆ getPosition()

ilStartingPoint::getPosition ( )

Gets the starting point position.

@access public

Returns
int

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

References $starting_position.

Referenced by update().

+ 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.

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

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

Referenced by getGlobalRolesWithoutStartingPoint().

+ Here is the caller graph for this function:

◆ getRuleOptions()

ilStartingPoint::getRuleOptions ( )

Gets the rule options.

@access public

Returns
int

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

215 {
216 return $this->rule_options;
217 }

References $rule_options.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getRuleType()

ilStartingPoint::getRuleType ( )

Gets the rule type.

@access public

Returns
int

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

153 {
154 return $this->rule_type;
155 }

References $rule_type.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getStartingObject()

ilStartingPoint::getStartingObject ( )

Gets the starting object.

@access public

Returns
int

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

109 {
111 }

References $starting_object.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getStartingPoint()

ilStartingPoint::getStartingPoint ( )

Gets the starting point.

@access public

Returns
int

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

References $starting_point.

Referenced by save(), and update().

+ 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.

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 }

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

Referenced by ilUserRoleStartingPointTableGUI\getItems().

+ 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.

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 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getId()
get object id @access public
$data
Definition: storeScorm.php:23

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

+ 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.

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 }

Referenced by ilUserRoleStartingPointTableGUI\getItems().

+ 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.

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 }
getCalendarView()
Gets calendar view.
getStartingObject()
Gets the starting object.
getRuleType()
Gets the rule type.
getCalendarPeriod()
Gets calendar Period.
getRuleOptions()
Gets the rule options.
getStartingPoint()
Gets the starting point.

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

+ 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.

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 }

References $DIC, $id, and $ilDB.

◆ setCalendarPeriod()

ilStartingPoint::setCalendarPeriod ( int  $calendar_period)

Sets calendar Period.

Parameters
int$calendar_period

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

203 : void
204 {
205 $this->calendar_period = $calendar_period;
206 }

References $calendar_period.

Referenced by setData().

+ 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.

183 : void
184 {
185 $this->calendar_view = $calendar_view;
186 }

References $calendar_view.

Referenced by setData().

+ 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.

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 }
setStartingObject($a_starting_object)
Sets the starting object.
setPosition($a_starting_position)
Sets the starting position.
setRuleOptions($a_rule_options)
Sets rule type options.
setRuleType($a_rule_type)
Sets rule type.
setCalendarPeriod(int $calendar_period)
Sets calendar Period.
setCalendarView(int $calendar_view)
Sets calendar view.
setStartingPoint($a_starting_point)
Sets the starting point.

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

Referenced by __construct().

+ 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.

@access public

Parameters
int

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

120 {
121 $this->starting_position = $a_starting_position;
122 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setRuleOptions()

ilStartingPoint::setRuleOptions (   $a_rule_options)

Sets rule type options.

@access public

Parameters
int

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

164 {
165 $this->rule_options = $a_rule_options;
166 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setRuleType()

ilStartingPoint::setRuleType (   $a_rule_type)

Sets rule type.

@access public

Parameters
int

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

142 {
143 $this->rule_type = $a_rule_type;
144 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setStartingObject()

ilStartingPoint::setStartingObject (   $a_starting_object)

Sets the starting object.

@access public

Parameters
int

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

98 {
99 $this->starting_object = $a_starting_object;
100 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setStartingPoint()

ilStartingPoint::setStartingPoint (   $a_starting_point)

Sets the starting point.

@access public

Parameters
int

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

76 {
77 $this->starting_point = $a_starting_point;
78 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ update()

ilStartingPoint::update ( )

update starting point

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

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 }
getPosition()
Gets the starting point position.

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

+ 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: