Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class perm extends perm_ext

Hide Inherited MembersHelix Core
Description
No description.
 
Constants
constantTABLENAME ["cor_perm"][ perm ]
 
Properties
protected_cdate[ perm_db ]
protected_cdate_dirty[ perm_db ]
protected_deleted[ perm_db ]
protected_deleted_dirty[ perm_db ]
protected_description[ perm_db ]
protected_description_dirty[ perm_db ]
protected_dirty[ obj ]
protected_id[ perm_db ]
protected_id_dirty[ perm_db ]
protected_mdate[ perm_db ]
protected_mdate_dirty[ perm_db ]
protected_name[ perm_db ]
protected_name_dirty[ perm_db ]
publicproperty_objects_array[ obj ]
 
Methods
publiccommit ( )[ perm_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 )[ perm_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 = perm::db();
064      $q  = " SELECT cor_perm.id,cor_perm.name,cor_perm.description,cor_perm.mdate,cor_perm.cdate,cor_perm.deleted ";
065      $q .= " FROM cor_perm ";       
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 ( )[ perm_db ]
Parameters
No parameters for this method
Code
615  protected static function db()
616  {
617      return new db();
618  }
publicdelete ( )[ perm_db ]
Parameters
No parameters for this method
Code
149  public function delete()
150  {
151      $db = perm::db();
152      $q  = " UPDATE cor_perm 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 ( )[ perm_db ]
Parameters
No parameters for this method
Code
255  public static function delete_all()
256  {
257      $db = perm::db();
258      $q  = " UPDATE cor_perm 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] )[ perm_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 = perm::db();
187      $data = array();
188      $q  = " SELECT $colstring ";
189      $q .= " FROM cor_perm ";
190      $q .= " WHERE cor_perm.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] )[ perm_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 perm::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] )[ perm_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 (perm::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
249      {
250          $objects[] = new perm($id);
251      }
252      return $objects;
253  }
publicget_page ( type ["default"] )[ perm_db ]
Parameters
optionaltype ["default"]
Code
318  public function get_page($__type="default")
319  {
320      $object = is_null(keyval($this->property_objects_array,"{$__type}_page")) ? new page($this->get_page_id($__type)) : $this->property_objects_array["{$__type}_page"];
321      $this->property_objects_array["{$__type}_page"] = $object;
322      return $object;
323  }
publicget_page_id ( type ["default"] )[ perm_db ]
Parameters
optionaltype ["default"]
Code
324  public function get_page_id($__type="default")
325  {
326      $ids = $this->get_page_ids($__type, true);
327      return (count($ids)==1 ? $ids[0] : null);
328  }
publicget_page_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ perm_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
329  public function get_page_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
330  {
331      $page_ids = array();
332      $db = perm::db();
333      $q  = " SELECT cor_page.id FROM cor_page_perm INNER JOIN cor_page ON cor_page_perm.page_id=cor_page.id AND cor_page_perm.deleted=0 AND cor_page.deleted=0 AND cor_page_perm.perm_id='$this->id' " . (is_null($__type) ? "" : " AND cor_page_perm.page_perm_type_id='" . page_perm::type_id($__type) . "'") . ($__get_primary ? " AND cor_page_perm.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          $page_ids[] = $db->f("id");
341      }
342      return $page_ids;
343  }
publicget_page_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ perm_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
344  public function get_page_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
345  {
346      $ids = $this->get_page_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
347      $objects = array();
348      foreach ($ids as $index=>$id)
349      {
350          $objects[$index] = new page($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  }
publicget_role ( type ["default"] )[ perm_db ]
Parameters
optionaltype ["default"]
Code
417  public function get_role($__type="default")
418  {
419      $object = is_null(keyval($this->property_objects_array,"{$__type}_role")) ? new role($this->get_role_id($__type)) : $this->property_objects_array["{$__type}_role"];
420      $this->property_objects_array["{$__type}_role"] = $object;
421      return $object;
422  }
publicget_role_id ( type ["default"] )[ perm_db ]
Parameters
optionaltype ["default"]
Code
423  public function get_role_id($__type="default")
424  {
425      $ids = $this->get_role_ids($__type, true);
426      return (count($ids)==1 ? $ids[0] : null);
427  }
publicget_role_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ perm_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
428  public function get_role_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
429  {
430      $role_ids = array();
431      $db = perm::db();
432      $q  = " SELECT cor_role.id FROM cor_perm_role INNER JOIN cor_role ON cor_perm_role.role_id=cor_role.id AND cor_perm_role.deleted=0 AND cor_role.deleted=0 AND cor_perm_role.perm_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 " : "");
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          $role_ids[] = $db->f("id");
440      }
441      return $role_ids;
442  }
publicget_role_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ perm_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
443  public function get_role_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
444  {
445      $ids = $this->get_role_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
446      $objects = array();
447      foreach ($ids as $index=>$id)
448      {
449          $objects[$index] = new role($id);
450      }
451      return $objects;
452  }
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"] )[ perm_db ]
Parameters
optionaltype ["default"]
Code
516  public function get_user($__type="default")
517  {
518      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
519      $this->property_objects_array["{$__type}_user"] = $object;
520      return $object;
521  }
publicget_user_id ( type ["default"] )[ perm_db ]
Parameters
optionaltype ["default"]
Code
522  public function get_user_id($__type="default")
523  {
524      $ids = $this->get_user_ids($__type, true);
525      return (count($ids)==1 ? $ids[0] : null);
526  }
publicget_user_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ perm_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
527  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
528  {
529      $user_ids = array();
530      $db = perm::db();
531      $q  = " SELECT cor_user.person_entity_id FROM cor_perm_user INNER JOIN cor_user ON cor_perm_user.user_person_entity_id=cor_user.person_entity_id AND cor_perm_user.deleted=0 AND cor_user.deleted=0 AND cor_perm_user.perm_id='$this->id' " . (is_null($__type) ? "" : " AND cor_perm_user.perm_user_type_id='" . perm_user::type_id($__type) . "'") . ($__get_primary ? " AND cor_perm_user.primary=1 " : "");
532      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
533      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
534      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
535      $db->query($q);
536      while ($db->next_record())
537      {
538          $user_ids[] = $db->f("person_entity_id");
539      }
540      return $user_ids;
541  }
publicget_user_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ perm_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
542  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
543  {
544      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
545      $objects = array();
546      foreach ($ids as $index=>$id)
547      {
548          $objects[$index] = new user($id);
549      }
550      return $objects;
551  }
protectedinsert ( )[ perm_db ]
Parameters
No parameters for this method
Code
115  protected function insert()
116  {
117      $db = perm::db();
118      $q  = " INSERT INTO cor_perm ( ";
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 ( )[ perm_db ]
Parameters
No parameters for this method
Code
087  public function map()
088  {
089      $this->_name = array_key_exists("perm:name",$_REQUEST) ? reqval("perm:name") : $this->_name;
090      $this->_description = array_key_exists("perm:description",$_REQUEST) ? reqval("perm:description") : $this->_description;
091      $this->_mdate = array_key_exists("perm:mdate",$_REQUEST) ? reqval("perm:mdate") : $this->_mdate;
092      $this->_cdate = array_key_exists("perm:cdate",$_REQUEST) ? reqval("perm:cdate") : $this->_cdate;
093      $this->_deleted = array_key_exists("perm:deleted",$_REQUEST) ? reqval("perm:deleted") : $this->_deleted;
094  }
publicpurge ( )[ perm_db ]
Parameters
No parameters for this method
Code
171  public function purge()
172  {
173      $db = perm::db();
174      $q  = " DELETE FROM cor_perm ";
175      $q .= " WHERE id = " . $this->_id;
176      $db->query($q);
177      return true;
178  }
public staticsearch ( keyword )[ perm_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_page ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
355  public function set_page($__v, $__type="default")
356  {
357      $object = is_null(keyval($this->property_objects_array,"{$__type}_page")) ? new page($this->get_page_id($__type)) : $this->property_objects_array["{$__type}_page"];
358      if (is_null($__v))
359      {
360          $rel = new page_perm(null,$object->id,$this->id,page_perm::type_id($__type));
361          $rel->delete();
362          if (!is_null(keyval($this->property_objects_array,"{$__type}_page")))
363          {
364              $this->property_objects_array["{$__type}_page"] = 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_page_ids(array($object->id),$__type);
374      }
375  }
publicset_page_id ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
376  public function set_page_id($__v, $__type="default")
377  {
378      $this->set_page_ids(array($__v),$__type);
379  }
publicset_page_ids ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
380  public function set_page_ids($__v, $__type="default")
381  {
382      if ($this->id == 0)
383      {
384          $this->commit();
385      }
386      $type_id = page_perm::type_id($__type);
387      page_perm::delete_all(null,$this->id,$type_id);
388      if (is_array($__v))
389      {
390          foreach ($__v as $index=>$id)
391          {
392              $object = new page_perm(null,$id,$this->id,$type_id);
393              $object->deleted = false;
394              $object->page_perm_type_id = $type_id;
395              $object->commit();
396              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_page")))
397              {
398                  $this->property_objects_array["{$__type}_page"] = new page($object->page_id);
399              }
400          }
401          $this->_dirty = true;
402      }
403  }
publicset_page_list ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
404  public function set_page_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_page_ids($ids,$__type);
414      }
415  }
publicset_role ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
454  public function set_role($__v, $__type="default")
455  {
456      $object = is_null(keyval($this->property_objects_array,"{$__type}_role")) ? new role($this->get_role_id($__type)) : $this->property_objects_array["{$__type}_role"];
457      if (is_null($__v))
458      {
459          $rel = new perm_role(null,$this->id,$object->id,perm_role::type_id($__type));
460          $rel->delete();
461          if (!is_null(keyval($this->property_objects_array,"{$__type}_role")))
462          {
463              $this->property_objects_array["{$__type}_role"] = 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_role_ids(array($object->id),$__type);
473      }
474  }
publicset_role_id ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
475  public function set_role_id($__v, $__type="default")
476  {
477      $this->set_role_ids(array($__v),$__type);
478  }
publicset_role_ids ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
479  public function set_role_ids($__v, $__type="default")
480  {
481      if ($this->id == 0)
482      {
483          $this->commit();
484      }
485      $type_id = perm_role::type_id($__type);
486      perm_role::delete_all($this->id,null,$type_id);
487      if (is_array($__v))
488      {
489          foreach ($__v as $index=>$id)
490          {
491              $object = new perm_role(null,$this->id,$id,$type_id);
492              $object->deleted = false;
493              $object->perm_role_type_id = $type_id;
494              $object->commit();
495              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_role")))
496              {
497                  $this->property_objects_array["{$__type}_role"] = new role($object->role_id);
498              }
499          }
500          $this->_dirty = true;
501      }
502  }
publicset_role_list ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
503  public function set_role_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_role_ids($ids,$__type);
513      }
514  }
publicset_user ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
553  public function set_user($__v, $__type="default")
554  {
555      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
556      if (is_null($__v))
557      {
558          $rel = new perm_user(null,$this->id,$object->id,perm_user::type_id($__type));
559          $rel->delete();
560          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
561          {
562              $this->property_objects_array["{$__type}_user"] = null;
563          }
564      }
565      else
566      {
567          $id = $object->id;
568          $object = $__v;
569          $object->id = $__v->id>0 ? $__v->id : $id;
570          $object->commit();
571          $this->set_user_ids(array($object->id),$__type);
572      }
573  }
publicset_user_id ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
574  public function set_user_id($__v, $__type="default")
575  {
576      $this->set_user_ids(array($__v),$__type);
577  }
publicset_user_ids ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
578  public function set_user_ids($__v, $__type="default")
579  {
580      if ($this->id == 0)
581      {
582          $this->commit();
583      }
584      $type_id = perm_user::type_id($__type);
585      perm_user::delete_all($this->id,null,$type_id);
586      if (is_array($__v))
587      {
588          foreach ($__v as $index=>$id)
589          {
590              $object = new perm_user(null,$this->id,$id,$type_id);
591              $object->deleted = false;
592              $object->perm_user_type_id = $type_id;
593              $object->commit();
594              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
595              {
596                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
597              }
598          }
599          $this->_dirty = true;
600      }
601  }
publicset_user_list ( v , type ["default"] )[ perm_db ]
Parameters
requiredv
optionaltype ["default"]
Code
602  public function set_user_list($__v, $__type="default")
603  {
604      if (is_array($__v))
605      {
606          $ids = array();
607          foreach ($__v as $index=>$object)
608          {
609              $ids[] = $object->id;
610          }
611          $this->set_user_ids($ids,$__type);
612      }
613  }
public__toString ( )[ perm_db ]
Parameters
No parameters for this method
Code
313  public function __toString()
314  {
315      return (is_null($this->name) ? "" : $this->name);
316  }
publicundelete ( )[ perm_db ]
Parameters
No parameters for this method
Code
160  public function undelete()
161  {
162      $db = perm::db();
163      $q  = " UPDATE cor_perm SET ";
164      $q .= " deleted = 0 ";
165      $q .= " WHERE id = " . $this->_id;
166      $db->query($q);
167      $this->deleted = false;
168      return true;
169  }
protectedupdate ( )[ perm_db ]
Parameters
No parameters for this method
Code
136  protected function update()
137  {
138      $db = perm::db();
139      $q  = " UPDATE cor_perm 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[ perm_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 = perm::db();
187      $data = array();
188      $q  = " SELECT $colstring ";
189      $q .= " FROM cor_perm ";
190      $q .= " WHERE cor_perm.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[ perm_db ]
Code
240  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
241  {
242      return perm::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[ perm_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 (perm::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
249      {
250          $objects[] = new perm($id);
251      }
252      return $objects;
253  }
publicpage[ perm_db ]
Code
318  public function get_page($__type="default")
319  {
320      $object = is_null(keyval($this->property_objects_array,"{$__type}_page")) ? new page($this->get_page_id($__type)) : $this->property_objects_array["{$__type}_page"];
321      $this->property_objects_array["{$__type}_page"] = $object;
322      return $object;
323  }
Code
355  public function set_page($__v, $__type="default")
356  {
357      $object = is_null(keyval($this->property_objects_array,"{$__type}_page")) ? new page($this->get_page_id($__type)) : $this->property_objects_array["{$__type}_page"];
358      if (is_null($__v))
359      {
360          $rel = new page_perm(null,$object->id,$this->id,page_perm::type_id($__type));
361          $rel->delete();
362          if (!is_null(keyval($this->property_objects_array,"{$__type}_page")))
363          {
364              $this->property_objects_array["{$__type}_page"] = 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_page_ids(array($object->id),$__type);
374      }
375  }
publicpage_id[ perm_db ]
Code
324  public function get_page_id($__type="default")
325  {
326      $ids = $this->get_page_ids($__type, true);
327      return (count($ids)==1 ? $ids[0] : null);
328  }
Code
376  public function set_page_id($__v, $__type="default")
377  {
378      $this->set_page_ids(array($__v),$__type);
379  }
publicpage_ids[ perm_db ]
Code
329  public function get_page_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
330  {
331      $page_ids = array();
332      $db = perm::db();
333      $q  = " SELECT cor_page.id FROM cor_page_perm INNER JOIN cor_page ON cor_page_perm.page_id=cor_page.id AND cor_page_perm.deleted=0 AND cor_page.deleted=0 AND cor_page_perm.perm_id='$this->id' " . (is_null($__type) ? "" : " AND cor_page_perm.page_perm_type_id='" . page_perm::type_id($__type) . "'") . ($__get_primary ? " AND cor_page_perm.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          $page_ids[] = $db->f("id");
341      }
342      return $page_ids;
343  }
Code
380  public function set_page_ids($__v, $__type="default")
381  {
382      if ($this->id == 0)
383      {
384          $this->commit();
385      }
386      $type_id = page_perm::type_id($__type);
387      page_perm::delete_all(null,$this->id,$type_id);
388      if (is_array($__v))
389      {
390          foreach ($__v as $index=>$id)
391          {
392              $object = new page_perm(null,$id,$this->id,$type_id);
393              $object->deleted = false;
394              $object->page_perm_type_id = $type_id;
395              $object->commit();
396              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_page")))
397              {
398                  $this->property_objects_array["{$__type}_page"] = new page($object->page_id);
399              }
400          }
401          $this->_dirty = true;
402      }
403  }
publicpage_list[ perm_db ]
Code
344  public function get_page_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
345  {
346      $ids = $this->get_page_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
347      $objects = array();
348      foreach ($ids as $index=>$id)
349      {
350          $objects[$index] = new page($id);
351      }
352      return $objects;
353  }
Code
404  public function set_page_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_page_ids($ids,$__type);
414      }
415  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicrole[ perm_db ]
Code
417  public function get_role($__type="default")
418  {
419      $object = is_null(keyval($this->property_objects_array,"{$__type}_role")) ? new role($this->get_role_id($__type)) : $this->property_objects_array["{$__type}_role"];
420      $this->property_objects_array["{$__type}_role"] = $object;
421      return $object;
422  }
Code
454  public function set_role($__v, $__type="default")
455  {
456      $object = is_null(keyval($this->property_objects_array,"{$__type}_role")) ? new role($this->get_role_id($__type)) : $this->property_objects_array["{$__type}_role"];
457      if (is_null($__v))
458      {
459          $rel = new perm_role(null,$this->id,$object->id,perm_role::type_id($__type));
460          $rel->delete();
461          if (!is_null(keyval($this->property_objects_array,"{$__type}_role")))
462          {
463              $this->property_objects_array["{$__type}_role"] = 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_role_ids(array($object->id),$__type);
473      }
474  }
publicrole_id[ perm_db ]
Code
423  public function get_role_id($__type="default")
424  {
425      $ids = $this->get_role_ids($__type, true);
426      return (count($ids)==1 ? $ids[0] : null);
427  }
Code
475  public function set_role_id($__v, $__type="default")
476  {
477      $this->set_role_ids(array($__v),$__type);
478  }
publicrole_ids[ perm_db ]
Code
428  public function get_role_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
429  {
430      $role_ids = array();
431      $db = perm::db();
432      $q  = " SELECT cor_role.id FROM cor_perm_role INNER JOIN cor_role ON cor_perm_role.role_id=cor_role.id AND cor_perm_role.deleted=0 AND cor_role.deleted=0 AND cor_perm_role.perm_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 " : "");
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          $role_ids[] = $db->f("id");
440      }
441      return $role_ids;
442  }
Code
479  public function set_role_ids($__v, $__type="default")
480  {
481      if ($this->id == 0)
482      {
483          $this->commit();
484      }
485      $type_id = perm_role::type_id($__type);
486      perm_role::delete_all($this->id,null,$type_id);
487      if (is_array($__v))
488      {
489          foreach ($__v as $index=>$id)
490          {
491              $object = new perm_role(null,$this->id,$id,$type_id);
492              $object->deleted = false;
493              $object->perm_role_type_id = $type_id;
494              $object->commit();
495              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_role")))
496              {
497                  $this->property_objects_array["{$__type}_role"] = new role($object->role_id);
498              }
499          }
500          $this->_dirty = true;
501      }
502  }
publicrole_list[ perm_db ]
Code
443  public function get_role_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
444  {
445      $ids = $this->get_role_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
446      $objects = array();
447      foreach ($ids as $index=>$id)
448      {
449          $objects[$index] = new role($id);
450      }
451      return $objects;
452  }
Code
503  public function set_role_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_role_ids($ids,$__type);
513      }
514  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicuser[ perm_db ]
Code
516  public function get_user($__type="default")
517  {
518      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
519      $this->property_objects_array["{$__type}_user"] = $object;
520      return $object;
521  }
Code
553  public function set_user($__v, $__type="default")
554  {
555      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
556      if (is_null($__v))
557      {
558          $rel = new perm_user(null,$this->id,$object->id,perm_user::type_id($__type));
559          $rel->delete();
560          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
561          {
562              $this->property_objects_array["{$__type}_user"] = null;
563          }
564      }
565      else
566      {
567          $id = $object->id;
568          $object = $__v;
569          $object->id = $__v->id>0 ? $__v->id : $id;
570          $object->commit();
571          $this->set_user_ids(array($object->id),$__type);
572      }
573  }
publicuser_id[ perm_db ]
Code
522  public function get_user_id($__type="default")
523  {
524      $ids = $this->get_user_ids($__type, true);
525      return (count($ids)==1 ? $ids[0] : null);
526  }
Code
574  public function set_user_id($__v, $__type="default")
575  {
576      $this->set_user_ids(array($__v),$__type);
577  }
publicuser_ids[ perm_db ]
Code
527  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
528  {
529      $user_ids = array();
530      $db = perm::db();
531      $q  = " SELECT cor_user.person_entity_id FROM cor_perm_user INNER JOIN cor_user ON cor_perm_user.user_person_entity_id=cor_user.person_entity_id AND cor_perm_user.deleted=0 AND cor_user.deleted=0 AND cor_perm_user.perm_id='$this->id' " . (is_null($__type) ? "" : " AND cor_perm_user.perm_user_type_id='" . perm_user::type_id($__type) . "'") . ($__get_primary ? " AND cor_perm_user.primary=1 " : "");
532      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
533      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
534      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
535      $db->query($q);
536      while ($db->next_record())
537      {
538          $user_ids[] = $db->f("person_entity_id");
539      }
540      return $user_ids;
541  }
Code
578  public function set_user_ids($__v, $__type="default")
579  {
580      if ($this->id == 0)
581      {
582          $this->commit();
583      }
584      $type_id = perm_user::type_id($__type);
585      perm_user::delete_all($this->id,null,$type_id);
586      if (is_array($__v))
587      {
588          foreach ($__v as $index=>$id)
589          {
590              $object = new perm_user(null,$this->id,$id,$type_id);
591              $object->deleted = false;
592              $object->perm_user_type_id = $type_id;
593              $object->commit();
594              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
595              {
596                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
597              }
598          }
599          $this->_dirty = true;
600      }
601  }
publicuser_list[ perm_db ]
Code
542  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
543  {
544      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
545      $objects = array();
546      foreach ($ids as $index=>$id)
547      {
548          $objects[$index] = new user($id);
549      }
550      return $objects;
551  }
Code
602  public function set_user_list($__v, $__type="default")
603  {
604      if (is_array($__v))
605      {
606          $ids = array();
607          foreach ($__v as $index=>$object)
608          {
609              $ids[] = $object->id;
610          }
611          $this->set_user_ids($ids,$__type);
612      }
613  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads