예제 #1
0
 /**
  * Carica da database tutti i report per l'oggetto passato e li salva nell'oggetto.
  * @param Editable $object un oggetto di cui si possono caricare i report.
  * @return l'oggetto aggiornato 
  */
 function loadAll($object)
 {
     parent::load($object);
     $objectClass = get_class($object);
     $rs = $this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(REPORT_OBJECT_ID), Operator::EQUAL, $object->getID()), new WhereConstraint($this->table->getColumn(REPORT_OBJECT_CLASS), Operator::EQUAL, get_class($object))), array()));
     $reports = array();
     while ($row = $this->db->fetch_result()) {
         $report = new Report(intval($row[DB::REPORT_USER]), $object, $row[DB::REPORT_TEXT]);
         $report->setID($row[REPORT_ID]);
         $reports[] = $report;
     }
     return $object->setReports($reports);
 }
예제 #2
0
파일: Post.php 프로젝트: Esisto/IoEsisto
 /**
  * Carica in this i report recuperati dal database per questo post (deve avere un ID!).
  */
 function loadReports()
 {
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineReportColumns();
         $table = Query::getDBSchema()->getTable(TABLE_REPORT);
         $rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(REPORT_POST), Operator::EQUAL, $this->getID())), array()), $table->getName(), $this);
         if ($rs !== false) {
             $reports = array();
             while ($row = $db->fetch_result()) {
                 require_once "common.php";
                 $report = new Report(intval($row[REPORT_USER]), intval($row[REPORT_POST]), $row[REPORT_TEXT]);
                 $report->setID($row[REPORT_ID]);
                 $reports[] = $report;
             }
             $this->setReports($reports);
         } else {
             if ($db->errno()) {
                 $db->display_error("Post::loadReports()");
             }
         }
     } else {
         $db->display_connect_error("Post::loadReports()");
     }
     return $this;
 }
예제 #3
0
 private function reportPost()
 {
     $report = new Report();
     //update if an id exists
     if (isset($this->request['id'])) {
         $report->setID($this->request['id']);
     }
     $report->setDescription($this->request['description']);
     //given name. get id
     $report->setInvolvementKindID(getInvolvementKindID($this->request['involvementKind']));
     //given name. get id
     $report->setReportKindID(getReportKindID($this->request['reportKind']));
     //set up location
     if (!$this->requestFieldsSubmitted(["buildingName"])) {
         $this->response['message'] = "error: missing location information";
         $this->response['code'] = 400;
     }
     $locID = $this->setUpLocation();
     if ($locID != -1) {
         $report->setLocationID($locID);
     } else {
         $this->response['message'] = "error: invalid location information";
         $this->response['code'] = 400;
     }
     //set up person
     if (!$this->requestFieldsSubmitted(["personKind", "username", "name", "phone"])) {
         $this->response['message'] = "error: missing person information";
         $this->response['code'] = 400;
     }
     $personID = $this->setUpPerson();
     if ($personID != -1) {
         $report->setPersonID($personID);
     } else {
         $this->response['message'] = "error: invalid person data";
         $this->response['code'] = 400;
     }
     //given dept name. get id
     $report->setDepartmentID(getDepartmentID($this->request['department']));
     $report->setDateTime($this->request['dateTime']);
     $report->setStatusID($this->request['statusID']);
     $report->setActionTaken($this->request['actionTaken']);
     $report->save();
     //return the report item in array format
     return $report->toArray();
 }