ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjectFactory Class Reference

Class ilObjectFactory. More...

+ Collaboration diagram for ilObjectFactory:

Public Member Functions

 ObjectIdExists ($a_obj_id)
 check if obj_id exists.
 getObjectsForOwner ($object_type, $owner_id)
 returns all objects of an owner, filtered by type, objects are not deleted!
 getInstanceByObjId ($a_obj_id, $stop_on_error=true)
 get an instance of an Ilias object by object id
 getInstanceByRefId ($a_ref_id, $stop_on_error=true)
 get an instance of an Ilias object by reference id
 getTypeByRefId ($a_ref_id, $stop_on_error=true)
 get object type by reference id

Static Public Member Functions

static getClassByType ($a_obj_type)
 Get class by type.

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:
class.ilObjectFactory.php 23253 2010-03-18 11:37:29Z smeyer

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

Member Function Documentation

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(), ilAdministrationCommandGUI\delete(), ilObject2GUI\deleteConfirmation(), ilPersonalWorkspaceGUI\initTree(), and ilRepUtilGUI\showDeleteConfirmation().

{
global $objDefinition;
$location = $objDefinition->getLocation($a_obj_type);
$class_name = "ilObj".$objDefinition->getClassName($a_obj_type);
// create instance
include_once($location."/class.".$class_name.".php");
return $class_name;
}

+ Here is the caller graph for this function:

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

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, DB_FETCHMODE_ASSOC, and exit.

Referenced by ilLearningProgressBaseGUI\__appendUserInfo(), ilRoleDesktopItem\__assign(), ilObjCategoryGUI\__checkGlobalRoles(), ilCalendarUserSettings\__construct(), ilAdminUserSearchGUI\__fillRoleTable(), ilAdminUserSearchGUI\__fillUserTable(), ilObjExercise\__formatRecipients(), ilObjCategoryGUI\__getAssignableRoles(), ilObjPaymentSettingsGUI\__getVendors(), ilPaymentObjectGUI\__getVendors(), ilObjectGUIAdapter\__initGUIObject(), ilLPListOfProgressGUI\__initUser(), ilLinkChecker\__sendMail(), ilObjCategoryGUI\__showRolesTable(), ilObjCourseGUI\__showWaitingList(), ilSearch\__validateResults(), ilObjGroup\_isMember(), ilPaymentStatisticGUI\addCustomer(), ilObjPaymentSettingsGUI\addCustomerObject(), ilInfoScreenGUI\addObjectSections(), ilSoapRBACAdministration\addUserRoleEntry(), ilObjPaymentSettingsGUI\addVendorWorksheet(), ilObjUserFolderGUI\appliedUsersObject(), ilSoapCourseAdministration\assignCourseMember(), ilObjGroupGUI\assignFromWaitingListObject(), ilObjCourseGUI\assignFromWaitingListObject(), ilSoapGroupAdministration\assignGroupMember(), ilExerciseMembers\assignMember(), ilObjCourseGUI\assignMembersObject(), ilObject2GUI\assignObject(), ilObjectGUI\assignObject(), ilObjCategoryGUI\assignRolesObject(), ilParticipants\assignSubscriber(), ilRbacAdmin\assignUser(), ilChatroom\byRoomId(), ilWorkspaceTree\cascadingDelete(), ilObjiLincCourseGUI\changeMemberObject(), ilCronCheckUserAccounts\checkNotConfirmedUserAccounts(), ilStartUpGUI\confirmRegistration(), ilContainerXmlParser\createObject(), ilObjWorkspaceFolderGUI\cut(), ilExerciseMembers\deassignMember(), ilObject2GUI\deleteConfirmedObjects(), ilSoapUtils\deleteExpiredDualOptInUserObjects(), ilRepUtil\deleteObjects(), ilSoapRBACAdministration\deleteRole(), ilObjRoleFolderGUI\deleteRoleObject(), ilObjCourseGUI\deleteSubscribers(), ilSoapUserAdministration\deleteUser(), ilSoapRBACAdministration\deleteUserRoleEntry(), ilObjExerciseGUI\downloadAllObject(), ilObjUserFolderGUI\editAppliedUsersObject(), ilPaymentStatisticGUI\editStatistic(), ilObjPaymentSettingsGUI\editStatisticObject(), ilObjCourseGUI\fetchPrintMemberData(), ilObjCourseGUI\fetchPrintSubscriberData(), ilPublicSubmissionsTableGUI\fillRow(), ilExerciseMemberTableGUI\fillRow(), ilSoapCourseAdministration\getCoursesForUser(), ilObjCourse\getDefaultAdminRole(), ilObjCourse\getDefaultTutorRole(), ilChatroom\getDescription(), ilSoapExerciseAdministration\getExerciseXML(), ilSoapFileAdministration\getFileXML(), ilSoapGroupAdministration\getGroupsForUser(), ilSoapSCORMAdministration\getIMSManifestXML(), ilSoapRBACAdministration\getLocalRoles(), ilSoapObjectAdministration\getObjectsByTitle(), ilSoapRBACAdministration\getObjectTreeOperations(), ilSoapRBACAdministration\getRoles(), ilChatroom\getTitle(), ilSoapUserAdministration\getUser(), ilForum\getUser(), ilForum\getUserData(), ilObjForumGUI\getUserInstance(), ilSoapRBACAdministration\getUserRoles(), ilSoapRBACAdministration\grantPermissions(), ilECSTaskScheduler\handleDeprecatedAccounts(), ilECSAppEventListener\handleEvent(), ilECSTaskScheduler\handleNewlyCreate(), ilECSTaskScheduler\handleUpdate(), ilExternalFeedBlockGUI\importFile(), ilObjectGUI\importFileObject(), ilExternalFeedDataSet\importRecord(), ilMediaCastDataSet\importRecord(), ilHTMLLearningModuleDataSet\importRecord(), ilWikiDataSet\importRecord(), ilMediaPoolDataSet\importRecord(), ilExerciseDataSet\importRecord(), ilSessionDataSet\importRecord(), ilFileImporter\importXmlRepresentation(), ilForumImporter\importXmlRepresentation(), ilGlossaryImporter\importXmlRepresentation(), ilTestImporter\importXmlRepresentation(), ilLearningModuleImporter\importXmlRepresentation(), ilSurveyImporter\importXmlRepresentation(), ilSurveyQuestionPoolImporter\importXmlRepresentation(), ilTestQuestionPoolImporter\importXmlRepresentation(), ilFolderImporter\importXmlRepresentation(), ilWebResourceImporter\importXmlRepresentation(), ilWebLinkXmlWriter\init(), ilFolderXmlWriter\init(), ilRoleXmlImporter\initRole(), ilParticipants\isGroupingMember(), ilLMStatisticsGUI\listUsersGroup(), ilObjiLincCourseGUI\listUsersGroupObject(), ilObjRoleGUI\listUsersGroupObject(), ilLMStatisticsGUI\listUsersRole(), ilObjiLincCourseGUI\listUsersRoleObject(), ilObjRoleGUI\listUsersRoleObject(), ilObjGroupGUI\membersGalleryObject(), ilObjiLincCourseGUI\membersGalleryObject(), ilObjCourseGUI\membersGalleryObject(), ilObjPaymentSettingsGUI\objectsObject(), ilSoapMailXmlParser\parseName(), ilLPTableBaseGUI\parseTitle(), ilObjCategoryGUI\performDeleteUsersObject(), ilObjWorkspaceFolderGUI\performPasteIntoMultipleObjects(), ilPaymentTrusteeGUI\performSearch(), ilPaymentStatisticGUI\performSearch(), ilObjPaymentSettingsGUI\performSearchSPObject(), ilPermission2GUI\permSave(), ilParticipants\readSubscribers(), ilObjCourseGUI\removeFromWaitingList(), ilObjiLincCourseGUI\removeMemberObject(), ilOrgUnitTreeExplorerGUI\renderUnit(), ilSoapRBACAdministration\revokePermissions(), ilCronDeleteInactiveUserAccounts\run(), ilPermissionGUI\savePermissions(), ilLMStatisticsGUI\search(), ilObjiLincCourseGUI\searchObject(), ilObjRoleGUI\searchObject(), ilObjPaymentSettingsGUI\searchObject(), ilShopBoughtObjectsGUI\showItems(), ilMailSearchCoursesGUI\showMembers(), ilForumModeratorsGUI\showModerators(), ilMailSearchCoursesGUI\showMyCourses(), ilPaymentObjectGUI\showObjects(), ilPaymentTrusteeGUI\showTrustees(), ilOrgUnitAssignmentList\sortCallback(), ilObjUserFolderGUI\updateAppliedUsersObject(), ilSoapExerciseAdministration\updateExercise(), ilSoapFileAdministration\updateFile(), ilSoapObjectAdministration\updateObjects(), ilSoapUserAdministration\updatePassword(), ilRegistrationSettingsGUI\updateRoles(), ilSoapUserAdministration\updateUser(), ilSoapWebLinkAdministration\updateWebLink(), and ilObjPaymentSettingsGUI\vendorsObject().

{
global $ilias, $objDefinition, $ilDB;
// check object id
if (!isset($a_obj_id))
{
$message = "ilObjectFactory::getInstanceByObjId(): No obj_id given!";
if ($stop_on_error === true)
{
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
#var_dump("<pre>",$message,"<pre>");
return false;
}
// read object data
$q = "SELECT * FROM object_data ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer');
$object_set = $ilias->db->query($q);
// check number of records
if ($object_set->numRows() == 0)
{
$message = "ilObjectFactory::getInstanceByObjId(): Object with obj_id: ".$a_obj_id." not found!";
if ($stop_on_error === true)
{
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
#var_dump("<pre>",$message,"<pre>");
return false;
}
$object_rec = $object_set->fetchRow(DB_FETCHMODE_ASSOC);
$class_name = "ilObj".$objDefinition->getClassName($object_rec["type"]);
// check class
if ($class_name == "ilObj")
{
$message = "ilObjectFactory::getInstanceByObjId(): Not able to determine object ".
"class for type".$object_rec["type"].".";
if ($stop_on_error === true)
{
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
return false;
}
// get location
$location = $objDefinition->getLocation($object_rec["type"]);
// create instance
include_once($location."/class.".$class_name.".php");
$obj = new $class_name(0, false); // this avoids reading of data
$obj->setId($a_obj_id);
$obj->setObjDataRecord($object_rec);
$obj->read();
return $obj;
}

+ Here is the caller graph for this function:

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

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 143 of file class.ilObjectFactory.php.

References $ilDB, $location, $query, DB_FETCHMODE_ASSOC, and exit.

Referenced by ilCourseArchives\__addHTMLFiles(), ilCourseArchives\__addZipFiles(), ilCourseXMLWriter\__buildObject(), ilCourseArchives\__buildStructure(), ilShopPurchaseGUI\__construct(), ilObjPaymentSettingsGUI\__editPricesTable(), ilPaymentObjectGUI\__editPricesTable(), ilAdminUserSearchGUI\__fillGroupTable(), ilForum\__formatMessage(), ilObjExerciseGUI\__getMembersOfObject(), ilPurchaseBaseGUI\__getShoppingCart(), ilCourseObjectivesGUI\__initCourseObject(), ilCourseArchivesGUI\__initCourseObject(), ilCourseObjectivePresentationGUI\__initCourseObject(), ilCourseContentGUI\__initCourseObject(), ilObjectGUIAdapter\__initGUIObject(), ilCourseItemAdministrationGUI\__initItem(), ilObjExerciseGUI\__showObjectSelect(), ilPurchaseBaseGUI\__showShoppingCart(), ilECSContentWriter\_handleDelete(), ilForumNotification\_isParentNodeGrpCrs(), ilShopUtils\_sendNotificationToVATAdministration(), ilSoapCourseAdministration\addCourse(), ilPaymentStatisticGUI\addCustomer(), ilObjPaymentSettingsGUI\addCustomerObject(), ilSoapExerciseAdministration\addExercise(), ilSoapFileAdministration\addFile(), ilSoapObjectAdministration\addObject(), ilTestExpressPageObjectGUI\addPageOfQuestions(), ilPaymentObjectGUI\addPrice(), ilObjPaymentSettingsGUI\addPriceObject(), ilSoapObjectAdministration\addReference(), ilSoapObjectAdministration\addReferences(), ilPermission2GUI\addRole(), ilSoapRBACAdministration\addRole(), ilSoapRBACAdministration\addRoleFromTemplate(), ilDidacticTemplateLocalRoleAction\apply(), ilObjRoleGUI\askDeleteDesktopItemObject(), ilConditionHandlerInterface\assign(), ilObjCourseGroupingGUI\assignCourse(), ilSoapCourseAdministration\assignCourseMember(), ilSoapGroupAdministration\assignGroupMember(), ilObject2GUI\assignObject(), ilObjectGUI\assignObject(), ilCronWebResourceCheck\check(), ilSoapAdministration\checkObjectAccess(), ilForumNotification\checkParentNodeTree(), ilConditionHandlerInterface\chi_init(), ilContainerGUI\clipboardObject(), ilObjectGUI\cloneAllObject(), ilContainerGUI\cloneAllObject(), ilObjWorkspaceFolder\cloneDependencies(), ilCourseItems\cloneDependencies(), ilObjFolder\cloneDependencies(), ilSoapUtils\cloneDependencies(), ilObjGroup\cloneDependencies(), ilSoapUtils\cloneNode(), ilObjectCopyGUI\copyContainer(), ilRbacAdmin\copyLocalRoles(), ilSoapObjectAdministration\copyObject(), ilObjectCopyGUI\copySingleObject(), ilObjStyleSheetGUI\copyStyleObject(), ilSoapWebLinkAdministration\createWebLink(), ilSoapObjectAdministration\deleteObject(), ilRepUtil\deleteObjects(), ilContainerReferenceAppEventListener\deleteReferences(), ilPaymentObjectGUI\editDetails(), ilObjPaymentSettingsGUI\editDetailsObject(), ilObjSessionGUI\eventsListObject(), ilSoapCourseAdministration\excludeCourseMember(), ilSoapGroupAdministration\excludeGroupMember(), ilTestExpressPageObjectGUI\executeCommand(), ilSessionOverviewGUI\exportCSV(), ilChatroomViewTask\forcePublicRoom(), ilForum\generatePost(), ilMail\getEmailsOfRecipients(), ilSoapGroupAdministration\getGroup(), ilSoapRBACAdministration\getLocalRoles(), ilCourseObjectiveQuestion\getMaxPointsByObjective(), ilCourseObjectiveQuestion\getMaxPointsByTest(), ilSoapObjectAdministration\getObjectByReference(), ilSoapObjectAdministration\getObjectsByTitle(), ilSoapRBACAdministration\getObjectTreeOperations(), ilCourseStartObjectsTableGUI\getPossibleObjects(), ilPaymentShoppingCart\getShoppingCart(), ilCourseStartObjectsTableGUI\getStartObjects(), ilSOAPStructureObjectAdministration\getStructureObjects(), ilSoapObjectAdministration\getTreeChilds(), ilMail\getUserIds(), ilObjForumGUI\getUserProfileAdditional(), ilCourseExporter\getXmlRepresentation(), ilGroupExporter\getXmlRepresentation(), ilSoapObjectAdministration\getXMLTree(), ilSoapRBACAdministration\grantPermissions(), ilECSTaskScheduler\handleDelete(), ilECSCategoryMapping\handleUpdate(), ilCourseObjective\ilClone(), ilConditionHandlerInterface\ilConditionHandlerInterface(), ilForumExplorer\ilForumExplorer(), ilObjStyleSheetGUI\importStyleObject(), ilSoapUserAdministration\importUsers(), ilGroupImporter\importXmlRepresentation(), ilCourseImporter\importXmlRepresentation(), ilFolderImporter\importXmlRepresentation(), ilDidacticTemplateAction\initSourceObject(), ilRepUtil\insertSavedNodes(), ilSoapCourseAdministration\isAssignedToCourse(), ilSoapGroupAdministration\isAssignedToGroup(), ilShopRepositoryExplorer\isVisible(), ilRepositoryExplorer\isVisible(), ilObjectGUI\isVisible(), ilSoapUtils\linkNode(), ilObjRoleGUI\listDesktopItemsObject(), ilSessionOverviewGUI\listSessions(), ilLMStatisticsGUI\listUsersGroup(), ilAdminUserSearchGUI\listUsersGroup(), ilObjiLincCourseGUI\listUsersGroupObject(), ilObjRoleGUI\listUsersGroupObject(), ilObjPaymentSettingsGUI\objectsObject(), ilCourseObjectiveQuestionAssignmentTableGUI\parse(), ilContainerGUI\performPasteIntoMultipleObjectsObject(), ilObjDlBookGUI\properties(), ilRepUtil\removeDeletedNodes(), ilSoapObjectAdministration\removeFromSystemByImportId(), ilRepUtil\removeObjectsFromSystem(), ilSoapTestAdministration\removeTestResults(), ilCourseObjectiveResult\reset(), ilRepUtil\restoreObjects(), ilSoapRBACAdministration\revokePermissions(), ilObjSessionGUI\saveObject(), ilObjStyleSheetGUI\saveObject(), ilLMStatisticsGUI\search(), ilObjiLincCourseGUI\searchObject(), ilObjRoleGUI\searchObject(), ilSoapObjectAdministration\searchObjects(), ilCourseMembershipMailNotification\send(), ilObjDlBookGUI\showAbstract(), ilPaymentCouponGUI\showCoupons(), ilShopPurchaseGUI\showDemoVersion(), ilShopBoughtObjectsGUI\showItems(), ilMailSearchGroupsGUI\showMembers(), ilObjForumGUI\showMembersObject(), ilWysiwygUtil\showMoveCopyQuestion(), ilPaymentObjectGUI\showObjects(), ilPaymentCouponGUI\showObjects(), ilPaymentObjectGUI\showSelectedObject(), ilObjDlBookGUI\showTranslationSelect(), ilSoapCourseAdministration\updateCourse(), ilSoapGroupAdministration\updateGroup(), ilSoapObjectAdministration\updateReferences(), ilMembershipRegistrationCodeUtils\useCode(), and ilConditionHandler\validate().

{
global $ilias, $objDefinition, $ilDB;
// check reference id
if (!isset($a_ref_id))
{
if ($stop_on_error === true)
{
$message = "ilObjectFactory::getInstanceByRefId(): No ref_id given!";
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
return false;
}
// read object data
$query = "SELECT * FROM object_data,object_reference ".
"WHERE object_reference.obj_id = object_data.obj_id ".
"AND object_reference.ref_id = ".$ilDB->quote($a_ref_id,'integer');
$object_set = $ilDB->query($query);
// check number of records
if ($object_set->numRows() == 0)
{
if ($stop_on_error === true)
{
$message = "ilObjectFactory::getInstanceByRefId(): Object with ref_id ".$a_ref_id." not found!";
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
return false;
}
$object_rec = $object_set->fetchRow(DB_FETCHMODE_ASSOC);
$class_name = "ilObj".$objDefinition->getClassName($object_rec["type"]);
// check class
if ($class_name == "ilObj")
{
if ($stop_on_error === true)
{
$message = "ilObjectFactory::getInstanceByRefId(): Not able to determine object ".
"class for type".$object_rec["type"].".";
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
return false;
}
// get location
$location = $objDefinition->getLocation($object_rec["type"]);
// create instance
include_once($location."/class.".$class_name.".php");
$obj = new $class_name(0, false); // this avoids reading of data
$obj->setId($object_rec["obj_id"]);
$obj->setRefId($a_ref_id);
$obj->setObjDataRecord($object_rec);
$obj->read();
return $obj;
}

+ Here is the caller graph for this function:

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, and DB_FETCHMODE_ASSOC.

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

{
global $ilias, $ilDB;
$query = "SELECT * FROM object_data,object_reference ".
"WHERE object_reference.obj_id = object_data.obj_id ".
" AND object_data.type=".$ilDB->quote($object_type,'text').
" AND object_data.owner = ".$ilDB->quote($owner_id,'integer');
$res = $ilDB->query($query);
$obj_ids = array();
while($object_rec = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
$obj_ids [] = $object_rec["obj_id"];
}
return $obj_ids;
}

+ Here is the caller graph for this function:

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

get object type by reference id

Parameters
int$obj_idobject id
Returns
string object type

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

References $ilDB, DB_FETCHMODE_ASSOC, and exit.

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

{
global $ilias, $objDefinition, $ilDB;
// check reference id
if (!isset($a_ref_id))
{
if ($stop_on_error === true)
{
$message = "ilObjectFactory::getTypeByRefId(): No ref_id given!";
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
return false;
}
// read object data
$q = "SELECT * FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id ".
"WHERE object_reference.ref_id=".$ilDB->quote($a_ref_id,'integer');
$object_set = $ilias->db->query($q);
if ($object_set->numRows() == 0)
{
if ($stop_on_error === true)
{
$message = "ilObjectFactory::getTypeByRefId(): Object with ref_id ".$a_ref_id." not found!";
$ilias->raiseError($message,$ilias->error_obj->WARNING);
exit();
}
return false;
}
$object_rec = $object_set->fetchRow(DB_FETCHMODE_ASSOC);
return $object_rec["type"];
}

+ Here is the caller graph for this function:

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.

{
global $ilias, $ilDB;
$query = "SELECT * FROM object_data ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer');
$res = $ilias->db->query($query);
return $res->numRows() ? true : false;
}

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