Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class role extends role_ext

Hide Inherited MembersHelix Core
Description
No description.
 
Constants
constantTABLENAME ["cor_role"][ role ]
 
Properties
protected_cdate[ role_db ]
protected_cdate_dirty[ role_db ]
protected_deleted[ role_db ]
protected_deleted_dirty[ role_db ]
protected_description[ role_db ]
protected_description_dirty[ role_db ]
protected_dirty[ obj ]
protected_id[ role_db ]
protected_id_dirty[ role_db ]
protected_mdate[ role_db ]
protected_mdate_dirty[ role_db ]
protected_name[ role_db ]
protected_name_dirty[ role_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ role_db ]
Parameters
No parameters for this method
Code
096  public function commit()
097  {
098      if ($this->_id > 0)
099      {
100          $this->update();
101      }
102      else
103      {
104          $this->insert();
105      }
106 
107      foreach ($this->property_objects_array as $property=>$object)
108      {
109          $this->{$property} = $object;
110      }
111 
112      return true;
113  }
public__construct ( id , name )[ role_db ]
Parameters
optionalid
optionalname
Code
042  public function __construct($__id=null, $__name=null)
043  {
044      $this->_id = 0;
045      $this->_name = $__name;
046      $this->_description = "";
047      $this->_mdate = null;
048      $this->_cdate = null;
049      $this->_deleted = false;
050 
051      $this->_id_dirty = false;
052      $this->_name_dirty = false;
053      $this->_description_dirty = false;
054      $this->_mdate_dirty = false;
055      $this->_cdate_dirty = false;
056      $this->_deleted_dirty = false;
057 
058      if (is_null($__id) && is_null($__name))
059      {
060          return;
061      }
062 
063      $db = role::db();
064      $q  = " SELECT cor_role.id,cor_role.name,cor_role.description,cor_role.mdate,cor_role.cdate,cor_role.deleted ";
065      $q .= " FROM cor_role ";       
066      if (!is_null($__id))
067      {
068          $q .= " WHERE id = '$__id' ";
069      }
070      else if (!is_null($__name))
071      {
072          $q .= " WHERE name = '$__name' ";
073      }
074 
075      $db->query($q);
076      if ($db->next_record() && $db->num_rows() == 1)
077      {
078          $this->_id = $db->f("id");
079          $this->_name = $db->f("name");
080          $this->_description = $db->f("description");
081          $this->_mdate = $db->f("mdate");
082          $this->_cdate = $db->f("cdate");
083          $this->_deleted = $db->f("deleted");
084      }
085  }
protected staticdb ( )[ role_db ]
Parameters
No parameters for this method
Code
516  protected static function db()
517  {
518      return new db();
519  }
publicdelete ( )[ role_db ]
Parameters
No parameters for this method
Code
149  public function delete()
150  {
151      $db = role::db();
152      $q  = " UPDATE cor_role SET ";
153      $q .= " deleted = 1 ";
154      $q .= " WHERE id = " . $this->_id;
155      $db->query($q);
156      $this->deleted = true;
157      return true;
158  }
public staticdelete_all ( )[ role_db ]
Parameters
No parameters for this method
Code
255  public static function delete_all()
256  {
257      $db = role::db();
258      $q  = " UPDATE cor_role SET ";
259      $q .= " deleted = 1 ";
260     
261      $db->query($q);
262      return true;
263  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
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] )[ role_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
180  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
181  {
182      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
183      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
184      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
185 
186      $db = role::db();
187      $data = array();
188      $q  = " SELECT $colstring ";
189      $q .= " FROM cor_role ";
190      $q .= " WHERE cor_role.deleted = 0 ";
191      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
192 
193      if (is_string($__order))
194      {
195          $q .= "ORDER BY " . $__order;
196      }
197      else if (is_array($__order) and count($__order)>0)
198      {
199          $orderings = array();
200          foreach ($__order as $col=>$dir)
201          {
202              $orderings[] = " $col $dir ";
203          }
204          $q .= "ORDER BY " . implode(", ", $orderings);
205      }
206      else if (is_object($__order))
207      {
208          $q .= "";
209      }
210      else
211      {
212          // THERE IS NO `order` COLUMN ON THIS OBJECT
213      }
214 
215      if (!is_null($__limit))
216      {
217          $q .= " LIMIT $__offset , $__limit ";
218      }
219 
220      $db->query($q);
221 
222      if (count($colarray)>1 || $colstring=="*")
223      {
224          while ($db->next_record())
225          {
226              $data[] = $db->record;
227          }
228      }
229      else
230      {
231          while ($db->next_record())
232          {
233              $data[] = $db->f(0);
234          }
235      }
236 
237      return $data;
238  }
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] )[ role_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
240  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
241  {
242      return role::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
243  }
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  }
public staticget_objects ( order , lookups , where_clause , limit , offset [0] )[ role_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
245  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
246  {
247      $objects = array();
248      foreach (role::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
249      {
250          $objects[] = new role($id);
251      }
252      return $objects;
253  }
publicget_perm ( type ["default"] )[ role_db ]
Parameters
optionaltype ["default"]
Code
318  public function get_perm($__type="default")
319  {
320      $object = is_null(keyval($this->property_objects_array,"{$__type}_perm")) ? new perm($this->get_perm_id($__type)) : $this->property_objects_array["{$__type}_perm"];
321      $this->property_objects_array["{$__type}_perm"] = $object;
322      return $object;
323  }
publicget_perm_id ( type ["default"] )[ role_db ]
Parameters
optionaltype ["default"]
Code
324  public function get_perm_id($__type="default")
325  {
326      $ids = $this->get_perm_ids($__type, true);
327      return (count($ids)==1 ? $ids[0] : null);
328  }
publicget_perm_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ role_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
329  public function get_perm_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
330  {
331      $perm_ids = array();
332      $db = role::db();
333      $q  = " SELECT cor_perm.id FROM cor_perm_role INNER JOIN cor_perm ON cor_perm_role.perm_id=cor_perm.id AND cor_perm_role.deleted=0 AND cor_perm.deleted=0 AND cor_perm_role.role_id='$this->id' " . (is_null($__type) ? "" : " AND cor_perm_role.perm_role_type_id='" . perm_role::type_id($__type) . "'") . ($__get_primary ? " AND cor_perm_role.primary=1 " : "");
334      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
335      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
336      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
337      $db->query($q);
338      while ($db->next_record())
339      {
340          $perm_ids[] = $db->f("id");
341      }
342      return $perm_ids;
343  }
publicget_perm_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ role_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
344  public function get_perm_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
345  {
346      $ids = $this->get_perm_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
347      $objects = array();
348      foreach ($ids as $index=>$id)
349      {
350          $objects[$index] = new perm($id);
351      }
352      return $objects;
353  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
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"] )[ role_db ]
Parameters
optionaltype ["default"]
Code
417  public function get_user($__type="default")
418  {
419      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
420      $this->property_objects_array["{$__type}_user"] = $object;
421      return $object;
422  }
publicget_user_id ( type ["default"] )[ role_db ]
Parameters
optionaltype ["default"]
Code
423  public function get_user_id($__type="default")
424  {
425      $ids = $this->get_user_ids($__type, true);
426      return (count($ids)==1 ? $ids[0] : null);
427  }
publicget_user_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ role_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
428  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
429  {
430      $user_ids = array();
431      $db = role::db();
432      $q  = " SELECT cor_user.person_entity_id FROM cor_role_user INNER JOIN cor_user ON cor_role_user.user_person_entity_id=cor_user.person_entity_id AND cor_role_user.deleted=0 AND cor_user.deleted=0 AND cor_role_user.role_id='$this->id' " . (is_null($__type) ? "" : " AND cor_role_user.role_user_type_id='" . role_user::type_id($__type) . "'") . ($__get_primary ? " AND cor_role_user.primary=1 " : "");
433      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
434      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
435      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
436      $db->query($q);
437      while ($db->next_record())
438      {
439          $user_ids[] = $db->f("person_entity_id");
440      }
441      return $user_ids;
442  }
publicget_user_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ role_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
443  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
444  {
445      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
446      $objects = array();
447      foreach ($ids as $index=>$id)
448      {
449          $objects[$index] = new user($id);
450      }
451      return $objects;
452  }
protectedinsert ( )[ role_db ]
Parameters
No parameters for this method
Code
115  protected function insert()
116  {
117      $db = role::db();
118      $q  = " INSERT INTO cor_role ( ";
119      $q .= $db->param_string("name") . ", ";
120      $q .= $db->param_string("description") . ", ";
121      $q .= $db->param_string("mdate") . ", ";
122      $q .= $db->param_string("cdate") . ", ";
123      $q .= $db->param_string("deleted");
124      $q .= " ) VALUES ( ";
125      $q .= $db->value_string($this->_name) . ", ";
126      $q .= $db->value_string($this->_description) . ", ";
127      $q .= $db->value_string(timestamp()) . ", ";
128      $q .= $db->value_string(timestamp()) . ", ";
129      $q .= $this->deleted ? "'1'" : "'0'";
130      $q .= " ) ";
131      $db->query($q);
132      $this->_id = $db->insert_id;
133      return true;
134  }
publicmap ( )[ role_db ]
Parameters
No parameters for this method
Code
087  public function map()
088  {
089      $this->_name = array_key_exists("role:name",$_REQUEST) ? reqval("role:name") : $this->_name;
090      $this->_description = array_key_exists("role:description",$_REQUEST) ? reqval("role:description") : $this->_description;
091      $this->_mdate = array_key_exists("role:mdate",$_REQUEST) ? reqval("role:mdate") : $this->_mdate;
092      $this->_cdate = array_key_exists("role:cdate",$_REQUEST) ? reqval("role:cdate") : $this->_cdate;
093      $this->_deleted = array_key_exists("role:deleted",$_REQUEST) ? reqval("role:deleted") : $this->_deleted;
094  }
publicpurge ( )[ role_db ]
Parameters
No parameters for this method
Code
171  public function purge()
172  {
173      $db = role::db();
174      $q  = " DELETE FROM cor_role ";
175      $q .= " WHERE id = " . $this->_id;
176      $db->query($q);
177      return true;
178  }
public staticsearch ( keyword )[ role_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_perm ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
355  public function set_perm($__v, $__type="default")
356  {
357      $object = is_null(keyval($this->property_objects_array,"{$__type}_perm")) ? new perm($this->get_perm_id($__type)) : $this->property_objects_array["{$__type}_perm"];
358      if (is_null($__v))
359      {
360          $rel = new perm_role(null,$object->id,$this->id,perm_role::type_id($__type));
361          $rel->delete();
362          if (!is_null(keyval($this->property_objects_array,"{$__type}_perm")))
363          {
364              $this->property_objects_array["{$__type}_perm"] = null;
365          }
366      }
367      else
368      {
369          $id = $object->id;
370          $object = $__v;
371          $object->id = $__v->id>0 ? $__v->id : $id;
372          $object->commit();
373          $this->set_perm_ids(array($object->id),$__type);
374      }
375  }
publicset_perm_id ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
376  public function set_perm_id($__v, $__type="default")
377  {
378      $this->set_perm_ids(array($__v),$__type);
379  }
publicset_perm_ids ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
380  public function set_perm_ids($__v, $__type="default")
381  {
382      if ($this->id == 0)
383      {
384          $this->commit();
385      }
386      $type_id = perm_role::type_id($__type);
387      perm_role::delete_all(null,$this->id,$type_id);
388      if (is_array($__v))
389      {
390          foreach ($__v as $index=>$id)
391          {
392              $object = new perm_role(null,$id,$this->id,$type_id);
393              $object->deleted = false;
394              $object->perm_role_type_id = $type_id;
395              $object->commit();
396              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_perm")))
397              {
398                  $this->property_objects_array["{$__type}_perm"] = new perm($object->perm_id);
399              }
400          }
401          $this->_dirty = true;
402      }
403  }
publicset_perm_list ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
404  public function set_perm_list($__v, $__type="default")
405  {
406      if (is_array($__v))
407      {
408          $ids = array();
409          foreach ($__v as $index=>$object)
410          {
411              $ids[] = $object->id;
412          }
413          $this->set_perm_ids($ids,$__type);
414      }
415  }
publicset_user ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
454  public function set_user($__v, $__type="default")
455  {
456      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
457      if (is_null($__v))
458      {
459          $rel = new role_user(null,$this->id,$object->id,role_user::type_id($__type));
460          $rel->delete();
461          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
462          {
463              $this->property_objects_array["{$__type}_user"] = null;
464          }
465      }
466      else
467      {
468          $id = $object->id;
469          $object = $__v;
470          $object->id = $__v->id>0 ? $__v->id : $id;
471          $object->commit();
472          $this->set_user_ids(array($object->id),$__type);
473      }
474  }
publicset_user_id ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
475  public function set_user_id($__v, $__type="default")
476  {
477      $this->set_user_ids(array($__v),$__type);
478  }
publicset_user_ids ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
479  public function set_user_ids($__v, $__type="default")
480  {
481      if ($this->id == 0)
482      {
483          $this->commit();
484      }
485      $type_id = role_user::type_id($__type);
486      role_user::delete_all($this->id,null,$type_id);
487      if (is_array($__v))
488      {
489          foreach ($__v as $index=>$id)
490          {
491              $object = new role_user(null,$this->id,$id,$type_id);
492              $object->deleted = false;
493              $object->role_user_type_id = $type_id;
494              $object->commit();
495              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
496              {
497                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
498              }
499          }
500          $this->_dirty = true;
501      }
502  }
publicset_user_list ( v , type ["default"] )[ role_db ]
Parameters
requiredv
optionaltype ["default"]
Code
503  public function set_user_list($__v, $__type="default")
504  {
505      if (is_array($__v))
506      {
507          $ids = array();
508          foreach ($__v as $index=>$object)
509          {
510              $ids[] = $object->id;
511          }
512          $this->set_user_ids($ids,$__type);
513      }
514  }
public__toString ( )[ role_db ]
Parameters
No parameters for this method
Code
313  public function __toString()
314  {
315      return (is_null($this->name) ? "" : $this->name);
316  }
publicundelete ( )[ role_db ]
Parameters
No parameters for this method
Code
160  public function undelete()
161  {
162      $db = role::db();
163      $q  = " UPDATE cor_role SET ";
164      $q .= " deleted = 0 ";
165      $q .= " WHERE id = " . $this->_id;
166      $db->query($q);
167      $this->deleted = false;
168      return true;
169  }
protectedupdate ( )[ role_db ]
Parameters
No parameters for this method
Code
136  protected function update()
137  {
138      $db = role::db();
139      $q  = " UPDATE cor_role SET ";
140      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
141      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
142      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
143      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
144      $q .= " WHERE id = " . $this->_id;
145      $db->query($q);
146      return true;
147  }
 
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[ role_db ]
Code
180  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
181  {
182      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
183      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
184      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
185 
186      $db = role::db();
187      $data = array();
188      $q  = " SELECT $colstring ";
189      $q .= " FROM cor_role ";
190      $q .= " WHERE cor_role.deleted = 0 ";
191      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
192 
193      if (is_string($__order))
194      {
195          $q .= "ORDER BY " . $__order;
196      }
197      else if (is_array($__order) and count($__order)>0)
198      {
199          $orderings = array();
200          foreach ($__order as $col=>$dir)
201          {
202              $orderings[] = " $col $dir ";
203          }
204          $q .= "ORDER BY " . implode(", ", $orderings);
205      }
206      else if (is_object($__order))
207      {
208          $q .= "";
209      }
210      else
211      {
212          // THERE IS NO `order` COLUMN ON THIS OBJECT
213      }
214 
215      if (!is_null($__limit))
216      {
217          $q .= " LIMIT $__offset , $__limit ";
218      }
219 
220      $db->query($q);
221 
222      if (count($colarray)>1 || $colstring=="*")
223      {
224          while ($db->next_record())
225          {
226              $data[] = $db->record;
227          }
228      }
229      else
230      {
231          while ($db->next_record())
232          {
233              $data[] = $db->f(0);
234          }
235      }
236 
237      return $data;
238  }
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[ role_db ]
Code
240  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
241  {
242      return role::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
243  }
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  }
publicobjects[ role_db ]
Code
245  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
246  {
247      $objects = array();
248      foreach (role::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
249      {
250          $objects[] = new role($id);
251      }
252      return $objects;
253  }
publicperm[ role_db ]
Code
318  public function get_perm($__type="default")
319  {
320      $object = is_null(keyval($this->property_objects_array,"{$__type}_perm")) ? new perm($this->get_perm_id($__type)) : $this->property_objects_array["{$__type}_perm"];
321      $this->property_objects_array["{$__type}_perm"] = $object;
322      return $object;
323  }
Code
355  public function set_perm($__v, $__type="default")
356  {
357      $object = is_null(keyval($this->property_objects_array,"{$__type}_perm")) ? new perm($this->get_perm_id($__type)) : $this->property_objects_array["{$__type}_perm"];
358      if (is_null($__v))
359      {
360          $rel = new perm_role(null,$object->id,$this->id,perm_role::type_id($__type));
361          $rel->delete();
362          if (!is_null(keyval($this->property_objects_array,"{$__type}_perm")))
363          {
364              $this->property_objects_array["{$__type}_perm"] = null;
365          }
366      }
367      else
368      {
369          $id = $object->id;
370          $object = $__v;
371          $object->id = $__v->id>0 ? $__v->id : $id;
372          $object->commit();
373          $this->set_perm_ids(array($object->id),$__type);
374      }
375  }
publicperm_id[ role_db ]
Code
324  public function get_perm_id($__type="default")
325  {
326      $ids = $this->get_perm_ids($__type, true);
327      return (count($ids)==1 ? $ids[0] : null);
328  }
Code
376  public function set_perm_id($__v, $__type="default")
377  {
378      $this->set_perm_ids(array($__v),$__type);
379  }
publicperm_ids[ role_db ]
Code
329  public function get_perm_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
330  {
331      $perm_ids = array();
332      $db = role::db();
333      $q  = " SELECT cor_perm.id FROM cor_perm_role INNER JOIN cor_perm ON cor_perm_role.perm_id=cor_perm.id AND cor_perm_role.deleted=0 AND cor_perm.deleted=0 AND cor_perm_role.role_id='$this->id' " . (is_null($__type) ? "" : " AND cor_perm_role.perm_role_type_id='" . perm_role::type_id($__type) . "'") . ($__get_primary ? " AND cor_perm_role.primary=1 " : "");
334      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
335      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
336      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
337      $db->query($q);
338      while ($db->next_record())
339      {
340          $perm_ids[] = $db->f("id");
341      }
342      return $perm_ids;
343  }
Code
380  public function set_perm_ids($__v, $__type="default")
381  {
382      if ($this->id == 0)
383      {
384          $this->commit();
385      }
386      $type_id = perm_role::type_id($__type);
387      perm_role::delete_all(null,$this->id,$type_id);
388      if (is_array($__v))
389      {
390          foreach ($__v as $index=>$id)
391          {
392              $object = new perm_role(null,$id,$this->id,$type_id);
393              $object->deleted = false;
394              $object->perm_role_type_id = $type_id;
395              $object->commit();
396              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_perm")))
397              {
398                  $this->property_objects_array["{$__type}_perm"] = new perm($object->perm_id);
399              }
400          }
401          $this->_dirty = true;
402      }
403  }
publicperm_list[ role_db ]
Code
344  public function get_perm_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
345  {
346      $ids = $this->get_perm_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
347      $objects = array();
348      foreach ($ids as $index=>$id)
349      {
350          $objects[$index] = new perm($id);
351      }
352      return $objects;
353  }
Code
404  public function set_perm_list($__v, $__type="default")
405  {
406      if (is_array($__v))
407      {
408          $ids = array();
409          foreach ($__v as $index=>$object)
410          {
411              $ids[] = $object->id;
412          }
413          $this->set_perm_ids($ids,$__type);
414      }
415  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicuser[ role_db ]
Code
417  public function get_user($__type="default")
418  {
419      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
420      $this->property_objects_array["{$__type}_user"] = $object;
421      return $object;
422  }
Code
454  public function set_user($__v, $__type="default")
455  {
456      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
457      if (is_null($__v))
458      {
459          $rel = new role_user(null,$this->id,$object->id,role_user::type_id($__type));
460          $rel->delete();
461          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
462          {
463              $this->property_objects_array["{$__type}_user"] = null;
464          }
465      }
466      else
467      {
468          $id = $object->id;
469          $object = $__v;
470          $object->id = $__v->id>0 ? $__v->id : $id;
471          $object->commit();
472          $this->set_user_ids(array($object->id),$__type);
473      }
474  }
publicuser_id[ role_db ]
Code
423  public function get_user_id($__type="default")
424  {
425      $ids = $this->get_user_ids($__type, true);
426      return (count($ids)==1 ? $ids[0] : null);
427  }
Code
475  public function set_user_id($__v, $__type="default")
476  {
477      $this->set_user_ids(array($__v),$__type);
478  }
publicuser_ids[ role_db ]
Code
428  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
429  {
430      $user_ids = array();
431      $db = role::db();
432      $q  = " SELECT cor_user.person_entity_id FROM cor_role_user INNER JOIN cor_user ON cor_role_user.user_person_entity_id=cor_user.person_entity_id AND cor_role_user.deleted=0 AND cor_user.deleted=0 AND cor_role_user.role_id='$this->id' " . (is_null($__type) ? "" : " AND cor_role_user.role_user_type_id='" . role_user::type_id($__type) . "'") . ($__get_primary ? " AND cor_role_user.primary=1 " : "");
433      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
434      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
435      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
436      $db->query($q);
437      while ($db->next_record())
438      {
439          $user_ids[] = $db->f("person_entity_id");
440      }
441      return $user_ids;
442  }
Code
479  public function set_user_ids($__v, $__type="default")
480  {
481      if ($this->id == 0)
482      {
483          $this->commit();
484      }
485      $type_id = role_user::type_id($__type);
486      role_user::delete_all($this->id,null,$type_id);
487      if (is_array($__v))
488      {
489          foreach ($__v as $index=>$id)
490          {
491              $object = new role_user(null,$this->id,$id,$type_id);
492              $object->deleted = false;
493              $object->role_user_type_id = $type_id;
494              $object->commit();
495              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
496              {
497                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
498              }
499          }
500          $this->_dirty = true;
501      }
502  }
publicuser_list[ role_db ]
Code
443  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
444  {
445      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
446      $objects = array();
447      foreach ($ids as $index=>$id)
448      {
449          $objects[$index] = new user($id);
450      }
451      return $objects;
452  }
Code
503  public function set_user_list($__v, $__type="default")
504  {
505      if (is_array($__v))
506      {
507          $ids = array();
508          foreach ($__v as $index=>$object)
509          {
510              $ids[] = $object->id;
511          }
512          $this->set_user_ids($ids,$__type);
513      }
514  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads