コード例 #1
0
 /**
  *
  * @param integer $batch_id
  * @param array $options
  * @return integer
  */
 public function get_cnt($batch_id, $options)
 {
     $this->transaction = new RP_Transaction($this->credentials, true);
     $cnt = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_indexed_source_cnt($batch_id);
     $this->transaction->close();
     return $cnt;
 }
コード例 #2
0
ファイル: surname_widget.php プロジェクト: markc/rootspersona
 /**
  * How to display the widget on the screen.
  */
 function widget($args, $instance)
 {
     global $wpdb;
     extract($args);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $cnt = $instance['cnt'];
     /* Before widget (defined by themes). */
     echo $before_widget;
     /* Display the widget title if one was input (before and after defined by themes). */
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     /* Display name from widget settings if one was input. */
     if ($cnt > 0) {
         $creds = new RP_Credentials();
         $creds->set_prefix($wpdb->prefix);
         $transaction = new RP_Transaction($creds, false);
         $rows = RP_Dao_Factory::get_rp_persona_dao($wpdb->prefix)->get_top_x_surnames($cnt);
         $rCnt = count($rows);
         if ($rCnt > 0) {
             for ($idx = 0; $idx < $rCnt; $idx++) {
                 //echo '<div style="margin-left:10px;">' . $rows[$idx]['surname'] . ' (' . $rows[$idx]['cnt'] . ')</div>';
                 echo '<div style="margin-left:10px;"><a href="' . get_home_url(null, '/?s=' . $rows[$idx]['surname'] . '&posttype=page&widget=advanced-search-widget-3') . '" rel="nofollow">' . $rows[$idx]['surname'] . '</a> (' . $rows[$idx]['cnt'] . ')</div>';
             }
         }
         $transaction->close();
     }
     /* After widget (defined by themes). */
     echo $after_widget;
 }
コード例 #3
0
 /**
  *
  * @param integer $batch_id
  * @param array $options
  * @return integer
  */
 public function get_cnt($batch_id, $options)
 {
     $this->transaction = new RP_Transaction($this->credentials, true);
     $cnt = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_indexed_page_cnt($batch_id, $options['surname']);
     // @todo we are adjusted for Exc, but not for Pvt or Mbr
     $this->transaction->close();
     return $cnt;
 }
コード例 #4
0
 /**
  * @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);
 }
コード例 #5
0
 public function query_by_indi_id($id, $batch_id)
 {
     $sql = 'SELECT * FROM rp_indi_note WHERE indi_id = ? AND indi_batch_id = ?';
     $sql_query = new RP_Sql_Query($sql, $this->prefix);
     $sql_query->set($id);
     $sql_query->set_number($batch_id);
     $notes = $this->get_list($sql_query);
     if (isset($notes) && count($notes) > 0) {
         foreach ($notes as $note) {
             if ((!isset($note->note) || empty($note->note)) && isset($note->note_rec_id)) {
                 $rec = RP_Dao_Factory::get_rp_note_dao($this->prefix)->load($note->note_rec_id, $batch_id);
                 $note->note = $rec->submitter_text;
             }
         }
     }
     return $notes;
 }
コード例 #6
0
 private function get_persons($src, $options)
 {
     $sql = 'SELECT DISTINCT ri.id AS id' . ',rnp.surname AS surname' . ',rnp.given AS given' . ',ri.wp_page_id AS page' . ',rio.privacy_code AS privacy_code' . ' FROM rp_indi ri' . ' LEFT OUTER JOIN rp_indi_option rio' . ' ON rio.indi_batch_id = ri.batch_id AND rio.indi_id = ri.id' . ' JOIN rp_indi_name rip' . ' ON ri.id = rip.indi_id AND ri.batch_id = rip.indi_batch_id' . ' JOIN rp_name_personal rnp ON rip.name_id = rnp.id' . " WHERE ri.batch_id = ? AND ri.wp_page_id IS NOT null" . " AND IFNULL(rio.privacy_code,'Def') != '" . RP_Persona_Helper::EXC . "' AND ri.id IN " . '(SELECT ric.indi_id AS id' . ' FROM rp_indi_cite ric' . ' JOIN rp_source_cite rsc ON ric.cite_id = rsc.id' . ' WHERE rsc.source_id = ? AND rsc.source_batch_id = ?' . ' UNION' . ' SELECT rie.indi_id AS id' . ' FROM rp_indi_event rie' . ' JOIN rp_event_cite rec ON rie.event_id = rec.event_id' . ' JOIN rp_source_cite rsc ON rsc.id = rec.cite_id' . ' WHERE rsc.source_id = ? AND rsc.source_batch_id = ?' . ' UNION' . ' SELECT rif.indi_id AS id' . ' FROM rp_indi_fam rif' . ' JOIN rp_fam_cite rfc ON rfc.fam_id = rif.fam_id AND rfc.fam_batch_id = rif.fam_batch_id' . ' JOIN rp_source_cite rsc ON rsc.id = rfc.cite_id' . ' WHERE rsc.source_id = ? AND rsc.source_batch_id = ?' . ' UNION' . ' SELECT rin.indi_id AS id' . ' FROM rp_indi_name rin' . ' JOIN rp_name_cite rnc ON rnc.name_id = rin.name_id' . ' JOIN rp_source_cite rsc ON rsc.id = rnc.cite_id' . ' WHERE rsc.source_id = ? AND rsc.source_batch_id = ?)' . ' ORDER BY rnp.surname, rnp.given';
     $sql_query = new RP_Sql_Query($sql, $this->prefix);
     $sql_query->set_number($src->batch_id);
     $sql_query->set($src->id);
     $sql_query->set_number($src->batch_id);
     $sql_query->set($src->id);
     $sql_query->set_number($src->batch_id);
     $sql_query->set($src->id);
     $sql_query->set_number($src->batch_id);
     $sql_query->set($src->id);
     $sql_query->set_number($src->batch_id);
     $rows = RP_Query_Executor::execute($sql_query);
     $cnt = count($rows);
     $persons = null;
     if ($cnt > 0) {
         $persons = array();
         for ($idx = 0; $idx < $cnt; $idx++) {
             $persona = new RP_Persona();
             $persona->surname = $rows[$idx]['surname'];
             $persona->given = $rows[$idx]['given'];
             $persona->page = $rows[$idx]['page'];
             $persona->privacy = $rows[$idx]['privacy_code'];
             $persona->birth_date = RP_Dao_Factory::get_rp_persona_dao($this->prefix)->get_birth_date($src->batch_id, $rows[$idx]['id']);
             $persona->death_date = RP_Dao_Factory::get_rp_persona_dao($this->prefix)->get_death_date($src->batch_id, $rows[$idx]['id']);
             $pscore = RP_Persona_Helper::score_persona($persona, $options);
             if (!RP_Persona_Helper::is_restricted($options['uscore'], $pscore)) {
                 $persons[$idx] = $persona;
             }
         }
     }
     return $persons;
 }
コード例 #7
0
 /**
  *
  * @param RP_Persona $persona
  * @param array $options
  * @return array
  */
 protected function get_siblings($persona, $options)
 {
     $uscore = $options['uscore'];
     $siblings = array();
     $sibs = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_children($persona->famc, $persona->batch_id, $options);
     foreach ($sibs as $sib) {
         if ($sib == $persona->id) {
             $siblings[] = $persona;
         } else {
             $p = $this->get_persona($sib, $persona->batch_id, $uscore, $options);
             $p->marriages = $this->get_marriages($p, $uscore, $options);
             $siblings[] = $p;
         }
     }
     if (count($siblings) == 0) {
         $siblings[] = $persona;
     }
     return $siblings;
 }
コード例 #8
0
 /**
  *
  * @param RP_Source_Record $source
  */
 function update_src_notes($source)
 {
     RP_Dao_Factory::get_rp_source_note_dao($this->credentials->prefix)->delete_by_src($source->id, $this->batch_id);
     foreach ($source->notes as $note) {
         $src_note = new RP_Source_Note();
         $src_note->source_id = $source->id;
         $src_note->source_batch_id = $this->batch_id;
         $src_note->note_rec_id = $note->id;
         $src_note->note = $note->text;
         try {
             $id = RP_Dao_Factory::get_rp_source_note_dao($this->credentials->prefix)->insert($src_note);
         } catch (Exception $e) {
             error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
             echo $e->getMessage();
             throw $e;
         }
     }
 }
コード例 #9
0
 /**
  *
  * @param string $plugin_dir
  * @param string $version
  * @param array $options
  * @param string $prefix
  */
 function persona_upgrade($plugin_dir, $version, $options, $prefix)
 {
     global $wpdb;
     if ($options['version'] < '2.0.3') {
         unset($options['evidence_page']);
         unset($options['index_page']);
     }
     if ($options['version'] < '2.2.0') {
         $options['hide_descendancy'] = 0;
     }
     if ($options['version'] < '3.0.0') {
         $stmt = "CREATE TABLE IF NOT EXISTS rp_indi_seq (id INT NOT NULL)";
         if ($prefix != null) {
             $stmt = str_replace('rp_', $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             throw new Exception($stmt);
         }
         $stmt = "INSERT INTO rp_indi_seq VALUES (100000)";
         if ($prefix != null) {
             $stmt = str_replace('INTO rp_', 'INTO ' . $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             //throw new Exception( $stmt );
         }
         $stmt = "CREATE TABLE IF NOT EXISTS rp_fam_seq (id INT NOT NULL)";
         if ($prefix != null) {
             $stmt = str_replace('rp_', $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             throw new Exception($stmt);
         }
         $stmt = "INSERT INTO rp_fam_seq VALUES (100000)";
         if ($prefix != null) {
             $stmt = str_replace('INTO rp_', 'INTO ' . $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             //throw new Exception( $stmt );
         }
     }
     // support table recreation on activation
     try {
         $credentials = new RP_Credentials();
         $credentials->set_prefix($wpdb->prefix);
         $transaction = new RP_Transaction($credentials, true);
         RP_Dao_Factory::get_rp_persona_dao($credentials->prefix)->get_batch_ids();
         $transaction->close();
     } catch (Exception $e) {
         if (strpos($e->getMessage(), "doesn't exist") >= 0) {
             $creator = new RP_Table_Creator();
             $creator->update_tables($this->sql_file_to_create_tables, $prefix);
         } else {
             error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
             throw $e;
         }
     }
     $options['version'] = $version;
     update_option('persona_plugin', $options);
 }
コード例 #10
0
ファイル: rootspersona.php プロジェクト: markc/rootspersona
 /**
  *
  * @return string
  */
 function build_roots_tools_page()
 {
     try {
         if (isset($_GET['rootspage'])) {
             $page = $_GET['rootspage'];
             if ($page == 'upload') {
                 echo $this->upload_gedcom_handler();
             } else {
                 if ($page == 'create') {
                     echo $this->add_page_handler();
                 } else {
                     if ($page == 'include') {
                         echo $this->include_page_handler();
                     } else {
                         if ($page == 'edit') {
                             echo $this->edit_persona_page_handler();
                         } else {
                             if ($page == 'util') {
                                 echo $this->utility_page_handler();
                             }
                         }
                     }
                 }
             }
         } else {
             $this->transaction = new RP_Transaction($this->credentials, true);
             $batch_ids = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_batch_ids();
             $this->transaction->close();
             $options = get_option('persona_plugin');
             $options['home_url'] = home_url();
             $builder = new RP_Tools_Page_Builder();
             echo $builder->build($options, $batch_ids);
         }
     } catch (Exception $e) {
         error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
         echo '<span style="color:red;margin-top:20px;display:inline-block;">' . $e->getMessage() . "::" . RP_Persona_Helper::trace_caller() . '</span>';
     }
 }
コード例 #11
0
 function process_form($credentials, $parms, $options)
 {
     $isSOR = $options['is_system_of_record'] == '1' ? true : false;
     $validator = new Persona_Validator();
     $ret = $validator->validate($parms, $options);
     $options = $ret[1];
     if ($ret[0] !== false) {
         if ($isSOR) {
             $handler = new RP_Gedcom_Loader();
             $handler->credentials = $credentials;
             $handler->batch_id = $ret[0]->batch_id;
             $options['editMode'] = 1;
             $indi = $handler->process_individual($ret[0], $options);
         } else {
             $indi = $ret[0];
         }
         if ($indi instanceof RP_Individual_Record) {
             if (isset($indi->id) && !empty($indi->id)) {
                 $page = $indi->page;
                 if (!isset($page) || empty($page)) {
                     $title = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_fullname($indi->id, $batch_id);
                     $content = "[rootsPersona   personid='{$indi->id}' batchId='{$indi->batch_id}'";
                     for ($i = 1; $i <= 7; $i++) {
                         $pf = 'picfile' . $i;
                         if (isset($indi->images[$i - 1])) {
                             $content = $content . ' ' . $pf . "='" . $indi->images[$i - 1] . "'";
                             $pc = 'piccap' . $i;
                             if (isset($indi->captions[$i - 1])) {
                                 $content = $content . ' ' . $pc . "='" . $indi->captions[$i - 1] . "'";
                             }
                         }
                     }
                     $content = $content . "/]";
                     $page_id = RP_Persona_Helper::add_page(null, $title, $options, null, $content);
                     $indi->page = $page_id;
                     if ($page_id != false) {
                         $this->transaction = new RP_Transaction($credentials);
                         RP_Dao_Factory::get_rp_indi_dao($credentials->prefix)->update_page($indi->id, $indi->batch_id, $page_id);
                         RP_Dao_Factory::get_rp_persona_dao($credentials->prefix)->update_persona_privacy($indi->id, $indi->batch_id, $indi->privacy, '');
                         $this->transaction->commit();
                     }
                 } else {
                     if ($indi->privacy != 'Exc') {
                         $my_post = array();
                         $my_post['ID'] = $page;
                         if ($isSOR) {
                             $title = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_fullname($indi->id, $batch_id);
                             $my_post['post_title'] = $title;
                         }
                         $content = "[rootsPersona   personid='{$indi->id}' batchId='{$indi->batch_id}'";
                         for ($i = 1; $i <= 7; $i++) {
                             $pf = 'picfile' . $i;
                             if (isset($indi->images[$i - 1])) {
                                 $content = $content . ' ' . $pf . "='" . $indi->images[$i - 1] . "'";
                                 $pc = 'piccap' . $i;
                                 if (isset($indi->captions[$i - 1])) {
                                     $content = $content . ' ' . $pc . "='" . $indi->captions[$i - 1] . "'";
                                 }
                             }
                         }
                         $content = $content . "/]";
                         $my_post['post_content'] = $content;
                         wp_update_post($my_post);
                         $this->transaction = new RP_Transaction($credentials);
                         RP_Dao_Factory::get_rp_persona_dao($credentials->prefix)->update_persona_privacy($indi->id, $indi->batch_id, $indi->privacy, '');
                         $this->transaction->commit();
                     } else {
                         wp_delete_post($page);
                         RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->delete_persona($indi->id, $indi->batch_id);
                         $r = array();
                         $r['error'] = 'Persona deleted.';
                         return $r;
                     }
                 }
             }
         } else {
             $r = array();
             $r['error'] = 'Error saving record.';
             return $r;
         }
     } else {
         return $ret[1]['errors'];
     }
     $r = array();
     $r['rp_id'] = $indi->id;
     $r['rp_page'] = $indi->page;
     if (isset($indi->parental->id) && !empty($indi->parental->id)) {
         $r['rp_famc'] = $indi->parental->id;
     }
     if (isset($indi->newFams) && !empty($indi->newFams)) {
         $r['rp_fams'] = $indi->newFams;
     }
     return $r;
 }
コード例 #12
0
 /**
  *
  * @param array $options
  * @return string
  */
 function add_evidence_pages($options, $batch_id)
 {
     $this->transaction = new RP_Transaction($this->credentials, false);
     $sources = RP_Dao_Factory::get_rp_source_dao($this->credentials->prefix)->get_source_no_page($batch_id);
     foreach ($sources as $src) {
         $content = sprintf("[rootsEvidencePage sourceId='%s' batchId='%s'/]", $src['id'], $batch_id);
         $page_id = RP_Persona_Helper::create_evidence_page($src['title'], $content, $options);
         RP_Dao_Factory::get_rp_source_dao($this->credentials->prefix)->update_page($src['id'], $batch_id, $page_id);
         set_time_limit(60);
     }
     $this->transaction->commit();
     return count($sources) . ' ' . sprintf(__('source page(s) added for batchId %s', 'rootspersona'), $batch_id) . '.<br/>';
 }