/** * Create * * @param array $data * @return unknown */ protected function air_create($data) { if (!isset($data['org_uuid'])) { throw new Rframe_Exception(Rframe::BAD_DATA, "org_uuid required"); } $org = AIR2_Record::find('Organization', $data['org_uuid']); if (!$org) { $u = $data['org_uuid']; throw new Rframe_Exception(Rframe::BAD_DATA, "Invalid org_uuid '{$u}'"); } if (!$this->parent_rec->user_may_write($this->user)) { throw new Rframe_Exception(Rframe::BAD_DATA, "You do not appear to have access to modify this Inquiry (Invalid Inquiry authz)"); } $iorg = new InqOrg(); $iorg->iorg_inq_id = $this->parent_rec->inq_id; $iorg->Organization = $org; $iorg->mapValue('org_uuid', $iorg->Organization->org_uuid); // 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('org %s added by {USER}', $org->org_name); $this->parent_rec->InquiryActivity[] = $activity; return $iorg; }
/** * Change the side from which this table is accessed. For instance, to * access from "Inquiry->InqOrg", you would call change_uuid_col(false). * To access from "Organization->InqOrg", pass in true. * * @param boolean $is_org_side */ public static function change_uuid_col($is_org_side) { if ($is_org_side) { InqOrg::$UUID_COL = 'Inquiry:inq_uuid'; } else { InqOrg::$UUID_COL = 'Organization:org_uuid'; } }