Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class document extends document_ext

Hide Inherited MembersDocument Management
Description
No description.
 
Constants
constantTABLENAME ["doc_document"][ document ]
 
Properties
protected_cdate[ document_db ]
protected_cdate_dirty[ document_db ]
protected_code[ document_db ]
protected_code_dirty[ document_db ]
protected_deleted[ document_db ]
protected_deleted_dirty[ document_db ]
protected_description[ document_db ]
protected_description_dirty[ document_db ]
protected_dirty[ obj ]
protected_document_type_id[ document_db ]
protected_document_type_id_dirty[ document_db ]
protected_documentstatus_id[ document_db ]
protected_documentstatus_id_dirty[ document_db ]
protected_id[ document_db ]
protected_id_dirty[ document_db ]
protected_mdate[ document_db ]
protected_mdate_dirty[ document_db ]
publicproperty_objects_array[ obj ]
protected_revision[ document_db ]
protected_revision_dirty[ document_db ]
protected_summary[ document_db ]
protected_summary_dirty[ document_db ]
protected_title[ document_db ]
protected_title_dirty[ document_db ]
 
Methods
publiccommit ( )[ document_db ]
Parameters
No parameters for this method
Code
122  public function commit()
123  {
124      if ($this->_id > 0)
125      {
126          $this->update();
127      }
128      else
129      {
130          $this->insert();
131      }
132 
133      foreach ($this->property_objects_array as $property=>$object)
134      {
135          $this->{$property} = $object;
136      }
137 
138      return true;
139  }
public__construct ( id )[ document_db ]
Parameters
optionalid
Code
052  public function __construct($__id=null)
053  {
054      $this->_id = 0;
055      $this->_title = "";
056      $this->_description = "";
057      $this->_summary = "";
058      $this->_code = "";
059      $this->_revision = "";
060      $this->_document_type_id = 0;
061      $this->_documentstatus_id = 0;
062      $this->_mdate = null;
063      $this->_cdate = null;
064      $this->_deleted = false;
065 
066      $this->_id_dirty = false;
067      $this->_title_dirty = false;
068      $this->_description_dirty = false;
069      $this->_summary_dirty = false;
070      $this->_code_dirty = false;
071      $this->_revision_dirty = false;
072      $this->_document_type_id_dirty = false;
073      $this->_documentstatus_id_dirty = false;
074      $this->_mdate_dirty = false;
075      $this->_cdate_dirty = false;
076      $this->_deleted_dirty = false;
077 
078      if (is_null($__id))
079      {
080          return;
081      }
082 
083      $db = document::db();
084      $q  = " SELECT doc_document.id,doc_document.title,doc_document.description,doc_document.summary,doc_document.code,doc_document.revision,doc_document.document_type_id,doc_document.documentstatus_id,doc_document.mdate,doc_document.cdate,doc_document.deleted ";
085      $q .= " FROM doc_document ";       
086      if (!is_null($__id))
087      {
088          $q .= " WHERE id = '$__id' ";
089      }
090 
091      $db->query($q);
092      if ($db->next_record() && $db->num_rows() == 1)
093      {
094          $this->_id = $db->f("id");
095          $this->_title = $db->f("title");
096          $this->_description = $db->f("description");
097          $this->_summary = $db->f("summary");
098          $this->_code = $db->f("code");
099          $this->_revision = $db->f("revision");
100          $this->_document_type_id = $db->f("document_type_id");
101          $this->_documentstatus_id = $db->f("documentstatus_id");
102          $this->_mdate = $db->f("mdate");
103          $this->_cdate = $db->f("cdate");
104          $this->_deleted = $db->f("deleted");
105      }
106  }
protected staticdb ( )[ document_db ]
Parameters
No parameters for this method
Code
996  protected static function db()
997  {
998      return new db();
999  }
publicdelete ( )[ document_db ]
Parameters
No parameters for this method
Code
190  public function delete()
191  {
192      $db = document::db();
193      $q  = " UPDATE doc_document SET ";
194      $q .= " deleted = 1 ";
195      $q .= " WHERE id = " . $this->_id;
196      $db->query($q);
197      $this->deleted = true;
198      return true;
199  }
public staticdelete_all ( )[ document_db ]
Parameters
No parameters for this method
Code
298  public static function delete_all()
299  {
300      $db = document::db();
301      $q  = " UPDATE doc_document SET ";
302      $q .= " deleted = 1 ";
303     
304      $db->query($q);
305      return true;
306  }
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] )[ document_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
221  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
222  {
223      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
224      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
225      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
226 
227      $db = document::db();
228      $data = array();
229      $q  = " SELECT $colstring ";
230      $q .= " FROM doc_document ";
231      $q .= " WHERE doc_document.deleted = 0 ";
232      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
233      $q .= array_key_exists("document_type_id",$lookups) ? " AND doc_document.document_type_id='" . $lookups["document_type_id"] . "' " : "";
234      $q .= array_key_exists("documentstatus_id",$lookups) ? " AND doc_document.documentstatus_id='" . $lookups["documentstatus_id"] . "' " : "";
235 
236      if (is_string($__order))
237      {
238          $q .= "ORDER BY " . $__order;
239      }
240      else if (is_array($__order) and count($__order)>0)
241      {
242          $orderings = array();
243          foreach ($__order as $col=>$dir)
244          {
245              $orderings[] = " $col $dir ";
246          }
247          $q .= "ORDER BY " . implode(", ", $orderings);
248      }
249      else if (is_object($__order))
250      {
251          $q .= "";
252      }
253      else
254      {
255          // THERE IS NO `order` COLUMN ON THIS OBJECT
256      }
257 
258      if (!is_null($__limit))
259      {
260          $q .= " LIMIT $__offset , $__limit ";
261      }
262 
263      $db->query($q);
264 
265      if (count($colarray)>1 || $colstring=="*")
266      {
267          while ($db->next_record())
268          {
269              $data[] = $db->record;
270          }
271      }
272      else
273      {
274          while ($db->next_record())
275          {
276              $data[] = $db->f(0);
277          }
278      }
279 
280      return $data;
281  }
publicget_comment ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
798  public function get_comment($__type="default")
799  {
800      $object = is_null(keyval($this->property_objects_array,"{$__type}_comment")) ? new comment($this->get_comment_id($__type)) : $this->property_objects_array["{$__type}_comment"];
801      $this->property_objects_array["{$__type}_comment"] = $object;
802      return $object;
803  }
publicget_comment_id ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
804  public function get_comment_id($__type="default")
805  {
806      $ids = $this->get_comment_ids($__type, true);
807      return (count($ids)==1 ? $ids[0] : null);
808  }
publicget_comment_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
809  public function get_comment_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
810  {
811      $comment_ids = array();
812      $db = document::db();
813      $q  = " SELECT cor_comment.id FROM doc_comment_document INNER JOIN cor_comment ON doc_comment_document.comment_id=cor_comment.id AND doc_comment_document.deleted=0 AND cor_comment.deleted=0 AND doc_comment_document.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_comment_document.comment_document_type_id='" . comment_document::type_id($__type) . "'") . ($__get_primary ? " AND doc_comment_document.primary=1 " : "");
814      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
815      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
816      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
817      $db->query($q);
818      while ($db->next_record())
819      {
820          $comment_ids[] = $db->f("id");
821      }
822      return $comment_ids;
823  }
publicget_comment_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
824  public function get_comment_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
825  {
826      $ids = $this->get_comment_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
827      $objects = array();
828      foreach ($ids as $index=>$id)
829      {
830          $objects[$index] = new comment($id);
831      }
832      return $objects;
833  }
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  }
publicget_document_type ( )[ document_db ]
Parameters
No parameters for this method
Code
378  public function get_document_type()
379  {
380      return new document_type($this->document_type_id);
381  }
publicget_documentdate ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
402  public function get_documentdate($__type="default")
403  {
404      $object = is_null(keyval($this->property_objects_array,"{$__type}_documentdate")) ? new documentdate($this->get_documentdate_id($__type)) : $this->property_objects_array["{$__type}_documentdate"];
405      $this->property_objects_array["{$__type}_documentdate"] = $object;
406      return $object;
407  }
publicget_documentdate_id ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
408  public function get_documentdate_id($__type="default")
409  {
410      $ids = $this->get_documentdate_ids($__type, true);
411      return (count($ids)==1 ? $ids[0] : null);
412  }
publicget_documentdate_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
413  public function get_documentdate_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
414  {
415      $documentdate_ids = array();
416      $db = document::db();
417      $q  = " SELECT doc_documentdate.id FROM doc_document_documentdate INNER JOIN doc_documentdate ON doc_document_documentdate.documentdate_id=doc_documentdate.id AND doc_document_documentdate.deleted=0 AND doc_documentdate.deleted=0 AND doc_document_documentdate.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_document_documentdate.document_documentdate_type_id='" . document_documentdate::type_id($__type) . "'") . ($__get_primary ? " AND doc_document_documentdate.primary=1 " : "");
418      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
419      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
420      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
421      $db->query($q);
422      while ($db->next_record())
423      {
424          $documentdate_ids[] = $db->f("id");
425      }
426      return $documentdate_ids;
427  }
publicget_documentdate_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
428  public function get_documentdate_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
429  {
430      $ids = $this->get_documentdate_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
431      $objects = array();
432      foreach ($ids as $index=>$id)
433      {
434          $objects[$index] = new documentdate($id);
435      }
436      return $objects;
437  }
publicget_documentstatus ( )[ document_db ]
Parameters
No parameters for this method
Code
390  public function get_documentstatus()
391  {
392      return new documentstatus($this->documentstatus_id);
393  }
publicget_entity ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
699  public function get_entity($__type="default")
700  {
701      $object = is_null(keyval($this->property_objects_array,"{$__type}_entity")) ? new entity($this->get_entity_id($__type)) : $this->property_objects_array["{$__type}_entity"];
702      $this->property_objects_array["{$__type}_entity"] = $object;
703      return $object;
704  }
publicget_entity_id ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
705  public function get_entity_id($__type="default")
706  {
707      $ids = $this->get_entity_ids($__type, true);
708      return (count($ids)==1 ? $ids[0] : null);
709  }
publicget_entity_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
710  public function get_entity_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
711  {
712      $entity_ids = array();
713      $db = document::db();
714      $q  = " SELECT cor_entity.id FROM doc_document_entity INNER JOIN cor_entity ON doc_document_entity.entity_id=cor_entity.id AND doc_document_entity.deleted=0 AND cor_entity.deleted=0 AND doc_document_entity.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_document_entity.document_entity_type_id='" . document_entity::type_id($__type) . "'") . ($__get_primary ? " AND doc_document_entity.primary=1 " : "");
715      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
716      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
717      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
718      $db->query($q);
719      while ($db->next_record())
720      {
721          $entity_ids[] = $db->f("id");
722      }
723      return $entity_ids;
724  }
publicget_entity_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
725  public function get_entity_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
726  {
727      $ids = $this->get_entity_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
728      $objects = array();
729      foreach ($ids as $index=>$id)
730      {
731          $objects[$index] = new entity($id);
732      }
733      return $objects;
734  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ document_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
283  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
284  {
285      return document::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
286  }
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] )[ document_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
288  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
289  {
290      $objects = array();
291      foreach (document::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
292      {
293          $objects[] = new document($id);
294      }
295      return $objects;
296  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_resource ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
598  public function get_resource($__type="default")
599  {
600      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
601      $this->property_objects_array["{$__type}_resource"] = $object;
602      return $object;
603  }
publicget_resource_id ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
604  public function get_resource_id($__type="default")
605  {
606      $ids = $this->get_resource_ids($__type, true);
607      return (count($ids)==1 ? $ids[0] : null);
608  }
publicget_resource_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
609  public function get_resource_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
610  {
611      $resource_ids = array();
612      $db = document::db();
613      $q  = " SELECT cor_resource.id FROM doc_document_resource INNER JOIN cor_resource ON doc_document_resource.resource_id=cor_resource.id AND doc_document_resource.deleted=0 AND cor_resource.deleted=0 AND doc_document_resource.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_document_resource.document_resource_type_id='" . document_resource::type_id($__type) . "'") . ($__get_primary ? " AND doc_document_resource.primary=1 " : "");
614      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
615      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
616      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
617      $db->query($q);
618      while ($db->next_record())
619      {
620          $resource_ids[] = $db->f("id");
621      }
622      return $resource_ids;
623  }
publicget_resource_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
624  public function get_resource_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
625  {
626      $ids = $this->get_resource_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
627      $objects = array();
628      foreach ($ids as $index=>$id)
629      {
630          $objects[$index] = new resource($id);
631      }
632      return $objects;
633  }
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_task ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
897  public function get_task($__type="default")
898  {
899      $object = is_null(keyval($this->property_objects_array,"{$__type}_task")) ? new task($this->get_task_id($__type)) : $this->property_objects_array["{$__type}_task"];
900      $this->property_objects_array["{$__type}_task"] = $object;
901      return $object;
902  }
publicget_task_id ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
903  public function get_task_id($__type="default")
904  {
905      $ids = $this->get_task_ids($__type, true);
906      return (count($ids)==1 ? $ids[0] : null);
907  }
publicget_task_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
908  public function get_task_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
909  {
910      $task_ids = array();
911      $db = document::db();
912      $q  = " SELECT prj_task.id FROM prj_document_task INNER JOIN prj_task ON prj_document_task.task_id=prj_task.id AND prj_document_task.deleted=0 AND prj_task.deleted=0 AND prj_document_task.document_id='$this->id' " . (is_null($__type) ? "" : " AND prj_document_task.document_task_type_id='" . document_task::type_id($__type) . "'") . ($__get_primary ? " AND prj_document_task.primary=1 " : "");
913      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
914      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
915      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
916      $db->query($q);
917      while ($db->next_record())
918      {
919          $task_ids[] = $db->f("id");
920      }
921      return $task_ids;
922  }
publicget_task_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
923  public function get_task_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
924  {
925      $ids = $this->get_task_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
926      $objects = array();
927      foreach ($ids as $index=>$id)
928      {
929          $objects[$index] = new task($id);
930      }
931      return $objects;
932  }
publicget_type ( )[ document_db ]
Parameters
No parameters for this method
Code
367  public function get_type()
368  {
369      $type = new document_type($this->_document_type_id);
370      return $type->name;
371  }
publicget_url ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
500  public function get_url($__type="default")
501  {
502      $object = is_null(keyval($this->property_objects_array,"{$__type}_url")) ? new url($this->get_url_id($__type)) : $this->property_objects_array["{$__type}_url"];
503      $this->property_objects_array["{$__type}_url"] = $object;
504      return $object;
505  }
publicget_url_id ( type ["default"] )[ document_db ]
Parameters
optionaltype ["default"]
Code
506  public function get_url_id($__type="default")
507  {
508      $ids = $this->get_url_ids($__type, true);
509      return (count($ids)==1 ? $ids[0] : null);
510  }
publicget_url_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
511  public function get_url_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
512  {
513      $url_ids = array();
514      $db = document::db();
515      $q  = " SELECT cor_url.id FROM doc_document_url INNER JOIN cor_url ON doc_document_url.url_id=cor_url.id AND doc_document_url.deleted=0 AND cor_url.deleted=0 AND doc_document_url.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_document_url.document_url_type_id='" . document_url::type_id($__type) . "'") . ($__get_primary ? " AND doc_document_url.primary=1 " : "");
516      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
517      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
518      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
519      $db->query($q);
520      while ($db->next_record())
521      {
522          $url_ids[] = $db->f("id");
523      }
524      return $url_ids;
525  }
publicget_url_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ document_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
526  public function get_url_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
527  {
528      $ids = $this->get_url_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
529      $objects = array();
530      foreach ($ids as $index=>$id)
531      {
532          $objects[$index] = new url($id);
533      }
534      return $objects;
535  }
protectedinsert ( )[ document_db ]
Parameters
No parameters for this method
Code
141  protected function insert()
142  {
143      $db = document::db();
144      $q  = " INSERT INTO doc_document ( ";
145      $q .= $db->param_string("title") . ", ";
146      $q .= $db->param_string("description") . ", ";
147      $q .= $db->param_string("summary") . ", ";
148      $q .= $db->param_string("code") . ", ";
149      $q .= $db->param_string("revision") . ", ";
150      $q .= $db->param_string("document_type_id") . ", ";
151      $q .= $db->param_string("documentstatus_id") . ", ";
152      $q .= $db->param_string("mdate") . ", ";
153      $q .= $db->param_string("cdate") . ", ";
154      $q .= $db->param_string("deleted");
155      $q .= " ) VALUES ( ";
156      $q .= $db->value_string($this->_title) . ", ";
157      $q .= $db->value_string($this->_description) . ", ";
158      $q .= $db->value_string($this->_summary) . ", ";
159      $q .= $db->value_string($this->_code) . ", ";
160      $q .= $db->value_string($this->_revision) . ", ";
161      $q .= $db->value_string($this->_document_type_id) . ", ";
162      $q .= $db->value_string($this->_documentstatus_id) . ", ";
163      $q .= $db->value_string(timestamp()) . ", ";
164      $q .= $db->value_string(timestamp()) . ", ";
165      $q .= $this->deleted ? "'1'" : "'0'";
166      $q .= " ) ";
167      $db->query($q);
168      $this->_id = $db->insert_id;
169      return true;
170  }
publicmap ( )[ document_db ]
Parameters
No parameters for this method
Code
108  public function map()
109  {
110      $this->_title = array_key_exists("document:title",$_REQUEST) ? reqval("document:title") : $this->_title;
111      $this->_description = array_key_exists("document:description",$_REQUEST) ? reqval("document:description") : $this->_description;
112      $this->_summary = array_key_exists("document:summary",$_REQUEST) ? reqval("document:summary") : $this->_summary;
113      $this->_code = array_key_exists("document:code",$_REQUEST) ? reqval("document:code") : $this->_code;
114      $this->_revision = array_key_exists("document:revision",$_REQUEST) ? reqval("document:revision") : $this->_revision;
115      $this->_document_type_id = array_key_exists("document:document_type_id",$_REQUEST) ? reqval("document:document_type_id") : $this->_document_type_id;
116      $this->_documentstatus_id = array_key_exists("document:documentstatus_id",$_REQUEST) ? reqval("document:documentstatus_id") : $this->_documentstatus_id;
117      $this->_mdate = array_key_exists("document:mdate",$_REQUEST) ? reqval("document:mdate") : $this->_mdate;
118      $this->_cdate = array_key_exists("document:cdate",$_REQUEST) ? reqval("document:cdate") : $this->_cdate;
119      $this->_deleted = array_key_exists("document:deleted",$_REQUEST) ? reqval("document:deleted") : $this->_deleted;
120  }
publicpurge ( )[ document_db ]
Parameters
No parameters for this method
Code
212  public function purge()
213  {
214      $db = document::db();
215      $q  = " DELETE FROM doc_document ";
216      $q .= " WHERE id = " . $this->_id;
217      $db->query($q);
218      return true;
219  }
public staticsearch ( keyword )[ document_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_comment ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
835  public function set_comment($__v, $__type="default")
836  {
837      $object = is_null(keyval($this->property_objects_array,"{$__type}_comment")) ? new comment($this->get_comment_id($__type)) : $this->property_objects_array["{$__type}_comment"];
838      if (is_null($__v))
839      {
840          $rel = new comment_document(null,$object->id,$this->id,comment_document::type_id($__type));
841          $rel->delete();
842          if (!is_null(keyval($this->property_objects_array,"{$__type}_comment")))
843          {
844              $this->property_objects_array["{$__type}_comment"] = null;
845          }
846      }
847      else
848      {
849          $id = $object->id;
850          $object = $__v;
851          $object->id = $__v->id>0 ? $__v->id : $id;
852          $object->commit();
853          $this->set_comment_ids(array($object->id),$__type);
854      }
855  }
publicset_comment_id ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
856  public function set_comment_id($__v, $__type="default")
857  {
858      $this->set_comment_ids(array($__v),$__type);
859  }
publicset_comment_ids ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
860  public function set_comment_ids($__v, $__type="default")
861  {
862      if ($this->id == 0)
863      {
864          $this->commit();
865      }
866      $type_id = comment_document::type_id($__type);
867      comment_document::delete_all(null,$this->id,$type_id);
868      if (is_array($__v))
869      {
870          foreach ($__v as $index=>$id)
871          {
872              $object = new comment_document(null,$id,$this->id,$type_id);
873              $object->deleted = false;
874              $object->comment_document_type_id = $type_id;
875              $object->commit();
876              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_comment")))
877              {
878                  $this->property_objects_array["{$__type}_comment"] = new comment($object->comment_id);
879              }
880          }
881          $this->_dirty = true;
882      }
883  }
publicset_comment_list ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
884  public function set_comment_list($__v, $__type="default")
885  {
886      if (is_array($__v))
887      {
888          $ids = array();
889          foreach ($__v as $index=>$object)
890          {
891              $ids[] = $object->id;
892          }
893          $this->set_comment_ids($ids,$__type);
894      }
895  }
publicset_document_type ( v )[ document_db ]
Parameters
requiredv
Code
382  public function set_document_type($v)
383  {
384      if ($v->id > 0)
385      {
386          $this->document_type_id = $v->id;
387      }
388  }
publicset_documentdate ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
439  public function set_documentdate($__v, $__type="default")
440  {
441      $object = is_null(keyval($this->property_objects_array,"{$__type}_documentdate")) ? new documentdate($this->get_documentdate_id($__type)) : $this->property_objects_array["{$__type}_documentdate"];
442      if (is_null($__v))
443      {
444          $rel = new document_documentdate(null,$this->id,$object->id,document_documentdate::type_id($__type));
445          $rel->delete();
446          $object->delete();
447          if (!is_null(keyval($this->property_objects_array,"{$__type}_documentdate")))
448          {
449              $this->property_objects_array["{$__type}_documentdate"] = null;
450          }
451      }
452      else
453      {
454          $object->value = is_object($__v) ? $__v->value : $__v;
455          $object->commit();
456          $this->set_documentdate_ids(array($object->id),$__type);
457      }
458  }
publicset_documentdate_id ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
459  public function set_documentdate_id($__v, $__type="default")
460  {
461      $this->set_documentdate_ids(array($__v),$__type);
462  }
publicset_documentdate_ids ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
463  public function set_documentdate_ids($__v, $__type="default")
464  {
465      if ($this->id == 0)
466      {
467          $this->commit();
468      }
469      $type_id = document_documentdate::type_id($__type);
470      document_documentdate::delete_all($this->id,null,$type_id);
471      if (is_array($__v))
472      {
473          foreach ($__v as $index=>$id)
474          {
475              $object = new document_documentdate(null,$this->id,$id,$type_id);
476              $object->deleted = false;
477              $object->document_documentdate_type_id = $type_id;
478              $object->commit();
479              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_documentdate")))
480              {
481                  $this->property_objects_array["{$__type}_documentdate"] = new documentdate($object->documentdate_id);
482              }
483          }
484          $this->_dirty = true;
485      }
486  }
publicset_documentdate_list ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
487  public function set_documentdate_list($__v, $__type="default")
488  {
489      if (is_array($__v))
490      {
491          $ids = array();
492          foreach ($__v as $index=>$object)
493          {
494              $ids[] = $object->id;
495          }
496          $this->set_documentdate_ids($ids,$__type);
497      }
498  }
publicset_documentstatus ( v )[ document_db ]
Parameters
requiredv
Code
394  public function set_documentstatus($v)
395  {
396      if ($v->id > 0)
397      {
398          $this->documentstatus_id = $v->id;
399      }
400  }
publicset_entity ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
736  public function set_entity($__v, $__type="default")
737  {
738      $object = is_null(keyval($this->property_objects_array,"{$__type}_entity")) ? new entity($this->get_entity_id($__type)) : $this->property_objects_array["{$__type}_entity"];
739      if (is_null($__v))
740      {
741          $rel = new document_entity(null,$this->id,$object->id,document_entity::type_id($__type));
742          $rel->delete();
743          if (!is_null(keyval($this->property_objects_array,"{$__type}_entity")))
744          {
745              $this->property_objects_array["{$__type}_entity"] = null;
746          }
747      }
748      else
749      {
750          $id = $object->id;
751          $object = $__v;
752          $object->id = $__v->id>0 ? $__v->id : $id;
753          $object->commit();
754          $this->set_entity_ids(array($object->id),$__type);
755      }
756  }
publicset_entity_id ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
757  public function set_entity_id($__v, $__type="default")
758  {
759      $this->set_entity_ids(array($__v),$__type);
760  }
publicset_entity_ids ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
761  public function set_entity_ids($__v, $__type="default")
762  {
763      if ($this->id == 0)
764      {
765          $this->commit();
766      }
767      $type_id = document_entity::type_id($__type);
768      document_entity::delete_all($this->id,null,$type_id);
769      if (is_array($__v))
770      {
771          foreach ($__v as $index=>$id)
772          {
773              $object = new document_entity(null,$this->id,$id,$type_id);
774              $object->deleted = false;
775              $object->document_entity_type_id = $type_id;
776              $object->commit();
777              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_entity")))
778              {
779                  $this->property_objects_array["{$__type}_entity"] = new entity($object->entity_id);
780              }
781          }
782          $this->_dirty = true;
783      }
784  }
publicset_entity_list ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
785  public function set_entity_list($__v, $__type="default")
786  {
787      if (is_array($__v))
788      {
789          $ids = array();
790          foreach ($__v as $index=>$object)
791          {
792              $ids[] = $object->id;
793          }
794          $this->set_entity_ids($ids,$__type);
795      }
796  }
publicset_resource ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
635  public function set_resource($__v, $__type="default")
636  {
637      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
638      if (is_null($__v))
639      {
640          $rel = new document_resource(null,$this->id,$object->id,document_resource::type_id($__type));
641          $rel->delete();
642          if (!is_null(keyval($this->property_objects_array,"{$__type}_resource")))
643          {
644              $this->property_objects_array["{$__type}_resource"] = null;
645          }
646      }
647      else
648      {
649          $hash = $object->hash;
650          $id = $object->id;
651          $object = $__v;
652          $object->hash = $__v->id>0 ? $__v->hash : $hash;
653          $object->id = $__v->id>0 ? $__v->id : $id;
654          $object->commit();
655          $this->set_resource_ids(array($object->id),$__type);
656      }
657  }
publicset_resource_id ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
658  public function set_resource_id($__v, $__type="default")
659  {
660      $this->set_resource_ids(array($__v),$__type);
661  }
publicset_resource_ids ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
662  public function set_resource_ids($__v, $__type="default")
663  {
664      if ($this->id == 0)
665      {
666          $this->commit();
667      }
668      $type_id = document_resource::type_id($__type);
669      document_resource::delete_all($this->id,null,$type_id);
670      if (is_array($__v))
671      {
672          foreach ($__v as $index=>$id)
673          {
674              $object = new document_resource(null,$this->id,$id,$type_id);
675              $object->deleted = false;
676              $object->document_resource_type_id = $type_id;
677              $object->commit();
678              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_resource")))
679              {
680                  $this->property_objects_array["{$__type}_resource"] = new resource($object->resource_id);
681              }
682          }
683          $this->_dirty = true;
684      }
685  }
publicset_resource_list ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
686  public function set_resource_list($__v, $__type="default")
687  {
688      if (is_array($__v))
689      {
690          $ids = array();
691          foreach ($__v as $index=>$object)
692          {
693              $ids[] = $object->id;
694          }
695          $this->set_resource_ids($ids,$__type);
696      }
697  }
publicset_task ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
934  public function set_task($__v, $__type="default")
935  {
936      $object = is_null(keyval($this->property_objects_array,"{$__type}_task")) ? new task($this->get_task_id($__type)) : $this->property_objects_array["{$__type}_task"];
937      if (is_null($__v))
938      {
939          $rel = new document_task(null,$this->id,$object->id,document_task::type_id($__type));
940          $rel->delete();
941          if (!is_null(keyval($this->property_objects_array,"{$__type}_task")))
942          {
943              $this->property_objects_array["{$__type}_task"] = null;
944          }
945      }
946      else
947      {
948          $id = $object->id;
949          $object = $__v;
950          $object->id = $__v->id>0 ? $__v->id : $id;
951          $object->commit();
952          $this->set_task_ids(array($object->id),$__type);
953      }
954  }
publicset_task_id ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
955  public function set_task_id($__v, $__type="default")
956  {
957      $this->set_task_ids(array($__v),$__type);
958  }
publicset_task_ids ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
959  public function set_task_ids($__v, $__type="default")
960  {
961      if ($this->id == 0)
962      {
963          $this->commit();
964      }
965      $type_id = document_task::type_id($__type);
966      document_task::delete_all($this->id,null,$type_id);
967      if (is_array($__v))
968      {
969          foreach ($__v as $index=>$id)
970          {
971              $object = new document_task(null,$this->id,$id,$type_id);
972              $object->deleted = false;
973              $object->document_task_type_id = $type_id;
974              $object->commit();
975              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_task")))
976              {
977                  $this->property_objects_array["{$__type}_task"] = new task($object->task_id);
978              }
979          }
980          $this->_dirty = true;
981      }
982  }
publicset_task_list ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
983  public function set_task_list($__v, $__type="default")
984  {
985      if (is_array($__v))
986      {
987          $ids = array();
988          foreach ($__v as $index=>$object)
989          {
990              $ids[] = $object->id;
991          }
992          $this->set_task_ids($ids,$__type);
993      }
994  }
publicset_type ( v )[ document_db ]
Parameters
requiredv
Code
372  public function set_type($v)
373  {
374      $type = new document_type(null, $v);
375      $this->document_type_id = $type->id;
376  }
publicset_url ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
537  public function set_url($__v, $__type="default")
538  {
539      $object = is_null(keyval($this->property_objects_array,"{$__type}_url")) ? new url($this->get_url_id($__type)) : $this->property_objects_array["{$__type}_url"];
540      if (is_null($__v))
541      {
542          $rel = new document_url(null,$this->id,$object->id,document_url::type_id($__type));
543          $rel->delete();
544          $object->delete();
545          if (!is_null(keyval($this->property_objects_array,"{$__type}_url")))
546          {
547              $this->property_objects_array["{$__type}_url"] = null;
548          }
549      }
550      else
551      {
552          $object->value = is_object($__v) ? $__v->value : $__v;
553          $object->commit();
554          $this->set_url_ids(array($object->id),$__type);
555      }
556  }
publicset_url_id ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
557  public function set_url_id($__v, $__type="default")
558  {
559      $this->set_url_ids(array($__v),$__type);
560  }
publicset_url_ids ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
561  public function set_url_ids($__v, $__type="default")
562  {
563      if ($this->id == 0)
564      {
565          $this->commit();
566      }
567      $type_id = document_url::type_id($__type);
568      document_url::delete_all($this->id,null,$type_id);
569      if (is_array($__v))
570      {
571          foreach ($__v as $index=>$id)
572          {
573              $object = new document_url(null,$this->id,$id,$type_id);
574              $object->deleted = false;
575              $object->document_url_type_id = $type_id;
576              $object->commit();
577              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_url")))
578              {
579                  $this->property_objects_array["{$__type}_url"] = new url($object->url_id);
580              }
581          }
582          $this->_dirty = true;
583      }
584  }
publicset_url_list ( v , type ["default"] )[ document_db ]
Parameters
requiredv
optionaltype ["default"]
Code
585  public function set_url_list($__v, $__type="default")
586  {
587      if (is_array($__v))
588      {
589          $ids = array();
590          foreach ($__v as $index=>$object)
591          {
592              $ids[] = $object->id;
593          }
594          $this->set_url_ids($ids,$__type);
595      }
596  }
public__toString ( )[ document_db ]
Parameters
No parameters for this method
Code
356  public function __toString()
357  {
358      return (is_null($this->description) ? "" : $this->description);
359  }
public statictype_id ( type_name )[ document_db ]
Parameters
requiredtype_name
Code
361  public static function type_id($__type_name)
362  {
363      $type = new document_type(null, $__type_name);
364      return $type->id;
365  }
publicundelete ( )[ document_db ]
Parameters
No parameters for this method
Code
201  public function undelete()
202  {
203      $db = document::db();
204      $q  = " UPDATE doc_document SET ";
205      $q .= " deleted = 0 ";
206      $q .= " WHERE id = " . $this->_id;
207      $db->query($q);
208      $this->deleted = false;
209      return true;
210  }
protectedupdate ( )[ document_db ]
Parameters
No parameters for this method
Code
172  protected function update()
173  {
174      $db = document::db();
175      $q  = " UPDATE doc_document SET ";
176      $q .= $db->param_string("title") . " = " . $db->value_string($this->_title) . ", ";
177      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
178      $q .= $db->param_string("summary") . " = " . $db->value_string($this->_summary) . ", ";
179      $q .= $db->param_string("code") . " = " . $db->value_string($this->_code) . ", ";
180      $q .= $db->param_string("revision") . " = " . $db->value_string($this->_revision) . ", ";
181      $q .= $db->param_string("document_type_id") . " = " . $db->value_string($this->_document_type_id) . ", ";
182      $q .= $db->param_string("documentstatus_id") . " = " . $db->value_string($this->_documentstatus_id) . ", ";
183      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
184      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
185      $q .= " WHERE id = " . $this->_id;
186      $db->query($q);
187      return true;
188  }
 
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[ document_db ]
Code
221  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
222  {
223      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
224      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
225      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
226 
227      $db = document::db();
228      $data = array();
229      $q  = " SELECT $colstring ";
230      $q .= " FROM doc_document ";
231      $q .= " WHERE doc_document.deleted = 0 ";
232      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
233      $q .= array_key_exists("document_type_id",$lookups) ? " AND doc_document.document_type_id='" . $lookups["document_type_id"] . "' " : "";
234      $q .= array_key_exists("documentstatus_id",$lookups) ? " AND doc_document.documentstatus_id='" . $lookups["documentstatus_id"] . "' " : "";
235 
236      if (is_string($__order))
237      {
238          $q .= "ORDER BY " . $__order;
239      }
240      else if (is_array($__order) and count($__order)>0)
241      {
242          $orderings = array();
243          foreach ($__order as $col=>$dir)
244          {
245              $orderings[] = " $col $dir ";
246          }
247          $q .= "ORDER BY " . implode(", ", $orderings);
248      }
249      else if (is_object($__order))
250      {
251          $q .= "";
252      }
253      else
254      {
255          // THERE IS NO `order` COLUMN ON THIS OBJECT
256      }
257 
258      if (!is_null($__limit))
259      {
260          $q .= " LIMIT $__offset , $__limit ";
261      }
262 
263      $db->query($q);
264 
265      if (count($colarray)>1 || $colstring=="*")
266      {
267          while ($db->next_record())
268          {
269              $data[] = $db->record;
270          }
271      }
272      else
273      {
274          while ($db->next_record())
275          {
276              $data[] = $db->f(0);
277          }
278      }
279 
280      return $data;
281  }
publiccomment[ document_db ]
Code
798  public function get_comment($__type="default")
799  {
800      $object = is_null(keyval($this->property_objects_array,"{$__type}_comment")) ? new comment($this->get_comment_id($__type)) : $this->property_objects_array["{$__type}_comment"];
801      $this->property_objects_array["{$__type}_comment"] = $object;
802      return $object;
803  }
Code
835  public function set_comment($__v, $__type="default")
836  {
837      $object = is_null(keyval($this->property_objects_array,"{$__type}_comment")) ? new comment($this->get_comment_id($__type)) : $this->property_objects_array["{$__type}_comment"];
838      if (is_null($__v))
839      {
840          $rel = new comment_document(null,$object->id,$this->id,comment_document::type_id($__type));
841          $rel->delete();
842          if (!is_null(keyval($this->property_objects_array,"{$__type}_comment")))
843          {
844              $this->property_objects_array["{$__type}_comment"] = null;
845          }
846      }
847      else
848      {
849          $id = $object->id;
850          $object = $__v;
851          $object->id = $__v->id>0 ? $__v->id : $id;
852          $object->commit();
853          $this->set_comment_ids(array($object->id),$__type);
854      }
855  }
publiccomment_id[ document_db ]
Code
804  public function get_comment_id($__type="default")
805  {
806      $ids = $this->get_comment_ids($__type, true);
807      return (count($ids)==1 ? $ids[0] : null);
808  }
Code
856  public function set_comment_id($__v, $__type="default")
857  {
858      $this->set_comment_ids(array($__v),$__type);
859  }
publiccomment_ids[ document_db ]
Code
809  public function get_comment_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
810  {
811      $comment_ids = array();
812      $db = document::db();
813      $q  = " SELECT cor_comment.id FROM doc_comment_document INNER JOIN cor_comment ON doc_comment_document.comment_id=cor_comment.id AND doc_comment_document.deleted=0 AND cor_comment.deleted=0 AND doc_comment_document.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_comment_document.comment_document_type_id='" . comment_document::type_id($__type) . "'") . ($__get_primary ? " AND doc_comment_document.primary=1 " : "");
814      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
815      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
816      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
817      $db->query($q);
818      while ($db->next_record())
819      {
820          $comment_ids[] = $db->f("id");
821      }
822      return $comment_ids;
823  }
Code
860  public function set_comment_ids($__v, $__type="default")
861  {
862      if ($this->id == 0)
863      {
864          $this->commit();
865      }
866      $type_id = comment_document::type_id($__type);
867      comment_document::delete_all(null,$this->id,$type_id);
868      if (is_array($__v))
869      {
870          foreach ($__v as $index=>$id)
871          {
872              $object = new comment_document(null,$id,$this->id,$type_id);
873              $object->deleted = false;
874              $object->comment_document_type_id = $type_id;
875              $object->commit();
876              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_comment")))
877              {
878                  $this->property_objects_array["{$__type}_comment"] = new comment($object->comment_id);
879              }
880          }
881          $this->_dirty = true;
882      }
883  }
publiccomment_list[ document_db ]
Code
824  public function get_comment_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
825  {
826      $ids = $this->get_comment_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
827      $objects = array();
828      foreach ($ids as $index=>$id)
829      {
830          $objects[$index] = new comment($id);
831      }
832      return $objects;
833  }
Code
884  public function set_comment_list($__v, $__type="default")
885  {
886      if (is_array($__v))
887      {
888          $ids = array();
889          foreach ($__v as $index=>$object)
890          {
891              $ids[] = $object->id;
892          }
893          $this->set_comment_ids($ids,$__type);
894      }
895  }
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  }
publicdocument_type[ document_db ]
Code
378  public function get_document_type()
379  {
380      return new document_type($this->document_type_id);
381  }
Code
382  public function set_document_type($v)
383  {
384      if ($v->id > 0)
385      {
386          $this->document_type_id = $v->id;
387      }
388  }
publicdocumentdate[ document_db ]
Code
402  public function get_documentdate($__type="default")
403  {
404      $object = is_null(keyval($this->property_objects_array,"{$__type}_documentdate")) ? new documentdate($this->get_documentdate_id($__type)) : $this->property_objects_array["{$__type}_documentdate"];
405      $this->property_objects_array["{$__type}_documentdate"] = $object;
406      return $object;
407  }
Code
439  public function set_documentdate($__v, $__type="default")
440  {
441      $object = is_null(keyval($this->property_objects_array,"{$__type}_documentdate")) ? new documentdate($this->get_documentdate_id($__type)) : $this->property_objects_array["{$__type}_documentdate"];
442      if (is_null($__v))
443      {
444          $rel = new document_documentdate(null,$this->id,$object->id,document_documentdate::type_id($__type));
445          $rel->delete();
446          $object->delete();
447          if (!is_null(keyval($this->property_objects_array,"{$__type}_documentdate")))
448          {
449              $this->property_objects_array["{$__type}_documentdate"] = null;
450          }
451      }
452      else
453      {
454          $object->value = is_object($__v) ? $__v->value : $__v;
455          $object->commit();
456          $this->set_documentdate_ids(array($object->id),$__type);
457      }
458  }
publicdocumentdate_id[ document_db ]
Code
408  public function get_documentdate_id($__type="default")
409  {
410      $ids = $this->get_documentdate_ids($__type, true);
411      return (count($ids)==1 ? $ids[0] : null);
412  }
Code
459  public function set_documentdate_id($__v, $__type="default")
460  {
461      $this->set_documentdate_ids(array($__v),$__type);
462  }
publicdocumentdate_ids[ document_db ]
Code
413  public function get_documentdate_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
414  {
415      $documentdate_ids = array();
416      $db = document::db();
417      $q  = " SELECT doc_documentdate.id FROM doc_document_documentdate INNER JOIN doc_documentdate ON doc_document_documentdate.documentdate_id=doc_documentdate.id AND doc_document_documentdate.deleted=0 AND doc_documentdate.deleted=0 AND doc_document_documentdate.document_id='$this->id' " . (is_null($__type) ? "" : " AND doc_document_documentdate.document_documentdate_type_id='" . document_documentdate::type_id($__type) . "'") . ($__get_primary ? " AND doc_document_documentdate.primary=1 " : "");
418      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
419      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
420      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
421      $db->query($q);
422      while ($db->next_record())
423      {
424          $documentdate_ids[] = $db->f("id");
425      }
426      return $documentdate_ids;
427  }
Code
463  public function set_documentdate_ids($__v, $__type="default")
464  {
465      if ($this->id == 0)
466      {
467          $this->commit();
468      }
469      $type_id = document_documentdate::type_id($__type);
470      document_documentdate::delete_all($this->id,null,$type_id);
471      if (is_array($__v))
472      {
473          foreach ($__v as $index=>$id)
474          {
475              $object = new document_documentdate(null,$this->id,$id,$type_id);
476              $object->deleted = false;
477              $object->document_documentdate_type_id = $type_id;
478              $object->commit();
479              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_documentdate")))
480              {
481                  $this->property_objects_array["{$__type}_documentdate"] = new documentdate($object->documentdate_id);
482              }
483          }
484          $this->_dirty = true;
</