ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjectFactory Class Reference

Class ilObjectFactory. More...

+ Collaboration diagram for ilObjectFactory:

Public Member Functions

 ObjectIdExists ($a_obj_id)
 check if obj_id exists. More...
 
 getObjectsForOwner ($object_type, $owner_id)
 returns all objects of an owner, filtered by type, objects are not deleted! More...
 

Static Public Member Functions

static getInstanceByObjId ($a_obj_id, $stop_on_error=true)
 get an instance of an Ilias object by object id More...
 
static getInstanceByRefId ($a_ref_id, $stop_on_error=true)
 get an instance of an Ilias object by reference id More...
 
static getTypeByRefId ($a_ref_id, $stop_on_error=true)
 get object type by reference id More...
 
static getClassByType ($a_obj_type)
 Get class by type. More...
 

Detailed Description

Class ilObjectFactory.

This class offers methods to get instances of the type-specific object classes (derived from ilObject) by their object or reference id

Note: The term "Ilias objects" means all object types that are stored in the database table "object_data"

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ getClassByType()

static ilObjectFactory::getClassByType (   $a_obj_type)
static

Get class by type.

Returns

Definition at line 260 of file class.ilObjectFactory.php.

References $location.

Referenced by ilWorkspaceExplorer\__construct(), ilRepUtilGUI\confirmRemoveFromSystemObject(), ilWorkspaceTree\createTreeForUser(), ilAdministrationCommandGUI\delete(), ilObjStudyProgrammeTreeGUI\delete(), ilObject2GUI\deleteConfirmation(), ilObjectCopyGUI\saveSource(), ilObjectCopyGUI\saveTarget(), and ilRepUtilGUI\showDeleteConfirmation().

261  {
262  global $objDefinition;
263 
264  $location = $objDefinition->getLocation($a_obj_type);
265  $class_name = "ilObj".$objDefinition->getClassName($a_obj_type);
266 
267  // create instance
268  include_once($location."/class.".$class_name.".php");
269  return $class_name;
270  }
$location
Definition: buildRTE.php:44
+ Here is the caller graph for this function:

◆ getInstanceByObjId()

static ilObjectFactory::getInstanceByObjId (   $a_obj_id,
  $stop_on_error = true 
)
static

get an instance of an Ilias object by object id

Parameters
int$obj_idobject id
Returns
object instance of Ilias object (i.e. derived from ilObject)

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

References $ilDB, $location, exit, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilLearningProgressBaseGUI\__appendUserInfo(), ilRoleDesktopItem\__assign(), ilLocalUserGUI\__checkGlobalRoles(), ilObjCategoryGUI\__checkGlobalRoles(), ilUsersGalleryParticipants\__construct(), ilCalendarUserSettings\__construct(), ilLocalUserGUI\__getAssignableRoles(), ilObjCategoryGUI\__getAssignableRoles(), ilLPListOfProgressGUI\__initUser(), ilLinkChecker\__sendMail(), ilLocalUserGUI\__showRolesTable(), ilSearch\__validateResults(), ilObjGroup\_isMember(), ilInfoScreenGUI\addObjectSections(), ilSoapRBACAdministration\addUserRoleEntry(), ilSoapCourseAdministration\assignCourseMember(), ilMembershipGUI\assignFromWaitingList(), ilSoapGroupAdministration\assignGroupMember(), ilExerciseMembers\assignMember(), ilCourseMembershipGUI\assignMembers(), ilObject2GUI\assignObject(), ilObjectGUI\assignObject(), ilLocalUserGUI\assignRoles(), ilObjCategoryGUI\assignRolesObject(), ilParticipants\assignSubscriber(), ilChatroom\byRoomId(), ilMailSearchGroupsGUI\cancel(), ilMailSearchCoursesGUI\cancel(), ilMailFolderGUI\cancelDeleteMails(), ilWorkspaceTree\cascadingDelete(), ilUserCronCheckAccounts\checkNotConfirmedUserAccounts(), ilObjPortfolioBase\cloneBasics(), ilContainer\cloneObject(), ilStartUpGUI\confirmRegistration(), ilContainerXmlParser\createObject(), ilObjWorkspaceFolderGUI\cut(), ilExerciseMembers\deassignMember(), ilObject2GUI\deleteConfirmedObjects(), ilSoapUtils\deleteExpiredDualOptInUserObjects(), ilRepUtil\deleteObjects(), ilSoapRBACAdministration\deleteRole(), ilObjRoleFolderGUI\deleteRoleObject(), ilSoapUserAdministration\deleteUser(), ilSoapRBACAdministration\deleteUserRoleEntry(), ilForumModeratorsGUI\detachModeratorRole(), ilObjBlog\doCloneObject(), ilExerciseManagementGUI\downloadAllObject(), ilPublicSubmissionsTableGUI\fillRow(), ilTestImporter\finalProcessing(), ilObjForumAccess\getCachedUserInstance(), ilSoapCourseAdministration\getCoursesForUser(), ilObjCourse\getDefaultAdminRole(), ilObjCourse\getDefaultTutorRole(), ilChatroom\getDescription(), ilSoapExerciseAdministration\getExerciseXML(), ilSoapFileAdministration\getFileXML(), ilSoapGroupAdministration\getGroupsForUser(), ilSoapSCORMAdministration\getIMSManifestXML(), ilSoapRBACAdministration\getLocalRoles(), ilAttendanceList\getNonMemberUserData(), ilSoapObjectAdministration\getObjectsByTitle(), ilSoapRBACAdministration\getObjectTreeOperations(), ilCourseMembershipGUI\getPrintMemberData(), ilSoapRBACAdministration\getRoles(), ilUsersGalleryUsers\getSortedRelations(), ilChatroom\getTitle(), ilSoapUserAdministration\getUser(), ilSoapRBACAdministration\getUserRoles(), ilDataCollectionDataSet\getXmlNamespace(), ilSoapRBACAdministration\grantPermissions(), ilObjSession\handleAutoFill(), ilObjGroup\handleAutoFill(), ilObjCourse\handleAutoFill(), ilECSTaskScheduler\handleDeprecatedAccounts(), ilECSAppEventListener\handleEvent(), ilRemoteObjectBase\handleUpdate(), ilCronDeleteInactiveUserAccounts\hasCustomSettings(), ilObjTestAccess\hasFinished(), ilObjTestAccess\hasVisibleCertificate(), ilExternalFeedBlockGUI\importFile(), ilObjectGUI\importFileObject(), ilBibliographicDataSet\importRecord(), ilExternalFeedDataSet\importRecord(), ilHTMLLearningModuleDataSet\importRecord(), ilItemGroupDataSet\importRecord(), ilMediaCastDataSet\importRecord(), ilPortfolioDataSet\importRecord(), ilPollDataSet\importRecord(), ilGlossaryDataSet\importRecord(), ilBlogDataSet\importRecord(), ilSessionDataSet\importRecord(), ilWikiDataSet\importRecord(), ilMediaPoolDataSet\importRecord(), ilExerciseDataSet\importRecord(), ilLearningModuleDataSet\importRecord(), ilStyleDataSet\importRecord(), ilObjStyleSheetGUI\importStyleObject(), ilForumImporter\importXmlRepresentation(), ilFileImporter\importXmlRepresentation(), ilSurveyQuestionPoolImporter\importXmlRepresentation(), ilTestImporter\importXmlRepresentation(), ilTestQuestionPoolImporter\importXmlRepresentation(), ilFolderImporter\importXmlRepresentation(), ilWebResourceImporter\importXmlRepresentation(), ilGlossaryImporter\importXmlRepresentation(), ilLearningModuleImporter\importXmlRepresentation(), ilSurveyImporter\importXmlRepresentation(), ilWebLinkXmlWriter\init(), ilFolderXmlWriter\init(), ilMimeMailNotification\initLanguage(), ilPluginLP\initPlugin(), ilRoleXmlImporter\initRole(), ilParticipants\isGroupingMember(), ilChatroom\isOwnerOfPrivateRoom(), ilObjRoleGUI\listUsersRoleObject(), ilSoapMailXmlParser\parseName(), ilExerciseSubmissionTableGUI\parseRow(), ilLPTableBaseGUI\parseTitle(), ilLocalUserGUI\performDeleteUsers(), ilObjCategoryGUI\performDeleteUsersObject(), ilObjWorkspaceFolderGUI\performPasteIntoMultipleObjects(), ilParticipants\readSubscribers(), ilPreviewGUI\renderPreview(), ilTestLP\resetCustomLPDataForUserIds(), ilSoapRBACAdministration\revokePermissions(), ilCronDeleteInactivatedUserAccounts\run(), ilPermissionGUI\savePermissions(), ilObjExercise\sendAssignment(), ilPDOAuthentication\setAuth(), ilMailSearchCoursesGUI\showMembers(), ilAuthContainerMDB2\supportsCaptchaVerification(), ilNotificationSystem\toUsers(), ilPermissionGUI\unblockRoles(), ilSoapExerciseAdministration\updateExercise(), ilSoapFileAdministration\updateFile(), ilSoapObjectAdministration\updateObjects(), ilECSCourseCreationHandler\updateParallelCourses(), ilECSCourseCreationHandler\updateParallelGroups(), ilRegistrationSettingsGUI\updateRoles(), ilSoapWebLinkAdministration\updateWebLink(), and ilObjTestAccess\visibleUserResultExists().

73  {
74  global $ilias, $objDefinition, $ilDB;
75 
76  // check object id
77  if (!isset($a_obj_id))
78  {
79  $message = "ilObjectFactory::getInstanceByObjId(): No obj_id given!";
80  if ($stop_on_error === true)
81  {
82  $ilias->raiseError($message,$ilias->error_obj->WARNING);
83  exit();
84  }
85  #var_dump("<pre>",$message,"<pre>");
86 
87  return false;
88  }
89 
90  // read object data
91  $q = "SELECT * FROM object_data ".
92  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer');
93  $object_set = $ilias->db->query($q);
94  // check number of records
95  if ($object_set->numRows() == 0)
96  {
97  $message = "ilObjectFactory::getInstanceByObjId(): Object with obj_id: ".$a_obj_id." not found!";
98  if ($stop_on_error === true)
99  {
100  $ilias->raiseError($message,$ilias->error_obj->WARNING);
101  exit();
102  }
103  #var_dump("<pre>",$message,"<pre>");
104  return false;
105  }
106 
107  $object_rec = $object_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
108  $class_name = "ilObj".$objDefinition->getClassName($object_rec["type"]);
109 
110  // check class
111  if ($class_name == "ilObj")
112  {
113  $message = "ilObjectFactory::getInstanceByObjId(): Not able to determine object ".
114  "class for type".$object_rec["type"].".";
115  if ($stop_on_error === true)
116  {
117  $ilias->raiseError($message,$ilias->error_obj->WARNING);
118  exit();
119  }
120  return false;
121  }
122 
123  // get location
124  $location = $objDefinition->getLocation($object_rec["type"]);
125 
126  // create instance
127  include_once($location."/class.".$class_name.".php");
128  $obj = new $class_name(0, false); // this avoids reading of data
129  $obj->setId($a_obj_id);
130  $obj->read();
131 
132  return $obj;
133  }
$location
Definition: buildRTE.php:44
global $ilDB
+ Here is the caller graph for this function:

◆ getInstanceByRefId()

static ilObjectFactory::getInstanceByRefId (   $a_ref_id,
  $stop_on_error = true 
)
static

get an instance of an Ilias object by reference id

Parameters
int$obj_idobject id
Returns
object instance of Ilias object (i.e. derived from ilObject)

Definition at line 142 of file class.ilObjectFactory.php.

References $ilDB, $location, $query, exit, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilCourseArchives\__addHTMLFiles(), ilCourseArchives\__addZipFiles(), ilCourseArchives\__buildStructure(), ilConditionHandlerGUI\__construct(), ilCourseObjectivesGUI\__initCourseObject(), ilCourseArchivesGUI\__initCourseObject(), ilCourseContentGUI\__initCourseObject(), ilECSObjectSettings\_handleDelete(), ilForumNotification\_isParentNodeGrpCrs(), assQuestionGUI\addBackTab(), ilSoapCourseAdministration\addCourse(), ilSoapExerciseAdministration\addExercise(), ilSoapFileAdministration\addFile(), ilSoapObjectAdministration\addObject(), ilTestExpressPageObjectGUI\addPageOfQuestions(), ilSoapObjectAdministration\addReference(), ilSoapRBACAdministration\addRole(), ilSoapRBACAdministration\addRoleFromTemplate(), ilObjRoleGUI\askDeleteDesktopItemObject(), ilConditionHandlerGUI\assign(), ilObjCourseGroupingGUI\assignCourse(), ilSoapCourseAdministration\assignCourseMember(), ilSoapGroupAdministration\assignGroupMember(), ilObject2GUI\assignObject(), ilObjectGUI\assignObject(), assQuestionGUI\cancelSync(), ilSoapAdministration\checkObjectAccess(), ilForumNotification\checkParentNodeTree(), ilConditionHandlerGUI\chi_init(), ilContainerGUI\clipboardObject(), ilObjectGUI\cloneAllObject(), ilContainerGUI\cloneAllObject(), ilSoapUtils\cloneDependencies(), ilObjectActivation\cloneDependencies(), ilSoapUtils\cloneNode(), ilObjectCopyGUI\copyContainer(), ilObjectCopyGUI\copyMultipleNonContainer(), ilSoapObjectAdministration\copyObject(), ilObjStyleSheetGUI\copyStyleObject(), ilSoapWebLinkAdministration\createWebLink(), ilSoapObjectAdministration\deleteObject(), ilContainerReferenceAppEventListener\deleteReferences(), ilObjTest\ensureParticipantsLastActivePassFinished(), ilTestInfoScreenToolbarFactory\ensureTestObjectInitialised(), ilObjSessionGUI\eventsListObject(), ilSoapCourseAdministration\excludeCourseMember(), ilSoapGroupAdministration\excludeGroupMember(), ilTestExpressPageObjectGUI\executeCommand(), ilSessionOverviewGUI\exportCSV(), ilChatroomAdminViewGUI\forcePublicRoom(), ilSessionOverviewTableGUI\gatherEvents(), ilFolderDownloadBackgroundTaskHandler\gatherFiles(), ilForum\generatePost(), ilStudyProgrammeExpandableProgressListGUI\getAccordionContentCoursesHTML(), ilChatroomBlockGUI\getChatroomSelectionList(), ilSoapGroupAdministration\getGroup(), ilObjectFactoryWrapper\getInstanceByRefId(), ilRoleDesktopItemsTableGUI\getItems(), ilSoapRBACAdministration\getLocalRoles(), ilCourseObjectiveQuestion\getMaxPointsByObjective(), ilCourseObjectiveQuestion\getMaxPointsByTest(), ilSoapObjectAdministration\getObjectByReference(), ilSoapObjectAdministration\getObjectsByTitle(), ilSoapRBACAdministration\getObjectTreeOperations(), ilOrgUnitExtension\getOrgUnit(), ilCourseStartObjectsTableGUI\getPossibleObjects(), ilContainerStartObjectsTableGUI\getPossibleObjects(), ilSoapLearningProgressAdministration\getProgressInfo(), ilCourseObjectivesGUI\getRandomTestQplOptions(), ilCourseStartObjectsTableGUI\getStartObjects(), ilContainerStartObjectsTableGUI\getStartObjects(), ilSOAPStructureObjectAdministration\getStructureObjects(), ilSoapObjectAdministration\getTreeChilds(), ilContainerReferenceExporter\getXmlRepresentation(), ilGroupExporter\getXmlRepresentation(), ilCategoryExporter\getXmlRepresentation(), ilCourseExporter\getXmlRepresentation(), ilSoapObjectAdministration\getXMLTree(), ilSoapRBACAdministration\grantPermissions(), ilRemoteObjectBase\handleDelete(), ilECSCategoryMapping\handleUpdate(), ilCourseObjective\ilClone(), ilObjStyleSheetGUI\importStyleObject(), ilSoapUserAdministration\importUsers(), ilCategoryImporter\importXmlRepresentation(), ilFolderImporter\importXmlRepresentation(), ilGroupImporter\importXmlRepresentation(), ilCourseImporter\importXmlRepresentation(), ilContainerReferenceImporter\initReference(), ilAssQuestionPreviewSettings\initSettingsWithTestObject(), ilDidacticTemplateAction\initSourceObject(), ilSoapCourseAdministration\isAssignedToCourse(), ilSoapGroupAdministration\isAssignedToGroup(), ilObjForumGUI\isParentObjectCrsOrGrp(), ilObjTest\isParticipantsLastPassActive(), ilObjectGUI\isVisible(), ilSoapUtils\linkNode(), ilLOUtils\lookupQplBySequence(), ilCourseObjectiveQuestionAssignmentTableGUI\parse(), ilLOTestAssignmentTableGUI\parse(), ilContainerGUI\performPasteIntoMultipleObjectsObject(), ilObjQuestionPoolGUI\questionsObject(), ilRepUtil\removeDeletedNodes(), ilSoapObjectAdministration\removeFromSystemByImportId(), ilRepUtil\removeObjectsFromSystem(), ilSoapTestAdministration\removeTestResults(), ilMailGroupAddressType\resolve(), ilRepUtil\restoreObjects(), ilSoapRBACAdministration\revokePermissions(), ilWebResourceCronLinkCheck\run(), ilObjStyleSheetGUI\saveObject(), ilSoapObjectAdministration\searchObjects(), ilCourseMembershipMailNotification\send(), ilMailSearchGroupsGUI\showMembers(), ilObjForumGUI\showUserObject(), assQuestionGUI\sync(), ilECSCmsTreeSynchronizer\syncCategory(), ilSoapCourseAdministration\updateCourse(), ilECSCourseCreationHandler\updateCourseData(), ilSoapGroupAdministration\updateGroup(), ilMembershipRegistrationCodeUtils\useCode(), and ilConditionHandler\validate().

143  {
144  global $ilias, $objDefinition, $ilDB;
145 
146  // check reference id
147  if (!isset($a_ref_id))
148  {
149  if ($stop_on_error === true)
150  {
151  $message = "ilObjectFactory::getInstanceByRefId(): No ref_id given!";
152  $ilias->raiseError($message,$ilias->error_obj->WARNING);
153  exit();
154  }
155 
156  return false;
157  }
158 
159  // read object data
160 
161  $query = "SELECT * FROM object_data,object_reference ".
162  "WHERE object_reference.obj_id = object_data.obj_id ".
163  "AND object_reference.ref_id = ".$ilDB->quote($a_ref_id,'integer');
164  $object_set = $ilDB->query($query);
165 
166  // check number of records
167  if ($object_set->numRows() == 0)
168  {
169  if ($stop_on_error === true)
170  {
171  $message = "ilObjectFactory::getInstanceByRefId(): Object with ref_id ".$a_ref_id." not found!";
172  $ilias->raiseError($message,$ilias->error_obj->WARNING);
173  exit();
174  }
175 
176  return false;
177  }
178 
179  $object_rec = $object_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
180  $class_name = "ilObj".$objDefinition->getClassName($object_rec["type"]);
181 
182  // check class
183  if ($class_name == "ilObj")
184  {
185  if ($stop_on_error === true)
186  {
187  $message = "ilObjectFactory::getInstanceByRefId(): Not able to determine object ".
188  "class for type".$object_rec["type"].".";
189  $ilias->raiseError($message,$ilias->error_obj->WARNING);
190  exit();
191  }
192 
193  return false;
194  }
195 
196  // get location
197  $location = $objDefinition->getLocation($object_rec["type"]);
198 
199  // create instance
200  include_once($location."/class.".$class_name.".php");
201  $obj = new $class_name(0, false); // this avoids reading of data
202  $obj->setId($object_rec["obj_id"]);
203  $obj->setRefId($a_ref_id);
204  $obj->read();
205  return $obj;
206  }
$location
Definition: buildRTE.php:44
global $ilDB
+ Here is the caller graph for this function:

◆ getObjectsForOwner()

ilObjectFactory::getObjectsForOwner (   $object_type,
  $owner_id 
)

returns all objects of an owner, filtered by type, objects are not deleted!

Parameters
unknown_type$object_type
unknown_type$owner_id
Returns
unknown

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

References $ilDB, $query, $res, array, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilSoapCourseAdministration\getCoursesForUser(), and ilSoapGroupAdministration\getGroupsForUser().

48  {
49  global $ilias, $ilDB;
50 
51  $query = "SELECT * FROM object_data,object_reference ".
52  "WHERE object_reference.obj_id = object_data.obj_id ".
53  " AND object_data.type=".$ilDB->quote($object_type,'text').
54  " AND object_data.owner = ".$ilDB->quote($owner_id,'integer');
55  $res = $ilDB->query($query);
56 
57  $obj_ids = array();
58  while($object_rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
59  $obj_ids [] = $object_rec["obj_id"];
60  }
61 
62  return $obj_ids;
63 
64  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getTypeByRefId()

static ilObjectFactory::getTypeByRefId (   $a_ref_id,
  $stop_on_error = true 
)
static

get object type by reference id

Parameters
int$obj_idobject id
Returns
string object type
Deprecated:
since version 5.3

Definition at line 216 of file class.ilObjectFactory.php.

References $ilDB, exit, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilSoapAdministration\checkObjectAccess(), ilSoapObjectAdministration\copyObject(), ilCopyWizardSettingsXMLParser\handlerBeginTag(), ilSoapObjectAdministration\moveObject(), and ilSoapGroupAdministration\updateGroup().

217  {
218  global $ilias, $objDefinition, $ilDB;
219 
220  // check reference id
221  if (!isset($a_ref_id))
222  {
223  if ($stop_on_error === true)
224  {
225  $message = "ilObjectFactory::getTypeByRefId(): No ref_id given!";
226  $ilias->raiseError($message,$ilias->error_obj->WARNING);
227  exit();
228  }
229 
230  return false;
231  }
232 
233  // read object data
234  $q = "SELECT * FROM object_data ".
235  "LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id ".
236  "WHERE object_reference.ref_id=".$ilDB->quote($a_ref_id,'integer');
237  $object_set = $ilias->db->query($q);
238 
239  if ($object_set->numRows() == 0)
240  {
241  if ($stop_on_error === true)
242  {
243  $message = "ilObjectFactory::getTypeByRefId(): Object with ref_id ".$a_ref_id." not found!";
244  $ilias->raiseError($message,$ilias->error_obj->WARNING);
245  exit();
246  }
247 
248  return false;
249  }
250 
251  $object_rec = $object_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
252  return $object_rec["type"];
253  }
global $ilDB
+ Here is the caller graph for this function:

◆ ObjectIdExists()

ilObjectFactory::ObjectIdExists (   $a_obj_id)

check if obj_id exists.

To check for ref_ids use ilTree::isInTree()

Parameters
int$obj_idobject id
Returns
bool

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

References $ilDB, $query, and $res.

29  {
30  global $ilias, $ilDB;
31 
32  $query = "SELECT * FROM object_data ".
33  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer');
34 
35  $res = $ilias->db->query($query);
36 
37  return $res->numRows() ? true : false;
38  }
global $ilDB

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