function cmis_content_create_form_submit in CMIS API 6
Handle content create form submission.
File
- cmis_content/
cmis_content.module, line 131
Code
function cmis_content_create_form_submit($form, &$form_state) {
module_load_include('api.inc', 'cmis');
$path = $form_state['values']['path'];
$name = $form_state['values']['name'];
$content = $form_state['values']['content'];
// Process the form
// Invoke Utility Service to get content id
$repository = cmisapi_getRepositoryInfo();
if (!$path) {
$folderId_parts = explode('/', $repository->rootFolderId);
$path = '/' . end($folderId_parts);
}
$cmis_object = cmisapi_getProperties($repository->repositoryId, drupal_urlencode($path));
if (false === $cmis_object) {
drupal_set_message(t('Failed to locate the target space with path ' . $path));
$form_state['redirect'] = 'cmis/create';
}
else {
if ($cmis_object->type == 'folder') {
$objectId = cmisapi_createDocument($repository->repositoryId, 'document', array(
'content-type' => 'text/html',
'title' => $name,
), $cmis_object->id, $content);
if ($objectId) {
drupal_set_message('CMIS content ' . $name . ' has been created.');
$form_state['redirect'] = 'cmis/browser' . $path;
}
else {
drupal_set_message('Unable to create ' . $name . ' content.', 'error');
$form_state['redirect'] = 'cmis/create';
return false;
}
}
else {
drupal_set_message(t('Error when locating the target space ' . $path, 'error'));
$form_state['redirect'] = 'cmis/create';
}
}
}