'); drupal_set_breadcrumb($breadcrumb); if (array_key_exists('name', $_GET)) { if ($_SESSION['stormorganization_list_filter']['name'] != $_GET['name']) { $_SESSION['stormorganization_list_filter']['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', ), ); $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'"; $where = array(); $args = array(); $filterfields = array(); $country = isset($_SESSION['stormorganization_list_filter']['country']) ? $_SESSION['stormorganization_list_filter']['country'] : '-'; if ($country != '-') { $where[] = "sor.country='%s'"; $args[] = $_SESSION['stormorganization_list_filter']['country']; $filterfields[] = t('Country'); } if (isset($_SESSION['stormorganization_list_filter']['name']) && $_SESSION['stormorganization_list_filter']['name'] != '') { $where[] = "LOWER(n.title) LIKE LOWER('%s')"; $args[] = $_SESSION['stormorganization_list_filter']['name']; $filterfields[] = t('Name'); } $iscustomer = isset($_SESSION['stormorganization_list_filter']['iscustomer']) ? $_SESSION['stormorganization_list_filter']['iscustomer'] : '-'; if ($iscustomer != '-') { if ($iscustomer == 'yes') { $where[] = "sor.iscustomer=1"; } elseif ($iscustomer == 'no') { $where[] = "sor.iscustomer=0"; } $filterfields[] = t('Customer'); } $isprovider = isset($_SESSION['stormorganization_list_filter']['isprovider']) ? $_SESSION['stormorganization_list_filter']['isprovider'] : '-'; if ($isprovider != '-') { if ($isprovider == 'yes') { $where[] = "sor.isprovider=1"; } elseif ($isprovider == 'no') { $where[] = "sor.isprovider=0"; } $filterfields[] = t('Provider'); } $isactive = isset($_SESSION['stormorganization_list_filter']['isactive']) ? $_SESSION['stormorganization_list_filter']['isactive'] : '-'; if ($isactive != '-') { if ($isactive == 'yes') { $where[] = "sor.isactive=1"; } elseif ($isactive == 'no') { $where[] = "sor.isactive=0"; } $filterfields[] = t('Active'); } // Sets value for fieldset label, does not affect filter itself. $itemsperpage = isset($_SESSION['stormorganization_list_filter']['itemsperpage']) ? $_SESSION['stormorganization_list_filter']['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 = isset($_SESSION['stormorganization_list_filter']['country']) ? $_SESSION['stormorganization_list_filter']['country'] : '-'; $_SESSION['stormorganization_list_filter']['country'] = $country; $name = isset($_SESSION['stormorganization_list_filter']['name']) ? $_SESSION['stormorganization_list_filter']['name'] : ''; $iscustomer = isset($_SESSION['stormorganization_list_filter']['iscustomer']) ? $_SESSION['stormorganization_list_filter']['iscustomer'] : NULL; $isprovider = isset($_SESSION['stormorganization_list_filter']['isprovider']) ? $_SESSION['stormorganization_list_filter']['isprovider'] : NULL; $isactive = isset($_SESSION['stormorganization_list_filter']['isactive']) ? $_SESSION['stormorganization_list_filter']['isactive'] : 'yes'; $_SESSION['stormorganization_list_filter']['isactive'] = $isactive; $itemsperpage = isset($_SESSION['stormorganization_list_filter']['itemsperpage']) ? $_SESSION['stormorganization_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10); $_SESSION['stormorganization_list_filter']['itemsperpage'] = $itemsperpage; $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 = '