/[drupal]/contributions/modules/singlesignon/singlesignon.module
ViewVC logotype

Diff of /contributions/modules/singlesignon/singlesignon.module

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

revision 1.21.2.11, Sat May 3 11:35:50 2008 UTC revision 1.21.2.12, Mon May 5 11:20:03 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: singlesignon.module,v 1.21.2.10 2008/05/02 03:51:38 wayland76 Exp $  // $Id: singlesignon.module,v 1.21.2.11 2008/05/03 11:35:50 wayland76 Exp $
3    
4    
5  /**  /**
# Line 49  Line 49 
49   *   *
50   * @link     http://drupal.org/project/singlesignon   * @link     http://drupal.org/project/singlesignon
51   * @author   Daniel Convissor <danielc@analysisandsolutions.com>   * @author   Daniel Convissor <danielc@analysisandsolutions.com>
52   * @version  $Revision: 1.21.2.10 $  (HEAD)   * @version  $Revision: 1.21.2.11 $  (HEAD)
53   */   */
54    
55  // {{{ core functions  // {{{ core functions
# Line 99  function singlesignon_init() { Line 99  function singlesignon_init() {
99          return;          return;
100        }        }
101    
       // url() only available if bootstrap has reached FULL.  
       drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);  
   
102        // This is the user's first hit to a slave site.  Take note of their        // This is the user's first hit to a slave site.  Take note of their
103        // session ID, since that's how we tell if they've been here or not.        // session ID, since that's how we tell if they've been here or not.
104        // Then go to the master site to see if they are logged in over there.        // Then go to the master site to see if they are logged in over there.
105        $_SESSION['singlesignon_prior_sid'] = session_id();        $_SESSION['singlesignon_prior_sid'] = session_id();
106        $query = 'slave_session='. session_id() .'&singlesignon_dest='. _singlesignon_get_dest();  
107        _singlesignon_goto($master_url . url('singlesignon/initial_check', $query));        _singlesignon_goto_url('singlesignon/initial_check');
108      }      }
109    }    }
110    
# Line 159  function singlesignon_init() { Line 156  function singlesignon_init() {
156        return;        return;
157      }      }
158      else if ($user->uid) {      else if ($user->uid) {
       // url() only available if bootstrap has reached FULL.  
       drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);  
   
159        // Tell the master site the user just logged in.        // Tell the master site the user just logged in.
160        $query = 'slave_session='. session_id() .'&singlesignon_dest='. _singlesignon_get_dest();        _singlesignon_goto_url('singlesignon/login');
       _singlesignon_goto($master_url . url('singlesignon/login', $query));  
161      }      }
162    }    }
163  }  }
# Line 215  function _singlesignon_master($master_ur Line 208  function _singlesignon_master($master_ur
208  // }}}  // }}}
209  // {{{ helper functions  // {{{ helper functions
210    
211    /**
212     * Sets up the URL and goes to it
213     */
214    function _singlesignon_goto_url($url) {
215          // url() only available if bootstrap has reached FULL.
216          drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
217    
218          $query = 'slave_session='. session_id() .'&singlesignon_dest='. _singlesignon_get_dest();
219          _singlesignon_goto($master_url . url($url, $query));
220    }
221    
222    /**
223     * Gets the SQL to update the sessions a bit -- can equivalent code be found somewhere else?
224     */
225  function _singlesignon_get_sql($user) {  function _singlesignon_get_sql($user) {
226    $in   = substr(str_repeat("'%s',", count($_SESSION['singlesignon_slave_sessions'])), 0, -1);    $in   = substr(str_repeat("'%s',", count($_SESSION['singlesignon_slave_sessions'])), 0, -1);
227    $sql  = "UPDATE {sessions} SET uid = %d WHERE sid IN ($in)"; // I know the coder module complains about this, but it appears to be necessary in this case    $sql  = "UPDATE {sessions} SET uid = %d WHERE sid IN ($in)"; // I know the coder module complains about this, but it appears to be necessary in this case

Legend:
Removed from v.1.21.2.11  
changed lines
  Added in v.1.21.2.12

  ViewVC Help
Powered by ViewVC 1.1.2