/[drupal]/contributions/modules/hidden/hidden.admin.inc
ViewVC logotype

Diff of /contributions/modules/hidden/hidden.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Dec 10 23:03:47 2008 UTC revision 1.2, Thu Dec 18 15:29:07 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: hidden.admin.inc,v 1.1 2008/12/10 23:03:47 ekes Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 132  function hidden_admin_settings(&$form_st Line 132  function hidden_admin_settings(&$form_st
132   * Menu callback; Hidden admin change reasons for hiding   * Menu callback; Hidden admin change reasons for hiding
133   */   */
134  function hidden_reasons_admin() {  function hidden_reasons_admin() {
135    $result = db_query('SELECT {hidden_reasons}.* FROM {hidden_reasons} WHERE enabled=1');    $enabled = array();
136    $table = theme('item_list', array(l(t('Add new reason'), 'admin/content/hidden/reasons/add/'))); // yes I know one item    $disabled = array();
137    $header = array(t('Reason'), array('data' => t('Operations'), 'colspan' => '2'));    $reasons = hidden_reason_get_all(FALSE);
138    $rows = array();    foreach ($reasons as $reason) {
139    while ($reason = db_fetch_object($result)) {      if ($reason->enabled) {
140      $rows[] = array(        $enabled[] = array(
141        check_plain($reason->title),          check_plain($reason->title),
142        l(t('edit'), 'admin/content/hidden/reasons/edit/'. $reason->rid),          l(t('edit'), 'admin/content/hidden/reasons/edit/'. $reason->rid),
143        l(t('disable'), 'admin/content/hidden/reasons/disable/'. $reason->rid),          l(t('disable'), 'admin/content/hidden/reasons/disable/'. $reason->rid),
144      );        );
145    }      }
146    if (count($rows)==0) {      else {
147      $rows[] = array(t('No enabled reasons'), '', '');        $disabled[] = array(
148            check_plain($reason->title),
149            l(t('edit'), 'admin/content/hidden/reasons/edit/'. $reason->rid),
150            l(t('enable'), 'admin/content/hidden/reasons/enable/'. $reason->rid),
151          );
152        }
153    }    }
154    $table .= theme('table', $header, $rows);    if (count($enabled) == 0) {
155    $page = theme('box', t('Reasons for hiding'), $table);      $enabled[] = array(t('No enabled reasons'), '', '');
   
   $result = db_query('SELECT {hidden_reasons}.* FROM {hidden_reasons} WHERE enabled=0');  
   $rows = array();  
   while ($reason = db_fetch_object($result)) {  
     $rows[] = array(  
       check_plain($reason->title),  
       l(t('edit'), 'admin/content/hidden/reasons/edit/'. $reason->rid),  
       l(t('enable'), 'admin/content/hidden/reasons/enable/'. $reason->rid),  
     );  
156    }    }
157    if (count($rows)==0) {    if (count($disabled) == 0) {
158      $rows[] = array(t('No disabled reasons'), '', '');      $disabled[] = array(t('No disabled reasons'), '', '');
159    }    }
160    $table = theme('table', $header, $rows);  
161      $table = theme('item_list', array(l(t('Add new reason'), 'admin/content/hidden/reasons/add/'))); // yes I know one item
162      $header = array(t('Reason'), array('data' => t('Operations'), 'colspan' => '2'));
163      $table .= theme('table', $header, $enabled);
164      $page = theme('box', t('Reasons for hiding'), $table);
165      $table = theme('table', $header, $disabled);
166    $page .= theme('box', t('Disabled reasons for hiding'), $table);    $page .= theme('box', t('Disabled reasons for hiding'), $table);
167    
168    return $page;    return $page;
# Line 170  function hidden_reasons_admin() { Line 171  function hidden_reasons_admin() {
171  /**  /**
172   * Menu callback; Admin new or edit hidden reason   * Menu callback; Admin new or edit hidden reason
173   *   *
174   * @ingroup themes   * @ingroup forms
175   * @see hidden_reasons_admin_form_submit   * @see hidden_reasons_admin_form_submit
176   */   */
177  function hidden_reasons_admin_form(&$form_state, $op, $rid=0) {  function hidden_reasons_admin_form(&$form_state, $op, $rid=0) {
# Line 223  function hidden_reasons_admin_form_submi Line 224  function hidden_reasons_admin_form_submi
224    $description = (string) $form_state['values']['description'];    $description = (string) $form_state['values']['description'];
225    $rid = (int) $form_state['values']['rid'];    $rid = (int) $form_state['values']['rid'];
226    $enabled = (bool) $form_state['values']['enabled'];    $enabled = (bool) $form_state['values']['enabled'];
227    
228      if ($rid) {
229        $result = hidden_reason_update($title, $description, $enabled, $rid);
230      }
231      else {
232        $result = hidden_reason_create($title, $description, $enabled);
233      }
234    
   $result = _hidden_reasons_admin_form_submit($title, $description, $rid, $enabled);  
235    $t_args = array('%title' => $title);    $t_args = array('%title' => $title);
236    if ($result == FALSE) {    if ($result == FALSE) {
237      drupal_set_message(t('Error saving reason %title', $t_args), 'error');      drupal_set_message(t('Error saving reason %title', $t_args), 'error');
# Line 239  function hidden_reasons_admin_form_submi Line 246  function hidden_reasons_admin_form_submi
246      _hidden_log(HIDDEN_LOG_REASONS, t('Reason %title added.', $t_args), 'reason', $rid);      _hidden_log(HIDDEN_LOG_REASONS, t('Reason %title added.', $t_args), 'reason', $rid);
247    }    }
248    
249    return 'admin/content/hidden/reasons';    $form_state['redirect'] = 'admin/content/hidden/reasons';
 }  
   
 /**  
  * Insert or update hidden reason from hidden_reasons_admin_form_submit()  
  *  
  * @param $title  
  *   plain text(255) title for hidden_reason  
  * @param $description  
  *   html text describing reason  
  * @param $reason  
  *   int 0 if new reason, reason id if editing  
  * @param $enabled  
  *   bool true for an enabled reason  
  * @return  
  *   FALSE fail, SAVED_* const for type of saved  
  */  
 function _hidden_reasons_admin_form_submit($title, $description, $rid, $enabled) {  
   if ($rid != 0) {  
     if (_hidden_reason_check($rid)) {  
       if (! db_query("UPDATE {hidden_reasons} SET title='%s', description='%s', enabled=%d WHERE rid=%d", $title, $description, $enabled, $rid)) {  
         _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_reasons_admin_form_submit() failed UPDATE.', 'reason', $rid);  
         return FALSE;  
       }  
       return $rid;  
     }  
     else {  
       _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_reasons_admin_form_submit() passed invalid $rid.', 'reason', $rid);  
       return FALSE;  
     }  
   }  
   else {  
     if (! db_query("INSERT INTO {hidden_reasons} (title, description, enabled) VALUES ('%s', '%s', %d)", $title, $description, $enabled)) {  
       _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_reasons_form_submit() failed INSERT.');  
       return FALSE;  
     }  
     $rid = db_last_insert_id("{hidden_reasons}_rid", "rid");  
     return $rid;  
   }  
250  }  }
251    
252  /**  /**
# Line 287  function hidden_reasons_admin_able($acti Line 256  function hidden_reasons_admin_able($acti
256    $rid = (int)$rid;    $rid = (int)$rid;
257    
258    if ($action == 'enable') {    if ($action == 'enable') {
259      $able = 1;      $result = hidden_reason_enable($rid);
260    }    }
261    elseif ($action == 'disable') {    elseif ($action == 'disable') {
262      $able = 0;      $result = hidden_reason_disable($rid);
263    }    }
264    else {    else {
265      _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_reasons_admin_able() called with invalid $action');      _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_reasons_admin_able() called with invalid $action');
     drupal_goto('admin/content/hidden/reasons');  
266    }    }
267    
268    if ($reason=hidden_reason_get($rid)) {    if ($result) {
269      $t_args = array('%title' => check_plain($reason->title), '%action' => $action);      $action = ($action == 'enable') ? 'enabled' : 'disabled';
270      if (! db_query('UPDATE {hidden_reasons} SET enabled=%d WHERE rid=%d', $able, $rid)) {      drupal_set_message(t('Reason %action', array('%action' => $action)));
       _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_reasons_admin_able() failed UPDATE to '. $action, 'reason', $rid);  
       drupal_set_message(t('Database error trying to %action reason %title', $t_args));  
     }  
     else {  
       _hidden_log(HIDDEN_LOG_REASONS, t('Reason %title changed.', $t_args), 'reason', $rid);  
       drupal_set_message(t('Reason %title updated', $t_args));  
     }  
271    }    }
272    else {    else {
273      _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_reasons_admin() passed $rid that does not exist', 'reason', $rid);      $action = ($action == 'enable') ? 'enabling' : 'disabling';
274      drupal_set_message(t('Tried to update a reason that does not exist'), 'error');      drupal_set_message(t('Error %action reason', array('%action' => $action)));
275    }    }
276    
277    drupal_goto('admin/content/hidden/reasons');    drupal_goto('admin/content/hidden/reasons');
# Line 324  function hidden_reasons_admin_able($acti Line 285  function hidden_reasons_admin_able($acti
285   * Menu callback; administer filters.   * Menu callback; administer filters.
286   */   */
287  function hidden_filters_admin() {  function hidden_filters_admin() {
 // test a preg filter for FALSE  
288    $enabled = theme('item_list', array(l(t('Add new filter'), 'admin/content/hidden/filters/add')));    $enabled = theme('item_list', array(l(t('Add new filter'), 'admin/content/hidden/filters/add')));
289    $enabled .= drupal_get_form('hidden_filters_admin_enabled_form');    $enabled .= drupal_get_form('hidden_filters_admin_enabled_form');
290    $page = theme('box', t('Enabled filters'), $enabled);    $page = theme('box', t('Enabled filters'), $enabled);
291    
292    $query = 'SELECT f.hfid as hfid, f.hits as hits, f.lasthit as date,'    $result = hidden_filter_all_get_pager(0, 0);
          .' r.title'  
          .' FROM {hidden_filters} AS f'  
          .' INNER JOIN {hidden_filter_reasons} AS r ON f.hfid = r.hfid'  
          .' WHERE f.enabled=0'  
          .' ORDER BY f.weight DESC';  
   $result = db_query($query);  
293    $header = array(t('filter name'), t('hits'), t('last hit'), array('data' => t('operations'), '#colspan' => 2));    $header = array(t('filter name'), t('hits'), t('last hit'), array('data' => t('operations'), '#colspan' => 2));
294    $rows = array();    $rows = array();
295    while ($filter = db_fetch_object($result)) {    while ($filter = db_fetch_object($result)) {
# Line 364  function hidden_filters_admin() { Line 318  function hidden_filters_admin() {
318   * @see hidden_filters_admin_form_submit()   * @see hidden_filters_admin_form_submit()
319   */   */
320  function hidden_filters_admin_form(&$form_state, $op, $hfid=0) {  function hidden_filters_admin_form(&$form_state, $op, $hfid=0) {
321    $hfid = (int)$hfid;    $hfid = (int) $hfid;
322    if ($op == 'edit') {    if ($op == 'edit') {
323      if (! $item=_hidden_filter_get($hfid)) {      if (! $item=hidden_filter_load($hfid)) {
324        drupal_not_found();        drupal_not_found();
325        return;        return;
326      }      }
327    }    }
328    elseif ($op == 'add') {    elseif ($op == 'add') {
329      $item = (object)array('hfid' => 0, 'enabled' => 1, 'rid' => 0, 'delay' => 1, 'type' => HIDDEN_FILTER_PLAIN);      $item = (object)array('hfid' => 0, 'enabled' => 1, 'rid' => 0, 'delay' => 1, 'type' => HIDDEN_FILTER_PLAIN, 'weight' => 0);
330    }    }
331    else {    else {
332      _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_filters_admin_form() passed invalid $op');      _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_filters_admin_form() passed invalid $op');
# Line 382  function hidden_filters_admin_form(&$for Line 336  function hidden_filters_admin_form(&$for
336    $form['title'] = array(    $form['title'] = array(
337      '#type' => 'textfield',      '#type' => 'textfield',
338      '#title' => t('Title'),      '#title' => t('Title'),
339      '#default_value' => check_plain($item->filtertitle),      '#default_value' => isset($item->title) ? check_plain($item->title) : '',
340      '#maxlength' => 255,      '#maxlength' => 255,
341      '#description' => t('A name for the filter.'),      '#description' => t('A name for the filter.'),
342      '#required' => TRUE,      '#required' => TRUE,
# Line 390  function hidden_filters_admin_form(&$for Line 344  function hidden_filters_admin_form(&$for
344    $form['filter'] = array(    $form['filter'] = array(
345      '#type' => 'textfield',      '#type' => 'textfield',
346      '#title' => t('Filter'),      '#title' => t('Filter'),
347      '#default_value' => $item->filter,      '#default_value' => isset($item->filter) ? $item->filter : '',
348      '#maxlength' => 255,      '#maxlength' => 255,
349      '#description' => t('What to filter for.'),      '#description' => t('What to filter for.'),
350      '#required' => TRUE,      '#required' => TRUE,
# Line 422  function hidden_filters_admin_form(&$for Line 376  function hidden_filters_admin_form(&$for
376      '#default_value' => $item->enabled,      '#default_value' => $item->enabled,
377      '#description' => t('If this filter is enabled.'),      '#description' => t('If this filter is enabled.'),
378    );    );
379    $form += hidden_hide_form('filter', $item);    if (isset($item->uid)) {
380        $hide_user = user_load($item->uid);
381        $item->name = is_object($hide_user) ? $hide_user->name : '';
382      }
383      // @TODO move _hidden_hide_form?
384      require_once('hidden.action-pages.inc');
385      global $user;
386      $form['hidden'] = _hidden_hide_form($user, $item);
387      $form['hidden']['#type'] = 'fieldset';
388      $form['hidden']['#title'] = t('Reason to use for hiding');
389    $form['hfid'] = array('#type' => 'value', '#value' => $item->hfid);    $form['hfid'] = array('#type' => 'value', '#value' => $item->hfid);
390    $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));    $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
391    return $form;    return $form;
# Line 432  function hidden_filters_admin_form(&$for Line 395  function hidden_filters_admin_form(&$for
395   * Implementation of form API hook; validate hidden_filters_admin_form().   * Implementation of form API hook; validate hidden_filters_admin_form().
396   */   */
397  function hidden_filters_admin_form_validate($form, &$form_state) {  function hidden_filters_admin_form_validate($form, &$form_state) {
   hidden_hide_validate($form, &$form_state);  
398    if ($form_state['values']['type']==HIDDEN_FILTER_PREG) {    if ($form_state['values']['type']==HIDDEN_FILTER_PREG) {
399  // TODO switch off error reporting      $msg = '';
400      if (preg_match($form_state['values']['filter'], 'string')===FALSE) {      if (! _hidden_filter_preg_test($form_state['values']['filter'], $msg)) {
401        form_set_error('filter', t('The filter is not a valid regular expression'));        form_set_error('filter', $msg);
402      }      }
 // turn it back  
403    }    }
404  }  }
405    
# Line 446  function hidden_filters_admin_form_valid Line 407  function hidden_filters_admin_form_valid
407   * Implementation of form API hook; submit hidden_filters_admin_form().   * Implementation of form API hook; submit hidden_filters_admin_form().
408   */   */
409  function hidden_filters_admin_form_submit($form, &$form_state) {  function hidden_filters_admin_form_submit($form, &$form_state) {
410    $hfid = (int)$form_state['values']['hfid'];    $filter = new stdClass();
411    $title = (string)$form_state['values']['title'];    $filter->hfid = (int) $form_state['values']['hfid'];
412    $filter = (string)$form_state['values']['filter'];    $filter->title = (string) $form_state['values']['title'];
413    $type = (int)$form_state['values']['type'];    $filter->filter = (string) $form_state['values']['filter'];
414    $delay = (int)$form_state['values']['delay'];    $filter->type = (int) $form_state['values']['type'];
415    $weight = (int)$form_state['values']['weight'];    $filter->delay = (int) $form_state['values']['delay'];
416    $enabled = (int)$form_state['values']['enabled'];    $filter->weight = (int) $form_state['values']['weight'];
417      $filter->enabled = (int) $form_state['values']['enabled'];
418    if (user_access('administer hidden')) {    if (user_access('administer hidden')) {
419      $user = user_load(array('name' => $form_values['user']));      $user = user_load(array('name' => $form_state['values']['user']));
420      $uid = $user->uid;      $filter->uid = is_object($user) ? $user->uid : 0;
421    }    }
422    else {    else {
423      global $user;      global $user;
424      $uid = $user->uid;      $filter->uid = $user->uid;
425    }    }
426    $rid = (int)$form_state['values']['reason'];    $filter->rid = (int) $form_state['values']['reason'];
427    if (! _hidden_reason_check($rid)) {    if (! hidden_reason_check($filter->rid)) {
428      $rid = 0;      $filter->rid = 0;
429    }    }
430    $public = (string)$form_state['values']['publictext'];    $filter->publicnote = (string) $form_state['values']['publictext'];
431    $private = (string)$form_state['values']['privatetext'];    $filter->privatenote = (string) $form_state['values']['privatetext'];
432    
433    $result = _hidden_filters_admin_form_submit($hfid, $title, $filter, $type, $delay, $weight, $enabled, $uid, $rid, $public, $private);    $result = hidden_filter_save($filter);
434    if ($result == FALSE) {    if ($result == FALSE) {
435    }      drupal_set_message('Error saving filter.');
   elseif ($result == $hfid) {  
   }  
   else {  
436    }    }
437    
438    drupal_goto('admin/content/hidden/filters');    $form_state['redirect'] = 'admin/content/hidden/filters';
 }  
   
 /**  
  * Execute sql to update hidden filter for hidden_filters_admin_form().  
  */  
 function _hidden_filters_admin_form_submit($hfid, $title, $filter, $type, $delay, $weight, $enabled, $uid, $rid, $public, $private) {  
   if ($hfid != 0) {  
     if (_hidden_filter_reason_get($hfid)) {  
       if (! db_query("UPDATE {hidden_filters} SET filter='%s', type=%d, weight=%d, enabled=%d WHERE hfid=%d", $filter, $type, $weight, $enabled, $hfid)) {  
         _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_filters_admin_form_submit() failed UPDATE {hidden_filters}', 'filter', $hfid);  
         return FALSE;  
       }  
       if (! db_query("UPDATE {hidden_filter_reasons} SET title='%s', delay=%d, uid=%d, rid=%d, publicnote='%s', privatenote='%s' WHERE hfid=%d", $title, $delay, $uid, $rid, $public, $private, $hfid)) {  
         _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_filters_admin_form_submit() failed UPDATE {hidden_filter_reasons}', 'filter', $hfid);  
         return FALSE;  
       }  
       return $hfid;  
     }  
     else {  
       _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_filters_admin_form_sumbit() passed invalid $hfid.', 'filter', $hfid);  
     }  
   }  
   else {  
     if (! db_query("INSERT INTO {hidden_filters} (filter, type, weight, enabled) VALUES ('%s', %d, %d, %d)", $filter, $type, $weight, $enabled)) {  
       _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_filters_admin_form_submit failed INSERT to {hidden_filters}', 'filter', $hfid);  
       return FALSE;  
     }  
     $hfid = db_last_insert_id("{hidden_filters}_hfid", "hfid");  
     if (! db_query("INSERT INTO {hidden_filter_reasons} (hfid, title, delay, uid, rid, publicnote, privatenote) VALUES (%d, '%s', %d, %d, %d, '%s', '%s')", $hfid, $title, $delay, $uid, $rid, $public, $private)) {  
       _hidden_log(HIDDEN_LOG_DEBUG, '_hidden_filters_admin_form_submit() failed INSERT to {hidden_filter_reasons}', 'filter', $hfid);  
       // maybe good to delete {hidden_filters} here?  
       return FALSE;  
     }  
     return $hfid;  
   }  
439  }  }
440    
441  /**  /**
# Line 536  function hidden_filters_admin_able($acti Line 460  function hidden_filters_admin_able($acti
460      drupal_goto('admin/content/hidden/filters');      drupal_goto('admin/content/hidden/filters');
461    }    }
462    
463    if ($filter=_hidden_filter_reason_get($hfid)) {    if ($filter = hidden_filter_load($hfid)) {
464      $t_args = array('%title' => check_plain($filter->title), '%action' => $action);      $t_args = array('%title' => check_plain($filter->title), '%action' => $action);
465      if (! db_query('UPDATE {hidden_filters} SET enabled=%d WHERE hfid=%d', $able, $hfid)) {      if (! db_query('UPDATE {hidden_filters} SET enabled=%d WHERE hfid=%d', $able, $hfid)) {
466        _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_filters_admin_able() failed to UPDATE to '. $action, 'filter', $hfid);        _hidden_log(HIDDEN_LOG_DEBUG, 'hidden_filters_admin_able() failed to UPDATE to '. $action, 'filter', $hfid);
# Line 555  function hidden_filters_admin_able($acti Line 479  function hidden_filters_admin_able($acti
479    drupal_goto('admin/content/hidden/filters');    drupal_goto('admin/content/hidden/filters');
480  }  }
481    
482    /**
483     * form; list enabled filters, submission changes weight order.
484     *
485     * @ingroup forms
486     * @see hidden_filters_admin_enabled_form_submit()
487     */
488    function hidden_filters_admin_enabled_form() {
489      $form['header'] = array(
490        '#type' => 'value',
491        '#value' => array(
492          array('data' => t('filter name')),
493          array('data' => t('hits')),
494          array('data' => t('date')),
495          array('data' => t('weight')),
496          array('data' => t('operations'), 'colspan' => 2),
497        )
498      );
499      $result = hidden_filter_all_get_pager(0, 1);
500      $form['weight'] = array('#tree' => TRUE);
501      while ($filter = db_fetch_object($result)) {
502        $form['title'][$filter->hfid] = array('#value' => check_plain($filter->title));
503        $form['hits'][$filter->hfid] = array('#value' => $filter->hits);
504        $form['date'][$filter->hfid] = array('#value' => ($filter->date==0) ? t('Never') : format_date($filter->date, 'small'));
505        $form['weight'][$filter->hfid] = array('#type' => 'weight', '#default_value' => $filter->weight, '#tree' => TRUE);
506        $form['edit'][$filter->hfid] = array('#value' => l(t('edit'), 'admin/content/hidden/filters/edit/'. $filter->hfid));
507        $form['enable'][$filter->hfid] = array( '#value' => l(t('disable'), 'admin/content/hidden/filters/disable/'. $filter->hfid));
508      }
509    
510      $form['submit'] = array('#value' => t('Update weights'),  '#type' => 'submit');
511      return $form;
512    }
513    
514    /**
515     * theme hidden_filters_admin_enabled_form().
516     *
517     * @ingroup themeable
518     */
519    function theme_hidden_filters_admin_enabled_form($form) {
520      $rows = array();
521      if (isset($form['title']) && is_array($form['title'])) {
522        foreach (element_children($form['title']) as $key) {
523          $row = array();
524          $row[] = drupal_render($form['title'][$key]);
525          $row[] = drupal_render($form['hits'][$key]);
526          $row[] = drupal_render($form['date'][$key]);
527          $row[] = drupal_render($form['weight'][$key]);
528          $row[] = drupal_render($form['edit'][$key]);
529          $row[] = drupal_render($form['enable'][$key]);
530          $rows[] = $row;
531        }
532      }
533      else {
534        $rows[] = array(array('data' => t('No filters enabled'), 'colspan' => '6'));
535      }
536    
537      $output = theme('table', $form['header']['#value'], $rows);
538      $output .= drupal_render($form);
539      return $output;
540    }
541    
542    /**
543     * Implementation of form API hook; submit hidden_filters_admin_form().
544     */
545    function hidden_filters_admin_enabled_form_submit($form, &$form_state) {
546      $error = FALSE;
547      foreach ($form_state['values']['weight'] as $hfid => $weight) {
548        $weight = array('hfid' => $hfid, 'weight' => $weight);
549        if (! drupal_write_record('hidden_filters', $weight, array('hfid'))) {
550          $error = TRUE;
551        }
552      }
553    
554      if ($error) {
555        drupal_set_message(t('Problem updating weights'), 'error');
556      }
557      else {
558        drupal_set_message(t('Weights updated'));
559      }
560    }
561    
562  /***********************************************************************  /***********************************************************************
563   * Theme   * Theme
564   */   */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2