ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 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$ @ilCtrl_Calls ilStartingPoint:

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

314 {
315 global $ilDB;
316
317 $query = "DELETE FROM usr_starting_point WHERE id = " . $ilDB->quote($this->id, "integer");
318 $ilDB->manipulate($query);
319 }
$query
global $ilDB

References $ilDB, and $query.

◆ getGlobalRolesWithoutStartingPoint()

static ilStartingPoint::getGlobalRolesWithoutStartingPoint ( )
static

Get id and title of the roles without starting points.

Returns
array

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

233 {
234 global $rbacreview;
235
236 require_once "./Services/AccessControl/classes/class.ilObjRole.php";
237
238 $global_roles = $rbacreview->getGlobalRoles();
239
240 $roles_with_starting_point = self::getRolesWithStartingPoint();
241
242 $ids_roles_with_sp = array();
243 foreach ($roles_with_starting_point as $role) {
244 array_push($ids_roles_with_sp, $role['role_id']);
245 }
246
247 $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
248
249 $roles = array();
250 foreach ($ids_roles_without_sp as $roleid) {
251 $role_obj = new ilObjRole($roleid);
252 $roles[] = array(
253 "id" => $role_obj->getId(),
254 "title" => $role_obj->getTitle(),
255 );
256 }
257
258 return $roles;
259 }
Class ilObjRole.
static getRolesWithStartingPoint()
get array with all roles which have starting point defined.

References 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 326 of file class.ilStartingPoint.php.

327 {
328 global $ilDB;
329
330 //get max order number
331 $result = $ilDB->query("SELECT max(position) as max_order FROM usr_starting_point");
332
333 while ($row = $ilDB->fetchAssoc($result)) {
334 $order_val = (int) $row['max_order'];
335 }
336 return $order_val;
337 }
$result

References $ilDB, $result, and $row.

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 126 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 205 of file class.ilStartingPoint.php.

206 {
207 global $ilDB;
208
209 $query = "SELECT * FROM usr_starting_point WHERE rule_options LIKE %s";
210 $res = $ilDB->queryF($query, array('text'), array("%role_id%"));
211
212 $roles = array();
213 while ($sp = $ilDB->fetchAssoc($res)) {
214 $options = unserialize($sp['rule_options']);
215
216 $roles[$options['role_id']] = array(
217 "id" => $sp['id'],
218 "starting_point" => $sp['starting_point'],
219 "starting_object" => $sp['starting_object'],
220 "position" => $sp['position'],
221 "role_id" => $options['role_id'],
222
223 );
224 }
225 return $roles;
226 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
foreach($_POST as $key=> $value) $res

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

Referenced by getGlobalRolesWithoutStartingPoint(), and ilUserUtil\getStartingPointAsUrl().

+ Here is the caller graph for this function:

◆ getRuleOptions()

ilStartingPoint::getRuleOptions ( )

Gets the rule options.

@access public

Returns
int

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

172 {
173 return $this->rule_options;
174 }

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 148 of file class.ilStartingPoint.php.

149 {
150 return $this->rule_type;
151 }

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 104 of file class.ilStartingPoint.php.

105 {
107 }

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 82 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 180 of file class.ilStartingPoint.php.

181 {
182 global $ilDB;
183
184 $query = "SELECT * FROM usr_starting_point";
185 $res = $ilDB->query($query);
186 $points = array();
187 while ($point = $ilDB->fetchAssoc($res)) {
188 $points[] = array(
189 "id" => $point["id"],
190 "position" => $point["position"],
191 "starting_point" => $point['starting_point'],
192 "starting_object" => $point['starting_object'],
193 "rule_type" => $point['rule_type'],
194 "rule_options" => $point['rule_options']
195 );
196 }
197
198 return $points;
199 }

References $ilDB, $query, and $res.

Referenced by ilUserRoleStartingPointTableGUI\getItems().

+ Here is the caller graph for this function:

◆ reArrangePositions()

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

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

344 {
345 //first and last items doesn't have order position, are fixed.
346 $ord_const = 10;
347 foreach ($a_items as $k => $v) {
348 if ($k > 0) {
349 $item = $v;
350 $item['starting_position'] = $ord_const;
351 unset($a_items[$k]);
352 $a_items[$ord_const] = $item;
353 $ord_const = $ord_const + 10;
354 }
355 }
356
357 return $a_items;
358 }

Referenced by ilUserRoleStartingPointTableGUI\getItems().

+ Here is the caller graph for this function:

◆ save()

ilStartingPoint::save ( )

insert starting point into database

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

265 {
266 global $ilDB;
267
268 //get position
269 $max_position = $this->getMaxPosition();
270 $position = $max_position + 10;
271
272 $next_id = $ilDB->nextId('usr_starting_point');
273 $values = array(
274 $next_id,
275 $this->getStartingPoint(),
276 $this->getStartingObject(),
277 $position,
278 $this->getRuleType(),
279 $this->getRuleOptions()
280 );
281
282 $ilDB->manipulateF(
283 "INSERT INTO usr_starting_point (id, starting_point, starting_object, position, rule_type, rule_options) VALUES (%s, %s, %s, %s, %s, %s)",
284 array('integer', 'integer', 'integer', 'integer', 'integer', 'text'),
285 $values
286 );
287 }
getStartingObject()
Gets the starting object.
getRuleType()
Gets the rule type.
getRuleOptions()
Gets the rule options.
getStartingPoint()
Gets the starting point.

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

+ 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 364 of file class.ilStartingPoint.php.

365 {
366 global $ilDB;
367
368 asort($a_items);
369 $nr = 10;
370 foreach ($a_items as $id => $position) {
371 if ($position > self::ORDER_POSITION_MIN && $position < self::ORDER_POSITION_MAX) {
372 $ilDB->manipulate(
373 "UPDATE usr_starting_point SET" .
374 " position = " . $ilDB->quote($nr, 'integer') .
375 " WHERE id = " . $ilDB->quote($id, 'integer')
376 );
377 $nr+=10;
378 }
379 }
380 }

References $id, and $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.

50 {
51 global $ilDB;
52
53 $query = "SELECT * FROM usr_starting_point WHERE id = " . $ilDB->quote($a_id, 'integer');
54 $res = $ilDB->query($query);
55
56 while ($point = $ilDB->fetchAssoc($res)) {
57 $this->setStartingPoint($point['starting_point']);
58 $this->setRuleOptions($point['rule_options']);
59 $this->setPosition($point['position']);
60 $this->setStartingObject($point['starting_object']);
61 $this->setRuleType($point['rule_type']);
62 }
63 }
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.
setStartingPoint($a_starting_point)
Sets the starting point.

References $ilDB, $query, $res, 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 115 of file class.ilStartingPoint.php.

116 {
117 $this->starting_position = $a_starting_position;
118 }

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 159 of file class.ilStartingPoint.php.

160 {
161 $this->rule_options = $a_rule_options;
162 }

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 137 of file class.ilStartingPoint.php.

138 {
139 $this->rule_type = $a_rule_type;
140 }

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 93 of file class.ilStartingPoint.php.

94 {
95 $this->starting_object = $a_starting_object;
96 }

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 71 of file class.ilStartingPoint.php.

72 {
73 $this->starting_point = $a_starting_point;
74 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ update()

ilStartingPoint::update ( )

update starting point

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

293 {
294 global $ilDB;
295
296 $ilDB->manipulateF(
297 'UPDATE usr_starting_point
298 SET starting_point = %s,
299 starting_object = %s,
300 position = %s,
301 rule_type = %s,
302 rule_options = %s
303 WHERE id = %s',
304 array('integer', 'integer', 'integer', 'integer', 'text', 'integer'),
305 array($this->getStartingPoint(), $this->getStartingObject(), $this->getPosition(),
306 $this->getRuleType(), $this->getRuleOptions(), $this->id)
307 );
308 }
getPosition()
Gets the starting point position.

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

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