/[drupal]/contributions/modules/seo_checklist/seochecklist.admin.inc
ViewVC logotype

Diff of /contributions/modules/seo_checklist/seochecklist.admin.inc

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

revision 1.4, Thu Oct 22 23:57:52 2009 UTC revision 1.5, Fri Oct 23 00:00:15 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: seochecklist.admin.inc,v 1.3 2009/10/22 23:00:01 davereid Exp $  // $Id: seochecklist.admin.inc,v 1.4 2009/10/22 23:57:52 davereid Exp $
3    
4  /**  /**
5   * Define the settings form.   * Define the settings form.
# Line 11  function seochecklist_admin_settings() { Line 11  function seochecklist_admin_settings() {
11      '#type' => 'submit',      '#type' => 'submit',
12      '#value' => t('Save'),      '#value' => t('Save'),
13    );    );
   $form['check_existing'] = array(  
     '#type' => 'submit',  
     '#value' => t('Check for already installed modules'),  
   );  
14    
15    // Fetch modules and groups from database.    // Fetch modules and groups from database.
16    $query = "SELECT id, name, description FROM {seo_group} ORDER BY id";    $query = "SELECT id, name, description FROM {seo_group} ORDER BY id";
# Line 106  function seochecklist_admin_settings() { Line 102  function seochecklist_admin_settings() {
102  function seochecklist_admin_settings_submit($form, &$form_state) {  function seochecklist_admin_settings_submit($form, &$form_state) {
103    global $user;    global $user;
104    
105    // Saving checked modules.    foreach ($form_state['values'] as $key => $value) {
106    if ($form_state['values']['op'] == t('Save')) {      if (preg_match('/seochecklist_nodetypes/', $key)) {
107      foreach ($form_state['values'] as $key => $value) {        $key = explode('_', $key);
108        if (preg_match('/seochecklist_nodetypes/', $key)) {        $key = $key[2];
109          $key = explode('_', $key);        $current = (bool) db_result(db_query("SELECT completed FROM {seo_checklist} WHERE id = %d", $key));
110          $key = $key[2];        if ($current != $value) {
111          $current = (bool) db_result(db_query("SELECT completed FROM {seo_checklist} WHERE id = %d", $key));          // If the checkbox changed states, update the record.
112          if ($current != $value) {          db_query("UPDATE {seo_checklist} SET completed = %d, uid = %d WHERE id = %d", ($value ? time() : 0), $user->uid, $key);
           // If the checkbox changed states, update the record.  
           db_query("UPDATE {seo_checklist} SET completed = %d, uid = %d WHERE id = %d", ($value ? time() : 0), $user->uid, $key);  
         }  
113        }        }
114      }      }
   
     // Special values not in database.  
     variable_set('seo_checklist_link', $form_state['values']['seo_checklist_link']);  
     variable_set('seo_checklist_thanks', $form_state['values']['seo_checklist_thanks']);  
     variable_set('seo_checklist_podcast', $form_state['values']['seo_checklist_podcast']);  
115    }    }
116    
117    // Check for already installed modules.    // Special values not in database.
118    if ($form_state['values']['op'] == t('Check for already installed modules')) {    variable_set('seo_checklist_link', $form_state['values']['seo_checklist_link']);
119      $query = db_query("SELECT id, module FROM {seo_checklist} WHERE module <> '' AND completed = 0");    variable_set('seo_checklist_thanks', $form_state['values']['seo_checklist_thanks']);
120      while ($task = db_fetch_object($query)) {    variable_set('seo_checklist_podcast', $form_state['values']['seo_checklist_podcast']);
       if (module_exists($task->module)) {  
         db_query("UPDATE {seo_checklist} SET completed = %d WHERE id = %d", time(), $task->id);  
       }  
     }  
   }  
121  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.2