ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 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
 

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$ ilStartingPoint:

Definition at line 13 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 345 of file class.ilStartingPoint.php.

References $DIC, $ilDB, and $query.

346  {
347  global $DIC;
348 
349  $ilDB = $DIC['ilDB'];
350 
351  $query = "DELETE FROM usr_starting_point WHERE id = " . $ilDB->quote($this->id, "integer");
352  $ilDB->manipulate($query);
353  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ getGlobalRolesWithoutStartingPoint()

static ilStartingPoint::getGlobalRolesWithoutStartingPoint ( )
static

Get id and title of the roles without starting points.

Returns
array

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

References $DIC.

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

259  {
260  global $DIC;
261 
262  $rbacreview = $DIC['rbacreview'];
263 
264  require_once "./Services/AccessControl/classes/class.ilObjRole.php";
265 
266  $global_roles = $rbacreview->getGlobalRoles();
267 
268  $roles_with_starting_point = self::getRolesWithStartingPoint();
269 
270  $ids_roles_with_sp = array();
271  foreach ($roles_with_starting_point as $role) {
272  array_push($ids_roles_with_sp, $role['role_id']);
273  }
274 
275  $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
276 
277  $roles = array();
278  foreach ($ids_roles_without_sp as $roleid) {
279  $role_obj = new ilObjRole($roleid);
280  $roles[] = array(
281  "id" => $role_obj->getId(),
282  "title" => $role_obj->getTitle(),
283  );
284  }
285 
286  return $roles;
287  }
Class ilObjRole.
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ getMaxPosition()

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

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

References $DIC, $ilDB, $result, and $row.

Referenced by save().

361  {
362  global $DIC;
363 
364  $ilDB = $DIC['ilDB'];
365 
366  //get max order number
367  $result = $ilDB->query("SELECT max(position) as max_order FROM usr_starting_point");
368 
369  while ($row = $ilDB->fetchAssoc($result)) {
370  $order_val = (int) $row['max_order'];
371  }
372  return $order_val;
373  }
$result
global $DIC
Definition: saml.php:7
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getPosition()

ilStartingPoint::getPosition ( )

Gets the starting point position.

public

Returns
int

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

References $starting_position.

Referenced by update().

129  {
131  }
+ 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 229 of file class.ilStartingPoint.php.

References $DIC, $ilDB, PHPMailer\PHPMailer\$options, $query, and $res.

Referenced by ilUserUtil\getStartingPointAsUrl().

230  {
231  global $DIC;
232 
233  $ilDB = $DIC['ilDB'];
234 
235  $query = "SELECT * FROM usr_starting_point WHERE rule_options LIKE %s";
236  $res = $ilDB->queryF($query, array('text'), array("%role_id%"));
237 
238  $roles = array();
239  while ($sp = $ilDB->fetchAssoc($res)) {
240  $options = unserialize($sp['rule_options']);
241 
242  $roles[$options['role_id']] = array(
243  "id" => $sp['id'],
244  "starting_point" => $sp['starting_point'],
245  "starting_object" => $sp['starting_object'],
246  "position" => $sp['position'],
247  "role_id" => $options['role_id'],
248 
249  );
250  }
251  return $roles;
252  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getRuleOptions()

ilStartingPoint::getRuleOptions ( )

Gets the rule options.

public

Returns
int

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

References $rule_options.

Referenced by save(), and update().

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

◆ getRuleType()

ilStartingPoint::getRuleType ( )

Gets the rule type.

public

Returns
int

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

References $rule_type.

Referenced by save(), and update().

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

◆ getStartingObject()

ilStartingPoint::getStartingObject ( )

Gets the starting object.

public

Returns
int

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

References $starting_object.

Referenced by save(), and update().

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

◆ getStartingPoint()

ilStartingPoint::getStartingPoint ( )

Gets the starting point.

public

Returns
int

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

References $starting_point.

Referenced by save(), and update().

85  {
86  return $this->starting_point;
87  }
+ 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 182 of file class.ilStartingPoint.php.

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

Referenced by ilUserRoleStartingPointTableGUI\getItems().

183  {
184  global $DIC;
185 
186  $ilDB = $DIC['ilDB'];
187 
188  $query = "SELECT * FROM usr_starting_point";
189  $res = $ilDB->query($query);
190  $points = array();
191  while ($point = $ilDB->fetchAssoc($res)) {
192  $points[] = array(
193  "id" => $point["id"],
194  "position" => $point["position"],
195  "starting_point" => $point['starting_point'],
196  "starting_object" => $point['starting_object'],
197  "rule_type" => $point['rule_type'],
198  "rule_options" => $point['rule_options']
199  );
200  }
201 
202  return $points;
203  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$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 209 of file class.ilStartingPoint.php.

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

Referenced by ilUserAppEventListener\handleEvent().

210  {
211  foreach (self::getRolesWithStartingPoint() as $roleId => $data) {
212  if ((int) $roleId === (int) $role->getId()) {
213  $sp = new self((int) $data['id']);
214  $sp->delete();
215  } elseif (
216  false === ($maybeDeletedRole = ilObjectFactory::getInstanceByObjId((int) $roleId, false)) ||
217  !($maybeDeletedRole instanceof ilObjRole)
218  ) {
219  $sp = new self((int) $data['id']);
220  $sp->delete();
221  }
222  }
223  }
Class ilObjRole.
getId()
get object id public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reArrangePositions()

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

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

Referenced by ilUserRoleStartingPointTableGUI\getItems().

380  {
381  $ord_const = 0;
382  $rearranged = [];
383  foreach ($a_items as $k => $v) {
384  $v['starting_position'] = $ord_const;
385  $rearranged[$ord_const] = $v;
386  $ord_const = $ord_const + 10;
387  }
388  return $rearranged;
389  }
+ Here is the caller graph for this function:

◆ save()

ilStartingPoint::save ( )

insert starting point into database

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

References $DIC, $ilDB, $values, getMaxPosition(), getRuleOptions(), getRuleType(), getStartingObject(), and getStartingPoint().

293  {
294  global $DIC;
295 
296  $ilDB = $DIC['ilDB'];
297 
298  //get position
299  $max_position = $this->getMaxPosition();
300  $position = $max_position + 10;
301 
302  $next_id = $ilDB->nextId('usr_starting_point');
303  $values = array(
304  $next_id,
305  $this->getStartingPoint(),
306  $this->getStartingObject(),
307  $position,
308  $this->getRuleType(),
309  $this->getRuleOptions()
310  );
311 
312  $ilDB->manipulateF(
313  "INSERT INTO usr_starting_point (id, starting_point, starting_object, position, rule_type, rule_options) VALUES (%s, %s, %s, %s, %s, %s)",
314  array('integer', 'integer', 'integer', 'integer', 'integer', 'text'),
315  $values
316  );
317  }
global $DIC
Definition: saml.php:7
getRuleOptions()
Gets the rule options.
getStartingObject()
Gets the starting object.
$values
getRuleType()
Gets the rule type.
global $ilDB
getStartingPoint()
Gets the starting point.
+ 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 395 of file class.ilStartingPoint.php.

References $DIC, $id, and $ilDB.

396  {
397  global $DIC;
398 
399  $ilDB = $DIC['ilDB'];
400 
401  asort($a_items);
402  $nr = 10;
403  foreach ($a_items as $id => $position) {
404  if ($position > self::ORDER_POSITION_MIN && $position < self::ORDER_POSITION_MAX) {
405  $ilDB->manipulate(
406  "UPDATE usr_starting_point SET" .
407  " position = " . $ilDB->quote($nr, 'integer') .
408  " WHERE id = " . $ilDB->quote($id, 'integer')
409  );
410  $nr += 10;
411  }
412  }
413  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ 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, 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  }
65  }
setRuleOptions($a_rule_options)
Sets rule type options.
setStartingObject($a_starting_object)
Sets the starting object.
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
setPosition($a_starting_position)
Sets the starting position.
setStartingPoint($a_starting_point)
Sets the starting point.
$query
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 117 of file class.ilStartingPoint.php.

Referenced by setData().

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

◆ setRuleOptions()

ilStartingPoint::setRuleOptions (   $a_rule_options)

Sets rule type options.

public

Parameters
int

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

Referenced by setData().

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

◆ setRuleType()

ilStartingPoint::setRuleType (   $a_rule_type)

Sets rule type.

public

Parameters
int

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

Referenced by setData().

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

◆ setStartingObject()

ilStartingPoint::setStartingObject (   $a_starting_object)

Sets the starting object.

public

Parameters
int

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

Referenced by setData().

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

◆ setStartingPoint()

ilStartingPoint::setStartingPoint (   $a_starting_point)

Sets the starting point.

public

Parameters
int

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

Referenced by setData().

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

◆ update()

ilStartingPoint::update ( )

update starting point

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

References $DIC, $ilDB, getPosition(), getRuleOptions(), getRuleType(), getStartingObject(), and getStartingPoint().

323  {
324  global $DIC;
325 
326  $ilDB = $DIC['ilDB'];
327 
328  $ilDB->manipulateF(
329  'UPDATE usr_starting_point
330  SET starting_point = %s,
331  starting_object = %s,
332  position = %s,
333  rule_type = %s,
334  rule_options = %s
335  WHERE id = %s',
336  array('integer', 'integer', 'integer', 'integer', 'text', 'integer'),
337  array($this->getStartingPoint(), $this->getStartingObject(), $this->getPosition(),
338  $this->getRuleType(), $this->getRuleOptions(), $this->id)
339  );
340  }
global $DIC
Definition: saml.php:7
getRuleOptions()
Gets the rule options.
getStartingObject()
Gets the starting object.
getPosition()
Gets the starting point position.
getRuleType()
Gets the rule type.
global $ilDB
getStartingPoint()
Gets the starting point.
+ Here is the call graph for this function:

Field Documentation

◆ $id

ilStartingPoint::$id
protected

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

Referenced by saveOrder().

◆ $rule_options

ilStartingPoint::$rule_options
protected

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

Referenced by getRuleOptions().

◆ $rule_type

ilStartingPoint::$rule_type
protected

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

Referenced by getRuleType().

◆ $starting_object

ilStartingPoint::$starting_object
protected

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

Referenced by getStartingObject().

◆ $starting_point

ilStartingPoint::$starting_point
protected

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

Referenced by getStartingPoint().

◆ $starting_position

ilStartingPoint::$starting_position
protected

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

Referenced by getPosition().

◆ FALLBACK_RULE

const ilStartingPoint::FALLBACK_RULE = 1

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

◆ ORDER_POSITION_MAX

const ilStartingPoint::ORDER_POSITION_MAX = 9999

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

◆ ORDER_POSITION_MIN

const ilStartingPoint::ORDER_POSITION_MIN = 0

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

◆ ROLE_BASED

◆ USER_SELECTION_RULE

const ilStartingPoint::USER_SELECTION_RULE = 3

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


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