19 require_once SQ_INCLUDE_PATH.
'/asset.inc';
20 require_once SQ_PACKAGES_PATH.
'/sharepoint/lib/cmis_common.inc';
52 $this->_ser_attrs = TRUE;
53 parent::__construct($assetid);
70 if (!parent::_preCreateCheck($link))
return FALSE;
72 $name = trim($this->
attr(
'name'));
74 trigger_localised_error(
'CORE0083', E_USER_WARNING, $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->type(),
'name'));
95 if (!parent::_createAdditional($link))
return FALSE;
118 $allowed = parent::_getAllowedLinks();
119 $allowed[SQ_LINK_TYPE_1][
'file'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
120 $allowed[SQ_LINK_TYPE_2][
'file'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
139 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), 0);
140 if (empty($values) === TRUE) {
141 return parent::_getName($short_name);
143 return $values[$this->id];
158 public function connect($service_name, $verify = FALSE)
161 if (!$verify && isset($this->soap[$service_name]))
return TRUE;
164 $wsdl = $this->
attr(
'wsdl');
166 'username' => $this->
attr(
'username'),
167 'password' => $this->
attr(
'password'),
168 'ws_security' => $this->
attr(
'ws_security'),
170 'service_name'=> $service_name
174 if (!$cmis->connect($wsdl[$service_name], $conn_info))
return FALSE;
175 if (is_null($cmis->ptr))
return FALSE;
177 $this->soap[$service_name] = $cmis;
193 'update_assetids' => Array(),
194 'create_objectIds' => Array(),
195 'delete_assetids' => Array()
198 $dont_delete = Array();
205 if (empty($repositoryId))
return $sync_info;
208 if (empty($folderId))
return $sync_info;
211 if ($children_data === FALSE)
return $sync_info;
213 foreach ($children_data as $object_data){
216 if ($object_data[
'cmis:objectTypeId'] !=
'cmis:document' || !isset($object_data[
'cmis:contentStreamFileName']))
continue;
218 $objectId = $object_data[
'cmis:objectId'];
219 if (array_key_exists($objectId, $current_files)) {
220 $assetid = $current_files[$objectId][
'assetid'];
221 $dont_delete[] = $assetid;
224 if (isset($current_files[$objectId][
'lastModificationDate'])){
225 $lastModifiedCMIS = strtotime($object_data[
'cmis:lastModificationDate']);
226 $lastModifiedMetadata = str_replace(
'/',
'-', $current_files[$objectId][
'lastModificationDate']);
227 $lastModifiedMetadata = strtotime($lastModifiedMetadata);
229 if ($lastModifiedCMIS > $lastModifiedMetadata){
230 $sync_info[
'update_assetids'][] = Array(
231 'object_data' => $object_data,
232 'assetid' => $assetid
237 $sync_info[
'create_objectIds'][] = $object_data;
242 foreach ($current_files as $objectid => $info){
243 if (!in_array($info[
'assetid'], $dont_delete)) {
244 $sync_info[
'delete_assetids'][] = $info[
'assetid'];
262 $file_info = Array();
264 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
265 $metadata_fields = $this->
attr(
'metadata_fields');
266 if (!empty($metadata_fields[
'cmis:objectId'][
'field'])) $sync_fields[
'objectId'] = $metadata_fields[
'cmis:objectId'][
'field'];
267 if (!empty($metadata_fields[
'cmis:lastModificationDate'][
'field'])) $sync_fields[
'lastModificationDate'] = $metadata_fields[
'cmis:lastModificationDate'][
'field'];
269 if (!isset($sync_fields[
'objectId']))
return $file_info;
270 $field_names = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_values($sync_fields),
'metadata_field', FALSE,
'name');
272 $files = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($this->
id,
'file', FALSE);
273 foreach (array_keys($files) as $file_id){
274 $metadata_values = $mm->getMetadataFieldValues($file_id, array_values($field_names));
275 $objectId = $metadata_values[$field_names[$sync_fields[
'objectId']]];
276 if (!empty($objectId)) {
277 $file_info[$objectId][
'assetid'] = $file_id;
278 if (isset($sync_fields[
'lastModificationDate'])){
279 $lastModificationDate = $metadata_values[$field_names[$sync_fields[
'lastModificationDate']]];
280 if (!empty($lastModificationDate)) $file_info[$objectId][
'lastModificationDate'] = $lastModificationDate;
299 if (!$this->
connect(
'RepositoryService'))
return $fields;
302 if (empty($repositoryId))
return $fields;
304 $type_def = $this->soap[
'RepositoryService']->getTypeDefinition($repositoryId,
'cmis:document');
305 if(!isset($type_def->type->q1id) || (
string)$type_def->type->q1id !=
'cmis:document')
return $fields;
307 $properties = Array (
308 'q1propertyBooleanDefinition',
309 'q1propertyDateTimeDefinition',
310 'q1propertyDecimalDefinition',
311 'q1propertyIdDefinition',
312 'q1propertyIntegerDefinition',
313 'q1propertyStringDefinition'
316 $cmis_fields = Array (
318 'cmis:lastModificationDate',
322 foreach($properties as $propertyType) {
323 if (isset($type_def->type->$propertyType)){
324 $type = str_replace(
'Definition',
'', substr($propertyType, 10));
325 foreach($type_def->type->$propertyType as $property){
326 $propertyId = (string)$property->q1id;
327 if (strpos($propertyId,
'cmis:') !== FALSE && !in_array($propertyId, $cmis_fields))
continue;
328 $fields[$propertyId] = Array (
329 'display_name' => (
string)$property->q1displayName,
352 if (!$this->
connect(
'RepositoryService'))
return $repositoryId;
354 $repositories = $this->soap[
'RepositoryService']->getRepositories();
355 if(!isset($repositories->repositories))
return $repositoryId;
357 foreach($repositories->repositories as $repository){
358 if ($repository->repositoryName == $this->attr(
'repository_name')){
359 $repositoryId = (string)$repository->repositoryId;
364 return $repositoryId;
379 if (!$this->
connect(
'RepositoryService'))
return $folderId;
381 $repositoryInfo = $this->soap[
'RepositoryService']->getRepositoryInfo($repositoryId);
382 if (isset($repositoryInfo->repositoryInfo->rootFolderId)) $folderId = (string)$repositoryInfo->repositoryInfo->rootFolderId;
400 $children_data = Array();
401 if (!$this->
connect(
'NavigationService'))
return FALSE;
403 $children = $this->soap[
'NavigationService']->getChildren($repositoryId, $folderId);
404 if (isset($children->objects->numItems)){
405 if ((
int)$children->objects->numItems == 0)
return $children_data;
407 if (!isset($children->objects->objects))
return FALSE;
410 $properties = Array (
418 foreach ($children->objects->objects as $object){
419 foreach($properties as $propertyType) {
420 if (isset($object->object->properties->$propertyType)){
421 foreach($object->object->properties->$propertyType as $property){
422 $attributes = $property->attributes();
423 $children_data[$key][(string)$attributes[
'propertyDefinitionId']] = (
string)$property->value;
431 return $children_data;
447 if (!$this->
connect(
'ObjectService'))
return $binary_data;
449 $binary_data = $this->soap[
'ObjectService']->getContentStream($repositoryId, $objectId);