ILIAS  release_4-4 Revision
ilObjectActivation Class Reference

Class ilObjectActivation. More...

+ Inheritance diagram for ilObjectActivation:
+ Collaboration diagram for ilObjectActivation:

Public Member Functions

 __construct ()
 
 setTimingType ($a_type)
 Set timing type. More...
 
 getTimingType ()
 get timing type More...
 
 setTimingStart ($a_start)
 Set timing start. More...
 
 getTimingStart ()
 Get timing start. More...
 
 setTimingEnd ($a_end)
 Set timing end. More...
 
 getTimingEnd ()
 Get timing end. More...
 
 setSuggestionStart ($a_start)
 Set suggestion start. More...
 
 getSuggestionStart ()
 Get suggestion start. More...
 
 setSuggestionEnd ($a_end)
 Set suggestion end. More...
 
 getSuggestionEnd ()
 Get suggestion end. More...
 
 setEarliestStart ($a_start)
 Set earliest start. More...
 
 getEarliestStart ()
 Get earliest start. More...
 
 setLatestEnd ($a_end)
 Set latest end. More...
 
 getLatestEnd ()
 Get latest end. More...
 
 toggleVisible ($a_status)
 Set visible status. More...
 
 enabledVisible ()
 Get visible status. More...
 
 toggleChangeable ($a_status)
 Set changeable status. More...
 
 enabledChangeable ()
 Get changeable status. More...
 
 validateActivation ()
 Validate current properties. More...
 
 update ($a_ref_id, $a_parent_id=null)
 Update db entry. More...
 

Static Public Member Functions

static preloadData (array $a_ref_ids)
 Preload data to internal cache. More...
 
static getItem ($a_ref_id)
 Get item data. More...
 
static addAdditionalSubItemInformation (array &$a_item)
 Parse item data for list entries. More...
 
static addListGUIActivationProperty (ilObjectListGUI $a_list_gui, array &$a_item)
 Get timing details for list gui. More...
 
static deleteAllEntries ($a_ref_id)
 Delete all db entries for ref id. More...
 
static cloneDependencies ($a_ref_id, $a_target_id, $a_copy_id)
 Clone dependencies. More...
 
static hasTimings ($a_ref_id)
 Check if there is any active timing (in subtree) More...
 
static hasChangeableTimings ($a_ref_id)
 Check if there is any active changeable timing (in subtree) More...
 
static getItemsByEvent ($a_event_id)
 Get session material / event items. More...
 
static getItemsByItemGroup ($a_item_group_ref_id)
 Get materials of item group. More...
 
static getItemsByObjective ($a_objective_id)
 Get objective items. More...
 
static getItems ($a_parent_id, $a_with_list_data=true)
 Get sub item data. More...
 
static getTimingsAdministrationItems ($a_parent_id)
 Get (sub) item data for timings administration view (active/inactive) More...
 
static getTimingsItems ($a_container_ref_id)
 Get (sub) item data for timings view (no session material, no side blocks) More...
 

Data Fields

const TIMINGS_ACTIVATION = 0
 
const TIMINGS_DEACTIVATED = 1
 
const TIMINGS_PRESETTING = 2
 
const TIMINGS_FIXED = 3
 

Static Protected Member Functions

static createDefaultEntry ($a_ref_id)
 Create db entry with default values. More...
 
static processListItems (array $a_ref_ids)
 Validate ref ids and add list data. More...
 

Protected Attributes

 $timing_type
 
 $timing_start
 
 $timing_end
 
 $suggestion_start
 
 $suggestion_end
 
 $earliest_start
 
 $latest_end
 
 $visible
 
 $changeable
 

Static Protected Attributes

static $preloaded_data = array()
 

Detailed Description

Class ilObjectActivation.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilCourseItems.php 30321 2011-08-22 12:05:03Z jluetzen

Definition at line 12 of file class.ilObjectActivation.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectActivation::__construct ( )

Definition at line 31 of file class.ilObjectActivation.php.

32  {
33 
34  }

Member Function Documentation

◆ addAdditionalSubItemInformation()

static ilObjectActivation::addAdditionalSubItemInformation ( array &  $a_item)
static

Parse item data for list entries.

Parameters
array&$a_item

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

References $ilUser, ilTimingPlaned\_getPlanedTimings(), ilSessionAppointment\_lookupAppointment(), ilObject\_lookupObjId(), and ilObject\_lookupType().

Referenced by ilObjRootFolder\addAdditionalSubItemInformation(), ilObjCategory\addAdditionalSubItemInformation(), ilObjFolder\addAdditionalSubItemInformation(), ilObjGroup\addAdditionalSubItemInformation(), and ilObjCourse\addAdditionalSubItemInformation().

341  {
342  global $ilUser;
343 
344  $item = self::getItem($a_item['ref_id']);
345 
346  $a_item['obj_id'] = ($a_item['obj_id'] > 0)
347  ? $a_item['obj_id']
348  : ilObject::_lookupObjId($a_item['ref_id']);
349  $a_item['type'] = ($a_item['type'] != '')
350  ? $a_item['type']
351  : ilObject::_lookupType($a_item['obj_id']);
352 
353  $a_item['timing_type'] = $item['timing_type'];
354 
355  if($item['changeable'] &&
356  $item['timing_type'] == self::TIMINGS_PRESETTING)
357  {
358  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
359  $user_data = ilTimingPlaned::_getPlanedTimings($ilUser->getId(), $a_item['ref_id']);
360  if($user_data['planed_start'])
361  {
362  $a_item['start'] = $user_data['planed_start'];
363  $a_item['end'] = $user_data['planed_end'];
364  $a_item['activation_info'] = 'crs_timings_planed_info';
365  }
366  else
367  {
368  $a_item['start'] = $item['suggestion_start'];
369  $a_item['end'] = $item['suggestion_end'];
370  $a_item['activation_info'] = 'crs_timings_suggested_info';
371  }
372  }
373  elseif($item['timing_type'] == self::TIMINGS_PRESETTING)
374  {
375  $a_item['start'] = $item['suggestion_start'];
376  $a_item['end'] = $item['suggestion_end'];
377  $a_item['activation_info'] = 'crs_timings_suggested_info';
378  }
379  elseif($item['timing_type'] == self::TIMINGS_ACTIVATION)
380  {
381  $a_item['start'] = $item['timing_start'];
382  $a_item['end'] = $item['timing_end'];
383  $a_item['activation_info'] = 'obj_activation_list_gui';
384  }
385  else
386  {
387  $a_item['start'] = 'abc';
388  }
389 
390  // #7359 - session sorting should always base on appointment date
391  if($a_item['type'] == 'sess')
392  {
393  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
394  $info = ilSessionAppointment::_lookupAppointment($a_item['obj_id']);
395 
396  // #11987
397  $a_item['masked_start'] = $a_item['start'];
398  $a_item['masked_end'] = $a_item['end'];
399  $a_item['start'] = $info['start'];
400  $a_item['end'] = $info['end'];
401  }
402  }
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
_getPlanedTimings($a_usr_id, $a_item_id)
global $ilUser
Definition: imgupload.php:15
static _lookupAppointment($a_obj_id)
lookup appointment
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addListGUIActivationProperty()

static ilObjectActivation::addListGUIActivationProperty ( ilObjectListGUI  $a_list_gui,
array &  $a_item 
)
static

Get timing details for list gui.

Parameters
ilObjectListGUI$a_list_gui
array&$a_item
Returns
array caption, value

Definition at line 411 of file class.ilObjectActivation.php.

References $lng, ilObjectListGUI\addCustomProperty(), ilDatePresentation\formatPeriod(), IL_CAL_UNIX, TIMINGS_ACTIVATION, and TIMINGS_PRESETTING.

Referenced by ilSearchResultTableGUI\fillRow(), ilPDSelectedItemsBlockGUI\getMembershipItemsPerLocation(), ilPDSelectedItemsBlockGUI\getMembershipItemsPerType(), ilPDSelectedItemsBlockGUI\getSelectedItemsPerLocation(), ilPDSelectedItemsBlockGUI\getSelectedItemsPerType(), ilObjSessionGUI\modifyItemGUI(), and ilContainerContentGUI\renderItem().

412  {
413  global $lng;
414 
415  self::addAdditionalSubItemInformation($a_item);
416  if(isset($a_item['timing_type']))
417  {
418  if(!isset($a_item['masked_start']))
419  {
420  $start = $a_item['start'];
421  $end = $a_item['end'];
422  }
423  else
424  {
425  $start = $a_item['masked_start'];
426  $end = $a_item['masked_end'];
427  }
428  $activation = '';
429  switch($a_item['timing_type'])
430  {
432  $activation = ilDatePresentation::formatPeriod(
433  new ilDateTime($start,IL_CAL_UNIX),
434  new ilDateTime($end,IL_CAL_UNIX));
435  break;
436 
438  $activation = ilDatePresentation::formatPeriod(
439  new ilDate($start,IL_CAL_UNIX),
440  new ilDate($end,IL_CAL_UNIX));
441  break;
442  }
443  if ($activation != "")
444  {
445  global $lng;
446  $lng->loadLanguageModule('crs');
447 
448  $a_list_gui->addCustomProperty($lng->txt($a_item['activation_info']),
449  $activation, false, true);
450  }
451  }
452  }
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
const IL_CAL_UNIX
Class for single dates.
Date and time handling
addCustomProperty($a_property="", $a_value="", $a_alert=false, $a_newline=false)
add custom property
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneDependencies()

static ilObjectActivation::cloneDependencies (   $a_ref_id,
  $a_target_id,
  $a_copy_id 
)
static

Clone dependencies.

Parameters
int$a_ref_id
int$a_target_id
int$a_copy_id

Definition at line 558 of file class.ilObjectActivation.php.

References $ilLog, ilCopyWizardOptions\_getInstance(), and ilObjectFactory\getInstanceByRefId().

Referenced by ilObjFolder\cloneDependencies(), ilObjGroup\cloneDependencies(), and ilObjCourse\cloneDependencies().

559  {
560  global $ilLog;
561 
562  $ilLog->write(__METHOD__.': Begin course items...');
563 
564  $items = self::getItems($a_ref_id);
565  if(!$items)
566  {
567  $ilLog->write(__METHOD__.': No course items found.');
568  return true;
569  }
570 
571  // new course item object
572  if(!is_object($new_container = ilObjectFactory::getInstanceByRefId($a_target_id,false)))
573  {
574  $ilLog->write(__METHOD__.': Cannot create target object.');
575  return false;
576  }
577 
578  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
579  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
580  $mappings = $cp_options->getMappings();
581 
582  foreach($items as $item)
583  {
584  if(!isset($mappings[$item['parent_id']]) or !$mappings[$item['parent_id']])
585  {
586  $ilLog->write(__METHOD__.': No mapping for parent nr. '.$item['parent_id']);
587  continue;
588  }
589  if(!isset($mappings[$item['obj_id']]) or !$mappings[$item['obj_id']])
590  {
591  $ilLog->write(__METHOD__.': No mapping for item nr. '.$item['obj_id']);
592  continue;
593  }
594  $new_item_id = $mappings[$item['obj_id']];
595  $new_parent = $mappings[$item['parent_id']];
596 
597  $new_item = new self();
598  $new_item->setTimingType($item['timing_type']);
599  $new_item->setTimingStart($item['timing_start']);
600  $new_item->setTimingEnd($item['timing_end']);
601  $new_item->setSuggestionStart($item['suggestion_start']);
602  $new_item->setSuggestionEnd($item['suggestion_end']);
603  $new_item->toggleChangeable($item['changeable']);
604  $new_item->setEarliestStart($item['earliest_start']);
605  $new_item->setLatestEnd($item['latest_end']);
606  $new_item->toggleVisible($item['visible']);
607  $new_item->update($new_item_id, $new_parent);
608 
609  $ilLog->write(__METHOD__.': Added new entry for item nr. '.$item['obj_id']);
610  }
611  $ilLog->write(__METHOD__.': Finished course items.');
612  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getInstance($a_copy_id)
Get instance of copy wizard options.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDefaultEntry()

static ilObjectActivation::createDefaultEntry (   $a_ref_id)
staticprotected

Create db entry with default values.

Parameters
int$a_ref_id
Returns
array

Definition at line 460 of file class.ilObjectActivation.php.

References $query, and ilDB\LOCK_WRITE.

461  {
462  global $ilDB, $tree;
463 
464  $parent_id = $tree->getParentId($a_ref_id);
465  if(!$parent_id)
466  {
467  return;
468  }
469 
470  // #10077
471  $ilDB->lockTables(array(
472  array("name" => "crs_items",
473  "type" => ilDB::LOCK_WRITE,
474  "alias" => "")
475  ));
476 
477  $sql = "SELECT * FROM crs_items".
478  " WHERE obj_id = ".$ilDB->quote($a_ref_id, "integer");
479  $set = $ilDB->query($sql);
480  if(!$ilDB->numRows($set))
481  {
482  $now = time();
483  $now_parts = getdate($now);
484 
485  $a_item = array();
486  $a_item["timing_type"] = self::TIMINGS_DEACTIVATED;
487  $a_item["timing_start"] = $now;
488  $a_item["timing_end"] = $now;
489  $a_item["suggestion_start"] = $now;
490  $a_item["suggestion_end"] = $now;
491  $a_item['visible'] = 0;
492  $a_item['changeable'] = 0;
493  $a_item['earliest_start'] = $now;
494  $a_item['latest_end'] = mktime(23,55,00,$now_parts["mon"],$now_parts["mday"],$now_parts["year"]);
495  $a_item['visible'] = 0;
496  $a_item['changeable'] = 0;
497 
498  $query = "INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,timing_end," .
499  "suggestion_start,suggestion_end, ".
500  "changeable,earliest_start,latest_end,visible,position) ".
501  "VALUES( ".
502  $ilDB->quote($parent_id,'integer').",".
503  $ilDB->quote($a_ref_id,'integer').",".
504  $ilDB->quote($a_item["timing_type"],'integer').",".
505  $ilDB->quote($a_item["timing_start"],'integer').",".
506  $ilDB->quote($a_item["timing_end"],'integer').",".
507  $ilDB->quote($a_item["suggestion_start"],'integer').",".
508  $ilDB->quote($a_item["suggestion_end"],'integer').",".
509  $ilDB->quote($a_item["changeable"],'integer').",".
510  $ilDB->quote($a_item['earliest_start'],'integer').", ".
511  $ilDB->quote($a_item['latest_end'],'integer').", ".
512  $ilDB->quote($a_item["visible"],'integer').", ".
513  $ilDB->quote(0,'integer').")";
514  $ilDB->manipulate($query);
515  }
516 
517  $ilDB->unlockTables();
518 
519  // #9982 - to make getItem()-cache work
520  $a_item["obj_id"] = $a_ref_id;
521  $a_item["parent_id"] = $parent_id;
522 
523  return $a_item;
524  }
const LOCK_WRITE
Definition: class.ilDB.php:30

◆ deleteAllEntries()

static ilObjectActivation::deleteAllEntries (   $a_ref_id)
static

Delete all db entries for ref id.

Parameters
int$a_ref_id

Definition at line 531 of file class.ilObjectActivation.php.

References $query.

Referenced by ilObject\delete(), and ilObjPoll\doDelete().

532  {
533  global $ilDB;
534 
535  if(!$a_ref_id)
536  {
537  return;
538  }
539 
540  $query = "DELETE FROM crs_items ".
541  "WHERE obj_id = ".$ilDB->quote($a_ref_id,'integer');
542  $ilDB->manipulate($query);
543 
544  $query = "DELETE FROM crs_items ".
545  "WHERE parent_id = ".$ilDB->quote($a_ref_id,'integer');
546  $ilDB->manipulate($query);
547 
548  return true;
549  }
+ Here is the caller graph for this function:

◆ enabledChangeable()

ilObjectActivation::enabledChangeable ( )

Get changeable status.

Returns
bool

Definition at line 213 of file class.ilObjectActivation.php.

References $changeable.

Referenced by update().

214  {
215  return (bool) $this->changeable;
216  }
+ Here is the caller graph for this function:

◆ enabledVisible()

ilObjectActivation::enabledVisible ( )

Get visible status.

Returns
bool

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

References $visible.

Referenced by update().

194  {
195  return (bool) $this->visible;
196  }
+ Here is the caller graph for this function:

◆ getEarliestStart()

ilObjectActivation::getEarliestStart ( )

Get earliest start.

Returns
timestamp

Definition at line 153 of file class.ilObjectActivation.php.

Referenced by update().

154  {
155  return $this->earliest_start ? $this->earliest_start : mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
156  }
+ Here is the caller graph for this function:

◆ getItem()

static ilObjectActivation::getItem (   $a_ref_id)
static

Get item data.

Parameters
int$a_ref_id
Returns
array

Definition at line 310 of file class.ilObjectActivation.php.

References $row.

Referenced by ilObjectXMLWriter\__appendTimeTargets(), ilObjCourse\__readSettings(), ilTimingCache\_getTimings(), ilObjPollAccess\_isActivated(), ilObjCourseAccess\_isActivated(), ilObjSurvey\checkReminder(), ilAccessHandler\doActivationCheck(), ilObjPortfolioTemplate\doRead(), ilObjPoll\doRead(), ilObjectActivationGUI\getValues(), ilObjSurvey\loadFromDb(), ilObjTest\loadFromDb(), ilObjSurvey\saveToDb(), ilObjTest\saveToDb(), ilObjPortfolioTemplate\updateActivation(), ilSoapObjectAdministration\updateReferences(), ilObjCourse\updateSettings(), ilCourseContentGUI\updateTimings(), ilTimingPlaned\validate(), and ilContainerXmlWriter\writeCourseItemInformation().

311  {
312  global $ilDB;
313 
314  if(isset(self::$preloaded_data[$a_ref_id]))
315  {
316  return self::$preloaded_data[$a_ref_id];
317  }
318 
319  $sql = "SELECT * FROM crs_items".
320  " WHERE obj_id = ".$ilDB->quote($a_ref_id, "integer");
321  $set = $ilDB->query($sql);
322  $row = $ilDB->fetchAssoc($set);
323 
324  if(!isset($row["obj_id"]))
325  {
326  $row = self::createDefaultEntry($a_ref_id);
327  }
328  if($row["obj_id"])
329  {
330  self::$preloaded_data[$row["obj_id"]] = $row;
331  }
332  return $row;
333  }
+ Here is the caller graph for this function:

◆ getItems()

static ilObjectActivation::getItems (   $a_parent_id,
  $a_with_list_data = true 
)
static

Get sub item data.

Parameters
int$a_parent_id
bool$a_with_list_data
Returns
array

Definition at line 755 of file class.ilObjectActivation.php.

Referenced by ilCourseObjectivePresentationGUI\__getAllTests(), ilCourseObjectivePresentationGUI\__getOtherResources(), ilCourseStart\getPossibleStarters(), and ilCourseContentGUI\setColumnSettings().

756  {
757  global $tree;
758 
759  $items = array();
760 
761  $ref_ids = array();
762  foreach($tree->getChilds($a_parent_id) as $item)
763  {
764  if($item['type'] != 'rolf')
765  {
766  $items[] = $item;
767  $ref_ids[] = $item['ref_id'];
768  }
769  }
770 
771  if($ref_ids)
772  {
773  self::preloadData($ref_ids);
774 
775  foreach($items as $idx => $item)
776  {
777  if(!$a_with_list_data)
778  {
779  $items[$idx] = array_merge($item, self::getItem($item['ref_id']));
780  }
781  else
782  {
783  self::addAdditionalSubItemInformation($item);
784  $items[$idx] = $item;
785  }
786  }
787  }
788 
789  return $items;
790  }
+ Here is the caller graph for this function:

◆ getItemsByEvent()

static ilObjectActivation::getItemsByEvent (   $a_event_id)
static

Get session material / event items.

Parameters
int$a_event_id(object id)
Returns
array

Definition at line 714 of file class.ilObjectActivation.php.

Referenced by ilObjSessionGUI\infoScreen(), ilContainerGUI\redrawListItemObject(), and ilContainerContentGUI\renderItem().

715  {
716  include_once 'Modules/Session/classes/class.ilEventItems.php';
717  $event_items = new ilEventItems($a_event_id);
718  return self::processListItems($event_items->getItems());
719  }
class ilEvent
+ Here is the caller graph for this function:

◆ getItemsByItemGroup()

static ilObjectActivation::getItemsByItemGroup (   $a_item_group_ref_id)
static

Get materials of item group.

Parameters
int$a_item_group_id(object id)
Returns
array

Definition at line 727 of file class.ilObjectActivation.php.

Referenced by ilContainerContentGUI\renderItemGroup(), and ilRepositoryExplorerGUI\sortChilds().

728  {
729  include_once 'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
730  $ig_items = new ilItemGroupItems($a_item_group_ref_id);
731  $items = $ig_items->getValidItems();
732  return self::processListItems($items);
733  }
Item group items.
+ Here is the caller graph for this function:

◆ getItemsByObjective()

static ilObjectActivation::getItemsByObjective (   $a_objective_id)
static

Get objective items.

Parameters
int$a_objective_id
Returns
array

Definition at line 741 of file class.ilObjectActivation.php.

References ilCourseObjectiveMaterials\_getAssignedMaterials().

Referenced by ilContainerObjectiveGUI\renderObjective().

742  {
743  include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
744  $item_ids = ilCourseObjectiveMaterials::_getAssignedMaterials($a_objective_id);
745  return self::processListItems($item_ids);
746  }
static _getAssignedMaterials($a_objective_id)
get assigned materials
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLatestEnd()

ilObjectActivation::getLatestEnd ( )

Get latest end.

Returns
timestamp

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

Referenced by update().

174  {
175  return $this->latest_end ? $this->latest_end : mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
176  }
+ Here is the caller graph for this function:

◆ getSuggestionEnd()

ilObjectActivation::getSuggestionEnd ( )

Get suggestion end.

Returns
timestamp

Definition at line 133 of file class.ilObjectActivation.php.

Referenced by update(), and validateActivation().

134  {
135  return $this->suggestion_end ? $this->suggestion_end : mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
136  }
+ Here is the caller graph for this function:

◆ getSuggestionStart()

ilObjectActivation::getSuggestionStart ( )

Get suggestion start.

Returns
timestamp

Definition at line 113 of file class.ilObjectActivation.php.

Referenced by update(), and validateActivation().

114  {
115  return $this->suggestion_start ? $this->suggestion_start : mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
116  }
+ Here is the caller graph for this function:

◆ getTimingEnd()

ilObjectActivation::getTimingEnd ( )

Get timing end.

Returns
timestamp

Definition at line 93 of file class.ilObjectActivation.php.

References $timing_end.

Referenced by update(), and validateActivation().

94  {
95  return $this->timing_end;
96  }
+ Here is the caller graph for this function:

◆ getTimingsAdministrationItems()

static ilObjectActivation::getTimingsAdministrationItems (   $a_parent_id)
static

Get (sub) item data for timings administration view (active/inactive)

Parameters
int$a_parent_id
Returns
array

Definition at line 798 of file class.ilObjectActivation.php.

References ilUtil\sortArray().

Referenced by ilCourseContentGUI\__renderUserItem(), ilCourseContentGUI\editTimings(), and ilCourseContentGUI\showUserTimings().

799  {
800  $items = self::getItems($a_parent_id, false);
801 
802  if($items)
803  {
804  $active = $inactive = array();
805  foreach($items as $item)
806  {
807  // active should be first in order
808  if($item['timing_type'] == self::TIMINGS_DEACTIVATED)
809  {
810  $inactive[] = $item;
811  }
812  else
813  {
814  $active[] = $item;
815  }
816  }
817 
818  $active = ilUtil::sortArray($active,'start','asc');
819  $inactive = ilUtil::sortArray($inactive,'title','asc');
820  $items = array_merge($active,$inactive);
821  }
822 
823  return $items;
824  }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingsItems()

static ilObjectActivation::getTimingsItems (   $a_container_ref_id)
static

Get (sub) item data for timings view (no session material, no side blocks)

Parameters
int$a_container_ref_id
Returns
array

Definition at line 832 of file class.ilObjectActivation.php.

References ilEventItems\_getItemsOfContainer().

Referenced by ilCourseContentGUI\__editAdvancedUserTimings(), ilCourseContentGUI\__editUserTimings(), and ilCourseContentGUI\__renderItem().

833  {
834  global $objDefinition;
835 
836  $filtered = array();
837 
838  include_once 'Modules/Session/classes/class.ilEventItems.php';
839  $event_items = ilEventItems::_getItemsOfContainer($a_container_ref_id);
840  foreach(self::getTimingsAdministrationItems($a_container_ref_id) as $item)
841  {
842  if(!in_array($item['ref_id'],$event_items) &&
843  !$objDefinition->isSideBlock($item['type']))
844  {
845  $filtered[] = $item;
846  }
847  }
848 
849  return $filtered;
850  }
_getItemsOfContainer($a_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingStart()

ilObjectActivation::getTimingStart ( )

Get timing start.

Returns
timestamp

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

References $timing_start.

Referenced by update(), and validateActivation().

+ Here is the caller graph for this function:

◆ getTimingType()

ilObjectActivation::getTimingType ( )

get timing type

See also
class constants
Returns
int

Definition at line 53 of file class.ilObjectActivation.php.

References $timing_type.

Referenced by update(), and validateActivation().

+ Here is the caller graph for this function:

◆ hasChangeableTimings()

static ilObjectActivation::hasChangeableTimings (   $a_ref_id)
static

Check if there is any active changeable timing (in subtree)

Parameters
intref_id
Returns
bool

Definition at line 649 of file class.ilObjectActivation.php.

References $query, and $res.

Referenced by ilCourseContentGUI\__renderUserItem(), ilCourseContentGUI\editUserTimings(), and ilCourseContentGUI\showUserTimings().

650  {
651  global $tree, $ilDB;
652 
653  $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
654  $ref_ids = array();
655  foreach($subtree as $node)
656  {
657  $ref_ids[] = $node['ref_id'];
658  }
659 
660  $query = "SELECT * FROM crs_items ".
661  "WHERE timing_type = ".$ilDB->quote(self::TIMINGS_PRESETTING,'integer')." ".
662  "AND changeable = ".$ilDB->quote(1,'integer')." ".
663  "AND ".$ilDB->in('obj_id',$ref_ids,false,'integer');
664  $res = $ilDB->query($query);
665  return $res->numRows() ? true : false;
666  }
+ Here is the caller graph for this function:

◆ hasTimings()

static ilObjectActivation::hasTimings (   $a_ref_id)
static

Check if there is any active timing (in subtree)

Parameters
intref_id
Returns
bool

Definition at line 625 of file class.ilObjectActivation.php.

References $query, and $res.

Referenced by ilObjCourseGUI\membersObject().

626  {
627  global $tree, $ilDB;
628 
629  $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
630  $ref_ids = array();
631  foreach($subtree as $node)
632  {
633  $ref_ids[] = $node['ref_id'];
634  }
635 
636  $query = "SELECT * FROM crs_items ".
637  "WHERE timing_type = ".$ilDB->quote(self::TIMINGS_PRESETTING,'integer')." ".
638  "AND ".$ilDB->in('obj_id',$ref_ids,false,'integer');
639  $res = $ilDB->query($query);
640  return $res->numRows() ? true :false;
641  }
+ Here is the caller graph for this function:

◆ preloadData()

static ilObjectActivation::preloadData ( array  $a_ref_ids)
static

Preload data to internal cache.

Parameters
array$a_ref_ids

Definition at line 291 of file class.ilObjectActivation.php.

References $row.

Referenced by ilNewsItem\getAggregatedNewsData(), and ilObjectListGUIPreloader\preload().

292  {
293  global $ilDB;
294 
295  $sql = "SELECT * FROM crs_items".
296  " WHERE ".$ilDB->in("obj_id", $a_ref_ids, "", "integer");
297  $set = $ilDB->query($sql);
298  while($row = $ilDB->fetchAssoc($set))
299  {
300  self::$preloaded_data[$row["obj_id"]] = $row;
301  }
302  }
+ Here is the caller graph for this function:

◆ processListItems()

static ilObjectActivation::processListItems ( array  $a_ref_ids)
staticprotected

Validate ref ids and add list data.

Parameters
array$a_ref_ids
Returns
array

Definition at line 674 of file class.ilObjectActivation.php.

References $res.

675  {
676  global $tree;
677 
678  $res = array();
679 
680  foreach($a_ref_ids as $item_ref_id)
681  {
682  if($tree->isDeleted($item_ref_id))
683  {
684  continue;
685  }
686  // #7571: when node is removed from system, e.g. inactive trashcan, an empty array is returned
687  $node = $tree->getNodeData($item_ref_id);
688  if($node["ref_id"] != $item_ref_id)
689  {
690  continue;
691  }
692  $res[$item_ref_id] = $node;
693  }
694 
695  if(sizeof($res))
696  {
697  self::preloadData(array_keys($res));
698  foreach($res as $idx => $item)
699  {
700  self::addAdditionalSubItemInformation($item);
701  $res[$idx] = $item;
702  }
703  }
704 
705  return array_values($res);
706  }

◆ setEarliestStart()

ilObjectActivation::setEarliestStart (   $a_start)

Set earliest start.

Parameters
timestamp$a_start

Definition at line 143 of file class.ilObjectActivation.php.

144  {
145  $this->earliest_start = $a_start;
146  }

◆ setLatestEnd()

ilObjectActivation::setLatestEnd (   $a_end)

Set latest end.

Parameters
timestamp$a_end

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

164  {
165  $this->latest_end = $a_end;
166  }

◆ setSuggestionEnd()

ilObjectActivation::setSuggestionEnd (   $a_end)

Set suggestion end.

Parameters
timestamp$a_end

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

124  {
125  $this->suggestion_end = $a_end;
126  }

◆ setSuggestionStart()

ilObjectActivation::setSuggestionStart (   $a_start)

Set suggestion start.

Parameters
timestamp$a_start

Definition at line 103 of file class.ilObjectActivation.php.

104  {
105  $this->suggestion_start = $a_start;
106  }

◆ setTimingEnd()

ilObjectActivation::setTimingEnd (   $a_end)

Set timing end.

Parameters
timestamp$a_end

Definition at line 83 of file class.ilObjectActivation.php.

84  {
85  $this->timing_end = $a_end;
86  }

◆ setTimingStart()

ilObjectActivation::setTimingStart (   $a_start)

Set timing start.

Parameters
timestamp$a_start

Definition at line 63 of file class.ilObjectActivation.php.

64  {
65  $this->timing_start = $a_start;
66  }

◆ setTimingType()

ilObjectActivation::setTimingType (   $a_type)

Set timing type.

See also
class constants
Parameters
int$a_type

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

Referenced by ilObjSurvey\saveToDb(), ilObjTest\saveToDb(), ilObjPortfolioTemplate\updateActivation(), and ilObjCourse\updateSettings().

43  {
44  $this->timing_type = $a_type;
45  }
+ Here is the caller graph for this function:

◆ toggleChangeable()

ilObjectActivation::toggleChangeable (   $a_status)

Set changeable status.

Parameters
bool$a_status

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

204  {
205  $this->changeable = (int) $a_status;
206  }

◆ toggleVisible()

ilObjectActivation::toggleVisible (   $a_status)

Set visible status.

Parameters
bool$a_status

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

184  {
185  $this->visible = (int) $a_status;
186  }

◆ update()

ilObjectActivation::update (   $a_ref_id,
  $a_parent_id = null 
)

Update db entry.

Parameters
int$a_ref_id
int$a_parent_id

Definition at line 257 of file class.ilObjectActivation.php.

References $query, enabledChangeable(), enabledVisible(), getEarliestStart(), getLatestEnd(), getSuggestionEnd(), getSuggestionStart(), getTimingEnd(), getTimingStart(), and getTimingType().

258  {
259  global $ilDB;
260 
261  // #10110
262  $query = "UPDATE crs_items SET ".
263  "timing_type = ".$ilDB->quote($this->getTimingType(),'integer').", ".
264  "timing_start = ".$ilDB->quote((int)$this->getTimingStart(),'integer').", ".
265  "timing_end = ".$ilDB->quote((int)$this->getTimingEnd(),'integer').", ".
266  "suggestion_start = ".$ilDB->quote($this->getSuggestionStart(),'integer').", ".
267  "suggestion_end = ".$ilDB->quote($this->getSuggestionEnd(),'integer').", ".
268  "changeable = ".$ilDB->quote($this->enabledChangeable(),'integer').", ".
269  "earliest_start = ".$ilDB->quote($this->getEarliestStart(),'integer').", ".
270  "latest_end = ".$ilDB->quote($this->getLatestEnd(),'integer').", ";
271 
272  if($a_parent_id)
273  {
274  $query .= "parent_id = ".$ilDB->quote($a_parent_id,'integer').", ";
275  }
276 
277  $query .= "visible = ".$ilDB->quote($this->enabledVisible(),'integer')." ".
278  "WHERE obj_id = ".$ilDB->quote($a_ref_id,'integer');
279  $ilDB->manipulate($query);
280 
281  unset(self::$preloaded_data[$a_ref_id]);
282 
283  return true;
284  }
getTimingEnd()
Get timing end.
enabledVisible()
Get visible status.
getSuggestionEnd()
Get suggestion end.
getTimingStart()
Get timing start.
getTimingType()
get timing type
getSuggestionStart()
Get suggestion start.
enabledChangeable()
Get changeable status.
getLatestEnd()
Get latest end.
getEarliestStart()
Get earliest start.
+ Here is the call graph for this function:

◆ validateActivation()

ilObjectActivation::validateActivation ( )

Validate current properties.

Returns
boolean

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

References $ilErr, $lng, getSuggestionEnd(), getSuggestionStart(), getTimingEnd(), getTimingStart(), and getTimingType().

224  {
225  global $ilErr, $lng;
226 
227  $ilErr->setMessage('');
228 
229  if($this->getTimingType() == self::TIMINGS_ACTIVATION)
230  {
231  if($this->getTimingStart() > $this->getTimingEnd())
232  {
233  $ilErr->appendMessage($lng->txt("crs_activation_start_invalid"));
234  }
235  }
236  else if($this->getTimingType() == self::TIMINGS_PRESETTING)
237  {
238  if($this->getSuggestionStart() > $this->getSuggestionEnd())
239  {
240  $ilErr->appendMessage($lng->txt('crs_latest_end_not_valid'));
241  }
242  }
243 
244  if($ilErr->getMessage())
245  {
246  return false;
247  }
248  return true;
249  }
getTimingEnd()
Get timing end.
getSuggestionEnd()
Get suggestion end.
getTimingStart()
Get timing start.
getTimingType()
get timing type
getSuggestionStart()
Get suggestion start.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

Field Documentation

◆ $changeable

ilObjectActivation::$changeable
protected

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

Referenced by enabledChangeable().

◆ $earliest_start

ilObjectActivation::$earliest_start
protected

Definition at line 19 of file class.ilObjectActivation.php.

◆ $latest_end

ilObjectActivation::$latest_end
protected

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

◆ $preloaded_data

ilObjectActivation::$preloaded_data = array()
staticprotected

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

◆ $suggestion_end

ilObjectActivation::$suggestion_end
protected

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

◆ $suggestion_start

ilObjectActivation::$suggestion_start
protected

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

◆ $timing_end

ilObjectActivation::$timing_end
protected

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

Referenced by getTimingEnd().

◆ $timing_start

ilObjectActivation::$timing_start
protected

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

Referenced by getTimingStart().

◆ $timing_type

ilObjectActivation::$timing_type
protected

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

Referenced by getTimingType().

◆ $visible

ilObjectActivation::$visible
protected

Definition at line 21 of file class.ilObjectActivation.php.

Referenced by enabledVisible().

◆ TIMINGS_ACTIVATION

◆ TIMINGS_DEACTIVATED

◆ TIMINGS_FIXED

const ilObjectActivation::TIMINGS_FIXED = 3

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

◆ TIMINGS_PRESETTING


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