$info) { $info['type'] = $type; $vendors[$type] = $info; } return $vendors; } /** * Utility function used to call a CMIS method, * using the CMIS vendor selected in config. * * @return mixed */ function cmis_vendor_invoke() { $vendor = variable_get('cmis_vendor', null); if (is_null($vendor)) { watchdog('cmis_vendor_invoke', "cmis module not configured", null, WATCHDOG_ERROR); return; } $args = func_get_args(); $cmis_method = $args[0]; $vendors = cmis_get_vendors(); if (array_key_exists($vendor, $vendors)) { unset($args[0]); $function = $vendor . '_cmisapi_' . $cmis_method; if (function_exists($function)) { return call_user_func_array($function, $args); } watchdog('cmis_vendor_invoke', "$function not implemented", null, WATCHDOG_ERROR); return; } watchdog('cmis_vendor_invoke', "Unknown vendor: $vendor", null, WATCHDOG_ERROR); return; } /** * Implementation of hook_menu() for CMIS module. */ function cmis_menu() { $items = array(); $items['admin/settings/cmis'] = array( 'title' => 'CMIS Settings', 'description' => 'Connection settings to CMIS repositories', 'page callback' => 'drupal_get_form', 'page arguments' => array('cmis_admin_settings'), 'access callback' => 'user_access', 'access arguments' => array('administer cmis'), ); $items['cmis/autocomplete'] = array( 'title' => t('cmis path autocomplete'), 'page callback' => 'cmis_path_autocomplete', 'access callback' => 'user_access', 'access arguments' => array('access cmis'), 'type' => MENU_CALLBACK, ); return $items; } /** * Prepare and generate entry form for CMIS settings. */ function cmis_admin_settings() { $vendors = array('None'); foreach (cmis_get_vendors() as $key => $vendor) { $vendors[$key] = $vendor['name']; } $form['cmis_settings'] = array( '#type' => 'fieldset', '#title' => t('CMIS Settings'), '#description' => t('Settings for cmis repositories'), '#collapsible' => FALSE, '#collapsed' => FALSE, ); $form['cmis_settings']['cmis_vendor'] = array( '#type' => 'select', '#title' => t('Vendors'), '#default_value' => variable_get('cmis_vendor', null), '#options' => $vendors, '#description' => t('Select the CMIS vendor'), ); return system_settings_form($form); } /** * Validate Setting inputs for CMIS */ function cmis_admin_settings_validate($form, & $form_state) { // vendor is required $endpoint = $form_state['values']['cmis_vendor']; if ($endpoint == '') { form_set_error('cmis_vendor', t('You must specify the CMIS vendor.')); } } /** * Return permissions for the CMIS module. */ function cmis_perm() { $perms = array( 'administer cmis', 'access cmis', ); return $perms; } /** * Utitily function for supporting CMIS repository path auto-complete. */ function cmis_path_autocomplete() { module_load_include('api.inc', 'cmis'); $args = func_get_args(); $path = '/' . implode('/', array_slice($args, 0, sizeof($args) - 1)); $key = end($args); $matches = array(); $repository = cmisapi_getRepositoryInfo(); if ($path == '/') { $folderId_parts = explode('/', $repository->rootFolderId); $path = '/' . end($folderId_parts); $matches[$path] = $path; print drupal_to_js($matches); return; } $folderObject = cmisapi_getProperties($repository->repositoryId, drupal_urlencode($path)); foreach (array('folder', 'document') as $cmis_base_type) { $cmis_objects = cmisapi_query($repository->repositoryId, "SELECT * FROM $cmis_base_type WHERE ".($key!='*'?"Name like '%$key%' AND":"")." IN_FOLDER('$folderObject->id')"); foreach ($cmis_objects as $cmis_object) { $matches[$path . '/' . $cmis_object->title . ($cmis_base_type == 'folder' ? '/' : '')] = $cmis_object->title; } } print drupal_to_js($matches); }