Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class post extends post_ext

Hide Inherited MembersForum
Description
No description.
 
Constants
constantTABLENAME ["forum_post"][ post ]
 
Properties
protected_cdate[ post_db ]
protected_cdate_dirty[ post_db ]
protected_content[ post_db ]
protected_content_dirty[ post_db ]
protected_deleted[ post_db ]
protected_deleted_dirty[ post_db ]
protected_dirty[ obj ]
protected_id[ post_db ]
protected_id_dirty[ post_db ]
protected_mdate[ post_db ]
protected_mdate_dirty[ post_db ]
protected_post_type_id[ post_db ]
protected_post_type_id_dirty[ post_db ]
publicproperty_objects_array[ obj ]
protected_views[ post_db ]
protected_views_dirty[ post_db ]
 
Methods
publiccommit ( )[ post_db ]
Parameters
No parameters for this method
Code
098  public function commit()
099  {
100      if ($this->_id > 0)
101      {
102          $this->update();
103      }
104      else
105      {
106          $this->insert();
107      }
108 
109      foreach ($this->property_objects_array as $property=>$object)
110      {
111          $this->{$property} = $object;
112      }
113 
114      return true;
115  }
public__construct ( id )[ post_db ]
Parameters
optionalid
Code
044  public function __construct($__id=null)
045  {
046      $this->_id = 0;
047      $this->_post_type_id = 0;
048      $this->_content = "";
049      $this->_views = 0;
050      $this->_mdate = null;
051      $this->_cdate = null;
052      $this->_deleted = false;
053 
054      $this->_id_dirty = false;
055      $this->_post_type_id_dirty = false;
056      $this->_content_dirty = false;
057      $this->_views_dirty = false;
058      $this->_mdate_dirty = false;
059      $this->_cdate_dirty = false;
060      $this->_deleted_dirty = false;
061 
062      if (is_null($__id))
063      {
064          return;
065      }
066 
067      $db = post::db();
068      $q  = " SELECT forum_post.id,forum_post.post_type_id,forum_post.content,forum_post.views,forum_post.mdate,forum_post.cdate,forum_post.deleted ";
069      $q .= " FROM forum_post ";       
070      if (!is_null($__id))
071      {
072          $q .= " WHERE id = '$__id' ";
073      }
074 
075      $db->query($q);
076      if ($db->next_record() && $db->num_rows() == 1)
077      {
078          $this->_id = $db->f("id");
079          $this->_post_type_id = $db->f("post_type_id");
080          $this->_content = $db->f("content");
081          $this->_views = $db->f("views");
082          $this->_mdate = $db->f("mdate");
083          $this->_cdate = $db->f("cdate");
084          $this->_deleted = $db->f("deleted");
085      }
086  }
protected staticdb ( )[ post_db ]
Parameters
No parameters for this method
Code
551  protected static function db()
552  {
553      return new db();
554  }
publicdelete ( )[ post_db ]
Parameters
No parameters for this method
Code
154  public function delete()
155  {
156      $db = post::db();
157      $q  = " UPDATE forum_post SET ";
158      $q .= " deleted = 1 ";
159      $q .= " WHERE id = " . $this->_id;
160      $db->query($q);
161      $this->deleted = true;
162      return true;
163  }
public staticdelete_all ( )[ post_db ]
Parameters
No parameters for this method
Code
261  public static function delete_all()
262  {
263      $db = post::db();
264      $q  = " UPDATE forum_post SET ";
265      $q .= " deleted = 1 ";
266     
267      $db->query($q);
268      return true;
269  }
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] )[ post_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
185  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
186  {
187      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
188      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
189      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
190 
191      $db = post::db();
192      $data = array();
193      $q  = " SELECT $colstring ";
194      $q .= " FROM forum_post ";
195      $q .= " WHERE forum_post.deleted = 0 ";
196      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
197      $q .= array_key_exists("post_type_id",$lookups) ? " AND forum_post.post_type_id='" . $lookups["post_type_id"] . "' " : "";
198 
199      if (is_string($__order))
200      {
201          $q .= "ORDER BY " . $__order;
202      }
203      else if (is_array($__order) and count($__order)>0)
204      {
205          $orderings = array();
206          foreach ($__order as $col=>$dir)
207          {
208              $orderings[] = " $col $dir ";
209          }
210          $q .= "ORDER BY " . implode(", ", $orderings);
211      }
212      else if (is_object($__order))
213      {
214          $q .= "";
215      }
216      else
217      {
218          // THERE IS NO `order` COLUMN ON THIS OBJECT
219      }
220 
221      if (!is_null($__limit))
222      {
223          $q .= " LIMIT $__offset , $__limit ";
224      }
225 
226      $db->query($q);
227 
228      if (count($colarray)>1 || $colstring=="*")
229      {
230          while ($db->next_record())
231          {
232              $data[] = $db->record;
233          }
234      }
235      else
236      {
237          while ($db->next_record())
238          {
239              $data[] = $db->f(0);
240          }
241      }
242 
243      return $data;
244  }
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] )[ post_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
246  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
247  {
248      return post::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
249  }
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] )[ post_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
251  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
252  {
253      $objects = array();
254      foreach (post::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
255      {
256          $objects[] = new post($id);
257      }
258      return $objects;
259  }
publicget_post_type ( )[ post_db ]
Parameters
No parameters for this method
Code
341  public function get_post_type()
342  {
343      return new post_type($this->post_type_id);
344  }
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_topic ( type ["default"] )[ post_db ]
Parameters
optionaltype ["default"]
Code
353  public function get_topic($__type="default")
354  {
355      $object = is_null(keyval($this->property_objects_array,"{$__type}_topic")) ? new topic($this->get_topic_id($__type)) : $this->property_objects_array["{$__type}_topic"];
356      $this->property_objects_array["{$__type}_topic"] = $object;
357      return $object;
358  }
publicget_topic_id ( type ["default"] )[ post_db ]
Parameters
optionaltype ["default"]
Code
359  public function get_topic_id($__type="default")
360  {
361      $ids = $this->get_topic_ids($__type, true);
362      return (count($ids)==1 ? $ids[0] : null);
363  }
publicget_topic_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ post_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
364  public function get_topic_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
365  {
366      $topic_ids = array();
367      $db = post::db();
368      $q  = " SELECT forum_topic.id FROM forum_post_topic INNER JOIN forum_topic ON forum_post_topic.topic_id=forum_topic.id AND forum_post_topic.deleted=0 AND forum_topic.deleted=0 AND forum_post_topic.post_id='$this->id' " . (is_null($__type) ? "" : " AND forum_post_topic.post_topic_type_id='" . post_topic::type_id($__type) . "'") . ($__get_primary ? " AND forum_post_topic.primary=1 " : "");
369      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
370      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
371      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
372      $db->query($q);
373      while ($db->next_record())
374      {
375          $topic_ids[] = $db->f("id");
376      }
377      return $topic_ids;
378  }
publicget_topic_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ post_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
379  public function get_topic_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
380  {
381      $ids = $this->get_topic_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
382      $objects = array();
383      foreach ($ids as $index=>$id)
384      {
385          $objects[$index] = new topic($id);
386      }
387      return $objects;
388  }
publicget_type ( )[ post_db ]
Parameters
No parameters for this method
Code
330  public function get_type()
331  {
332      $type = new post_type($this->_post_type_id);
333      return $type->name;
334  }
publicget_user ( type ["default"] )[ post_db ]
Parameters
optionaltype ["default"]
Code
452  public function get_user($__type="default")
453  {
454      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
455      $this->property_objects_array["{$__type}_user"] = $object;
456      return $object;
457  }
publicget_user_id ( type ["default"] )[ post_db ]
Parameters
optionaltype ["default"]
Code
458  public function get_user_id($__type="default")
459  {
460      $ids = $this->get_user_ids($__type, true);
461      return (count($ids)==1 ? $ids[0] : null);
462  }
publicget_user_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ post_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
463  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
464  {
465      $user_ids = array();
466      $db = post::db();
467      $q  = " SELECT cor_user.person_entity_id FROM forum_post_user INNER JOIN cor_user ON forum_post_user.user_person_entity_id=cor_user.person_entity_id AND forum_post_user.deleted=0 AND cor_user.deleted=0 AND forum_post_user.post_id='$this->id' " . (is_null($__type) ? "" : " AND forum_post_user.post_user_type_id='" . post_user::type_id($__type) . "'") . ($__get_primary ? " AND forum_post_user.primary=1 " : "");
468      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
469      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
470      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
471      $db->query($q);
472      while ($db->next_record())
473      {
474          $user_ids[] = $db->f("person_entity_id");
475      }
476      return $user_ids;
477  }
publicget_user_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ post_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
478  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
479  {
480      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
481      $objects = array();
482      foreach ($ids as $index=>$id)
483      {
484          $objects[$index] = new user($id);
485      }
486      return $objects;
487  }
protectedinsert ( )[ post_db ]
Parameters
No parameters for this method
Code
117  protected function insert()
118  {
119      $db = post::db();
120      $q  = " INSERT INTO forum_post ( ";
121      $q .= $db->param_string("post_type_id") . ", ";
122      $q .= $db->param_string("content") . ", ";
123      $q .= $db->param_string("views") . ", ";
124      $q .= $db->param_string("mdate") . ", ";
125      $q .= $db->param_string("cdate") . ", ";
126      $q .= $db->param_string("deleted");
127      $q .= " ) VALUES ( ";
128      $q .= $db->value_string($this->_post_type_id) . ", ";
129      $q .= $db->value_string($this->_content) . ", ";
130      $q .= $db->value_string($this->_views) . ", ";
131      $q .= $db->value_string(timestamp()) . ", ";
132      $q .= $db->value_string(timestamp()) . ", ";
133      $q .= $this->deleted ? "'1'" : "'0'";
134      $q .= " ) ";
135      $db->query($q);
136      $this->_id = $db->insert_id;
137      return true;
138  }
publicmap ( )[ post_db ]
Parameters
No parameters for this method
Code
088  public function map()
089  {
090      $this->_post_type_id = array_key_exists("post:post_type_id",$_REQUEST) ? reqval("post:post_type_id") : $this->_post_type_id;
091      $this->_content = array_key_exists("post:content",$_REQUEST) ? reqval("post:content") : $this->_content;
092      $this->_views = array_key_exists("post:views",$_REQUEST) ? reqval("post:views") : $this->_views;
093      $this->_mdate = array_key_exists("post:mdate",$_REQUEST) ? reqval("post:mdate") : $this->_mdate;
094      $this->_cdate = array_key_exists("post:cdate",$_REQUEST) ? reqval("post:cdate") : $this->_cdate;
095      $this->_deleted = array_key_exists("post:deleted",$_REQUEST) ? reqval("post:deleted") : $this->_deleted;
096  }
publicpurge ( )[ post_db ]
Parameters
No parameters for this method
Code
176  public function purge()
177  {
178      $db = post::db();
179      $q  = " DELETE FROM forum_post ";
180      $q .= " WHERE id = " . $this->_id;
181      $db->query($q);
182      return true;
183  }
public staticsearch ( keyword )[ post_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_post_type ( v )[ post_db ]
Parameters
requiredv
Code
345  public function set_post_type($v)
346  {
347      if ($v->id > 0)
348      {
349          $this->post_type_id = $v->id;
350      }
351  }
publicset_topic ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
390  public function set_topic($__v, $__type="default")
391  {
392      $object = is_null(keyval($this->property_objects_array,"{$__type}_topic")) ? new topic($this->get_topic_id($__type)) : $this->property_objects_array["{$__type}_topic"];
393      if (is_null($__v))
394      {
395          $rel = new post_topic(null,$this->id,$object->id,post_topic::type_id($__type));
396          $rel->delete();
397          if (!is_null(keyval($this->property_objects_array,"{$__type}_topic")))
398          {
399              $this->property_objects_array["{$__type}_topic"] = null;
400          }
401      }
402      else
403      {
404          $id = $object->id;
405          $object = $__v;
406          $object->id = $__v->id>0 ? $__v->id : $id;
407          $object->commit();
408          $this->set_topic_ids(array($object->id),$__type);
409      }
410  }
publicset_topic_id ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
411  public function set_topic_id($__v, $__type="default")
412  {
413      $this->set_topic_ids(array($__v),$__type);
414  }
publicset_topic_ids ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
415  public function set_topic_ids($__v, $__type="default")
416  {
417      if ($this->id == 0)
418      {
419          $this->commit();
420      }
421      $type_id = post_topic::type_id($__type);
422      post_topic::delete_all($this->id,null,$type_id);
423      if (is_array($__v))
424      {
425          foreach ($__v as $index=>$id)
426          {
427              $object = new post_topic(null,$this->id,$id,$type_id);
428              $object->deleted = false;
429              $object->post_topic_type_id = $type_id;
430              $object->commit();
431              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_topic")))
432              {
433                  $this->property_objects_array["{$__type}_topic"] = new topic($object->topic_id);
434              }
435          }
436          $this->_dirty = true;
437      }
438  }
publicset_topic_list ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
439  public function set_topic_list($__v, $__type="default")
440  {
441      if (is_array($__v))
442      {
443          $ids = array();
444          foreach ($__v as $index=>$object)
445          {
446              $ids[] = $object->id;
447          }
448          $this->set_topic_ids($ids,$__type);
449      }
450  }
publicset_type ( v )[ post_db ]
Parameters
requiredv
Code
335  public function set_type($v)
336  {
337      $type = new post_type(null, $v);
338      $this->post_type_id = $type->id;
339  }
publicset_user ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
489  public function set_user($__v, $__type="default")
490  {
491      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
492      if (is_null($__v))
493      {
494          $rel = new post_user(null,$this->id,$object->id,post_user::type_id($__type));
495          $rel->delete();
496          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
497          {
498              $this->property_objects_array["{$__type}_user"] = null;
499          }
500      }
501      else
502      {
503          $id = $object->id;
504          $object = $__v;
505          $object->id = $__v->id>0 ? $__v->id : $id;
506          $object->commit();
507          $this->set_user_ids(array($object->id),$__type);
508      }
509  }
publicset_user_id ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
510  public function set_user_id($__v, $__type="default")
511  {
512      $this->set_user_ids(array($__v),$__type);
513  }
publicset_user_ids ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
514  public function set_user_ids($__v, $__type="default")
515  {
516      if ($this->id == 0)
517      {
518          $this->commit();
519      }
520      $type_id = post_user::type_id($__type);
521      post_user::delete_all($this->id,null,$type_id);
522      if (is_array($__v))
523      {
524          foreach ($__v as $index=>$id)
525          {
526              $object = new post_user(null,$this->id,$id,$type_id);
527              $object->deleted = false;
528              $object->post_user_type_id = $type_id;
529              $object->commit();
530              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
531              {
532                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
533              }
534          }
535          $this->_dirty = true;
536      }
537  }
publicset_user_list ( v , type ["default"] )[ post_db ]
Parameters
requiredv
optionaltype ["default"]
Code
538  public function set_user_list($__v, $__type="default")
539  {
540      if (is_array($__v))
541      {
542          $ids = array();
543          foreach ($__v as $index=>$object)
544          {
545              $ids[] = $object->id;
546          }
547          $this->set_user_ids($ids,$__type);
548      }
549  }
public__toString ( )[ post_db ]
Parameters
No parameters for this method
Code
319  public function __toString()
320  {
321      return (is_null($this->id) ? "" : $this->id);
322  }
public statictype_id ( type_name )[ post_db ]
Parameters
requiredtype_name
Code
324  public static function type_id($__type_name)
325  {
326      $type = new post_type(null, $__type_name);
327      return $type->id;
328  }
publicundelete ( )[ post_db ]
Parameters
No parameters for this method
Code
165  public function undelete()
166  {
167      $db = post::db();
168      $q  = " UPDATE forum_post SET ";
169      $q .= " deleted = 0 ";
170      $q .= " WHERE id = " . $this->_id;
171      $db->query($q);
172      $this->deleted = false;
173      return true;
174  }
protectedupdate ( )[ post_db ]
Parameters
No parameters for this method
Code
140  protected function update()
141  {
142      $db = post::db();
143      $q  = " UPDATE forum_post SET ";
144      $q .= $db->param_string("post_type_id") . " = " . $db->value_string($this->_post_type_id) . ", ";
145      $q .= $db->param_string("content") . " = " . $db->value_string($this->_content) . ", ";
146      $q .= $db->param_string("views") . " = " . $db->value_string($this->_views) . ", ";
147      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
148      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
149      $q .= " WHERE id = " . $this->_id;
150      $db->query($q);
151      return true;
152  }
 
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[ post_db ]
Code
185  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
186  {
187      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
188      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
189      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
190 
191      $db = post::db();
192      $data = array();
193      $q  = " SELECT $colstring ";
194      $q .= " FROM forum_post ";
195      $q .= " WHERE forum_post.deleted = 0 ";
196      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
197      $q .= array_key_exists("post_type_id",$lookups) ? " AND forum_post.post_type_id='" . $lookups["post_type_id"] . "' " : "";
198 
199      if (is_string($__order))
200      {
201          $q .= "ORDER BY " . $__order;
202      }
203      else if (is_array($__order) and count($__order)>0)
204      {
205          $orderings = array();
206          foreach ($__order as $col=>$dir)
207          {
208              $orderings[] = " $col $dir ";
209          }
210          $q .= "ORDER BY " . implode(", ", $orderings);
211      }
212      else if (is_object($__order))
213      {
214          $q .= "";
215      }
216      else
217      {
218          // THERE IS NO `order` COLUMN ON THIS OBJECT
219      }
220 
221      if (!is_null($__limit))
222      {
223          $q .= " LIMIT $__offset , $__limit ";
224      }
225 
226      $db->query($q);
227 
228      if (count($colarray)>1 || $colstring=="*")
229      {
230          while ($db->next_record())
231          {
232              $data[] = $db->record;
233          }
234      }
235      else
236      {
237          while ($db->next_record())
238          {
239              $data[] = $db->f(0);
240          }
241      }
242 
243      return $data;
244  }
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[ post_db ]
Code
246  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
247  {
248      return post::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
249  }
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[ post_db ]
Code
251  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
252  {
253      $objects = array();
254      foreach (post::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
255      {
256          $objects[] = new post($id);
257      }
258      return $objects;
259  }
publicpost_type[ post_db ]
Code
341  public function get_post_type()
342  {
343      return new post_type($this->post_type_id);
344  }
Code
345  public function set_post_type($v)
346  {
347      if ($v->id > 0)
348      {
349          $this->post_type_id = $v->id;
350      }
351  }
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  }
publictopic[ post_db ]
Code
353  public function get_topic($__type="default")
354  {
355      $object = is_null(keyval($this->property_objects_array,"{$__type}_topic")) ? new topic($this->get_topic_id($__type)) : $this->property_objects_array["{$__type}_topic"];
356      $this->property_objects_array["{$__type}_topic"] = $object;
357      return $object;
358  }
Code
390  public function set_topic($__v, $__type="default")
391  {
392      $object = is_null(keyval($this->property_objects_array,"{$__type}_topic")) ? new topic($this->get_topic_id($__type)) : $this->property_objects_array["{$__type}_topic"];
393      if (is_null($__v))
394      {
395          $rel = new post_topic(null,$this->id,$object->id,post_topic::type_id($__type));
396          $rel->delete();
397          if (!is_null(keyval($this->property_objects_array,"{$__type}_topic")))
398          {
399              $this->property_objects_array["{$__type}_topic"] = null;
400          }
401      }
402      else
403      {
404          $id = $object->id;
405          $object = $__v;
406          $object->id = $__v->id>0 ? $__v->id : $id;
407          $object->commit();
408          $this->set_topic_ids(array($object->id),$__type);
409      }
410  }
publictopic_id[ post_db ]
Code
359  public function get_topic_id($__type="default")
360  {
361      $ids = $this->get_topic_ids($__type, true);
362      return (count($ids)==1 ? $ids[0] : null);
363  }
Code
411  public function set_topic_id($__v, $__type="default")
412  {
413      $this->set_topic_ids(array($__v),$__type);
414  }
publictopic_ids[ post_db ]
Code
364  public function get_topic_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
365  {
366      $topic_ids = array();
367      $db = post::db();
368      $q  = " SELECT forum_topic.id FROM forum_post_topic INNER JOIN forum_topic ON forum_post_topic.topic_id=forum_topic.id AND forum_post_topic.deleted=0 AND forum_topic.deleted=0 AND forum_post_topic.post_id='$this->id' " . (is_null($__type) ? "" : " AND forum_post_topic.post_topic_type_id='" . post_topic::type_id($__type) . "'") . ($__get_primary ? " AND forum_post_topic.primary=1 " : "");
369      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
370      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
371      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
372      $db->query($q);
373      while ($db->next_record())
374      {
375          $topic_ids[] = $db->f("id");
376      }
377      return $topic_ids;
378  }
Code
415  public function set_topic_ids($__v, $__type="default")
416  {
417      if ($this->id == 0)
418      {
419          $this->commit();
420      }
421      $type_id = post_topic::type_id($__type);
422      post_topic::delete_all($this->id,null,$type_id);
423      if (is_array($__v))
424      {
425          foreach ($__v as $index=>$id)
426          {
427              $object = new post_topic(null,$this->id,$id,$type_id);
428              $object->deleted = false;
429              $object->post_topic_type_id = $type_id;
430              $object->commit();
431              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_topic")))
432              {
433                  $this->property_objects_array["{$__type}_topic"] = new topic($object->topic_id);
434              }
435          }
436          $this->_dirty = true;
437      }
438  }
publictopic_list[ post_db ]
Code
379  public function get_topic_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
380  {
381      $ids = $this->get_topic_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
382      $objects = array();
383      foreach ($ids as $index=>$id)
384      {
385          $objects[$index] = new topic($id);
386      }
387      return $objects;
388  }
Code
439  public function set_topic_list($__v, $__type="default")
440  {
441      if (is_array($__v))
442      {
443          $ids = array();
444          foreach ($__v as $index=>$object)
445          {
446              $ids[] = $object->id;
447          }
448          $this->set_topic_ids($ids,$__type);
449      }
450  }
publictype[ post_db ]
Code
330  public function get_type()
331  {
332      $type = new post_type($this->_post_type_id);
333      return $type->name;
334  }
Code
335  public function set_type($v)
336  {
337      $type = new post_type(null, $v);
338      $this->post_type_id = $type->id;
339  }
publicuser[ post_db ]
Code
452  public function get_user($__type="default")
453  {
454      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
455      $this->property_objects_array["{$__type}_user"] = $object;
456      return $object;
457  }
Code
489  public function set_user($__v, $__type="default")
490  {
491      $object = is_null(keyval($this->property_objects_array,"{$__type}_user")) ? new user($this->get_user_id($__type)) : $this->property_objects_array["{$__type}_user"];
492      if (is_null($__v))
493      {
494          $rel = new post_user(null,$this->id,$object->id,post_user::type_id($__type));
495          $rel->delete();
496          if (!is_null(keyval($this->property_objects_array,"{$__type}_user")))
497          {
498              $this->property_objects_array["{$__type}_user"] = null;
499          }
500      }
501      else
502      {
503          $id = $object->id;
504          $object = $__v;
505          $object->id = $__v->id>0 ? $__v->id : $id;
506          $object->commit();
507          $this->set_user_ids(array($object->id),$__type);
508      }
509  }
publicuser_id[ post_db ]
Code
458  public function get_user_id($__type="default")
459  {
460      $ids = $this->get_user_ids($__type, true);
461      return (count($ids)==1 ? $ids[0] : null);
462  }
Code
510  public function set_user_id($__v, $__type="default")
511  {
512      $this->set_user_ids(array($__v),$__type);
513  }
publicuser_ids[ post_db ]
Code
463  public function get_user_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
464  {
465      $user_ids = array();
466      $db = post::db();
467      $q  = " SELECT cor_user.person_entity_id FROM forum_post_user INNER JOIN cor_user ON forum_post_user.user_person_entity_id=cor_user.person_entity_id AND forum_post_user.deleted=0 AND cor_user.deleted=0 AND forum_post_user.post_id='$this->id' " . (is_null($__type) ? "" : " AND forum_post_user.post_user_type_id='" . post_user::type_id($__type) . "'") . ($__get_primary ? " AND forum_post_user.primary=1 " : "");
468      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
469      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
470      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
471      $db->query($q);
472      while ($db->next_record())
473      {
474          $user_ids[] = $db->f("person_entity_id");
475      }
476      return $user_ids;
477  }
Code
514  public function set_user_ids($__v, $__type="default")
515  {
516      if ($this->id == 0)
517      {
518          $this->commit();
519      }
520      $type_id = post_user::type_id($__type);
521      post_user::delete_all($this->id,null,$type_id);
522      if (is_array($__v))
523      {
524          foreach ($__v as $index=>$id)
525          {
526              $object = new post_user(null,$this->id,$id,$type_id);
527              $object->deleted = false;
528              $object->post_user_type_id = $type_id;
529              $object->commit();
530              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_user")))
531              {
532                  $this->property_objects_array["{$__type}_user"] = new user($object->user_id);
533              }
534          }
535          $this->_dirty = true;
536      }
537  }
publicuser_list[ post_db ]
Code
478  public function get_user_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
479  {
480      $ids = $this->get_user_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
481      $objects = array();
482      foreach ($ids as $index=>$id)
483      {
484          $objects[$index] = new user($id);
485      }
486      return $objects;
487  }
Code
538  public function set_user_list($__v, $__type="default")
539  {
540      if (is_array($__v))
541      {
542          $ids = array();
543          foreach ($__v as $index=>$object)
544          {
545              $ids[] = $object->id;
546          }
547          $this->set_user_ids($ids,$__type);
548      }
549  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads