/**
  * @todo Description of function deletePersona
  * @param  $id
  * @param  $batchId
  * @return
  */
 public function delete_persona($id, $batch_id)
 {
     RP_Dao_Factory::get_rp_indi_note_dao($this->prefix)->delete_by_indi_id($id, $batch_id);
     RP_Dao_Factory::get_rp_indi_event_dao($this->prefix)->delete_by_indi_id($id, $batch_id);
     RP_Dao_Factory::get_rp_indi_cite_dao($this->prefix)->delete_by_indi_id($id, $batch_id);
     RP_Dao_Factory::get_rp_indi_name_dao($this->prefix)->delete_by_indi_id($id, $batch_id);
     RP_Dao_Factory::get_rp_indi_dao($this->prefix)->delete($id, $batch_id);
 }
 /**
  *
  * @param string $id
  * @param integer $batch_id
  * @param array $options
  * @return RP_Persona
  */
 public function get_with_options($id, $batch_id, $options)
 {
     $persona = null;
     $uscore = $options['uscore'];
     $this->transaction = new RP_Transaction($this->credentials, true);
     if ($options['hide_header'] == 0 || $options['hide_facts'] == 0 || $options['hide_ancestors'] == 0 || $options['hide_descendancy'] == 0 || $options['hide_family_c'] == 0 || $options['hide_family_s'] == 0 || $options['hide_bio'] == 0) {
         // need the real thing
         $persona = $this->get_persona($id, $batch_id, $uscore, $options);
     } else {
         // just need a container
         $persona = new RP_Persona();
         $persona->pscore = RP_Persona_Helper::ANYONE;
     }
     $persona->picfiles = array();
     $persona->piccaps = array();
     $pscore = $persona->pscore;
     if (!RP_Persona_Helper::is_restricted($uscore, $pscore)) {
         if ($options['hide_header'] == 0 || $options['hide_bio'] == 0) {
             if ($options['hide_bio'] == 0 || isset($options['header_style']) && $options['header_style'] == '2') {
                 $persona->notes = RP_Dao_Factory::get_rp_indi_note_dao($this->credentials->prefix)->query_by_indi_id($persona->id, $persona->batch_id);
             }
         }
         // do I need fact data?
         if ($options['hide_facts'] == 0) {
             $persona->facts = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_persona_events($id, $batch_id);
             $persona->marriages = $this->get_marriages($persona, $uscore, $options);
         }
         // do I need family data?
         if ($options['hide_facts'] != 0 && ($options['hide_family_c'] == 0 || $options['hide_family_s'] == 0 || $options['hide_descendancy'] == 0)) {
             $persona->marriages = $this->get_marriages($persona, $uscore, $options);
         }
         if ($options['hide_ancestors'] == 0 || $options['hide_family_c'] == 0 || $options['hide_family_s'] == 0) {
             $persona->ancestors = $this->get_ancestors($persona, $options);
             if ($options['hide_family_c'] == 0) {
                 $persona->siblings = $this->get_siblings($persona, $options);
                 if ($persona->ancestors[2]->id != '0') {
                     $persona->ancestors[2]->marriages = $this->get_marriages($persona->ancestors[2], $uscore, $options);
                 }
                 if ($persona->ancestors[3]->id != '0') {
                     $persona->ancestors[3]->marriages = $this->get_marriages($persona->ancestors[3], $uscore, $options);
                 }
             }
         }
         if ($options['hide_family_s'] == 0 || $options['hide_descendancy'] == 0) {
             //if ( $options['hide_facts'] != 0 ) {
             //    $persona->marriages = $this->get_marriages( $persona, $uscore, $options );
             //}
             $cnt = count($persona->marriages);
             for ($idx = 0; $idx < $cnt; $idx++) {
                 $persona->marriages[$idx]['children'] = $this->get_children($persona->marriages[$idx]['fams'], $batch_id, $options);
                 if ($options['hide_family_s'] == 0) {
                     if ($persona->marriages[$idx]['spouse1']->id == $persona->id) {
                         $persona->marriages[$idx]['spouse2']->marriages = $this->get_marriages($persona->marriages[$idx]['spouse2'], $uscore, $options);
                     } else {
                         $persona->marriages[$idx]['spouse1']->marriages = $this->get_marriages($persona->marriages[$idx]['spouse1'], $uscore, $options);
                     }
                     $persona->marriages[$idx]['spouse2']->f_persona = $this->get_persona($persona->marriages[$idx]['spouse2']->father, $batch_id, $uscore, $options);
                     $persona->marriages[$idx]['spouse2']->m_persona = $this->get_persona($persona->marriages[$idx]['spouse2']->mother, $batch_id, $uscore, $options);
                     $persona->marriages[$idx]['spouse1']->f_persona = $this->get_persona($persona->marriages[$idx]['spouse1']->father, $batch_id, $uscore, $options);
                     $persona->marriages[$idx]['spouse1']->m_persona = $this->get_persona($persona->marriages[$idx]['spouse1']->mother, $batch_id, $uscore, $options);
                 }
             }
         }
         if ($options['hide_descendancy'] == 0) {
             // OK, let's build out what we have already, then fill in the rest
             $cnt = count($persona->marriages);
             for ($idx = 0; $idx < $cnt; $idx++) {
                 $cnt2 = count($persona->marriages[$idx]['children']);
                 for ($idx2 = 0; $idx2 < $cnt2; $idx2++) {
                     $this->get_descendents($persona->marriages[$idx]['children'][$idx2], $uscore, $batch_id, $options);
                 }
             }
         }
         // do I need evidence data?
         if ($options['hide_evidence'] == 0) {
             if (!RP_Persona_Helper::is_restricted($uscore, $pscore)) {
                 $persona->sources = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_persona_sources($id, $batch_id);
             }
         }
         // do I need picture data?
         for ($idx = 1; $idx <= 7; $idx++) {
             $pic = 'picfile' . $idx;
             if (isset($options[$pic])) {
                 $persona->picfiles[$idx - 1] = $options[$pic];
                 $cap = 'piccap' . $idx;
                 if (isset($options[$cap])) {
                     $persona->piccaps[$idx - 1] = $options[$cap];
                 }
             }
         }
     } else {
         $p = new RP_Persona();
         $persona = $this->privatize($p);
     }
     $this->transaction->close();
     return $persona;
 }
 /**
  *
  * @param RP_Individual_Record $person
  */
 function update_notes($person)
 {
     RP_Dao_Factory::get_rp_indi_note_dao($this->credentials->prefix)->delete_by_indi_id($person->id, $this->batch_id);
     if (isset($person->notes) && count($person->notes) > 0) {
         foreach ($person->notes as $note) {
             $new_note = new RP_Indi_Note();
             $new_note->indi_batch_id = $this->batch_id;
             $new_note->indi_id = $person->id;
             $new_note->note_rec_id = $note->id;
             $new_note->note = $note->text;
             try {
                 $note->id = RP_Dao_Factory::get_rp_indi_note_dao($this->credentials->prefix)->insert($new_note);
             } catch (Exception $e) {
                 error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
                 echo $e->getMessage();
                 throw $e;
             }
         }
     }
 }