'); drupal_set_breadcrumb($breadcrumb); if (array_key_exists('name', $_GET)) { if ($_SESSION['stormorganization_list_filter']['name'] != $_GET['name']) { _storm_set_filter_param('organization', 'name', $_GET['name']); } } $i = new stdClass(); $i->type = 'stormorganization'; $header = array( array( 'data' => t('Name'), 'field' => 'n.title', 'sort' => 'ASC', ), array( 'data' => t('Country'), 'field' => 'sor.country', 'sort' => '', ), array( 'data' => storm_icon_add_node($i, $_GET), 'class' => 'storm_list_operations', ), ); $where = array(); $args = array(); $filterfields = array(); $s = "SELECT n.*, sor.*, nre.format FROM {node} AS n INNER JOIN {stormorganization} AS sor ON n.vid=sor.vid INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid WHERE n.status=1 AND n.type='stormorganization'"; if (_storm_isset_filter_param('organization', 'country', '-')) { $where[] = "sor.country='%s'"; $args[] = $_SESSION['stormorganization_list_filter']['country']; $filterfields[] = t('Country'); } if (_storm_isset_filter_param('organization', 'name', '')) { $where[] = "LOWER(n.title) LIKE LOWER('%s')"; $args[] = $_SESSION['stormorganization_list_filter']['name']; $filterfields[] = t('Name'); } if (_storm_isset_filter_param('organization', 'iscustomer', NULL, '-')) { if ($_SESSION['stormorganization_list_filter']['iscustomer'] == 'yes') { $where[] = "sor.iscustomer=1"; } elseif ($_SESSION['stormorganization_list_filter']['iscustomer'] == 'no') { $where[] = "sor.iscustomer=0"; } $filterfields[] = t('Customer'); } if (_storm_isset_filter_param('organization', 'isprovider', NULL, '-')) { if ($_SESSION['stormorganization_list_filter']['isprovider'] == 'yes') { $where[] = "sor.isprovider=1"; } elseif ($_SESSION['stormorganization_list_filter']['isprovider'] == 'no') { $where[] = "sor.isprovider=0"; } $filterfields[] = t('Provider'); } if (_storm_isset_filter_param('organization', 'isactive', 'yes', '-')) { if ($_SESSION['stormorganization_list_filter']['isactive'] == 'yes') { $where[] = "sor.isactive=1"; } elseif ($_SESSION['stormorganization_list_filter']['isactive'] == 'no') { $where[] = "sor.isactive=0"; } $filterfields[] = t('Active'); } $itemsperpage = _storm_get_filter_param('organization', 'itemsperpage', variable_get('storm_default_items_per_page', 10)); if (count($filterfields) == 0) { $filterdesc = t('Not filtered'); } else { $filterdesc = t('Filtered by !fields', array('!fields' => implode(", ", array_unique($filterfields)))); } $filterdesc .= ' | '. t('!items items per page', array('!items' => $itemsperpage)); $o = drupal_get_form('stormorganization_list_filter', $filterdesc); $s = stormorganization_access_sql($s, $where); $s = db_rewrite_sql($s); $tablesort = tablesort_sql($header); $r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args); $organizations = array(); while ($organization = db_fetch_object($r)) { $organizations[] = $organization; } $o .= theme('stormorganization_list', $header, $organizations); $o .= theme('pager', NULL, $itemsperpage, 0); print theme('page', $o); } function stormorganization_list_filter(&$form_state, $filterdesc = 'Filter') { $country_list = storm_attributes_bydomain('Country'); $country = _storm_get_filter_param('organization', 'country', '-'); $name = _storm_get_filter_param('organization', 'name', ''); $iscustomer = _storm_get_filter_param('organization', 'iscustomer'); $isprovider = _storm_get_filter_param('organization', 'isprovider'); $isactive = _storm_get_filter_param('organization', 'isactive', 'yes'); $itemsperpage = _storm_get_filter_param('organization', 'itemsperpage', variable_get('storm_default_items_per_page', 10)); $form = array(); $form['filter'] = array( '#type' => 'fieldset', '#title' => $filterdesc, '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -20, ); $form['filter']['country'] = array( '#type' => 'select', '#title' => t('Country'), '#default_value' => $country, '#options' => array('-' => t('-')) + $country_list['values'], ); $form['filter']['name'] = array( '#type' => 'textfield', '#title' => t('Name'), '#default_value' => $name, '#autocomplete_path' => 'storm/organizations/autocomplete', ); $qs = '