/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. */ public static function get_form($args, $node, $response = null) { if (empty($_GET['group_id'])) { return 'This page needs a group_id URL parameter.'; } global $base_url; global $user; iform_load_helpers(array('data_entry_helper')); data_entry_helper::$javascript .= "indiciaData.nodeId=" . $node->nid . ";\n"; data_entry_helper::$javascript .= "indiciaData.baseUrl='" . $base_url . "';\n"; data_entry_helper::$javascript .= "indiciaData.currentUsername='******';\n"; //Translations for the comment that goes into occurrence_comments when a record is verified or rejected. data_entry_helper::$javascript .= 'indiciaData.verifiedTranslation = "' . lang::get('Verified') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.rejectedTranslation = "' . lang::get('Rejected') . "\";\n"; self::$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); group_authorise_form($args, self::$auth['read']); $group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => self::$auth['read'] + array('id' => $_GET['group_id'], 'view' => 'detail'))); $group = $group[0]; hostsite_set_page_title("{$group['title']}: {$node->title}"); $def = json_decode($group['filter_definition'], true); $defstring = ''; // reconstruct this as a string to feed into dynamic report explorer foreach ($def as $key => $value) { if ($key) { $value = is_array($value) ? json_encode($value) : $value; $defstring .= "{$key}={$value}\n"; if ($key === 'indexed_location_id' || $key === 'indexed_location_list' || $key === 'location_id' || $key === 'location_list') { $args['location_boundary_id'] = $value; } elseif (($key === 'taxon_group_id' || $key === 'taxon_group_list') && strpos($value, ',') === FALSE) { // if the report is locked to a single taxon group, then we don't need taxonomy columns. $args['skipped_report_columns'] = array('taxon_group', 'taxonomy'); } } } if (empty($_GET['implicit'])) { // no need for a group user filter $args['param_presets'] = implode("\n", array($args['param_presets'], $defstring)); } else { // filter to group users - either implicitly, or only if they explicitly submitted to the group $prefix = $_GET['implicit'] === 'true' || $_GET['implicit'] === 't' ? 'implicit_' : ''; // add the group parameters to the preset parameters passed to all reports on this page $args['param_presets'] = implode("\n", array($args['param_presets'], $defstring, "{$prefix}group_id=" . $_GET['group_id'])); } $args['param_presets'] .= "\n"; if (!empty($args['hide_standard_param_filter'])) { data_entry_helper::$javascript .= "\$('#standard-params').hide();\n"; } return parent::get_form($args, $node); }
/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. * @todo: Implement this method */ public static function get_form($args, $node, $response = null) { if (empty($_GET['group_id'])) { return 'This page needs a group_id URL parameter.'; } self::$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); $group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => self::$auth['read'] + array('id' => $_GET['group_id']))); $group = $group[0]; hostsite_set_page_title($group['title']); $filter = data_entry_helper::get_population_data(array('table' => 'filter', 'extraParams' => self::$auth['read'] + array('id' => $group['filter_id']))); $filter = $filter[0]; $def = json_decode($filter['definition'], true); $defstring = ''; // reconstruct this as a string to feed into dynamic report explorer foreach ($def as $key => $value) { if ($key) { $defstring .= "{$key}={$value}\n"; } } // add the group parameters to the preset parameters passed to all reports on this page $args['param_presets'] = implode("\n", array($args['param_presets'], $defstring, "group_id=" . $_GET['group_id'])); return parent::get_form($args, $node); }