Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class hit extends hit_ext

Hide Inherited MembersAmazon Web Services
Description
No description.
 
Constants
constantTABLENAME ["aws_hit"][ hit ]
 
Properties
protected_assignmentdurationinseconds[ hit_db ]
protected_assignmentdurationinseconds_dirty[ hit_db ]
protected_autoapprovaldelayinseconds[ hit_db ]
protected_autoapprovaldelayinseconds_dirty[ hit_db ]
protected_cdate[ hit_db ]
protected_cdate_dirty[ hit_db ]
protected_deleted[ hit_db ]
protected_deleted_dirty[ hit_db ]
protected_description[ hit_db ]
protected_description_dirty[ hit_db ]
protected_dirty[ obj ]
protected_hitid[ hit_db ]
protected_hitid_dirty[ hit_db ]
protected_hitreviewstatus_id[ hit_db ]
protected_hitreviewstatus_id_dirty[ hit_db ]
protected_hitstatus_id[ hit_db ]
protected_hitstatus_id_dirty[ hit_db ]
protected_id[ hit_db ]
protected_id_dirty[ hit_db ]
protected_keywords[ hit_db ]
protected_keywords_dirty[ hit_db ]
protected_lifetimeinseconds[ hit_db ]
protected_lifetimeinseconds_dirty[ hit_db ]
protected_maxassignments[ hit_db ]
protected_maxassignments_dirty[ hit_db ]
protected_mdate[ hit_db ]
protected_mdate_dirty[ hit_db ]
protected_name[ hit_db ]
protected_name_dirty[ hit_db ]
protected_num_assignments[ hit_db ]
protected_num_assignments_dirty[ hit_db ]
protected_numberofassignmentsavailable[ hit_db ]
protected_numberofassignmentsavailable_dirty[ hit_db ]
protected_numberofassignmentscompleted[ hit_db ]
protected_numberofassignmentscompleted_dirty[ hit_db ]
protected_numberofassignmentspending[ hit_db ]
protected_numberofassignmentspending_dirty[ hit_db ]
protected_numberofsimilarhits[ hit_db ]
protected_numberofsimilarhits_dirty[ hit_db ]
publicproperty_objects_array[ obj ]
protected_question[ hit_db ]
protected_question_dirty[ hit_db ]
protected_requesterannotation[ hit_db ]
protected_requesterannotation_dirty[ hit_db ]
protected_title[ hit_db ]
protected_title_dirty[ hit_db ]
 
Methods
publiccommit ( )[ hit_db ]
Parameters
No parameters for this method
Code
192  public function commit()
193  {
194      if ($this->_id > 0)
195      {
196          $this->update();
197      }
198      else
199      {
200          $this->insert();
201      }
202 
203      foreach ($this->property_objects_array as $property=>$object)
204      {
205          $this->{$property} = $object;
206      }
207 
208      return true;
209  }
public__construct ( id , hitid )[ hit_db ]
Parameters
optionalid
optionalhitid
Code
074  public function __construct($__id=null, $__hitid=null)
075  {
076      $this->_id = 0;
077      $this->_hitid = $__hitid;
078      $this->_name = "";
079      $this->_description = "";
080      $this->_title = "";
081      $this->_keywords = "";
082      $this->_num_assignments = 0;
083      $this->_question = "";
084      $this->_hitstatus_id = 0;
085      $this->_hitreviewstatus_id = 0;
086      $this->_lifetimeinseconds = 0;
087      $this->_autoapprovaldelayinseconds = 0;
088      $this->_assignmentdurationinseconds = 0;
089      $this->_requesterannotation = "";
090      $this->_numberofsimilarhits = 0;
091      $this->_numberofassignmentspending = 0;
092      $this->_numberofassignmentsavailable = 0;
093      $this->_numberofassignmentscompleted = 0;
094      $this->_maxassignments = 0;
095      $this->_mdate = null;
096      $this->_cdate = null;
097      $this->_deleted = false;
098 
099      $this->_id_dirty = false;
100      $this->_hitid_dirty = false;
101      $this->_name_dirty = false;
102      $this->_description_dirty = false;
103      $this->_title_dirty = false;
104      $this->_keywords_dirty = false;
105      $this->_num_assignments_dirty = false;
106      $this->_question_dirty = false;
107      $this->_hitstatus_id_dirty = false;
108      $this->_hitreviewstatus_id_dirty = false;
109      $this->_lifetimeinseconds_dirty = false;
110      $this->_autoapprovaldelayinseconds_dirty = false;
111      $this->_assignmentdurationinseconds_dirty = false;
112      $this->_requesterannotation_dirty = false;
113      $this->_numberofsimilarhits_dirty = false;
114      $this->_numberofassignmentspending_dirty = false;
115      $this->_numberofassignmentsavailable_dirty = false;
116      $this->_numberofassignmentscompleted_dirty = false;
117      $this->_maxassignments_dirty = false;
118      $this->_mdate_dirty = false;
119      $this->_cdate_dirty = false;
120      $this->_deleted_dirty = false;
121 
122      if (is_null($__id) && is_null($__hitid))
123      {
124          return;
125      }
126 
127      $db = hit::db();
128      $q  = " SELECT aws_hit.id,aws_hit.hitid,aws_hit.name,aws_hit.description,aws_hit.title,aws_hit.keywords,aws_hit.num_assignments,aws_hit.question,aws_hit.hitstatus_id,aws_hit.hitreviewstatus_id,aws_hit.lifetimeinseconds,aws_hit.autoapprovaldelayinseconds,aws_hit.assignmentdurationinseconds,aws_hit.requesterannotation,aws_hit.numberofsimilarhits,aws_hit.numberofassignmentspending,aws_hit.numberofassignmentsavailable,aws_hit.numberofassignmentscompleted,aws_hit.maxassignments,aws_hit.mdate,aws_hit.cdate,aws_hit.deleted ";
129      $q .= " FROM aws_hit ";       
130      if (!is_null($__id))
131      {
132          $q .= " WHERE id = '$__id' ";
133      }
134      else if (!is_null($__hitid))
135      {
136          $q .= " WHERE hitid = '$__hitid' ";
137      }
138 
139      $db->query($q);
140      if ($db->next_record() && $db->num_rows() == 1)
141      {
142          $this->_id = $db->f("id");
143          $this->_hitid = $db->f("hitid");
144          $this->_name = $db->f("name");
145          $this->_description = $db->f("description");
146          $this->_title = $db->f("title");
147          $this->_keywords = $db->f("keywords");
148          $this->_num_assignments = $db->f("num_assignments");
149          $this->_question = $db->f("question");
150          $this->_hitstatus_id = $db->f("hitstatus_id");
151          $this->_hitreviewstatus_id = $db->f("hitreviewstatus_id");
152          $this->_lifetimeinseconds = $db->f("lifetimeinseconds");
153          $this->_autoapprovaldelayinseconds = $db->f("autoapprovaldelayinseconds");
154          $this->_assignmentdurationinseconds = $db->f("assignmentdurationinseconds");
155          $this->_requesterannotation = $db->f("requesterannotation");
156          $this->_numberofsimilarhits = $db->f("numberofsimilarhits");
157          $this->_numberofassignmentspending = $db->f("numberofassignmentspending");
158          $this->_numberofassignmentsavailable = $db->f("numberofassignmentsavailable");
159          $this->_numberofassignmentscompleted = $db->f("numberofassignmentscompleted");
160          $this->_maxassignments = $db->f("maxassignments");
161          $this->_mdate = $db->f("mdate");
162          $this->_cdate = $db->f("cdate");
163          $this->_deleted = $db->f("deleted");
164      }
165  }
protected staticdb ( )[ hit_db ]
Parameters
No parameters for this method
Code
982  protected static function db()
983  {
984      return new db();
985  }
publicdelete ( )[ hit_db ]
Parameters
No parameters for this method
Code
293  public function delete()
294  {
295      $db = hit::db();
296      $q  = " UPDATE aws_hit SET ";
297      $q .= " deleted = 1 ";
298      $q .= " WHERE id = " . $this->_id;
299      $db->query($q);
300      $this->deleted = true;
301      return true;
302  }
public staticdelete_all ( )[ hit_db ]
Parameters
No parameters for this method
Code
401  public static function delete_all()
402  {
403      $db = hit::db();
404      $q  = " UPDATE aws_hit SET ";
405      $q .= " deleted = 1 ";
406     
407      $db->query($q);
408      return true;
409  }
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] )[ hit_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
324  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
325  {
326      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
327      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
328      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
329 
330      $db = hit::db();
331      $data = array();
332      $q  = " SELECT $colstring ";
333      $q .= " FROM aws_hit ";
334      $q .= " WHERE aws_hit.deleted = 0 ";
335      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
336      $q .= array_key_exists("hitstatus_id",$lookups) ? " AND aws_hit.hitstatus_id='" . $lookups["hitstatus_id"] . "' " : "";
337      $q .= array_key_exists("hitreviewstatus_id",$lookups) ? " AND aws_hit.hitreviewstatus_id='" . $lookups["hitreviewstatus_id"] . "' " : "";
338 
339      if (is_string($__order))
340      {
341          $q .= "ORDER BY " . $__order;
342      }
343      else if (is_array($__order) and count($__order)>0)
344      {
345          $orderings = array();
346          foreach ($__order as $col=>$dir)
347          {
348              $orderings[] = " $col $dir ";
349          }
350          $q .= "ORDER BY " . implode(", ", $orderings);
351      }
352      else if (is_object($__order))
353      {
354          $q .= "";
355      }
356      else
357      {
358          // THERE IS NO `order` COLUMN ON THIS OBJECT
359      }
360 
361      if (!is_null($__limit))
362      {
363          $q .= " LIMIT $__offset , $__limit ";
364      }
365 
366      $db->query($q);
367 
368      if (count($colarray)>1 || $colstring=="*")
369      {
370          while ($db->next_record())
371          {
372              $data[] = $db->record;
373          }
374      }
375      else
376      {
377          while ($db->next_record())
378          {
379              $data[] = $db->f(0);
380          }
381      }
382 
383      return $data;
384  }
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_hitassignment ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
883  public function get_hitassignment($__type="default")
884  {
885      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitassignment")) ? new hitassignment($this->get_hitassignment_id($__type)) : $this->property_objects_array["{$__type}_hitassignment"];
886      $this->property_objects_array["{$__type}_hitassignment"] = $object;
887      return $object;
888  }
publicget_hitassignment_id ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
889  public function get_hitassignment_id($__type="default")
890  {
891      $ids = $this->get_hitassignment_ids($__type, true);
892      return (count($ids)==1 ? $ids[0] : null);
893  }
publicget_hitassignment_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
894  public function get_hitassignment_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
895  {
896      $hitassignment_ids = array();
897      $db = hit::db();
898      $q  = " SELECT aws_hitassignment.id FROM aws_hit_hitassignment INNER JOIN aws_hitassignment ON aws_hit_hitassignment.hitassignment_id=aws_hitassignment.id AND aws_hit_hitassignment.deleted=0 AND aws_hitassignment.deleted=0 AND aws_hit_hitassignment.hit_id='$this->id' " . (is_null($__type) ? "" : " AND aws_hit_hitassignment.hit_hitassignment_type_id='" . hit_hitassignment::type_id($__type) . "'") . ($__get_primary ? " AND aws_hit_hitassignment.primary=1 " : "");
899      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
900      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
901      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
902      $db->query($q);
903      while ($db->next_record())
904      {
905          $hitassignment_ids[] = $db->f("id");
906      }
907      return $hitassignment_ids;
908  }
publicget_hitassignment_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
909  public function get_hitassignment_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
910  {
911      $ids = $this->get_hitassignment_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
912      $objects = array();
913      foreach ($ids as $index=>$id)
914      {
915          $objects[$index] = new hitassignment($id);
916      }
917      return $objects;
918  }
publicget_hitdate ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
686  public function get_hitdate($__type="default")
687  {
688      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitdate")) ? new hitdate($this->get_hitdate_id($__type)) : $this->property_objects_array["{$__type}_hitdate"];
689      $this->property_objects_array["{$__type}_hitdate"] = $object;
690      return $object;
691  }
publicget_hitdate_id ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
692  public function get_hitdate_id($__type="default")
693  {
694      $ids = $this->get_hitdate_ids($__type, true);
695      return (count($ids)==1 ? $ids[0] : null);
696  }
publicget_hitdate_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
697  public function get_hitdate_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
698  {
699      $hitdate_ids = array();
700      $db = hit::db();
701      $q  = " SELECT aws_hitdate.id FROM aws_hit_hitdate INNER JOIN aws_hitdate ON aws_hit_hitdate.hitdate_id=aws_hitdate.id AND aws_hit_hitdate.deleted=0 AND aws_hitdate.deleted=0 AND aws_hit_hitdate.hit_id='$this->id' " . (is_null($__type) ? "" : " AND aws_hit_hitdate.hit_hitdate_type_id='" . hit_hitdate::type_id($__type) . "'") . ($__get_primary ? " AND aws_hit_hitdate.primary=1 " : "");
702      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
703      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
704      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
705      $db->query($q);
706      while ($db->next_record())
707      {
708          $hitdate_ids[] = $db->f("id");
709      }
710      return $hitdate_ids;
711  }
publicget_hitdate_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
712  public function get_hitdate_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
713  {
714      $ids = $this->get_hitdate_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
715      $objects = array();
716      foreach ($ids as $index=>$id)
717      {
718          $objects[$index] = new hitdate($id);
719      }
720      return $objects;
721  }
publicget_hitqualification ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
587  public function get_hitqualification($__type="default")
588  {
589      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitqualification")) ? new hitqualification($this->get_hitqualification_id($__type)) : $this->property_objects_array["{$__type}_hitqualification"];
590      $this->property_objects_array["{$__type}_hitqualification"] = $object;
591      return $object;
592  }
publicget_hitqualification_id ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
593  public function get_hitqualification_id($__type="default")
594  {
595      $ids = $this->get_hitqualification_ids($__type, true);
596      return (count($ids)==1 ? $ids[0] : null);
597  }
publicget_hitqualification_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
598  public function get_hitqualification_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
599  {
600      $hitqualification_ids = array();
601      $db = hit::db();
602      $q  = " SELECT aws_hitqualification.id FROM aws_hit_hitqualification INNER JOIN aws_hitqualification ON aws_hit_hitqualification.hitqualification_id=aws_hitqualification.id AND aws_hit_hitqualification.deleted=0 AND aws_hitqualification.deleted=0 AND aws_hit_hitqualification.hit_id='$this->id' " . (is_null($__type) ? "" : " AND aws_hit_hitqualification.hit_hitqualification_type_id='" . hit_hitqualification::type_id($__type) . "'") . ($__get_primary ? " AND aws_hit_hitqualification.primary=1 " : "");
603      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
604      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
605      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
606      $db->query($q);
607      while ($db->next_record())
608      {
609          $hitqualification_ids[] = $db->f("id");
610      }
611      return $hitqualification_ids;
612  }
publicget_hitqualification_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
613  public function get_hitqualification_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
614  {
615      $ids = $this->get_hitqualification_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
616      $objects = array();
617      foreach ($ids as $index=>$id)
618      {
619          $objects[$index] = new hitqualification($id);
620      }
621      return $objects;
622  }
publicget_hitreviewstatus ( )[ hit_db ]
Parameters
No parameters for this method
Code
476  public function get_hitreviewstatus()
477  {
478      return new hitreviewstatus($this->hitreviewstatus_id);
479  }
publicget_hitreward ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
488  public function get_hitreward($__type="default")
489  {
490      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitreward")) ? new hitreward($this->get_hitreward_id($__type)) : $this->property_objects_array["{$__type}_hitreward"];
491      $this->property_objects_array["{$__type}_hitreward"] = $object;
492      return $object;
493  }
publicget_hitreward_id ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
494  public function get_hitreward_id($__type="default")
495  {
496      $ids = $this->get_hitreward_ids($__type, true);
497      return (count($ids)==1 ? $ids[0] : null);
498  }
publicget_hitreward_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
499  public function get_hitreward_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
500  {
501      $hitreward_ids = array();
502      $db = hit::db();
503      $q  = " SELECT aws_hitreward.id FROM aws_hit_hitreward INNER JOIN aws_hitreward ON aws_hit_hitreward.hitreward_id=aws_hitreward.id AND aws_hit_hitreward.deleted=0 AND aws_hitreward.deleted=0 AND aws_hit_hitreward.hit_id='$this->id' " . (is_null($__type) ? "" : " AND aws_hit_hitreward.hit_hitreward_type_id='" . hit_hitreward::type_id($__type) . "'") . ($__get_primary ? " AND aws_hit_hitreward.primary=1 " : "");
504      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
505      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
506      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
507      $db->query($q);
508      while ($db->next_record())
509      {
510          $hitreward_ids[] = $db->f("id");
511      }
512      return $hitreward_ids;
513  }
publicget_hitreward_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
514  public function get_hitreward_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
515  {
516      $ids = $this->get_hitreward_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
517      $objects = array();
518      foreach ($ids as $index=>$id)
519      {
520          $objects[$index] = new hitreward($id);
521      }
522      return $objects;
523  }
publicget_hitstatus ( )[ hit_db ]
Parameters
No parameters for this method
Code
464  public function get_hitstatus()
465  {
466      return new hitstatus($this->hitstatus_id);
467  }
publicget_hittemplate ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
784  public function get_hittemplate($__type="default")
785  {
786      $object = is_null(keyval($this->property_objects_array,"{$__type}_hittemplate")) ? new hittemplate($this->get_hittemplate_id($__type)) : $this->property_objects_array["{$__type}_hittemplate"];
787      $this->property_objects_array["{$__type}_hittemplate"] = $object;
788      return $object;
789  }
publicget_hittemplate_id ( type ["default"] )[ hit_db ]
Parameters
optionaltype ["default"]
Code
790  public function get_hittemplate_id($__type="default")
791  {
792      $ids = $this->get_hittemplate_ids($__type, true);
793      return (count($ids)==1 ? $ids[0] : null);
794  }
publicget_hittemplate_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
795  public function get_hittemplate_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
796  {
797      $hittemplate_ids = array();
798      $db = hit::db();
799      $q  = " SELECT aws_hittemplate.id FROM aws_hit_hittemplate INNER JOIN aws_hittemplate ON aws_hit_hittemplate.hittemplate_id=aws_hittemplate.id AND aws_hit_hittemplate.deleted=0 AND aws_hittemplate.deleted=0 AND aws_hit_hittemplate.hit_id='$this->id' " . (is_null($__type) ? "" : " AND aws_hit_hittemplate.hit_hittemplate_type_id='" . hit_hittemplate::type_id($__type) . "'") . ($__get_primary ? " AND aws_hit_hittemplate.primary=1 " : "");
800      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
801      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
802      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
803      $db->query($q);
804      while ($db->next_record())
805      {
806          $hittemplate_ids[] = $db->f("id");
807      }
808      return $hittemplate_ids;
809  }
publicget_hittemplate_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ hit_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
810  public function get_hittemplate_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
811  {
812      $ids = $this->get_hittemplate_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
813      $objects = array();
814      foreach ($ids as $index=>$id)
815      {
816          $objects[$index] = new hittemplate($id);
817      }
818      return $objects;
819  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ hit_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
386  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
387  {
388      return hit::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
389  }
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] )[ hit_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
391  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
392  {
393      $objects = array();
394      foreach (hit::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
395      {
396          $objects[] = new hit($id);
397      }
398      return $objects;
399  }
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  }
public staticimport_hits ( )[ hit_ext ]
Parameters
No parameters for this method
Code
026  public static function import_hits()
027  {
028      //returns number of hits imported
029      $mturk = new mturk(AWS_ACCESSKEYID,AWS_SECRETKEY);
030     
031      $arr = xml::xml2array($mturk->SearchHITs(1));
032      $total_hits = $arr["SearchHITsResponse"]["SearchHITsResult"]["TotalNumResults"];
033      $hit_number=0;
034     
035      //can get max of 100 records
036      for($pageNumber=1;$pageNumber<=($total_hits/100)+1;$pageNumber++)
037      {
038          debug("pageNumber = " . $pageNumber);
039          $arr = xml::xml2array($mturk->SearchHITs(100,$pageNumber));
040          foreach($arr["SearchHITsResponse"]["SearchHITsResult"]["HIT"] as $h)
041          {
042              $hit_number++;
043              debug("importing hit number: {$hit_number} of {$total_hits}");
044              $HITId = $h["HITId"];
045              $hit = new hit(null,$HITId);
046              $hit->sync_aws();
047          }
048         
049      }
050      return $hit_number;
051  }
protectedinsert ( )[ hit_db ]
Parameters
No parameters for this method
Code
211  protected function insert()
212  {
213      $db = hit::db();
214      $q  = " INSERT INTO aws_hit ( ";
215      $q .= $db->param_string("hitid") . ", ";
216      $q .= $db->param_string("name") . ", ";
217      $q .= $db->param_string("description") . ", ";
218      $q .= $db->param_string("title") . ", ";
219      $q .= $db->param_string("keywords") . ", ";
220      $q .= $db->param_string("num_assignments") . ", ";
221      $q .= $db->param_string("question") . ", ";
222      $q .= $db->param_string("hitstatus_id") . ", ";
223      $q .= $db->param_string("hitreviewstatus_id") . ", ";
224      $q .= $db->param_string("lifetimeinseconds") . ", ";
225      $q .= $db->param_string("autoapprovaldelayinseconds") . ", ";
226      $q .= $db->param_string("assignmentdurationinseconds") . ", ";
227      $q .= $db->param_string("requesterannotation") . ", ";
228      $q .= $db->param_string("numberofsimilarhits") . ", ";
229      $q .= $db->param_string("numberofassignmentspending") . ", ";
230      $q .= $db->param_string("numberofassignmentsavailable") . ", ";
231      $q .= $db->param_string("numberofassignmentscompleted") . ", ";
232      $q .= $db->param_string("maxassignments") . ", ";
233      $q .= $db->param_string("mdate") . ", ";
234      $q .= $db->param_string("cdate") . ", ";
235      $q .= $db->param_string("deleted");
236      $q .= " ) VALUES ( ";
237      $q .= $db->value_string($this->_hitid) . ", ";
238      $q .= $db->value_string($this->_name) . ", ";
239      $q .= $db->value_string($this->_description) . ", ";
240      $q .= $db->value_string($this->_title) . ", ";
241      $q .= $db->value_string($this->_keywords) . ", ";
242      $q .= $db->value_string($this->_num_assignments) . ", ";
243      $q .= $db->value_string($this->_question) . ", ";
244      $q .= $db->value_string($this->_hitstatus_id) . ", ";
245      $q .= $db->value_string($this->_hitreviewstatus_id) . ", ";
246      $q .= $db->value_string($this->_lifetimeinseconds) . ", ";
247      $q .= $db->value_string($this->_autoapprovaldelayinseconds) . ", ";
248      $q .= $db->value_string($this->_assignmentdurationinseconds) . ", ";
249      $q .= $db->value_string($this->_requesterannotation) . ", ";
250      $q .= $db->value_string($this->_numberofsimilarhits) . ", ";
251      $q .= $db->value_string($this->_numberofassignmentspending) . ", ";
252      $q .= $db->value_string($this->_numberofassignmentsavailable) . ", ";
253      $q .= $db->value_string($this->_numberofassignmentscompleted) . ", ";
254      $q .= $db->value_string($this->_maxassignments) . ", ";
255      $q .= $db->value_string(timestamp()) . ", ";
256      $q .= $db->value_string(timestamp()) . ", ";
257      $q .= $this->deleted ? "'1'" : "'0'";
258      $q .= " ) ";
259      $db->query($q);
260      $this->_id = $db->insert_id;
261      return true;
262  }
publicmap ( )[ hit_db ]
Parameters
No parameters for this method
Code
167  public function map()
168  {
169      $this->_hitid = array_key_exists("hit:hitid",$_REQUEST) ? reqval("hit:hitid") : $this->_hitid;
170      $this->_name = array_key_exists("hit:name",$_REQUEST) ? reqval("hit:name") : $this->_name;
171      $this->_description = array_key_exists("hit:description",$_REQUEST) ? reqval("hit:description") : $this->_description;
172      $this->_title = array_key_exists("hit:title",$_REQUEST) ? reqval("hit:title") : $this->_title;
173      $this->_keywords = array_key_exists("hit:keywords",$_REQUEST) ? reqval("hit:keywords") : $this->_keywords;
174      $this->_num_assignments = array_key_exists("hit:num_assignments",$_REQUEST) ? reqval("hit:num_assignments") : $this->_num_assignments;
175      $this->_question = array_key_exists("hit:question",$_REQUEST) ? reqval("hit:question") : $this->_question;
176      $this->_hitstatus_id = array_key_exists("hit:hitstatus_id",$_REQUEST) ? reqval("hit:hitstatus_id") : $this->_hitstatus_id;
177      $this->_hitreviewstatus_id = array_key_exists("hit:hitreviewstatus_id",$_REQUEST) ? reqval("hit:hitreviewstatus_id") : $this->_hitreviewstatus_id;
178      $this->_lifetimeinseconds = array_key_exists("hit:lifetimeinseconds",$_REQUEST) ? reqval("hit:lifetimeinseconds") : $this->_lifetimeinseconds;
179      $this->_autoapprovaldelayinseconds = array_key_exists("hit:autoapprovaldelayinseconds",$_REQUEST) ? reqval("hit:autoapprovaldelayinseconds") : $this->_autoapprovaldelayinseconds;
180      $this->_assignmentdurationinseconds = array_key_exists("hit:assignmentdurationinseconds",$_REQUEST) ? reqval("hit:assignmentdurationinseconds") : $this->_assignmentdurationinseconds;
181      $this->_requesterannotation = array_key_exists("hit:requesterannotation",$_REQUEST) ? reqval("hit:requesterannotation") : $this->_requesterannotation;
182      $this->_numberofsimilarhits = array_key_exists("hit:numberofsimilarhits",$_REQUEST) ? reqval("hit:numberofsimilarhits") : $this->_numberofsimilarhits;
183      $this->_numberofassignmentspending = array_key_exists("hit:numberofassignmentspending",$_REQUEST) ? reqval("hit:numberofassignmentspending") : $this->_numberofassignmentspending;
184      $this->_numberofassignmentsavailable = array_key_exists("hit:numberofassignmentsavailable",$_REQUEST) ? reqval("hit:numberofassignmentsavailable") : $this->_numberofassignmentsavailable;
185      $this->_numberofassignmentscompleted = array_key_exists("hit:numberofassignmentscompleted",$_REQUEST) ? reqval("hit:numberofassignmentscompleted") : $this->_numberofassignmentscompleted;
186      $this->_maxassignments = array_key_exists("hit:maxassignments",$_REQUEST) ? reqval("hit:maxassignments") : $this->_maxassignments;
187      $this->_mdate = array_key_exists("hit:mdate",$_REQUEST) ? reqval("hit:mdate") : $this->_mdate;
188      $this->_cdate = array_key_exists("hit:cdate",$_REQUEST) ? reqval("hit:cdate") : $this->_cdate;
189      $this->_deleted = array_key_exists("hit:deleted",$_REQUEST) ? reqval("hit:deleted") : $this->_deleted;
190  }
publicpurge ( )[ hit_db ]
Parameters
No parameters for this method
Code
315  public function purge()
316  {
317      $db = hit::db();
318      $q  = " DELETE FROM aws_hit ";
319      $q .= " WHERE id = " . $this->_id;
320      $db->query($q);
321      return true;
322  }
public staticsearch ( keyword )[ hit_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_hitassignment ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
920  public function set_hitassignment($__v, $__type="default")
921  {
922      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitassignment")) ? new hitassignment($this->get_hitassignment_id($__type)) : $this->property_objects_array["{$__type}_hitassignment"];
923      if (is_null($__v))
924      {
925          $rel = new hit_hitassignment(null,$this->id,$object->id,hit_hitassignment::type_id($__type));
926          $rel->delete();
927          if (!is_null(keyval($this->property_objects_array,"{$__type}_hitassignment")))
928          {
929              $this->property_objects_array["{$__type}_hitassignment"] = null;
930          }
931      }
932      else
933      {
934          $id = $object->id;
935          $object = $__v;
936          $object->id = $__v->id>0 ? $__v->id : $id;
937          $object->commit();
938          $this->set_hitassignment_ids(array($object->id),$__type);
939      }
940  }
publicset_hitassignment_id ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
941  public function set_hitassignment_id($__v, $__type="default")
942  {
943      $this->set_hitassignment_ids(array($__v),$__type);
944  }
publicset_hitassignment_ids ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
945  public function set_hitassignment_ids($__v, $__type="default")
946  {
947      if ($this->id == 0)
948      {
949          $this->commit();
950      }
951      $type_id = hit_hitassignment::type_id($__type);
952      hit_hitassignment::delete_all($this->id,null,$type_id);
953      if (is_array($__v))
954      {
955          foreach ($__v as $index=>$id)
956          {
957              $object = new hit_hitassignment(null,$this->id,$id,$type_id);
958              $object->deleted = false;
959              $object->hit_hitassignment_type_id = $type_id;
960              $object->commit();
961              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_hitassignment")))
962              {
963                  $this->property_objects_array["{$__type}_hitassignment"] = new hitassignment($object->hitassignment_id);
964              }
965          }
966          $this->_dirty = true;
967      }
968  }
publicset_hitassignment_list ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
969  public function set_hitassignment_list($__v, $__type="default")
970  {
971      if (is_array($__v))
972      {
973          $ids = array();
974          foreach ($__v as $index=>$object)
975          {
976              $ids[] = $object->id;
977          }
978          $this->set_hitassignment_ids($ids,$__type);
979      }
980  }
publicset_hitdate ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
723  public function set_hitdate($__v, $__type="default")
724  {
725      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitdate")) ? new hitdate($this->get_hitdate_id($__type)) : $this->property_objects_array["{$__type}_hitdate"];
726      if (is_null($__v))
727      {
728          $rel = new hit_hitdate(null,$this->id,$object->id,hit_hitdate::type_id($__type));
729          $rel->delete();
730          $object->delete();
731          if (!is_null(keyval($this->property_objects_array,"{$__type}_hitdate")))
732          {
733              $this->property_objects_array["{$__type}_hitdate"] = null;
734          }
735      }
736      else
737      {
738          $object->value = is_object($__v) ? $__v->value : $__v;
739          $object->commit();
740          $this->set_hitdate_ids(array($object->id),$__type);
741      }
742  }
publicset_hitdate_id ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
743  public function set_hitdate_id($__v, $__type="default")
744  {
745      $this->set_hitdate_ids(array($__v),$__type);
746  }
publicset_hitdate_ids ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
747  public function set_hitdate_ids($__v, $__type="default")
748  {
749      if ($this->id == 0)
750      {
751          $this->commit();
752      }
753      $type_id = hit_hitdate::type_id($__type);
754      hit_hitdate::delete_all($this->id,null,$type_id);
755      if (is_array($__v))
756      {
757          foreach ($__v as $index=>$id)
758          {
759              $object = new hit_hitdate(null,$this->id,$id,$type_id);
760              $object->deleted = false;
761              $object->hit_hitdate_type_id = $type_id;
762              $object->commit();
763              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_hitdate")))
764              {
765                  $this->property_objects_array["{$__type}_hitdate"] = new hitdate($object->hitdate_id);
766              }
767          }
768          $this->_dirty = true;
769      }
770  }
publicset_hitdate_list ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
771  public function set_hitdate_list($__v, $__type="default")
772  {
773      if (is_array($__v))
774      {
775          $ids = array();
776          foreach ($__v as $index=>$object)
777          {
778              $ids[] = $object->id;
779          }
780          $this->set_hitdate_ids($ids,$__type);
781      }
782  }
publicset_hitqualification ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
624  public function set_hitqualification($__v, $__type="default")
625  {
626      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitqualification")) ? new hitqualification($this->get_hitqualification_id($__type)) : $this->property_objects_array["{$__type}_hitqualification"];
627      if (is_null($__v))
628      {
629          $rel = new hit_hitqualification(null,$this->id,$object->id,hit_hitqualification::type_id($__type));
630          $rel->delete();
631          if (!is_null(keyval($this->property_objects_array,"{$__type}_hitqualification")))
632          {
633              $this->property_objects_array["{$__type}_hitqualification"] = null;
634          }
635      }
636      else
637      {
638          $id = $object->id;
639          $object = $__v;
640          $object->id = $__v->id>0 ? $__v->id : $id;
641          $object->commit();
642          $this->set_hitqualification_ids(array($object->id),$__type);
643      }
644  }
publicset_hitqualification_id ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
645  public function set_hitqualification_id($__v, $__type="default")
646  {
647      $this->set_hitqualification_ids(array($__v),$__type);
648  }
publicset_hitqualification_ids ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
649  public function set_hitqualification_ids($__v, $__type="default")
650  {
651      if ($this->id == 0)
652      {
653          $this->commit();
654      }
655      $type_id = hit_hitqualification::type_id($__type);
656      hit_hitqualification::delete_all($this->id,null,$type_id);
657      if (is_array($__v))
658      {
659          foreach ($__v as $index=>$id)
660          {
661              $object = new hit_hitqualification(null,$this->id,$id,$type_id);
662              $object->deleted = false;
663              $object->hit_hitqualification_type_id = $type_id;
664              $object->commit();
665              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_hitqualification")))
666              {
667                  $this->property_objects_array["{$__type}_hitqualification"] = new hitqualification($object->hitqualification_id);
668              }
669          }
670          $this->_dirty = true;
671      }
672  }
publicset_hitqualification_list ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
673  public function set_hitqualification_list($__v, $__type="default")
674  {
675      if (is_array($__v))
676      {
677          $ids = array();
678          foreach ($__v as $index=>$object)
679          {
680              $ids[] = $object->id;
681          }
682          $this->set_hitqualification_ids($ids,$__type);
683      }
684  }
publicset_hitreviewstatus ( v )[ hit_db ]
Parameters
requiredv
Code
480  public function set_hitreviewstatus($v)
481  {
482      if ($v->id > 0)
483      {
484          $this->hitreviewstatus_id = $v->id;
485      }
486  }
publicset_hitreward ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
525  public function set_hitreward($__v, $__type="default")
526  {
527      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitreward")) ? new hitreward($this->get_hitreward_id($__type)) : $this->property_objects_array["{$__type}_hitreward"];
528      if (is_null($__v))
529      {
530          $rel = new hit_hitreward(null,$this->id,$object->id,hit_hitreward::type_id($__type));
531          $rel->delete();
532          if (!is_null(keyval($this->property_objects_array,"{$__type}_hitreward")))
533          {
534              $this->property_objects_array["{$__type}_hitreward"] = null;
535          }
536      }
537      else
538      {
539          $id = $object->id;
540          $object = $__v;
541          $object->id = $__v->id>0 ? $__v->id : $id;
542          $object->commit();
543          $this->set_hitreward_ids(array($object->id),$__type);
544      }
545  }
publicset_hitreward_id ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
546  public function set_hitreward_id($__v, $__type="default")
547  {
548      $this->set_hitreward_ids(array($__v),$__type);
549  }
publicset_hitreward_ids ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
550  public function set_hitreward_ids($__v, $__type="default")
551  {
552      if ($this->id == 0)
553      {
554          $this->commit();
555      }
556      $type_id = hit_hitreward::type_id($__type);
557      hit_hitreward::delete_all($this->id,null,$type_id);
558      if (is_array($__v))
559      {
560          foreach ($__v as $index=>$id)
561          {
562              $object = new hit_hitreward(null,$this->id,$id,$type_id);
563              $object->deleted = false;
564              $object->hit_hitreward_type_id = $type_id;
565              $object->commit();
566              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_hitreward")))
567              {
568                  $this->property_objects_array["{$__type}_hitreward"] = new hitreward($object->hitreward_id);
569              }
570          }
571          $this->_dirty = true;
572      }
573  }
publicset_hitreward_list ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
574  public function set_hitreward_list($__v, $__type="default")
575  {
576      if (is_array($__v))
577      {
578          $ids = array();
579          foreach ($__v as $index=>$object)
580          {
581              $ids[] = $object->id;
582          }
583          $this->set_hitreward_ids($ids,$__type);
584      }
585  }
publicset_hitstatus ( v )[ hit_db ]
Parameters
requiredv
Code
468  public function set_hitstatus($v)
469  {
470      if ($v->id > 0)
471      {
472          $this->hitstatus_id = $v->id;
473      }
474  }
publicset_hittemplate ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
821  public function set_hittemplate($__v, $__type="default")
822  {
823      $object = is_null(keyval($this->property_objects_array,"{$__type}_hittemplate")) ? new hittemplate($this->get_hittemplate_id($__type)) : $this->property_objects_array["{$__type}_hittemplate"];
824      if (is_null($__v))
825      {
826          $rel = new hit_hittemplate(null,$this->id,$object->id,hit_hittemplate::type_id($__type));
827          $rel->delete();
828          if (!is_null(keyval($this->property_objects_array,"{$__type}_hittemplate")))
829          {
830              $this->property_objects_array["{$__type}_hittemplate"] = null;
831          }
832      }
833      else
834      {
835          $id = $object->id;
836          $object = $__v;
837          $object->id = $__v->id>0 ? $__v->id : $id;
838          $object->commit();
839          $this->set_hittemplate_ids(array($object->id),$__type);
840      }
841  }
publicset_hittemplate_id ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
842  public function set_hittemplate_id($__v, $__type="default")
843  {
844      $this->set_hittemplate_ids(array($__v),$__type);
845  }
publicset_hittemplate_ids ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
846  public function set_hittemplate_ids($__v, $__type="default")
847  {
848      if ($this->id == 0)
849      {
850          $this->commit();
851      }
852      $type_id = hit_hittemplate::type_id($__type);
853      hit_hittemplate::delete_all($this->id,null,$type_id);
854      if (is_array($__v))
855      {
856          foreach ($__v as $index=>$id)
857          {
858              $object = new hit_hittemplate(null,$this->id,$id,$type_id);
859              $object->deleted = false;
860              $object->hit_hittemplate_type_id = $type_id;
861              $object->commit();
862              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_hittemplate")))
863              {
864                  $this->property_objects_array["{$__type}_hittemplate"] = new hittemplate($object->hittemplate_id);
865              }
866          }
867          $this->_dirty = true;
868      }
869  }
publicset_hittemplate_list ( v , type ["default"] )[ hit_db ]
Parameters
requiredv
optionaltype ["default"]
Code
870  public function set_hittemplate_list($__v, $__type="default")
871  {
872      if (is_array($__v))
873      {
874          $ids = array();
875          foreach ($__v as $index=>$object)
876          {
877              $ids[] = $object->id;
878          }
879          $this->set_hittemplate_ids($ids,$__type);
880      }
881  }
publicsync_aws ( )[ hit_ext ]
Parameters
No parameters for this method
Code
053  public function sync_aws()
054  {
055      if($this->hitid!="")
056      {
057          debug("synchronizing hitid ".$this->hitid);
058          //returns number of hits imported
059          $mturk = new mturk(AWS_ACCESSKEYID,AWS_SECRETKEY);
060         
061          $hit_array = xml::xml2array($mturk->GetHIT($this->hitid));
062          $h=$hit_array["GetHITResponse"]["HIT"];
063          $hit_info = xml::xml2array($mturk->GetHIT($this->hitid));
064          $hittemplate = new hittemplate(null,$hit_info["GetHITResponse"]["HIT"]["HITTypeId"]);
065          if($hit_info["GetHITResponse"]["HIT"]["HITTypeId"]!="" && $hittemplate->id==0)
066          {
067              $hittemplate->commit();
068          }
069          if($hittemplate->id>0 && $hittemplate->hitreward->id==0)
070          {
071              //link reward to hittemplate if both exist
072              $r = new hitreward();
073              $cc = new currencycode(null,null,$hit_info["GetHITResponse"]["HIT"]["Reward"]["CurrencyCode"]);
074             
075              $r->amount = $hit_info["GetHITResponse"]["HIT"]["Reward"]["Amount"];
076              $r->formattedprice = $hit_info["GetHITResponse"]["HIT"]["Reward"]["FormattedPrice"];
077              $r->currencycode_id = $cc->id;
078              $r->commit();
079              $hittemplate->hitreward = $r;
080              $hittemplate->commit();
081          }
082         
083          $this->creation_hitdate->value = $hit_info["GetHITResponse"]["HIT"]["CreationTime"];
084          $this->title = $hit_info["GetHITResponse"]["HIT"]["Title"];
085          $this->keywords = $hit_info["GetHITResponse"]["HIT"]["Keywords"];
086          $this->description = $hit_info["GetHITResponse"]["HIT"]["Description"];
087          $this->question = $hit_info["GetHITResponse"]["HIT"]["Question"];
088          $hitstatus = new hitstatus(null,$hit_info["GetHITResponse"]["HIT"]["HITStatus"]);
089          $this->hitstatus_id = $hitstatus->id;
090          $hitreviewstatus = new hitreviewstatus(null,$hit_info["GetHITResponse"]["HIT"]["HITReviewStatus"]);
091          $this->hitreviewstatus_id = $hitreviewstatus->id;
092          $this->maxassignments = $hit_info["GetHITResponse"]["HIT"]["MaxAssignments"];
093         
094          $this->assignmentdurationinseconds = $hit_info["GetHITResponse"]["HIT"]["AssignmentDurationInSeconds"];
095          $this->numberofsimilarhits = $hit_info["GetHITResponse"]["HIT"]["NumberOfSimilarHITs"];
096          $this->autoapprovaldelayinseconds = $hit_info["GetHITResponse"]["HIT"]["AutoApprovalDelayInSeconds"];
097          $this->expiration_hitdate->value = $hit_info["GetHITResponse"]["HIT"]["Expiration"];
098          if(array_key_exists("RequesterAnnotation",$hit_info["GetHITResponse"]["HIT"]))
099          {
100              $this->requesterannotation = $hit_info["GetHITResponse"]["HIT"]["RequesterAnnotation"];
101          }
102         
103          if($hittemplate->id!=0)
104          {
105              //this hit has a parent hittemplate, make sure they are linked
106              $this->hittemplate = $hittemplate;
107              if($hittemplate->hitreward->id>0)
108              {
109                  $this->hitreward = $hittemplate->hitreward; //match rewards
110              }
111          }
112         
113          if($this->hitreward->id==0)
114          {
115              //make standalone reward object
116              $r = new hitreward();
117              $cc = new currencycode(null,null,$hit_info["GetHITResponse"]["HIT"]["Reward"]["CurrencyCode"]);
118             
119              $r->amount = $hit_info["GetHITResponse"]["HIT"]["Reward"]["Amount"];
120              $r->formattedprice = $hit_info["GetHITResponse"]["HIT"]["Reward"]["FormattedPrice"];
121              $r->currencycode_id = $cc->id;
122              $r->commit();
123              $this->hitreward = $r;
124          }   
125         
126          $this->commit();
127          //import hit assignments
128          $assignment_array = xml::xml2array($mturk->GetAssignmentsForHIT($this->hitid));
129          if($assignment_array["GetAssignmentsForHITResponse"]["GetAssignmentsForHITResult"]["TotalNumResults"]==1)
130          {
131              $assignment = $assignment_array["GetAssignmentsForHITResponse"]["GetAssignmentsForHITResult"]["Assignment"];
132              $a = new hitassignment(null,$assignment["AssignmentId"]);
133              $hitassignmentstatus = new hitassignmentstatus(null,$assignment["AssignmentStatus"]);
134              $a->hitassignmentstatus_id = $hitassignmentstatus->id;
135              $a->answer = $assignment["Answer"];
136              if(array_key_exists("AutoApprovalTime",$assignment))
137              {
138                  $a->autoapprovaltime_hitassignmentdate->value = $assignment["AutoApprovalTime"];
139              }
140              if(array_key_exists("AcceptTime",$assignment))
141              {
142                  $a->accept_hitassignmentdate->value = $assignment["AcceptTime"];
143              }
144              if(array_key_exists("SubmitTime",$assignment))
145              {
146                  $a->submit_hitassignmentdate->value = $assignment["SubmitTime"];
147              }
148              if(array_key_exists("ApprovalTime",$assignment))
149              {
150                  $a->autoapproval_hitassignmentdate->value = $assignment["ApprovalTime"]; 
151              }
152              if(array_key_exists("RejectionTime",$assignment))
153              {
154                  $a->rejection_hitassignmentdate->value = $assignment["RejectionTime"];
155              }
156              if(array_key_exists("Deadline",$assignment))
157              {
158                  $a->deadline_hitassignmentdate->value $assignment["Deadline"];
159              }
160              if(array_key_exists("WorkerId",$assignment))
161              {
162                  $turk = new turk(null,$assignment["WorkerId"]);
163                  if($turk->id==0)
164                  {
165                      $turk->commit();
166                      $a->turk_id $turk->id;
167                  }
168              }
169             
170              $a->commit();
171              $this->hitassignment_id = $a->id;
172          }
173          else {
174              hit_hitassignment::delete_all($this->id); //wipe before importing
175              //import all of the assignments
176              $num_assignments = $assignment_array["GetAssignmentsForHITResponse"]["GetAssignmentsForHITResult"]["TotalNumResults"]; //this will break if too result # too high
177 
178              for($i=0;$i<$num_assignments;$i++)
179              {
180                  $assignment = $assignment_array["GetAssignmentsForHITResponse"]["GetAssignmentsForHITResult"]["Assignment"]["$i"];
181                  $a = new hitassignment(null,$assignment["AssignmentId"]);
182                  $hitassignmentstatus = new hitassignmentstatus(null,$assignment["AssignmentStatus"]);
183                  $a->hitassignmentstatus_id = $hitassignmentstatus->id;
184                  $a->answer = $assignment["Answer"];
185                  if(array_key_exists("AutoApprovalTime",$assignment))
186                  {
187                      $a->autoapprovaltime_hitassignmentdate->value = $assignment["AutoApprovalTime"];
188                  }
189                  if(array_key_exists("AcceptTime",$assignment))
190                  {
191                      $a->accept_hitassignmentdate->value = $assignment["AcceptTime"];
192                  }
193                  if(array_key_exists("SubmitTime",$assignment))
194                  {
195                      $a->submit_hitassignmentdate->value = $assignment["SubmitTime"];
196                  }
197                  if(array_key_exists("ApprovalTime",$assignment))
198                  {
199                      $a->autoapproval_hitassignmentdate->value = $assignment["ApprovalTime"]; 
200                  }
201                  if(array_key_exists("RejectionTime",$assignment))
202                  {
203                      $a->rejection_hitassignmentdate->value = $assignment["RejectionTime"];
204                  }
205                  if(array_key_exists("Deadline",$assignment))
206                  {
207                      $a->deadline_hitassignmentdate->value $assignment["Deadline"];
208                  }
209                  if(array_key_exists("WorkerId",$assignment))
210                  {
211                      $turk = new turk(null,$assignment["WorkerId"]);
212                      if($turk->id==0)
213                      {
214                          $turk->commit();
215                          $a->turk_id $turk->id;
216                      }
217                  }
218                 
219                  $a->commit();
220                 
221                  $ha = new hit_hitassignment(null,$this->id,$a->id);
222                  $ha->deleted=0;
223                  $ha->commit();
224              }
225          }
226 
227          return true;
228      }
229      else {
230          return false;
231      }
232  }
public__toString ( )[ hit_db ]
Parameters
No parameters for this method
Code
459  public function __toString()
460  {
461      return (is_null($this->name) ? "" : $this->name);
462  }
publicundelete ( )[ hit_db ]
Parameters
No parameters for this method
Code
304  public function undelete()
305  {
306      $db = hit::db();
307      $q  = " UPDATE aws_hit SET ";
308      $q .= " deleted = 0 ";
309      $q .= " WHERE id = " . $this->_id;
310      $db->query($q);
311      $this->deleted = false;
312      return true;
313  }
protectedupdate ( )[ hit_db ]
Parameters
No parameters for this method
Code
264  protected function update()
265  {
266      $db = hit::db();
267      $q  = " UPDATE aws_hit SET ";
268      $q .= $db->param_string("hitid") . " = " . $db->value_string($this->_hitid) . ", ";
269      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
270      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
271      $q .= $db->param_string("title") . " = " . $db->value_string($this->_title) . ", ";
272      $q .= $db->param_string("keywords") . " = " . $db->value_string($this->_keywords) . ", ";
273      $q .= $db->param_string("num_assignments") . " = " . $db->value_string($this->_num_assignments) . ", ";
274      $q .= $db->param_string("question") . " = " . $db->value_string($this->_question) . ", ";
275      $q .= $db->param_string("hitstatus_id") . " = " . $db->value_string($this->_hitstatus_id) . ", ";
276      $q .= $db->param_string("hitreviewstatus_id") . " = " . $db->value_string($this->_hitreviewstatus_id) . ", ";
277      $q .= $db->param_string("lifetimeinseconds") . " = " . $db->value_string($this->_lifetimeinseconds) . ", ";
278      $q .= $db->param_string("autoapprovaldelayinseconds") . " = " . $db->value_string($this->_autoapprovaldelayinseconds) . ", ";
279      $q .= $db->param_string("assignmentdurationinseconds") . " = " . $db->value_string($this->_assignmentdurationinseconds) . ", ";
280      $q .= $db->param_string("requesterannotation") . " = " . $db->value_string($this->_requesterannotation) . ", ";
281      $q .= $db->param_string("numberofsimilarhits") . " = " . $db->value_string($this->_numberofsimilarhits) . ", ";
282      $q .= $db->param_string("numberofassignmentspending") . " = " . $db->value_string($this->_numberofassignmentspending) . ", ";
283      $q .= $db->param_string("numberofassignmentsavailable") . " = " . $db->value_string($this->_numberofassignmentsavailable) . ", ";
284      $q .= $db->param_string("numberofassignmentscompleted") . " = " . $db->value_string($this->_numberofassignmentscompleted) . ", ";
285      $q .= $db->param_string("maxassignments") . " = " . $db->value_string($this->_maxassignments) . ", ";
286      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
287      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
288      $q .= " WHERE id = " . $this->_id;
289      $db->query($q);
290      return true;
291  }
 
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[ hit_db ]
Code
324  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
325  {
326      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
327      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
328      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
329 
330      $db = hit::db();
331      $data = array();
332      $q  = " SELECT $colstring ";
333      $q .= " FROM aws_hit ";
334      $q .= " WHERE aws_hit.deleted = 0 ";
335      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
336      $q .= array_key_exists("hitstatus_id",$lookups) ? " AND aws_hit.hitstatus_id='" . $lookups["hitstatus_id"] . "' " : "";
337      $q .= array_key_exists("hitreviewstatus_id",$lookups) ? " AND aws_hit.hitreviewstatus_id='" . $lookups["hitreviewstatus_id"] . "' " : "";
338 
339      if (is_string($__order))
340      {
341          $q .= "ORDER BY " . $__order;
342      }
343      else if (is_array($__order) and count($__order)>0)
344      {
345          $orderings = array();
346          foreach ($__order as $col=>$dir)
347          {
348              $orderings[] = " $col $dir ";
349          }
350          $q .= "ORDER BY " . implode(", ", $orderings);
351      }
352      else if (is_object($__order))
353      {
354          $q .= "";
355      }
356      else
357      {
358          // THERE IS NO `order` COLUMN ON THIS OBJECT
359      }
360 
361      if (!is_null($__limit))
362      {
363          $q .= " LIMIT $__offset , $__limit ";
364      }
365 
366      $db->query($q);
367 
368      if (count($colarray)>1 || $colstring=="*")
369      {
370          while ($db->next_record())
371          {
372              $data[] = $db->record;
373          }
374      }
375      else
376      {
377          while ($db->next_record())
378          {
379              $data[] = $db->f(0);
380          }
381      }
382 
383      return $data;
384  }
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  }
publichitassignment[ hit_db ]
Code
883  public function get_hitassignment($__type="default")
884  {
885      $object = is_null(keyval($this->property_objects_array,"{$__type}_hitassignment")) ? new hitassignment($this->get_hitassignment_id($__type)) : $this->property_objects_array["{$__type}_hitassignment"];
886      $this->property_objects_array["{$__type}_hitassignment"] = $object;
887      return $object;
888  }
Code
920  public function set_hitassignment($__v, $__type="default")
921  {
922      $object