/** * Create * * @param array $data */ protected function air_create($data) { if (!isset($data['inq_uuid'])) { throw new Rframe_Exception(Rframe::BAD_DATA, "inq_uuid required"); } $inq = AIR2_Record::find('Inquiry', $data['inq_uuid']); if (!$inq) { $u = $data['inq_uuid']; throw new Rframe_Exception(Rframe::BAD_DATA, "Invalid inq_uuid '{$u}'"); } if (!$inq->user_may_write($this->user)) { throw new Rframe_Exception(Rframe::BAD_DATA, "Invalid Inquiry authz"); } $pinq = new ProjectInquiry(); $pinq->pinq_prj_id = $this->parent_rec->prj_id; $pinq->Inquiry = $inq; $pinq->mapValue('inq_uuid', $pinq->Inquiry->inq_uuid); return $pinq; }
/** * Create * * @param array $data * @return unknown */ protected function air_create($data) { if (!isset($data['prj_uuid'])) { throw new Rframe_Exception(Rframe::BAD_DATA, "prj_uuid required"); } $prj = AIR2_Record::find('Project', $data['prj_uuid']); if (!$prj) { $u = $data['prj_uuid']; throw new Rframe_Exception(Rframe::BAD_DATA, "Invalid prj_uuid '{$u}'"); } $pinq = new ProjectInquiry(); $pinq->pinq_inq_id = $this->parent_rec->inq_id; $pinq->Project = $prj; $pinq->mapValue('prj_uuid', $pinq->Project->prj_uuid); // adding a Project to a Query requires write authz on the Query, not the Project. if (!$pinq->user_may_write($this->user)) { throw new Rframe_Exception(Rframe::BAD_DATA, "Invalid Query authz"); } // log activity $activity = new InquiryActivity(); $activity->ia_inq_id = $this->parent_rec->inq_id; $activity->ia_actm_id = 49; $activity->ia_dtim = air2_date(); $activity->ia_desc = sprintf('project %s added by {USER}', $prj->prj_name); $this->parent_rec->InquiryActivity[] = $activity; return $pinq; }