'admin/content/types/deploy', 'title' => t('Deploy'), 'description' => t('Add a content type to a deployment plan.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('content_copy_deploy_add_form', $plans), 'access' => user_access('add items to deployment plan'), 'type' => MENU_LOCAL_TASK ); } return $items; } /** * deploy content type form */ function content_copy_deploy_add_form($plans) { $types = content_copy_types(); $form['pid'] = array( '#title' => t('Deployment Plan'), '#type' => 'select', '#options' => $plans, '#description' => t('The deployment plan to add this content type to.'), ); if (module_exists('hs_flatlist')) { $form['content_type'] = array( '#title' => t('Content Type'), '#type' => 'hierarchical_select', '#required' => TRUE, '#config' => array( 'module' => 'hs_flatlist', 'params' => array('options' => $types), 'dropbox' => array( 'status' => 1, 'title' => t('Selected content types'), ) ), '#description' => t('The content types to deploy.'), ); } else { $form['content_type'] = array( '#title' => t('Content Type'), '#type' => 'select', '#multiple' => TRUE, '#required' => TRUE, '#options' => $types, '#description' => t('The content type to deploy.'), ); } $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; } /** * deploy content type form submit callback */ function content_copy_deploy_add_form_submit($form_id, $form_values) { $pid = $form_values['pid']; $module = 'content_copy'; foreach ($form_values['content_type'] as $content_type) { $description = "Content Type: $content_type"; deploy_add_to_plan($pid, $module, $description, $content_type); } return "admin/build/deploy/list/$pid"; } /** * deploy content type form validation callback */ function content_copy_deploy_add_form_validate($form_id, $form_values) { foreach ($form_values['content_type'] as $content_type) { $result = db_query("select * from {deploy_plan_items} where module = 'content_copy' and pid = %d and data = '%s'", $form_values['pid'], $content_type); if (db_num_rows($result)) { form_set_error('content_type', t("Content type $content_type already exists in the deployment plan.")); } } } /** * deploy content deployment 'hook' */ function content_copy_deploy($url, $api_key, $content_type) { $groups = array(); if (module_exists('fieldgroup')) { $groups = content_copy_groups($content_type); } $fields = content_copy_fields($content_type); $fields = array_keys($fields); $values = array( 'type_name' => $content_type, 'groups' => $groups, 'fields' => $fields ); $export = content_copy_export('content_copy_export_form', $values); return xmlrpc($url, 'content_copy.import', $api_key, $content_type, $export); }