本文整理汇总了PHP中ilObjectFactory::getObjectsForOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjectFactory::getObjectsForOwner方法的具体用法?PHP ilObjectFactory::getObjectsForOwner怎么用?PHP ilObjectFactory::getObjectsForOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjectFactory
的用法示例。
在下文中一共展示了ilObjectFactory::getObjectsForOwner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
//.........这里部分代码省略.........