Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class session extends session_ext

Hide Inherited MembersHelix Core
Description
No description.
 
Constants
constantTABLENAME ["cor_session"][ session ]
 
Properties
protected_cdate[ session_db ]
protected_cdate_dirty[ session_db ]
protected_cleanup_rate[ session_ext ]
protected_data[ session_db ]
protected_data_dirty[ session_db ]
protected_deleted[ session_db ]
protected_deleted_dirty[ session_db ]
protected_dirty[ obj ]
protected_hash[ session_db ]
protected_hash_dirty[ session_db ]
protected_history[ session_ext ]
protected_id[ session_db ]
protected_id_dirty[ session_db ]
protected_ip[ session_db ]
protected_ip_dirty[ session_db ]
protected_mdate[ session_db ]
protected_mdate_dirty[ session_db ]
protected_name[ session_ext ]
publicproperty_objects_array[ obj ]
protected_request_number[ session_ext ]
protected_serial_spacer[ session_ext ]
protected_serialized_data[ session_ext ]
protected_timeout[ session_ext ]
protected_valid[ session_ext ]
 
Methods
privatecleanup ( )[ session_ext ]
Parameters
No parameters for this method
Code
212  private function cleanup()
213  {
214      if ((rand() % 100) < $this->cleanup_rate)
215      {
216          $db = new db();
217          $timeout = strtotime("now") - $this->history;
218          $q = "DELETE FROM cor_session_user where session_id in (";
219          $q .= "SELECT id from cor_session WHERE ";
220          $q .= "mdate < '" . date("Y-m-d G:i:s",$timeout) . "' AND id <> '$this->id')";
221          $db->query($q);
222          $q = "DELETE FROM cor_session WHERE ";
223          $q .= "mdate < '" . date("Y-m-d G:i:s",$timeout) . "' AND id <> '$this->id'";
224          $db->query($q);
225      }
226  }
publicclear ( )[ session_ext ]
Parameters
No parameters for this method
Code
228  public function clear()
229  {
230      $session_user = new session_user(null,$this->_id,$this->user_id);
231      $session_user->purge();
232      $this->_data = array();
233  }
publiccommit ( )[ session_ext ]
Parameters
No parameters for this method
Code
072  public function commit()
073  {
074      if (!is_true(NOSESSION))
075      {
076          if ($this->_id > 0)
077          {
078              $this->update();
079          }
080          else
081          {
082              $this->insert();
083          }
084      }
085      return true;
086  }
public__construct ( id , hash )[ session_ext ]
Parameters
optionalid
optionalhash
Code
039  public function __construct($__id=null, $__hash=null)
040  {
041      parent::__construct($__id,$__hash);
042      $this->_name = "sess";
043      $this->_ip = $_SERVER["REMOTE_ADDR"];
044      $this->_valid = false;
045      $this->_serial_spacer = "<DELIMITER>";
046      $this->_serialized_data = $this->_data;
047      $this->_data = array();
048      $this->_request_number = 0;
049     
050      if($this->_id > 0)
051      {
052          $this->_valid = true;
053          $this->_timeout = SESSION_EXPIRE;             //number of seconds before history session timesout
054          $this->_cleanup_rate = SESSION_CLEAN_PERC;     // percentage of visit that trigger cleanup
055          $this->_history = SESSION_HISTORY;             //number of seconds to keep inhistory sessions in history
056         
057          $sessionvars = explode($this->_serial_spacer,$this->_serialized_data);
058          foreach ($sessionvars as $s)
059          {
060              $nv = explode("=", $s);
061              if (count($nv)==2)
062              {
063                  list($name,$svar) = $nv;
064                  $this->_data[$this->decode($name)] = $this->decode(unserialize($svar));
065              }
066          }
067      }
068     
069      $this->cleanup();
070  }
protected staticdb ( )[ session_db ]
Parameters
No parameters for this method
Code
426  protected static function db()
427  {
428      return new db();
429  }
publicdecode ( d )[ session_ext ]
Parameters
requiredd
Code
165  public function decode($d)
166  {
167      if (is_array($d))
168      {
169          $dd = array();
170          foreach ($d as $k => $v)
171          {
172              $dd[$this->decode($k)] = $this->decode($v);
173          }
174          return $dd;
175      }
176      else if (is_string($d))
177      {
178          return rawurldecode($d);
179      }
180      else if (is_object($d))
181      {
182          return $d;
183      }
184      else
185      {
186          return $d;
187      }
188  }
publicdelete ( )[ session_db ]
Parameters
No parameters for this method
Code
158  public function delete()
159  {
160      $db = session::db();
161      $q  = " UPDATE cor_session SET ";
162      $q .= " deleted = 1 ";
163      $q .= " WHERE id = " . $this->_id;
164      $db->query($q);
165      $this->deleted = true;
166      return true;
167  }
public staticdelete_all ( )[ session_db ]
Parameters
No parameters for this method
Code
264  public static function delete_all()
265  {
266      $db = session::db();
267      $q  = " UPDATE cor_session SET ";
268      $q .= " deleted = 1 ";
269     
270      $db->query($q);
271      return true;
272  }
publicencode ( d )[ session_ext ]
Parameters
requiredd
Code
140  public function encode($d)
141  {
142      if (is_array($d))
143      {
144          $ed = array();
145          foreach ($d as $k => $v)
146          {
147              $ed[$this->encode($k)] = $this->encode($v);
148          }
149          return $ed;
150      }
151      else if (is_string($d))
152      {
153          return rawurlencode($d);
154      }
155      else if (is_object($d))
156      {
157          return $d;
158      }
159      else
160      {
161          return $d;
162      }
163  }
public__get ( p )[ session_ext ]
Parameters
requiredp
Code
017  public function __get($p)
018  {
019      $methods = get_class_methods($this);
020      $properties = get_object_vars($this);
021      if (in_array("get_$p",$methods))
022      {
023          return $this->{"get_$p"}();
024      }
025      else if (array_key_exists("_$p",$properties))
026      {
027          return $this->{"_$p"};
028      }
029      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
030      {
031          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
032      }
033      else
034      {
035          return keyval($this->_data,$p);
036      }
037  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
public staticget_columns ( columns , order , lookups , where_clause , limit , offset [0] )[ session_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
189  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
190  {
191      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
192      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
193      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
194 
195      $db = session::db();
196      $data = array();
197      $q  = " SELECT $colstring ";
198      $q .= " FROM cor_session ";
199      $q .= " WHERE cor_session.deleted = 0 ";
200      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
201 
202      if (is_string($__order))
203      {
204          $q .= "ORDER BY " . $__order;
205      }
206      else if (is_array($__order) and count($__order)>0)
207      {
208          $orderings = array();
209          foreach ($__order as $col=>$dir)
210          {
211              $orderings[] = " $col $dir ";
212          }
213          $q .= "ORDER BY " . implode(", ", $orderings);
214      }
215      else if (is_object($__order))
216      {
217          $q .= "";
218      }
219      else
220      {
221          // THERE IS NO `order` COLUMN ON THIS OBJECT
222      }
223 
224      if (!is_null($__limit))
225      {
226          $q .= " LIMIT $__offset , $__limit ";
227      }
228 
229      $db->query($q);
230 
231      if (count($colarray)>1 || $colstring=="*")
232      {
233          while ($db->next_record())
234          {
235              $data[] = $db->record;
236          }
237      }
238      else
239      {
240          while ($db->next_record())
241          {
242              $data[] = $db->f(0);
243          }
244      }
245 
246      return $data;
247  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ session_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
249  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      return session::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
252  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_last_location ( )[ session_ext ]
Parameters
No parameters for this method
Code
252  public function get_last_location()
253  {
254      $p = new page($this->last_page_id);
255      return $this->last_url . $this->last_page;
256  }
publicget_last_page ( )[ session_ext ]
Parameters
No parameters for this method
Code
246  public function get_last_page()
247  {
248      $p = new page($this->last_page_id);
249      return $p->name;
250  }
public staticget_objects ( order , lookups , where_clause , limit , offset [0] )[ session_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
254  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
255  {
256      $objects = array();
257      foreach (session::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
258      {
259          $objects[] = new session($id);
260      }
261      return $objects;
262  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_serialized_data ( )[ session_ext ]
Parameters
No parameters for this method
Code
235  public function get_serialized_data()
236  {
237      $sd = array();
238      $ed = $this->encode($this->_data);
239      foreach ($ed as $k => $v)
240      {
241          $sd[] = $k . "=" . serialize($v);
242      }
243      return implode($this->serial_spacer,$sd);
244  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicget_user ( type ["default"] )[ session_db ]
Parameters
optionaltype ["default"]
Code
327  public function get_user($__type="default")
328  {
329      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
330      $this->property_objects_array["{$__type}_user"] = $object;
331      return $object;
332  }
publicget_user_id ( type ["default"] )[ session_db ]
Parameters
optionaltype ["default"]
Code
333  public function get_user_id($__type="default")
334  {
335      $ids = $this->get_user_ids($__type, true);
336      return (count($ids)==1 ? $ids[0] : null);
337  }
publicget_user_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ session_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
338  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
339  {
340      $user_ids = array();
341      $db = session::db();
342      $q  = " SELECT cor_user.person_entity_id FROM cor_session_user INNER JOIN cor_user ON cor_session_user.user_person_entity_id=cor_user.person_entity_id AND cor_session_user.deleted=0 AND cor_user.deleted=0 AND cor_session_user.session_id='$this->id' " . (is_null($__type) ? "" : " AND cor_session_user.session_user_type_id='" . session_user::type_id($__type) . "'") . ($__get_primary ? " AND cor_session_user.primary=1 " : "");
343      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
344      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
345      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
346      $db->query($q);
347      while ($db->next_record())
348      {
349          $user_ids[] = $db->f("person_entity_id");
350      }
351      return $user_ids;
352  }
publicget_user_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ session_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
353  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
354  {
355      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
356      $objects = array();
357      foreach ($ids as $index=>$id)
358      {
359          $objects[$index] = new user($id);
360      }
361      return $objects;
362  }
protectedinsert ( )[ session_ext ]
Parameters
No parameters for this method
Code
088  protected function insert()
089  {
090      $db = session::db();
091      $q  = " INSERT INTO cor_session ( ";
092      $q .= $db->param_string("hash") . ", ";
093      $q .= $db->param_string("data") . ", ";
094      $q .= $db->param_string("ip") . ", ";
095      $q .= $db->param_string("mdate") . ", ";
096      $q .= $db->param_string("cdate") . ", ";
097      $q .= $db->param_string("deleted");
098      $q .= " ) VALUES ( ";
099      $q .= $db->value_string($this->_hash) . ", ";
100      $q .= $db->value_string($this->serialized_data) . ", ";
101      $q .= $db->value_string($this->_ip) . ", ";
102      $q .= $db->value_string(timestamp()) . ", ";
103      $q .= $db->value_string(timestamp()) . ", ";
104      $q .= $this->deleted ? "'1'" : "'0'";
105      $q .= " ) ";
106      $db->query($q);
107      $this->_id = $db->insert_id;
108      return true;
109  }
publicmap ( )[ session_db ]
Parameters
No parameters for this method
Code
092  public function map()
093  {
094      $this->_hash = array_key_exists("session:hash",$_REQUEST) ? reqval("session:hash") : $this->_hash;
095      $this->_data = array_key_exists("session:data",$_REQUEST) ? reqval("session:data") : $this->_data;
096      $this->_ip = array_key_exists("session:ip",$_REQUEST) ? reqval("session:ip") : $this->_ip;
097      $this->_mdate = array_key_exists("session:mdate",$_REQUEST) ? reqval("session:mdate") : $this->_mdate;
098      $this->_cdate = array_key_exists("session:cdate",$_REQUEST) ? reqval("session:cdate") : $this->_cdate;
099      $this->_deleted = array_key_exists("session:deleted",$_REQUEST) ? reqval("session:deleted") : $this->_deleted;
100  }
publicpurge ( )[ session_db ]
Parameters
No parameters for this method
Code
180  public function purge()
181  {
182      $db = session::db();
183      $q  = " DELETE FROM cor_session ";
184      $q .= " WHERE id = " . $this->_id;
185      $db->query($q);
186      return true;
187  }
publicpurl ( text , entities [true] )[ session_ext ]
Parameters
requiredtext
optionalentities [true]
Code
207  public function purl($text, $entities=true)
208  {
209      echo $this->url($text);
210  }
publicregister ( name , val , overwrite [true] )[ session_ext ]
Parameters
requiredname
requiredval
optionaloverwrite [true]
Code
130  public function register($__name, $__val, $__overwrite=true)
131  {
132      $this->_data[$__name] = ($__overwrite || !array_key_exists($__name,$this->_data)) ? $__val : keyval($this->_data,$__name);
133  }
public staticsearch ( keyword )[ session_db ]
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
publicset_user ( v , type ["default"] )[ session_db ]
Parameters
requiredv
optionaltype ["default"]
Code
364  public function set_user($__v, $__type="default")
365  {
366      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
367      if (is_null($__v))
368      {
369          $rel = new session_user(null,$this->id,$object->id,session_user::type_id($__type));
370          $rel->delete();
371          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
372          {
373              $this->property_objects_array["{$__type}_user"] = null;
374          }
375      }
376      else
377      {
378          $id = $object->id;
379          $object = $__v;
380          $object->id = $__v->id>0 ? $__v->id : $id;
381          $object->commit();
382          $this->set_user_ids(array($object->id),$__type);
383      }
384  }
publicset_user_id ( v , type ["default"] )[ session_db ]
Parameters
requiredv
optionaltype ["default"]
Code
385  public function set_user_id($__v, $__type="default")
386  {
387      $this->set_user_ids(array($__v),$__type);
388  }
publicset_user_ids ( v , type ["default"] )[ session_db ]
Parameters
requiredv
optionaltype ["default"]
Code
389  public function set_user_ids($__v, $__type="default")
390  {
391      if ($this->id == 0)
392      {
393          $this->commit();
394      }
395      $type_id = session_user::type_id($__type);
396      session_user::delete_all($this->id,null,$type_id);
397      if (is_array($__v))
398      {
399          foreach ($__v as $index=>$id)
400          {
401              $object = new session_user(null,$this->id,$id,$type_id);
402              $object->deleted = false;
403              $object->session_user_type_id = $type_id;
404              $object->commit();
405              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
406              {
407                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
408              }
409          }
410          $this->_dirty = true;
411      }
412  }
publicset_user_list ( v , type ["default"] )[ session_db ]
Parameters
requiredv
optionaltype ["default"]
Code
413  public function set_user_list($__v, $__type="default")
414  {
415      if (is_array($__v))
416      {
417          $ids = array();
418          foreach ($__v as $index=>$object)
419          {
420              $ids[] = $object->id;
421          }
422          $this->set_user_ids($ids,$__type);
423      }
424  }
public__toString ( )[ session_db ]
Parameters
No parameters for this method
Code
322  public function __toString()
323  {
324      return (is_null($this->id) ? "" : $this->id);
325  }
publictrack ( text )[ session_ext ]
Parameters
requiredtext
Code
125  public function track($__text)
126  {
127      $this->_data["detail"][$this->request_number][] = $__text;
128  }
publicundelete ( )[ session_db ]
Parameters
No parameters for this method
Code
169  public function undelete()
170  {
171      $db = session::db();
172      $q  = " UPDATE cor_session SET ";
173      $q .= " deleted = 0 ";
174      $q .= " WHERE id = " . $this->_id;
175      $db->query($q);
176      $this->deleted = false;
177      return true;
178  }
publicunregister ( name )[ session_ext ]
Parameters
requiredname
Code
135  public function unregister($__name)
136  {
137      unset($this->_data[$__name]);
138  }
protectedupdate ( )[ session_ext ]
Parameters
No parameters for this method
Code
111  protected function update()
112  {
113      $db = session::db();
114      $q  = " UPDATE cor_session SET ";
115      $q .= $db->param_string("hash") . " = " . $db->value_string($this->_hash) . ", ";
116      $q .= $db->param_string("data") . " = " . $db->value_string($this->serialized_data) . ", ";
117      $q .= $db->param_string("ip") . " = " . $db->value_string($this->_ip) . ", ";
118      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
119      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
120      $q .= " WHERE id = " . $this->_id;
121      $db->query($q);
122      return true;
123  }
publicurl ( text , entities [true] )[ session_ext ]
Parameters
requiredtext
optionalentities [true]
Code
190  public function url($text, $entities=true)
191  {
192      global $page;
193      // Check for argument delimiter
194      if (preg_match("/.*\?.*/i",$text)) //if there are already arguments
195      {
196          $delim = ($entities) ? ent("&") : "&"; //append the session
197      }
198      else
199      {
200          $delim = "?"; //if no arguments, add the session
201      }
202      $text = ($entities) ? ent($text) : $text;
203  //        $text .= $delim . $this->name . "=" . $this->hash;
204      return $text;
205  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ session_db ]
Code
189  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
190  {
191      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
192      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
193      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
194 
195      $db = session::db();
196      $data = array();
197      $q  = " SELECT $colstring ";
198      $q .= " FROM cor_session ";
199      $q .= " WHERE cor_session.deleted = 0 ";
200      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
201 
202      if (is_string($__order))
203      {
204          $q .= "ORDER BY " . $__order;
205      }
206      else if (is_array($__order) and count($__order)>0)
207      {
208          $orderings = array();
209          foreach ($__order as $col=>$dir)
210          {
211              $orderings[] = " $col $dir ";
212          }
213          $q .= "ORDER BY " . implode(", ", $orderings);
214      }
215      else if (is_object($__order))
216      {
217          $q .= "";
218      }
219      else
220      {
221          // THERE IS NO `order` COLUMN ON THIS OBJECT
222      }
223 
224      if (!is_null($__limit))
225      {
226          $q .= " LIMIT $__offset , $__limit ";
227      }
228 
229      $db->query($q);
230 
231      if (count($colarray)>1 || $colstring=="*")
232      {
233          while ($db->next_record())
234          {
235              $data[] = $db->record;
236          }
237      }
238      else
239      {
240          while ($db->next_record())
241          {
242              $data[] = $db->f(0);
243          }
244      }
245 
246      return $data;
247  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicids[ session_db ]
Code
249  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      return session::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
252  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publiclast_location[ session_ext ]
Code
252  public function get_last_location()
253  {
254      $p = new page($this->last_page_id);
255      return $this->last_url . $this->last_page;
256  }
publiclast_page[ session_ext ]
Code
246  public function get_last_page()
247  {
248      $p = new page($this->last_page_id);
249      return $p->name;
250  }
publicobjects[ session_db ]
Code
254  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
255  {
256      $objects = array();
257      foreach (session::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
258      {
259          $objects[] = new session($id);
260      }
261      return $objects;
262  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicserialized_data[ session_ext ]
Code
235  public function get_serialized_data()
236  {
237      $sd = array();
238      $ed = $this->encode($this->_data);
239      foreach ($ed as $k => $v)
240      {
241          $sd[] = $k . "=" . serialize($v);
242      }
243      return implode($this->serial_spacer,$sd);
244  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicuser[ session_db ]
Code
327  public function get_user($__type="default")
328  {
329      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
330      $this->property_objects_array["{$__type}_user"] = $object;
331      return $object;
332  }
Code
364  public function set_user($__v, $__type="default")
365  {
366      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
367      if (is_null($__v))
368      {
369          $rel = new session_user(null,$this->id,$object->id,session_user::type_id($__type));
370          $rel->delete();
371          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
372          {
373              $this->property_objects_array["{$__type}_user"] = null;
374          }
375      }
376      else
377      {
378          $id = $object->id;
379          $object = $__v;
380          $object->id = $__v->id>0 ? $__v->id : $id;
381          $object->commit();
382          $this->set_user_ids(array($object->id),$__type);
383      }
384  }
publicuser_id[ session_db ]
Code
333  public function get_user_id($__type="default")
334  {
335      $ids = $this->get_user_ids($__type, true);
336      return (count($ids)==1 ? $ids[0] : null);
337  }
Code
385  public function set_user_id($__v, $__type="default")
386  {
387      $this->set_user_ids(array($__v),$__type);
388  }
publicuser_ids[ session_db ]
Code
338  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
339  {
340      $user_ids = array();
341      $db = session::db();
342      $q  = " SELECT cor_user.person_entity_id FROM cor_session_user INNER JOIN cor_user ON cor_session_user.user_person_entity_id=cor_user.person_entity_id AND cor_session_user.deleted=0 AND cor_user.deleted=0 AND cor_session_user.session_id='$this->id' " . (is_null($__type) ? "" : " AND cor_session_user.session_user_type_id='" . session_user::type_id($__type) . "'") . ($__get_primary ? " AND cor_session_user.primary=1 " : "");
343      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
344      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
345      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
346      $db->query($q);
347      while ($db->next_record())
348      {
349          $user_ids[] = $db->f("person_entity_id");
350      }
351      return $user_ids;
352  }
Code
389  public function set_user_ids($__v, $__type="default")
390  {
391      if ($this->id == 0)
392      {
393          $this->commit();
394      }
395      $type_id = session_user::type_id($__type);
396      session_user::delete_all($this->id,null,$type_id);
397      if (is_array($__v))
398      {
399          foreach ($__v as $index=>$id)
400          {
401              $object = new session_user(null,$this->id,$id,$type_id);
402              $object->deleted = false;
403              $object->session_user_type_id = $type_id;
404              $object->commit();
405              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
406              {
407                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
408              }
409          }
410          $this->_dirty = true;
411      }
412  }
publicuser_list[ session_db ]
Code
353  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
354  {
355      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
356      $objects = array();
357      foreach ($ids as $index=>$id)
358      {
359          $objects[$index] = new user($id);
360      }
361      return $objects;
362  }
Code
413  public function set_user_list($__v, $__type="default")
414  {
415      if (is_array($__v))
416      {
417          $ids = array();
418          foreach ($__v as $index=>$object)
419          {
420              $ids[] = $object->id;
421          }
422          $this->set_user_ids($ids,$__type);
423      }
424  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads