/** * Set the content of a user from an array * @input An array with all the values, including dependent rows (comes from the form) */ function setFromArray($input) { // OK, call the parent function, god for level-1 values parent::setFromArray($input); if (isset($_POST["topics"]) and is_array($_POST["topics"])) { $this->setTopicsFromArray($_POST["topics"]); } if (isset($_POST["roles"]) and is_array($_POST["roles"])) { $this->setRolesFromArray($_POST["roles"]); } // Get the registration answers if (isset($_POST['reg_answers']) and is_array($_POST["reg_answers"])) { $this->setAnswersFromArray($_POST["reg_answers"]); } }
/** * Set the content of a paper from an array * @input An array with all the values, including dependent rows * @fullArray false if the array only contains Paper data (no authors, abstracts, etc.) * */ function setFromArray($input, $fullArray = true) { // OK, call the parent function, god for level-1 values $this->setFilterData(true); parent::setFromArray($input); // Now set the authors and other dependent infos. if ($fullArray) { $this->setDependentFromArray($_POST); } }
/** * Set the content of a review from an array * @input An array with all the values, including dependent rows */ function setFromArray($input) { // Be careful: filter input data $this->setFilterData(true); // OK, call the parent function. parent::setFromArray($input); // Get the review marks $this->_marks = array(); $criteriaTbl = new Criteria(); $this->totalWeight = 0; $this->weightedMarks = 0; $markTbl = new ReviewMArk(); if (isset($input['marks'])) { foreach ($input['marks'] as $idCriteria => $value) { $criteria = $criteriaTbl->find($idCriteria)->current(); $this->_marks[$idCriteria] = $markTbl->createRow(); $this->totalWeight += $criteria->weight; $this->weightedMarks += $criteria->weight * $value; // Initialize the mark object. $this->_marks[$idCriteria]->setFromArray(array("idPaper" => $this->idPaper, "id_user" => $this->id_user, "idCriteria" => $idCriteria, "mark" => $value)); } } // Get the answers to additional questions $this->_answers = array(); $reviewAnswer = new ReviewAnswer(); if (isset($input['answers'])) { foreach ($input['answers'] as $idQuestion => $idAnswer) { $this->_answers[$idQuestion] = $reviewAnswer->createRow(); // Initialize the answer object. $this->_answers[$idQuestion]->setFromArray(array("id_paper" => $this->idPaper, "id_user" => $this->id_user, "id_question" => $idQuestion, "id_answer" => $idAnswer)); } } }