You are here

function CMISService::updateProperties in CMIS API 7

Same name and namespace in other branches
  1. 6.4 cmis_common/lib/cmis_repository_wrapper.php \CMISService::updateProperties()
  2. 6.3 cmis_common/lib/cmis_repository_wrapper.php \CMISService::updateProperties()

File

cmis_common/lib/cmis_repository_wrapper.php, line 879

Class

CMISService

Code

function updateProperties($objectId, $properties = array(), $options = array()) {

  // Yes
  $varmap = $options;
  $varmap["id"] = $objectId;
  $objectName = $this
    ->getTitle($objectId);
  $objectType = $this
    ->getObjectType($objectId);
  $obj_url = $this
    ->getLink($objectId, "edit");
  $obj_url = CMISRepositoryWrapper::getOpUrl($obj_url, $options);
  static $entry_template;
  if (!isset($entry_template)) {
    $entry_template = CMISService::getEntryTemplate();
  }
  if (is_array($properties)) {
    $hash_values = $properties;
  }
  else {
    $hash_values = array();
  }
  $properties_xml = $this
    ->processPropertyTemplates($objectType, $hash_values);
  if (is_array($options)) {
    $hash_values = $options;
  }
  else {
    $hash_values = array();
  }
  $fixed_hash_values = array(
    "PROPERTIES" => $properties_xml,
    "SUMMARY" => CMISService::getSummaryTemplate(),
  );

  // merge the fixes hash values first so that the processing order is correct
  $hash_values = array_merge($fixed_hash_values, $hash_values);
  if (!isset($hash_values['title'])) {
    $hash_values['title'] = $objectName;
  }
  if (!isset($hash_values['summary'])) {
    $hash_values['summary'] = $objectName;
  }
  $put_value = CMISRepositoryWrapper::processTemplate($entry_template, $hash_values);
  $ret = $this
    ->doPut($obj_url, $put_value, MIME_ATOM_XML_ENTRY);
  $obj = $this
    ->extractObject($ret->body);
  $this
    ->cacheEntryInfo($obj);
  return $obj;
}