/**
  * Post-insert hook to log an activity for "manual-entry" submissions.
  * (Can't use regular AIR2Logger, since we need the postInsert xid).
  *
  * @param DoctrineEvent $event
  */
 public function postInsert($event)
 {
     parent::postInsert($event);
     // only manual-entries, and only if requestion
     if ($this->srs_type != self::$TYPE_MANUAL_ENTRY) {
         return;
     }
     if (!self::$LOG_MANUAL_ENTRY) {
         return;
     }
     // figure out what type of entry this is
     $actm_id = false;
     foreach (Inquiry::$MANUAL_TYPES as $code => $config) {
         if ($this->SrcResponse[0]->sr_orig_value == $config['label']) {
             $actm_id = $config['actm'];
             break;
         }
     }
     // find project id
     $prj_id = false;
     if (count($this->Inquiry->ProjectInquiry) > 0) {
         $prj_id = $this->Inquiry->ProjectInquiry[0]->pinq_prj_id;
     }
     // only log if the type matched something
     if ($actm_id && $prj_id) {
         $sact = new SrcActivity();
         $sact->sact_src_id = $this->srs_src_id;
         $sact->sact_actm_id = $actm_id;
         $sact->sact_prj_id = $prj_id;
         $sact->sact_dtim = $this->srs_date;
         $sact->sact_desc = '{USER} entered {XID} for source {SRC}';
         $sact->sact_notes = null;
         $sact->sact_xid = $this->srs_id;
         $sact->sact_ref_type = SrcActivity::$REF_TYPE_RESPONSE;
         $sact->save();
     }
 }
 /**
  * Make sure new Organizations get default projects
  *
  * @param Doctrine_Event $event
  */
 public function postInsert($event)
 {
     if (self::$CREATE_DEFAULT_PRJ && $this->org_default_prj_id == 1 && $this->org_type != 'T') {
         $p = new Project();
         $p->prj_name = air2_urlify($this->org_name);
         $p->prj_display_name = 'Project ' . $this->org_display_name;
         $p->prj_desc = 'Default project for organization "' . $this->org_display_name . '"';
         $p->ProjectOrg[0]->porg_org_id = $this->org_id;
         $p->ProjectOrg[0]->porg_contact_user_id = $this->org_cre_user;
         // make sure prj_name is unique
         $count = 0;
         $orig = $p->prj_name;
         $tbl = Doctrine::getTable('Project');
         $name = $tbl->findOneBy('prj_name', $p->prj_name);
         while ($name) {
             $p->prj_name = $orig . '_' . $count;
             $name = $tbl->findOneBy('prj_name', $p->prj_name);
         }
         // save, and make default
         $p->save();
         $this->org_default_prj_id = $p->prj_id;
         $this->save();
     }
     parent::postInsert($event);
 }