本文整理汇总了PHP中ilObject::_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObject::_exists方法的具体用法?PHP ilObject::_exists怎么用?PHP ilObject::_exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObject
的用法示例。
在下文中一共展示了ilObject::_exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addItem
/**
* Add an item to the stack. If ref_id is already used,
* the item is moved to the top.
*/
public function addItem($a_ref_id, $a_link, $a_type, $a_title = "", $a_sub_obj_id = "", $a_goto_link = "")
{
global $ilUser, $ilDB;
// never store?
if ($ilUser->prefs["store_last_visited"] == 2) {
return;
}
$a_sub_obj_id = $a_sub_obj_id . "";
if ($a_title == "" && $a_ref_id > 0) {
$obj_id = ilObject::_lookupObjId($a_ref_id);
if (ilObject::_exists($obj_id)) {
$a_title = ilObject::_lookupTitle($obj_id);
}
}
$id = $a_ref_id . ":" . $a_sub_obj_id;
$new_items[$id] = array("id" => $id, "ref_id" => $a_ref_id, "link" => $a_link, "title" => $a_title, "type" => $a_type, "sub_obj_id" => $a_sub_obj_id, "goto_link" => $a_goto_link);
$cnt = 1;
foreach ($this->items as $key => $item) {
if ($item["id"] != $id && $cnt <= 10) {
$new_items[$item["id"]] = $item;
$cnt++;
}
}
// put items in session
$this->items = $new_items;
$items = serialize($this->items);
$_SESSION["il_nav_history"] = $items;
//var_dump($this->getItems());
// only store in session?
if ($ilUser->prefs["store_last_visited"] == 1) {
return;
}
// update entries in db
$ilDB->update("usr_data", array("last_visited" => array("clob", serialize($this->getItems()))), array("usr_id" => array("integer", $ilUser->getId())));
}
示例2: fillRow
/**
* Standard Version of Fill Row. Most likely to
* be overwritten by derived class.
*/
protected function fillRow($a_set)
{
global $lng, $ilCtrl, $ilAccess;
// rollback command
if ($a_set["nr"] > 0) {
$ilCtrl->setParameter($this->getParentObject(), "old_nr", $a_set["nr"]);
$this->tpl->setCurrentBlock("command");
$this->tpl->setVariable("TXT_COMMAND", $lng->txt("cont_rollback"));
$this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTarget($this->getParentObject(), "rollbackConfirmation"));
$this->tpl->parseCurrentBlock();
$ilCtrl->setParameter($this->getParentObject(), "old_nr", "");
}
if (!$this->rselect) {
$this->tpl->setVariable("RSELECT", 'checked="checked"');
$this->rselect = true;
} else {
if (!$this->lselect) {
$this->tpl->setVariable("LSELECT", 'checked="checked"');
$this->lselect = true;
}
}
$this->tpl->setVariable("NR", $a_set["nr"]);
$this->tpl->setVariable("TXT_HDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["hdate"], IL_CAL_DATETIME)));
$ilCtrl->setParameter($this->getParentObject(), "old_nr", $a_set["nr"]);
$ilCtrl->setParameter($this->getParentObject(), "history_mode", "1");
$this->tpl->setVariable("HREF_OLD_PAGE", $ilCtrl->getLinkTarget($this->getParentObject(), "preview"));
$ilCtrl->setParameter($this->getParentObject(), "history_mode", "");
if (ilObject::_exists($a_set["user"])) {
// user name
$user = ilObjUser::_lookupName($a_set["user"]);
$login = ilObjUser::_lookupLogin($a_set["user"]);
//$this->tpl->setVariable("TXT_LINKED_USER",
// $user["lastname"].", ".$user["firstname"]." [".$login."]");
// profile link
include_once "./Services/User/classes/class.ilUserUtil.php";
$name_pres = ilUserUtil::getNamePresentation($a_set["user"], true, true, $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd()));
//$ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user", $a_set["user"]);
//$ilCtrl->setParameterByClass("ilpublicuserprofilegui", "back_url",
// rawurlencode($ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())));
//$this->tpl->setVariable("USER_LINK",
// $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
//$img = ilObjUser::_getPersonalPicturePath($a_set["user"], "xxsmall");
//$this->tpl->setVariable("IMG_USER", $img);
$this->tpl->setVariable("TXT_USER", $name_pres);
}
$ilCtrl->setParameter($this->getParentObject(), "old_nr", "");
}
示例3: userDataArrayForExport
function userDataArrayForExport($user, $b_allowExportPrivacy = false)
{
$userArray = array();
if ($b_allowExportPrivacy == false) {
$userArray["user"] = $user;
} else {
global $ilUser;
$userArray["login"] = "";
$userArray["user"] = "";
$userArray["email"] = "";
$userArray["department"] = "";
if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
$e_user = new ilObjUser($user);
$userArray["login"] = $e_user->getLogin();
$userArray["user"] = $e_user->getLastname() . ', ' . $e_user->getFirstname();
$userArray["email"] = "" . $e_user->getEmail();
$userArray["department"] = "" . $e_user->getDepartment();
}
}
return $userArray;
}
示例4: testCreationDeletion
public function testCreationDeletion()
{
$obj = new ilObject();
$obj->setType("xxx");
$obj->create();
$id = $obj->getId();
$obj2 = new ilObject();
$obj2->setType("xxx");
$obj2->create();
$id2 = $obj2->getId();
if ($id2 == $id + 1) {
$value .= "create1-";
}
if (ilObject::_exists($id)) {
$value .= "create2-";
}
$obj->delete();
$obj2->delete();
if (!ilObject::_exists($id)) {
$value .= "create3-";
}
$this->assertEquals("create1-create2-create3-", $value);
}
示例5: parse
public function parse($userSelected, $report, $reports)
{
global $ilCtrl, $lng;
$lng->loadLanguageModule("scormtrac");
$this->form = new ilPropertyFormGUI();
$this->form->setFormAction($ilCtrl->getFormAction($this->parent_obj));
$options = array("all" => $lng->txt("all"));
include_once "Services/Tracking/classes/class.ilTrQuery.php";
$users = ilTrQuery::getParticipantsForObject($this->parent_obj->object->ref_id);
include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
$privacy = ilPrivacySettings::_getInstance();
$allowExportPrivacy = $privacy->enabledExportSCORM();
//$users = $this->parent_obj->object->getTrackedUsers("");
foreach ($users as $user) {
if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') {
if ($allowExportPrivacy == true) {
$e_user = new ilObjUser($user);
$options[$user] = $e_user->getLastname() . ", " . $e_user->getFirstname();
} else {
$options[$user] = 'User Id: ' . $user;
}
}
}
$si = new ilSelectInputGUI($lng->txt("user"), "userSelected");
$si->setOptions($options);
$si->setValue($userSelected);
$this->form->addItem($si);
$options = array("choose" => $lng->txt("please_choose"));
for ($i = 0; $i < count($reports); $i++) {
$options[$reports[$i]] = $lng->txt(strtolower($reports[$i]));
}
$si = new ilSelectInputGUI($lng->txt("report"), "report");
$si->setOptions($options);
$si->setValue($report);
$this->form->addItem($si);
$this->form->addCommandButton($this->parent_cmd, $lng->txt("apply_filter"));
}
示例6: delete
/**
* Delete news item
*
*/
public function delete()
{
global $ilDB;
// delete il_news_read entries
$ilDB->manipulate("DELETE FROM il_news_read " . " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
// delete multimedia object
$mob = $this->getMobId();
// delete
parent::delete();
// delete mob after news, to have a "mob usage" of 0
if ($mob > 0 and ilObject::_exists($mob)) {
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob = new ilObjMediaObject($mob);
$mob->delete();
}
}
示例7:
public static final function _exists($a_id, $a_reference = false)
{
return parent::_exists($a_id, $a_reference);
}
示例8: downloadAllObject
/**
* Download all submitted files (of all members).
*/
function downloadAllObject()
{
$this->checkPermission("write");
$members = array();
foreach ($this->object->members_obj->getMembers() as $member_id) {
// update download time
ilExAssignment::updateTutorDownloadTime($this->object->getId(), (int) $_GET["ass_id"], $member_id);
// get member object (ilObjUser)
if (ilObject::_exists($member_id)) {
$tmp_obj =& ilObjectFactory::getInstanceByObjId($member_id);
$members[$member_id] = $tmp_obj->getFirstname() . " " . $tmp_obj->getLastname();
unset($tmp_obj);
}
}
ilExAssignment::downloadAllDeliveredFiles($this->object->getId(), (int) $_GET["ass_id"], $members);
exit;
}
示例9: getUserListHtml
/**
* Get User List HTML (to be displayed besides the map)
*/
function getUserListHtml()
{
$list_tpl = new ilTemplate("tpl.openlayers_map_user_list.html", true, true, "Services/Maps");
$cnt = 0;
foreach ($this->user_marker as $user_id) {
if (ilObject::_exists($user_id)) {
$user = new ilObjUser($user_id);
$this->css_row = $this->css_row != "tblrow1_mo" ? "tblrow1_mo" : "tblrow2_mo";
if ($user->getLatitude() != 0 && $user->getLongitude() != 0 && $user->getPref("public_location") == "y") {
$list_tpl->setCurrentBlock("item");
$list_tpl->setVariable("MARKER_CNT", $cnt);
$list_tpl->setVariable("MAP_ID", $this->getMapId());
$cnt++;
} else {
$list_tpl->setCurrentBlock("item_no_link");
}
$list_tpl->setVariable("CSS_ROW", $this->css_row);
$list_tpl->setVariable("TXT_USER", $user->getLogin());
$list_tpl->setVariable("IMG_USER", $user->getPersonalPicturePath("xxsmall"));
$list_tpl->parseCurrentBlock();
$list_tpl->touchBlock("row");
}
}
return $list_tpl->get();
}
示例10: beforePageDelete
/**
* Before page is being deleted
*
* @param object $a_page page object
*/
static function beforePageDelete($a_page)
{
$files = self::collectFileItems($a_page, $a_page->getDomDoc());
// delete all file usages
include_once "./Modules/File/classes/class.ilObjFile.php";
ilObjFile::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), false, $a_page->getLanguage());
include_once "./Modules/File/classes/class.ilObjFile.php";
foreach ($files as $file_id) {
if (ilObject::_exists($file_id)) {
$file_obj = new ilObjFile($file_id, false);
$file_obj->delete();
}
}
}
示例11: getMemberListData
/**
* get member list data
*/
function getMemberListData($a_eph_id, $a_ass_id)
{
global $ilDB;
$mem = array();
// first get list of members from member table
$set = $ilDB->query("SELECT * FROM rep_robj_xeph_members " . "WHERE obj_id = " . $ilDB->quote($a_eph_id, "integer"));
while ($rec = $ilDB->fetchAssoc($set)) {
if (ilObject::_exists($rec["user_id"]) && ilObject::_lookupType($rec["user_id"]) == "usr") {
$name = ilObjUser::_lookupName($rec["user_id"]);
$login = ilObjUser::_lookupLogin($rec["user_id"]);
$mem[$rec["user_id"]] = array("name" => $name["lastname"] . ", " . $name["firstname"], "login" => $login, "user_id" => $rec["user_id"], "lastname" => $name["lastname"], "firstname" => $name["firstname"]);
}
}
$q = "SELECT * FROM rep_robj_xeph_ass_stat " . "WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer");
$set = $ilDB->query($q);
while ($rec = $ilDB->fetchAssoc($set)) {
if (isset($mem[$rec["user_id"]])) {
$mem[$rec["user_id"]]["sent_time"] = $rec["sent_time"];
$mem[$rec["user_id"]]["submission"] = ilEphAssignment::getLastSubmission($a_ass_id, $rec["user_id"]);
$mem[$rec["user_id"]]["status_time"] = $rec["status_time"];
$mem[$rec["user_id"]]["feedback_time"] = $rec["feedback_time"];
$mem[$rec["user_id"]]["notice"] = $rec["notice"];
$mem[$rec["user_id"]]["status"] = $rec["status"];
}
}
return $mem;
}
示例12: writeResources
/**
* Create resource entries for the learning module "PKG" and all SCOS and Assets
*/
function writeResources()
{
include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php";
$tree = new ilSCORM2004Tree($this->cont_obj->getId());
//$tree = new ilTree($this->cont_obj->getId());
//$tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
//$tree->setTreeTablePK("slm_id");
foreach ($tree->getSubTree($tree->getNodeData($tree->root_id), true, array('sco', 'ass')) as $obj) {
$attrs = array();
$attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . "_ref";
$attrs["type"] = "webcontent";
if ($obj['type'] == "sco") {
$attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "sco";
} else {
$attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
}
$attrs["href"] = "./" . $obj['obj_id'] . "/index.html";
$this->writer->xmlStartTag("resource", $attrs, "");
$this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'ITSELF'), "");
$this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'OBJECTS'), "");
$this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'RESOURCES'), "");
$this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'FLAVOUR'), "");
$this->writer->xmlEndTag("resource");
$attrs = array();
$attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'ITSELF';
$attrs["type"] = "webcontent";
$attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
$this->writer->xmlStartTag("resource", $attrs, "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.xml"), "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/ilias_co_3_7.dtd"), "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.html"), "");
$this->writer->xmlEndTag("resource");
$attrs = array();
$attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'RESOURCES';
$attrs["type"] = "webcontent";
$attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
$this->writer->xmlStartTag("resource", $attrs, "");
$this->writer->xmlEndTag("resource");
$attrs = array();
$attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'FLAVOUR';
$attrs["type"] = "webcontent";
$attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
$this->writer->xmlStartTag("resource", $attrs, "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.xml"), "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/sco.xsl"), "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/css/system.css"), "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/css/style.css"), "");
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/js/scorm.js"), "");
$this->writer->xmlEndTag("resource");
$attrs = array();
$attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'OBJECTS';
$attrs["type"] = "webcontent";
$attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
$this->writer->xmlStartTag("resource", $attrs, "");
include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
$active_css = ilObjStyleSheet::getContentStylePath($this->cont_obj->getStyleSheetId());
$active_css = split(@'\\?', $active_css, 2);
$css = fread(fopen($active_css[0], 'r'), filesize($active_css[0]));
preg_match_all("/url\\(([^\\)]*)\\)/", $css, $css_files);
$css_files = array_unique($css_files[1]);
$currdir = getcwd();
chdir(dirname($active_css[0]));
foreach ($css_files as $fileref) {
if (file_exists($fileref)) {
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/images/" . basename($fileref)), "");
}
}
chdir($currdir);
include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php";
$pagetree = new ilSCORM2004Tree($this->cont_obj->getId());
//$pagetree = new ilTree($this->cont_obj->getId());
//$pagetree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
//$pagetree->setTreeTablePK("slm_id");
foreach ($pagetree->getSubTree($pagetree->getNodeData($obj['obj_id']), false, 'page') as $page) {
$page_obj = new ilSCORM2004Page($page);
$page_obj->buildDom();
$mob_ids = $page_obj->collectMediaObjects(false);
foreach ($mob_ids as $mob_id) {
if ($mob_id > 0 && ilObject::_exists($mob_id)) {
$media_obj = new ilObjMediaObject($mob_id);
$media_obj = $media_obj->getMediaItem("Standard");
if ($media_obj != null && $media_obj->getLocationType() == "LocalFile") {
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/objects/il_" . IL_INST_ID . "_mob_" . $mob_id . "/" . rawurlencode($media_obj->getLocation())), "");
}
}
}
$file_ids = $page_obj->collectFileItems();
foreach ($file_ids as $file_id) {
if (ilObject::_lookupType($file_id) == "file") {
$file_obj = new ilObjFile($file_id, false);
$this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/objects/il_" . IL_INST_ID . "_file_" . $file_id . "/" . rawurlencode($file_obj->filename)), "");
}
}
unset($page_obj);
}
$this->writer->xmlEndTag("resource");
}
//.........这里部分代码省略.........
示例13: addObject
function addObject($sid, $a_target_id, $a_xml)
{
$this->initAuth($sid);
$this->initIlias();
if (!$this->__checkSession($sid)) {
return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
}
if (!strlen($a_xml)) {
return $this->__raiseError('No valid xml string given.', 'Client');
}
global $rbacsystem, $objDefinition, $ilUser, $lng, $ilObjDataCache;
if (!($target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id, false))) {
return $this->__raiseError('No valid target given.', 'Client');
}
if (ilObject::_isInTrash($a_target_id)) {
return $this->__raiseError("Parent with ID {$a_target_id} has been deleted.", 'Client');
}
$allowed_types = array('root', 'cat', 'grp', 'crs', 'fold');
if (!in_array($target_obj->getType(), $allowed_types)) {
return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
}
$allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
foreach ($allowed_subtypes as $row) {
if ($row['name'] != 'rolf') {
$allowed[] = $row['name'];
}
}
include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
$xml_parser =& new ilObjectXMLParser($a_xml, true);
try {
$xml_parser->startParsing();
} catch (ilSaxParserException $se) {
return $this->__raiseError($se->getMessage(), 'Client');
} catch (ilObjectXMLException $e) {
return $this->__raiseError($e->getMessage(), 'Client');
}
foreach ($xml_parser->getObjectData() as $object_data) {
$res = $this->validateReferences('create', $object_data, $a_target_id);
if ($this->isFault($res)) {
return $res;
}
// Check possible subtype
if (!in_array($object_data['type'], $allowed)) {
return $this->__raiseError('Objects of type: ' . $object_data['type'] . ' are not allowed to be subobjects of type ' . $target_obj->getType() . '!', 'Client');
}
if (!$rbacsystem->checkAccess('create', $a_target_id, $object_data['type'])) {
return $this->__raiseError('No permission to create objects of type ' . $object_data['type'] . '!', 'Client');
}
// begin-patch fm
/*
if($object_data['type'] == 'crs')
{
return $this->__raiseError('Cannot create course objects. Use method addCourse() ',
'Client');
}
*/
// end-patch fm
// It's not possible to add objects with non unique import ids
if (strlen($object_data['import_id']) and ilObject::_lookupObjIdByImportId($object_data['import_id'])) {
return $this->__raiseError('An object with import id ' . $object_data['import_id'] . ' already exists!', 'Server');
}
// call gui object method
$class_name = $objDefinition->getClassName($object_data['type']);
$location = $objDefinition->getLocation($object_data['type']);
$class_constr = "ilObj" . $class_name;
require_once $location . "/class.ilObj" . $class_name . ".php";
$newObj = new $class_constr();
if (isset($object_data['owner']) && strlen($object_data['owner'])) {
if ((int) $object_data['owner']) {
if (ilObject::_exists((int) $object_data['owner']) && $ilObjDataCache->lookupType((int) $object_data['owner']) == 'usr') {
$newObj->setOwner((int) $object_data['owner']);
}
} else {
$usr_id = ilObjUser::_lookupId(trim($object_data['owner']));
if ((int) $usr_id) {
$newObj->setOwner((int) $usr_id);
}
}
}
$newObj->setType($object_data['type']);
if (strlen($object_data['import_id'])) {
$newObj->setImportId($object_data['import_id']);
}
$newObj->setTitle($object_data['title']);
$newObj->setDescription($object_data['description']);
$newObj->create();
// true for upload
$newObj->createReference();
$newObj->putInTree($a_target_id);
$newObj->setPermissions($a_target_id);
switch ($object_data['type']) {
case 'grp':
// Add member
$newObj->addMember($object_data['owner'] ? $object_data['owner'] : $ilUser->getId(), $newObj->getDefaultAdminRole());
break;
// begin-patch fm
// begin-patch fm
case 'crs':
$newObj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
break;
//.........这里部分代码省略.........
示例14: _lookupOwnerName
/**
* lookup owner name for owner id
*/
function _lookupOwnerName($a_owner_id)
{
global $lng;
if ($a_owner_id != -1) {
if (ilObject::_exists($a_owner_id)) {
$owner = new ilObjUser($a_owner_id);
}
}
if (is_object($owner)) {
$own_name = $owner->getFullname();
} else {
$own_name = $lng->txt("unknown");
}
return $own_name;
}
示例15: getGroupsForUser
/**
* get groups which belong to a specific user, fullilling the status
*
* @param string $sid
* @param string $parameters following xmlresultset, columns (user_id, status with values 1 = "MEMBER", 2 = "TUTOR", 4 = "ADMIN", 8 = "OWNER" and any xor operation e.g. 1 + 4 = 5 = ADMIN and TUTOR, 7 = ADMIN and TUTOR and MEMBER)
* @param string XMLResultSet, columns (ref_id, xml, parent_ref_id)
*/
function getGroupsForUser($sid, $parameters)
{
$this->initAuth($sid);
$this->initIlias();
if (!$this->__checkSession($sid)) {
return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
}
global $rbacreview, $ilObjDataCache, $tree;
include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
$parser = new ilXMLResultSetParser($parameters);
try {
$parser->startParsing();
} catch (ilSaxParserException $exception) {
return $this->__raiseError($exception->getMessage(), "Client");
}
$xmlResultSet = $parser->getXMLResultSet();
if (!$xmlResultSet->hasColumn("user_id")) {
return $this->__raiseError("parameter user_id is missing", "Client");
}
if (!$xmlResultSet->hasColumn("status")) {
return $this->__raiseError("parameter status is missing", "Client");
}
$user_id = (int) $xmlResultSet->getValue(0, "user_id");
$status = (int) $xmlResultSet->getValue(0, "status");
$ref_ids = array();
// get roles
#var_dump($xmlResultSet);
#echo "uid:".$user_id;
#echo "status:".$status;
if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) || ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN)) {
foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
#echo $role->getType();
if ($role->getType() != "role") {
continue;
}
if ($role->getParent() == ROLE_FOLDER_ID) {
continue;
}
$role_title = $role->getTitle();
if ($ref_id = ilUtil::__extractRefId($role_title)) {
if (!ilObject::_exists($ref_id, true) || ilObject::_isInTrash($ref_id)) {
continue;
}
#echo $role_title;
if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) && strpos($role_title, "member") !== false) {
$ref_ids[] = $ref_id;
} elseif (ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN) && strpos($role_title, "admin") !== false) {
$ref_ids[] = $ref_id;
}
}
}
}
}
if (($status & ilSoapGroupAdministration::OWNER) == ilSoapGroupAdministration::OWNER) {
$owned_objects = ilObjectFactory::getObjectsForOwner("grp", $user_id);
foreach ($owned_objects as $obj_id) {
$allrefs = ilObject::_getAllReferences($obj_id);
$refs = array();
foreach ($allrefs as $r) {
if ($tree->isDeleted($r)) {
continue;
}
if ($tree->isInTree($r)) {
$refs[] = $r;
}
}
if (count($refs) > 0) {
$ref_ids[] = array_pop($refs);
}
}
}
$ref_ids = array_unique($ref_ids);
#print_r($ref_ids);
include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
include_once 'Modules/Group/classes/class.ilObjGroup.php';
include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
$xmlResultSet = new ilXMLResultSet();
$xmlResultSet->addColumn("ref_id");
$xmlResultSet->addColumn("xml");
$xmlResultSet->addColumn("parent_ref_id");
foreach ($ref_ids as $group_id) {
$group_obj = $this->checkObjectAccess($group_id, "grp", "write", true);
if ($group_obj instanceof ilObjGroup) {
$row = new ilXMLResultSetRow();
$row->setValue("ref_id", $group_id);
$xmlWriter = new ilGroupXMLWriter($group_obj);
$xmlWriter->setAttachUsers(false);
$xmlWriter->start();
$row->setValue("xml", $xmlWriter->getXML());
$row->setValue("parent_ref_id", $tree->getParentId($group_id));
$xmlResultSet->addRow($row);
}
//.........这里部分代码省略.........