ILIAS  release_8 Revision v8.24
ilStartingPoint Class Reference

Class ilStartingPoint. More...

+ Collaboration diagram for ilStartingPoint:

Public Member Functions

 __construct (int $a_id=0)
 
 setStartingPoint (int $a_starting_point)
 
 getStartingPoint ()
 
 setStartingObject (int $a_starting_object)
 
 getStartingObject ()
 
 setPosition (int $a_starting_position)
 
 getPosition ()
 
 setRuleType (int $a_rule_type)
 
 getRuleType ()
 
 setRuleOptions (string $a_rule_options)
 serialized string More...
 
 getCalendarView ()
 Gets calendar view. More...
 
 setCalendarView (int $calendar_view)
 Sets calendar view. More...
 
 getCalendarPeriod ()
 
 setCalendarPeriod (int $calendar_period)
 
 getRuleOptions ()
 
 save ()
 insert starting point into database More...
 
 update ()
 update starting point More...
 
 delete ()
 delete starting point More...
 
 getMaxPosition ()
 
 saveOrder (array $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 (array $a_items)
 

Data Fields

const FALLBACK_RULE = 1
 
const ROLE_BASED = 2
 
const USER_SELECTION_RULE = 3
 

Protected Attributes

const ORDER_POSITION_MIN = 0
 
const ORDER_POSITION_MAX = 9999
 
int $starting_point = null
 
int $starting_object = null
 
int $starting_position = null
 
int $rule_type = null
 
string $rule_options = null
 
int $id
 
int $calendar_view = null
 
int $calendar_period = null
 
ilDBInterface $db
 

Private Member Functions

 setData ()
 

Detailed Description

Class ilStartingPoint.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilStartingPoint::__construct ( int  $a_id = 0)

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

48 {
49 global $DIC;
50
51 $this->db = $DIC->database();
52 $this->id = $a_id;
53 $this->setData();
54 }
global $DIC
Definition: feed.php:28

References $DIC, and setData().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilStartingPoint::delete ( )

delete starting point

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

333 : void
334 {
335 $query = "DELETE FROM usr_starting_point WHERE id = " . $this->db->quote($this->id, "integer");
336 $this->db->manipulate($query);
337 }
$query

References $query.

◆ getCalendarPeriod()

ilStartingPoint::getCalendarPeriod ( )

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

136 : int
137 {
139 }

References $calendar_period.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getCalendarView()

ilStartingPoint::getCalendarView ( )

Gets calendar view.

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

123 : int
124 {
126 }

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.

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

228 : array
229 {
230 global $DIC;
231
232 $rbacreview = $DIC['rbacreview'];
233 $global_roles = $rbacreview->getGlobalRoles();
234 $roles_with_starting_point = self::getRolesWithStartingPoint();
235
236 $ids_roles_with_sp = array();
237 foreach ($roles_with_starting_point as $role) {
238 $ids_roles_with_sp[] = $role['role_id'];
239 }
240
241 $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
242
243 $roles = array();
244 foreach ($ids_roles_without_sp as $roleid) {
245 if ($roleid === ANONYMOUS_ROLE_ID) {
246 continue;
247 }
248 $role_obj = new ilObjRole($roleid);
249 $roles[] = array(
250 "id" => $role_obj->getId(),
251 "title" => $role_obj->getTitle(),
252 );
253 }
254
255 return $roles;
256 }
Class ilObjRole.
static getRolesWithStartingPoint()
get array with all roles which have starting point defined.
const ANONYMOUS_ROLE_ID
Definition: constants.php:28

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 ( )

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

339 : int
340 {
341 //get max order number
342 $result = $this->db->query("SELECT max(position) as max_order FROM usr_starting_point");
343
344 $order_val = 0;
345 while ($row = $this->db->fetchAssoc($result)) {
346 $order_val = (int) $row['max_order'];
347 }
348 return $order_val;
349 }

References ILIAS\Repository\int().

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPosition()

ilStartingPoint::getPosition ( )

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

97 : int
98 {
100 }

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<int, array{"id": int, "starting_point": int, "starting_object": int, "calendar_view": int, "calendar_period": int, "position": int, "role_id": int}>

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

199 : array
200 {
201 global $DIC;
202
203 $ilDB = $DIC['ilDB'];
204 $query = "SELECT * FROM usr_starting_point WHERE rule_options LIKE %s";
205 $res = $ilDB->queryF($query, ['text'], ["%role_id%"]);
206
207 $roles = [];
208 while ($sp = $ilDB->fetchAssoc($res)) {
209 $options = unserialize($sp['rule_options']);
210
211 $roles[(int) $options['role_id']] = [
212 "id" => (int) $sp['id'],
213 "starting_point" => (int) $sp['starting_point'],
214 "starting_object" => (int) $sp['starting_object'],
215 "calendar_view" => (int) $sp['calendar_view'],
216 "calendar_period" => (int) $sp['calendar_period'],
217 "position" => (int) $sp['position'],
218 "role_id" => (int) $options['role_id'],
219
220 ];
221 }
222 return $roles;
223 }
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $query, $res, and ILIAS\Repository\int().

Referenced by getGlobalRolesWithoutStartingPoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRuleOptions()

ilStartingPoint::getRuleOptions ( )

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

146 : ?string
147 {
148 return $this->rule_options;
149 }

References $rule_options.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getRuleType()

ilStartingPoint::getRuleType ( )

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

107 : int
108 {
109 return $this->rule_type;
110 }

References $rule_type.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getStartingObject()

ilStartingPoint::getStartingObject ( )

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

87 : int
88 {
90 }

References $starting_object.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getStartingPoint()

ilStartingPoint::getStartingPoint ( )

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

77 : int
78 {
80 }

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.

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

154 : array
155 {
156 global $DIC;
157
158 $ilDB = $DIC['ilDB'];
159
160 $query = "SELECT * FROM usr_starting_point";
161 $res = $ilDB->query($query);
162 $points = array();
163 while ($point = $ilDB->fetchAssoc($res)) {
164 $points[] = array(
165 "id" => $point["id"],
166 "position" => $point["position"],
167 "starting_point" => $point['starting_point'],
168 "starting_object" => $point['starting_object'],
169 "calendar_view" => $point['calendar_view'],
170 "calendar_period" => $point['calendar_period'],
171 "rule_type" => $point['rule_type'],
172 "rule_options" => $point['rule_options']
173 );
174 }
175
176 return $points;
177 }

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

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

179 : void
180 {
181 foreach (self::getRolesWithStartingPoint() as $roleId => $data) {
182 if ($roleId === $role->getId()) {
183 $sp = new self((int) $data['id']);
184 $sp->delete();
185 } elseif (
186 is_null($maybeDeletedRole = ilObjectFactory::getInstanceByObjId($roleId, false)) ||
187 !($maybeDeletedRole instanceof ilObjRole)
188 ) {
189 $sp = new self((int) $data['id']);
190 $sp->delete();
191 }
192 }
193 }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

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

+ Here is the call graph for this function:

◆ reArrangePositions()

static ilStartingPoint::reArrangePositions ( array  $a_items)
static

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

351 : array
352 {
353 $ord_const = 0;
354 $rearranged = [];
355 foreach ($a_items as $v) {
356 $v['starting_position'] = $ord_const;
357 $rearranged[$ord_const] = $v;
358 $ord_const += 10;
359 }
360 return $rearranged;
361 }

Referenced by ilUserRoleStartingPointTableGUI\getItems().

+ Here is the caller graph for this function:

◆ save()

ilStartingPoint::save ( )

insert starting point into database

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

261 : void
262 {
263 //get position
264 $max_position = $this->getMaxPosition();
265 $position = $max_position + 10;
266
267 $next_id = $this->db->nextId('usr_starting_point');
268 $values = array(
269 $next_id,
270 $this->getStartingPoint(),
271 $this->getStartingObject(),
272 $position,
273 $this->getRuleType(),
274 $this->getRuleOptions(),
275 $this->getCalendarView(),
276 $this->getCalendarPeriod()
277 );
278
279 $this->db->manipulateF(
280 "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)",
289 ),
290 $values
291 );
292 }
getCalendarView()
Gets calendar view.

References 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 ( array  $a_items)

Save all starting point positions.

Ordering values with increment +10

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

366 : void
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 $this->db->manipulate(
373 "UPDATE usr_starting_point SET" .
374 " position = " . $this->db->quote($nr, 'integer') .
375 " WHERE id = " . $this->db->quote($id, 'integer')
376 );
377 $nr += 10;
378 }
379 }
380 }

References $id.

◆ setCalendarPeriod()

ilStartingPoint::setCalendarPeriod ( int  $calendar_period)

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

141 : void
142 {
143 $this->calendar_period = $calendar_period;
144 }

References $calendar_period.

Referenced by setData().

+ Here is the caller graph for this function:

◆ setCalendarView()

ilStartingPoint::setCalendarView ( int  $calendar_view)

Sets calendar view.

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

131 : void
132 {
133 $this->calendar_view = $calendar_view;
134 }

References $calendar_view.

Referenced by setData().

+ Here is the caller graph for this function:

◆ setData()

ilStartingPoint::setData ( )
private

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

56 : void
57 {
58 $query = "SELECT * FROM usr_starting_point WHERE id = " . $this->db->quote($this->id, 'integer');
59 $res = $this->db->query($query);
60
61 while ($point = $this->db->fetchAssoc($res)) {
62 $this->setStartingPoint((int) $point['starting_point']);
63 $this->setRuleOptions((string) $point['rule_options']);
64 $this->setPosition((int) $point['position']);
65 $this->setStartingObject((int) $point['starting_object']);
66 $this->setRuleType((int) $point['rule_type']);
67 $this->setCalendarView((int) $point['calendar_view']);
68 $this->setCalendarPeriod((int) $point['calendar_period']);
69 }
70 }
setRuleOptions(string $a_rule_options)
serialized string
setRuleType(int $a_rule_type)
setStartingObject(int $a_starting_object)
setCalendarPeriod(int $calendar_period)
setStartingPoint(int $a_starting_point)
setCalendarView(int $calendar_view)
Sets calendar view.
setPosition(int $a_starting_position)

References $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 ( int  $a_starting_position)

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

92 : void
93 {
94 $this->starting_position = $a_starting_position;
95 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setRuleOptions()

ilStartingPoint::setRuleOptions ( string  $a_rule_options)

serialized string

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

115 : void
116 {
117 $this->rule_options = $a_rule_options;
118 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setRuleType()

ilStartingPoint::setRuleType ( int  $a_rule_type)

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

102 : void
103 {
104 $this->rule_type = $a_rule_type;
105 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setStartingObject()

ilStartingPoint::setStartingObject ( int  $a_starting_object)

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

82 : void
83 {
84 $this->starting_object = $a_starting_object;
85 }

Referenced by setData().

+ Here is the caller graph for this function:

◆ setStartingPoint()

ilStartingPoint::setStartingPoint ( int  $a_starting_point)

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

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

Referenced by setData().

+ Here is the caller graph for this function:

◆ update()

ilStartingPoint::update ( )

update starting point

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

297 : void
298 {
299 $this->db->manipulateF(
300 'UPDATE usr_starting_point
301 SET starting_point = %s,
302 starting_object = %s,
303 position = %s,
304 rule_type = %s,
305 rule_options = %s,
306 calendar_view = %s,
307 calendar_period = %s
308 WHERE id = %s',
317 ),
318 array($this->getStartingPoint(),
319 $this->getStartingObject(),
320 $this->getPosition(),
321 $this->getRuleType(),
322 $this->getRuleOptions(),
323 $this->getCalendarView(),
324 $this->getCalendarPeriod(),
325 $this->id
326 )
327 );
328 }

References 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

int ilStartingPoint::$calendar_period = null
protected

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

Referenced by getCalendarPeriod(), and setCalendarPeriod().

◆ $calendar_view

int ilStartingPoint::$calendar_view = null
protected

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

Referenced by getCalendarView(), and setCalendarView().

◆ $db

ilDBInterface ilStartingPoint::$db
protected

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

◆ $id

int ilStartingPoint::$id
protected

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

Referenced by saveOrder().

◆ $rule_options

string ilStartingPoint::$rule_options = null
protected

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

Referenced by getRuleOptions().

◆ $rule_type

int ilStartingPoint::$rule_type = null
protected

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

Referenced by getRuleType().

◆ $starting_object

int ilStartingPoint::$starting_object = null
protected

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

Referenced by getStartingObject().

◆ $starting_point

int ilStartingPoint::$starting_point = null
protected

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

Referenced by getStartingPoint().

◆ $starting_position

int ilStartingPoint::$starting_position = null
protected

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

Referenced by getPosition().

◆ FALLBACK_RULE

const ilStartingPoint::FALLBACK_RULE = 1

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

◆ ORDER_POSITION_MAX

const ilStartingPoint::ORDER_POSITION_MAX = 9999
protected

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

◆ ORDER_POSITION_MIN

const ilStartingPoint::ORDER_POSITION_MIN = 0
protected

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

◆ ROLE_BASED

◆ USER_SELECTION_RULE

const ilStartingPoint::USER_SELECTION_RULE = 3

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


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