本文整理汇总了PHP中ilObjectFactory::getTypeByRefId方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjectFactory::getTypeByRefId方法的具体用法?PHP ilObjectFactory::getTypeByRefId怎么用?PHP ilObjectFactory::getTypeByRefId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjectFactory
的用法示例。
在下文中一共展示了ilObjectFactory::getTypeByRefId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handlerBeginTag
/**
* handler for begin of element
*
* @param resource $a_xml_parser xml parser
* @param string $a_name element name
* @param array $a_attribs element attributes array
*/
function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
{
global $objDefinition, $ilAccess, $tree;
switch ($a_name) {
case 'Settings':
$this->options = array();
$this->source_id = (int) $a_attribs["source_id"];
if (ilObject::_isInTrash($this->source_id)) {
throw new ilSaxParserException("Source id " . $this->source_id . " is in trash");
}
$this->target_id = (int) $a_attribs["target_id"];
if (ilObject::_isInTrash($this->target_id)) {
throw new ilSaxParserException("target id" . $this->target_id . " is in trash");
}
$this->default_action = ilCopyWizardSettingsXMLParser::getActionForString($a_attribs["default_action"]);
break;
case 'Option':
$id = (int) $a_attribs["id"];
if (ilObject::_isInTrash($id)) {
throw new ilSaxParserException("Id {$id} is in trash");
}
if (!$tree->isInTree($id)) {
throw new ilSaxParserException("Id {$id} does not exist");
}
$action = ilCopyWizardSettingsXMLParser::getActionForString($a_attribs["action"]);
$type = ilObjectFactory::getTypeByRefId($id);
switch ($action) {
case ilCopyWizardOptions::COPY_WIZARD_COPY:
$perm_copy = $ilAccess->checkAccess('copy', '', $id);
$copy = $objDefinition->allowCopy($type);
if ($perm_copy && $copy) {
$this->options[$id] = array("type" => $action);
} elseif ($copy && !$perm_copy) {
throw new ilSaxParserException("Missing copy permission for object " . $id);
} elseif (!$copy) {
throw new ilSaxParserException("Copy for object " . $id . " of type " . $type . " is not supported");
}
break;
case ilCopyWizardOptions::COPY_WIZARD_LINK:
$perm_link = $ilAccess->checkAccess('write', '', $id);
$link = $objDefinition->allowLink($type);
if ($perm_link && $link) {
$this->options[$id] = array("type" => $action);
} elseif ($copy && !$perm_link) {
throw new ilSaxParserException("Missing write permission for object " . $id);
} elseif (!$link) {
throw new ilSaxParserException("Link for object " . $id . " of type " . $type . " is not supported");
}
break;
}
}
}
示例2: copyObject
/**
* copy object in repository
* $sid session id
* $settings_xml contains copy wizard settings following ilias_copy_wizard_settings.dtd
*/
function copyObject($sid, $copy_settings_xml)
{
$this->initAuth($sid);
$this->initIlias();
if (!$this->__checkSession($sid)) {
return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
}
include_once './webservice/soap/classes/class.ilSoapUtils.php';
global $rbacreview, $objDefinition, $rbacsystem, $lng, $ilUser;
include_once './webservice/soap/classes/class.ilCopyWizardSettingsXMLParser.php';
$xml_parser = new ilCopyWizardSettingsXMLParser($copy_settings_xml);
try {
$xml_parser->startParsing();
} catch (ilSaxParserException $se) {
return $this->__raiseError($se->getMessage(), "Client");
}
// checking copy permissions, objects and create permissions
if (!$rbacsystem->checkAccess('copy', $xml_parser->getSourceId())) {
return $this->__raiseError("Missing copy permissions for object with reference id " . $xml_parser->getSourceId(), 'Client');
}
// checking copy permissions, objects and create permissions
$source_id = $xml_parser->getSourceId();
$target_id = $xml_parser->getTargetId();
// does source object exist
if (!($source_object_type = ilObjectFactory::getTypeByRefId($source_id, false))) {
return $this->__raiseError('No valid source given.', 'Client');
}
// does target object exist
if (!($target_object_type = ilObjectFactory::getTypeByRefId($xml_parser->getTargetId(), false))) {
return $this->__raiseError('No valid target given.', 'Client');
}
$canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
if ($this->isFault($canAddType)) {
return $canAddType;
}
// if is container object than clone with sub items
$options = $xml_parser->getOptions();
// print_r($options);
$source_object = ilObjectFactory::getInstanceByRefId($source_id);
if ($source_object instanceof ilContainer) {
// get client id from sid
$clientid = substr($sid, strpos($sid, "::") + 2);
$sessionid = str_replace("::" . $clientid, "", $sid);
// call container clone
return $source_object->cloneAllObject($sessionid, $clientid, $source_object_type, $target_id, $source_id, $options, true);
} else {
// create copy wizard settings
$copy_id = ilCopyWizardOptions::_allocateCopyId();
$wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
$wizard_options->saveOwner($ilUser->getId());
$wizard_options->saveRoot($source_id);
foreach ($options as $source_id => $option) {
$wizard_options->addEntry($source_id, $option);
}
$wizard_options->read();
// call object clone
$newObject = $source_object->cloneObject($xml_parser->getTargetId(), $copy_id);
return is_object($newObject) ? $newObject->getRefId() : -1;
}
}
示例3: updateGroup
function updateGroup($sid, $ref_id, $grp_xml)
{
$this->initAuth($sid);
$this->initIlias();
if (!$this->__checkSession($sid)) {
return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
}
if (!is_numeric($ref_id)) {
return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category or group', 'Client');
}
global $rbacsystem;
if (!$rbacsystem->checkAccess('write', $ref_id, 'grp')) {
return $this->__raiseError('Check access failed. No permission to edit groups', 'Server');
}
// Start import
include_once "./Modules/Group/classes/class.ilObjGroup.php";
if (!($grp = ilObjectFactory::getInstanceByRefId($ref_id, false))) {
return $this->__raiseError('Cannot create group instance!', 'CLIENT_OBJECT_NOT_FOUND');
}
if (ilObject::_isInTrash($ref_id)) {
return $this->__raiseError("Object with ID {$ref_id} has been deleted.", 'CLIENT_OBJECT_DELETED');
}
if (ilObjectFactory::getTypeByRefId($ref_id, false) != "grp") {
return $this->__raiseError('Reference id does not point to a group!', 'CLIENT_WRONG_TYPE');
}
include_once 'Modules/Group/classes/class.ilGroupXMLParser.php';
$xml_parser = new ilGroupXMLParser($grp_xml, -1);
$xml_parser->setMode(ilGroupXMLParser::$UPDATE);
$xml_parser->setGroup($grp);
$new_ref_id = $xml_parser->startParsing();
return $new_ref_id ? $new_ref_id : "0";
}
示例4: checkObjectAccess
/**
* check access for ref id: expected type, permission, return object instance if returnobject is true
*
* @param int $ref_id
* @param string or array $expected_type
* @param string $permission
* @param boolean $returnObject
* @return Object or type
*/
public function checkObjectAccess($ref_id, $expected_type, $permission, $returnObject = false)
{
global $rbacsystem;
if (!is_numeric($ref_id)) {
return $this->__raiseError('No valid id given.', 'Client');
}
if (!ilObject::_exists($ref_id, true)) {
return $this->__raiseError('No object for id.', 'CLIENT_OBJECT_NOT_FOUND');
}
if (ilObject::_isInTrash($ref_id)) {
return $this->__raiseError('Object is already trashed.', 'CLIENT_OBJECT_DELETED');
}
$type = ilObjectFactory::getTypeByRefId($ref_id);
if (is_array($expected_type) && !in_array($type, $expected_type) || !is_array($expected_type) && $type != $expected_type) {
return $this->__raiseError("Wrong type {$type} for id. Expected: " . (is_array($expected_type) ? join(",", $expected_type) : $expected_type), 'CLIENT_OBJECT_WRONG_TYPE');
}
if (!$rbacsystem->checkAccess($permission, $ref_id, $type)) {
return $this->__raiseError('Missing permission $permission for type $type.', 'CLIENT_OBJECT_WRONG_PERMISSION');
}
if ($returnObject) {
return ilObjectFactory::getInstanceByRefId($ref_id);
}
return $type;
}