summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Bilbie <alex.bilbie@gmail.com>2011-08-20 18:35:22 +0200
committerAlex Bilbie <alex.bilbie@gmail.com>2011-08-20 18:35:22 +0200
commit95311be467faa2e744bbd9e932900a7cf96b081f (patch)
treea6c79c5bd332549e2f6746c4126879983f5b6d45
parent43194ea1af658914a89ca49aed4dca4617b9c4ff (diff)
Renamed some Session library functions to make them shorter. Includes backwards compatibility.
-rw-r--r--system/libraries/Cart.php10
-rw-r--r--system/libraries/Session.php59
2 files changed, 50 insertions, 19 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index b2eaa9ad7..1caef49cd 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -59,9 +59,9 @@ class CI_Cart {
$this->CI->load->library('session', $config);
// Grab the shopping cart array from the session table, if it exists
- if ($this->CI->session->userdata('cart_contents') !== FALSE)
+ if ($this->CI->session->get('cart_contents') !== FALSE)
{
- $this->_cart_contents = $this->CI->session->userdata('cart_contents');
+ $this->_cart_contents = $this->CI->session->get('cart_contents');
}
else
{
@@ -397,7 +397,7 @@ class CI_Cart {
// Is our cart empty? If so we delete it from the session
if (count($this->_cart_contents) <= 2)
{
- $this->CI->session->unset_userdata('cart_contents');
+ $this->CI->session->rm('cart_contents');
// Nothing more to do... coffee time!
return FALSE;
@@ -405,7 +405,7 @@ class CI_Cart {
// If we made it this far it means that our cart has data.
// Let's pass it to the Session class so it can be stored
- $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents));
+ $this->CI->session->set(array('cart_contents' => $this->_cart_contents));
// Woot!
return TRUE;
@@ -541,7 +541,7 @@ class CI_Cart {
$this->_cart_contents['cart_total'] = 0;
$this->_cart_contents['total_items'] = 0;
- $this->CI->session->unset_userdata('cart_contents');
+ $this->CI->session->rm('cart_contents');
}
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 2c8a80163..3203468b2 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -395,7 +395,7 @@ class CI_Session {
* @access public
* @return void
*/
- function sess_destroy()
+ function destroy()
{
// Kill the session DB row
if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
@@ -424,7 +424,7 @@ class CI_Session {
* @param string
* @return string
*/
- function userdata($item)
+ function get($item)
{
return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
}
@@ -437,7 +437,7 @@ class CI_Session {
* @access public
* @return array
*/
- function all_userdata()
+ function get_all()
{
return $this->userdata;
}
@@ -452,7 +452,7 @@ class CI_Session {
* @param string
* @return void
*/
- function set_userdata($newdata = array(), $newval = '')
+ function set($newdata = array(), $newval = '')
{
if (is_string($newdata))
{
@@ -478,7 +478,7 @@ class CI_Session {
* @access array
* @return void
*/
- function unset_userdata($newdata = array())
+ function rm($newdata = array())
{
if (is_string($newdata))
{
@@ -519,7 +519,7 @@ class CI_Session {
foreach ($newdata as $key => $val)
{
$flashdata_key = $this->flashdata_key.':new:'.$key;
- $this->set_userdata($flashdata_key, $val);
+ $this->set($flashdata_key, $val);
}
}
}
@@ -540,10 +540,10 @@ class CI_Session {
// Note the function will return FALSE if the $key
// provided cannot be found
$old_flashdata_key = $this->flashdata_key.':old:'.$key;
- $value = $this->userdata($old_flashdata_key);
+ $value = $this->get($old_flashdata_key);
$new_flashdata_key = $this->flashdata_key.':new:'.$key;
- $this->set_userdata($new_flashdata_key, $value);
+ $this->set($new_flashdata_key, $value);
}
// ------------------------------------------------------------------------
@@ -558,7 +558,7 @@ class CI_Session {
function flashdata($key)
{
$flashdata_key = $this->flashdata_key.':old:'.$key;
- return $this->userdata($flashdata_key);
+ return $this->get($flashdata_key);
}
// ------------------------------------------------------------------------
@@ -572,15 +572,15 @@ class CI_Session {
*/
function _flashdata_mark()
{
- $userdata = $this->all_userdata();
+ $userdata = $this->get_all();
foreach ($userdata as $name => $value)
{
$parts = explode(':new:', $name);
if (is_array($parts) && count($parts) === 2)
{
$new_name = $this->flashdata_key.':old:'.$parts[1];
- $this->set_userdata($new_name, $value);
- $this->unset_userdata($name);
+ $this->set($new_name, $value);
+ $this->unset($name);
}
}
}
@@ -596,12 +596,12 @@ class CI_Session {
function _flashdata_sweep()
{
- $userdata = $this->all_userdata();
+ $userdata = $this->get_all();
foreach ($userdata as $key => $value)
{
if (strpos($key, ':old:'))
{
- $this->unset_userdata($key);
+ $this->unset($key);
}
}
@@ -767,6 +767,37 @@ class CI_Session {
log_message('debug', 'Session garbage collection performed.');
}
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Backwards compatible functions
+ */
+
+ function userdata($item)
+ {
+ return $this->get($item);
+ }
+
+ function all_userdata()
+ {
+ return $this->get_all();
+ }
+
+ function set_userdata($newdata)
+ {
+ $this->set($newdata);
+ }
+
+ function unset_userdata($newdata)
+ {
+ $this->rm($newdata);
+ }
+
+ function sess_destroy()
+ {
+ $this->destroy();
+ }
}