/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { require_once drupal_get_path('module', 'iform') . '/client_helpers/import_helper.php'; $auth = import_helper::get_read_write_auth($args['website_id'], $args['password']); if ($args['model'] == 'url') { if (!isset($_GET['type'])) { return "This form is configured so that it must be called with a type parameter in the URL"; } $model = $_GET['type']; } else { $model = $args['model']; } if (isset($args['presetSettings'])) { $presets = array(); $presetLines = explode("\n", $args['presetSettings']); foreach ($presetLines as $preset) { $preset = explode('=', $preset); // skip any invalid data for the presets if (count($preset) == 2) { $presets[$preset[0]] = $preset[1]; } } $presets = array_merge(array('website_id' => $args['website_id'], 'password' => $args['password']), $presets); } else { $presets = array('website_id' => $args['website_id'], 'password' => $args['password']); } $r = import_helper::importer(array('model' => $model, 'auth' => $auth, 'presetSettings' => $presets)); return $r; }
/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { iform_load_helpers(array('import_helper')); $auth = import_helper::get_read_write_auth($args['website_id'], $args['password']); if ($args['model'] == 'url') { if (!isset($_GET['type'])) { return "This form is configured so that it must be called with a type parameter in the URL"; } $model = $_GET['type']; } else { $model = $args['model']; } if (isset($args['presetSettings'])) { $presets = get_options_array_with_user_data($args['presetSettings']); $presets = array_merge(array('website_id' => $args['website_id'], 'password' => $args['password']), $presets); } else { $presets = array('website_id' => $args['website_id'], 'password' => $args['password']); } $r = import_helper::importer(array('model' => $model, 'auth' => $auth, 'presetSettings' => $presets)); return $r; }
/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { iform_load_helpers(array('import_helper')); $auth = import_helper::get_read_write_auth($args['website_id'], $args['password']); group_authorise_form($args, $auth['read']); if ($args['model'] == 'url') { if (!isset($_GET['type'])) { return "This form is configured so that it must be called with a type parameter in the URL"; } $model = $_GET['type']; } else { $model = $args['model']; } if (isset($args['presetSettings'])) { $presets = get_options_array_with_user_data($args['presetSettings']); $presets = array_merge(array('website_id' => $args['website_id'], 'password' => $args['password']), $presets); } else { $presets = array('website_id' => $args['website_id'], 'password' => $args['password']); } if (!empty($_GET['group_id'])) { // loading data into a recording group. $group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $auth['read'] + array('id' => $_GET['group_id'], 'view' => 'detail'))); $group = $group[0]; $presets['sample:group_id'] = $_GET['group_id']; hostsite_set_page_title(lang::get('Import data into the {1} group', $group['title'])); // if a single survey specified for this group, then force the data into the correct survey $filterdef = json_decode($group['filter_definition'], true); if (!empty($filterdef['survey_list_op']) && $filterdef['survey_list_op'] === 'in' && !empty($filterdef['survey_list'])) { $surveys = explode(',', $filterdef['survey_list']); if (count($surveys) === 1) { $presets['survey_id'] = $surveys[0]; } } } try { $r = import_helper::importer(array('model' => $model, 'auth' => $auth, 'presetSettings' => $presets)); } catch (Exception $e) { hostsite_show_message($e->getMessage(), 'warning'); $reload = import_helper::get_reload_link_parts(); unset($reload['params']['total']); unset($reload['params']['uploaded_csv']); $reloadpath = $reload['path'] . '?' . import_helper::array_to_query_string($reload['params']); $r = "<p>" . lang::get('Would you like to ') . "<a href=\"{$reloadpath}\">" . lang::get('import another file?') . "</a></p>"; } return $r; }
* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/gpl.html. * * @package Core * @subpackage Libraries * @author Indicia Team * @license http://www.gnu.org/licenses/gpl.html GPL * @link http://code.google.com/p/indicia/ */ /** * This is a view which outputs a parameters entry form to capture values that will apply to every row during an import, such as the website id. */ require_once DOCROOT . 'client_helpers/import_helper.php'; $auth = import_helper::get_read_write_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key')); echo import_helper::importer(array('model' => $this->controllerpath, 'auth' => $auth)); import_helper::$dumped_resources[] = 'jquery'; import_helper::$dumped_resources[] = 'jquery-ui'; echo import_helper::dump_javascript(); ?>