/**
  *
  * @param array $facts
  * @param array $options
  * @return string
  */
 public static function create($facts, $options)
 {
     $block = '<section class="rp_truncate">';
     $block .= RP_Persona_Helper::get_banner($options, __('Facts', 'rootspersona'));
     $block .= '<div class="rp_facts">';
     $block .= '<ul>';
     $cnt = count($facts);
     for ($idx = 0; $idx < $cnt; $idx++) {
         if ((!isset($facts[$idx]['classification']) || empty($facts[$idx]['classification'])) && (!isset($facts[$idx]['cause']) || empty($facts[$idx]['cause'])) && ($options['hide_dates'] || !isset($facts[$idx]['date']) || empty($facts[$idx]['date']))) {
             continue;
         }
         // no real meaningfull data, so skip it
         $block .= '<li>';
         if (!$options['hide_dates'] && isset($facts[$idx]['date']) && !empty($facts[$idx]['date'])) {
             $block .= @preg_replace('/@.*@(.*)/US', '$1', $facts[$idx]['date']) . ' - ';
         }
         $block .= $facts[$idx]['type'] . ' - ' . $facts[$idx]['classification'] . ' ' . $facts[$idx]['cause'];
         if (!$options['hide_places'] && isset($facts[$idx]['place']) && !empty($facts[$idx]['place'])) {
             $block .= '; <span class="rp_place">' . $facts[$idx]['place'] . '</span>';
         }
         $p = $facts[$idx]['associated_person'];
         if (isset($p) && !empty($p)) {
             $block .= ' ' . __('with', 'rootspersona') . ' ' . $p['name'];
         }
         $block .= '</li>';
     }
     $block .= '</ul></div></section>';
     return $block;
 }
 /**
  *
  * @param array $marriage
  * @param array $options
  * @return string
  */
 public static function create_group_spouse($pfx, $marriage, $options)
 {
     $pframe_color = isset($options['pframe_color']) && !empty($options['pframe_color']) ? $options['pframe_color'] : 'brown';
     $fams = $marriage['fams'];
     $block = '<section class="rp_truncate">' . RP_Persona_Helper::get_banner($options, __('Family Group Sheet - Spouse', 'rootspersona')) . '<div class="rp_family">' . '<table class="familygroup" style="border-color:' . $pframe_color . ' !important"' . ' itemscope itemtype="http://historical-data.org/HistoricalFamily.html"><tbody>' . RP_Group_Sheet_Panel_Creator::show_parent($pfx . 'p', $marriage['spouse1'], $marriage['spouse1']->f_persona, $marriage['spouse1']->m_persona, $options) . RP_Group_Sheet_Panel_Creator::show_parent($pfx . 'm', $marriage['spouse2'], $marriage['spouse2']->f_persona, $marriage['spouse2']->m_persona, $options);
     if (isset($marriage['children'])) {
         $block .= RP_Group_Sheet_Panel_Creator::show_children($pfx . 'c', $marriage['children'], $options, $fams);
     }
     $block .= '</tbody></table></div></section>';
     return $block;
 }
 public static function create_for_edit($notes, $options)
 {
     $block = '<section class="rp_truncate">' . RP_Persona_Helper::get_banner($options, __('Biography', 'rootspersona')) . '<div class="rp_bio" style="margin:10px; 0px !important;">';
     $cnt = count($notes);
     if ($cnt == 0) {
         $block .= '<textarea id="rp_bio" name="rp_bio" cols="120" rows="5"></textarea><br/>';
     }
     for ($idx = 0; $idx < $cnt; $idx++) {
         $block .= '<textarea id="rp_bio" name="rp_bio" cols="120" rows="5">' . $notes[$idx]->note . '</textarea><br/>';
     }
     $block .= '</div></section>';
     return $block;
 }
 /**
  *
  * @param RP_Persona $persona
  * @param array $options
  * @return string
  */
 public static function create_for_edit($persona, $options)
 {
     $default = $options['plugin_url'] . '/images/boy-silhouette.gif';
     if (isset($persona->gender) && $persona->gender == 'F') {
         $default = $options['plugin_url'] . '/images/girl-silhouette.gif';
     }
     $block = '<div class="rp_truncate">' . RP_Persona_Helper::get_banner($options, 'Picture Gallery') . '<div class="rp_pictures">';
     $cnt = 6;
     for ($idx = 1; $idx <= $cnt; $idx++) {
         $link = isset($persona->picfiles[$idx]) ? $persona->picfiles[$idx] : $default;
         $i = $idx + 1;
         $block .= '<div class="rp_picture" style="text-align:center;"><a href="' . $link . '"><img id="img_' . $i . '" width="100px" src="' . $link . '"/></a>' . '<input id="img_path_' . $i . '" type="hidden" name="img_path_' . $i . '" value="' . $link . '"/>' . '<br/><input class="submitPersonForm"  id="img_' . $i . '_upload_button" type="button" value="Browse" />' . '<div class="rp_caption"><textarea id="cap_' . $i . '" name="cap_' . $i . '" cols="12">' . (isset($persona->piccaps[$idx]) ? $persona->piccaps[$idx] : '&#160;') . '</textarea></div>' . '</div>';
     }
     $block .= '</div>' . "</div>";
     return $block;
 }
Exemplo n.º 5
0
 /**
  *
  * @param integer $batch_id
  * @param array $options
  * @return array
  */
 public function get_with_options($batch_id, $options)
 {
     $this->transaction = new RP_Transaction($this->credentials, true);
     $rows = RP_Dao_Factory::get_rp_persona_dao($this->credentials->prefix)->get_indexed_page($batch_id, $options['surname'], $options['page_nbr'], $options['per_page'], $options['style']);
     $this->transaction->close();
     $cnt = count($rows);
     $uscore = $options['uscore'];
     $index = array();
     for ($idx = 0; $idx < $cnt; $idx++) {
         $persona = $rows[$idx];
         RP_Persona_Helper::score_persona($persona, $options);
         if (!RP_Persona_Helper::is_restricted($uscore, $persona->pscore)) {
             $index[] = $persona;
         }
     }
     return $index;
 }
 /**
  *
  * @global WP_Query $wp_query
  * @param array $options
  * @return array
  */
 public function get_options($options, $atts)
 {
     global $wp_query;
     $options['page_nbr'] = isset($wp_query->query_vars['rootsvar']) ? $wp_query->query_vars['rootsvar'] : 1;
     $options['per_page'] = isset($options['per_page']) ? $options['per_page'] : 25;
     $options['home_url'] = home_url();
     $options['uscore'] = RP_Persona_Helper::score_user();
     $options['surname'] = isset($atts['surname']) ? $atts['surname'] : null;
     $options['style'] = isset($atts['style']) ? $atts['style'] : 'paginated';
     //if(isset($atts['override-surname'])) {
     //    $options['surname'] = $atts['override-surname'];
     //}
     if (isset($wp_query->query_vars['override-surname'])) {
         $options['surname'] = $wp_query->query_vars['override-surname'];
     }
     return $options;
 }
 /**
  *
  * @param RP_Persona $persona
  * @param array $options
  * @return string
  */
 public static function create($persona, $options)
 {
     $block = '<section class="rp_truncate">';
     $block .= RP_Persona_Helper::get_banner($options, __('Evidence', 'rootspersona'));
     $block .= '<div class="rp_evidence">';
     $block .= '<table class="rp_evi">';
     $cnt = count($persona->sources);
     for ($idx = 0; $idx < $cnt; $idx++) {
         if (isset($persona->sources[$idx]['page_id']) && !empty($persona->sources[$idx]['page_id'])) {
             $link = '<a href="' . $options['home_url'] . "?page_id=" . $persona->sources[$idx]['page_id'] . '">' . '[' . $persona->sources[$idx]['src_id'] . ']</a>';
         } else {
             $win1 = sprintf(__('Evidence page has not yet been created for this source', 'rootspersona'), 'persona') . ".";
             $link = "<a href='#' onClick='javascript:rootsConfirm(\"" . $win1 . "\",\"\");return false;'>" . '[' . $persona->sources[$idx]['src_id'] . ']</a>';
         }
         $block .= '<tr><td valign="top"><sup>' . $link . '</sup></td><td><span style="padding-left:10px;display:inline-block;">' . $persona->sources[$idx]['src_title'] . '</span></td></tr>';
     }
     $block .= '</table></div></section>';
     return $block;
 }
 /**
  *
  * @param array $ancestors
  * @param array $options
  * @return string
  */
 public static function create($ancestors, $options)
 {
     $pframe_color = isset($options['pframe_color']) && !empty($options['pframe_color']) ? $options['pframe_color'] : 'brown';
     $isEdit = ($options['is_system_of_record'] == '1' ? true : false) && current_user_can("edit_pages");
     $fname = $ancestors[4]->full_name;
     if ($isEdit && $fname == '?' && $ancestors[2]->full_name != '?') {
         $fname = '+';
     }
     $block = '<section class="rp_truncate">' . RP_Persona_Helper::get_banner($options, __('Ancestors', 'rootspersona')) . '<div class="rp_ancestors">' . '<table cellpadding="0" cellspacing="0" class="ancestors"><tbody>' . '<tr><td colspan="2" rowspan="6">&#160;</td>' . '<td colspan="3" rowspan="2">&#160;</td><td>&#160;</td>' . '<td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[4], $options, $fname, $ancestors[2], 1, $ancestors[5]);
     $fname = $ancestors[2]->full_name;
     if ($isEdit && $fname == '?') {
         $fname = '+';
     }
     $block .= '</td></tr>' . '<tr><td class="rp_topleft" style="border-color:' . $pframe_color . ' !important">&#160;</td></tr>' . '<tr><td>&#160;</td>' . '<td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[2], $options, $fname, $ancestors[1], 1, $ancestors[3]);
     $fname = $ancestors[5]->full_name;
     if ($isEdit && $fname == '?' && $ancestors[2]->full_name != '?') {
         $fname = '+';
     }
     $block .= '</td><td class="rp_bottom" style="border-color:' . $pframe_color . ' !important">&#160;</td><td colspan="2" rowspan="2" class="rp_left" style="border-color:' . $pframe_color . ' !important">&#160;</td></tr>' . '<tr><td class="rp_topleft" style="border-color:' . $pframe_color . ' !important">&#160;</td><td>&#160;</td></tr>' . '<tr><td colspan="3" rowspan="6" class="rp_left" style="border-color:' . $pframe_color . ' !important">&#160;</td><td class="rp_leftbottom" style="border-color:' . $pframe_color . ' !important">&#160;</td>' . '<td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[5], $options, $fname, $ancestors[2], 2, $ancestors[4]);
     $block .= '</td></tr>' . '<tr><td>&#160;</td></tr><tr><td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[1], $options, $ancestors[1]->full_name, null, null, null);
     $fname = $ancestors[6]->full_name;
     if ($isEdit && $fname == '?' && $ancestors[3]->full_name != '?') {
         $fname = '+';
     }
     $block .= '</td><td class="rp_bottom" style="border-color:' . $pframe_color . ' !important">&#160;</td><td colspan="2" rowspan="2">&#160;</td></tr>' . '<tr><td>&#160;</td></tr>' . '<tr><td colspan="2" rowspan="6">&#160;</td><td>&#160;</td><td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[6], $options, $fname, $ancestors[3], 1, $ancestors[7]);
     $fname = $ancestors[3]->full_name;
     if ($isEdit && $fname == '?') {
         $fname = '+';
     }
     $block .= '</td></tr><tr><td class="rp_topleft" style="border-color:' . $pframe_color . ' !important">&#160;</td></tr>' . '<tr><td class="rp_leftbottom" style="border-color:' . $pframe_color . ' !important">&#160;</td><td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[3], $options, $fname, $ancestors[1], 2, $ancestors[2]);
     $fname = $ancestors[7]->full_name;
     if ($isEdit && $fname == '?' && $ancestors[3]->full_name != '?') {
         $fname = '+';
     }
     $block .= '</td><td class="rp_bottom" style="border-color:' . $pframe_color . ' !important">&#160;</td><td colspan="2" rowspan="2" class="rp_left" style="border-color:' . $pframe_color . ' !important">&#160;</td></tr>' . '<tr><td>&#160;</td><td>&#160;</td></tr><tr><td colspan="3" rowspan="2">&#160;</td>' . '<td class="rp_leftbottom" style="border-color:' . $pframe_color . ' !important">&#160;</td><td rowspan="2" class="rp_nameBox" style="border-color:' . $pframe_color . ' !important">' . RP_Ancestors_Panel_Creator::buildBlock($ancestors[7], $options, $fname, $ancestors[3], 2, $ancestors[6]);
     $block .= '</td></tr><tr><td>&#160;</td></tr>';
     $block .= '</tbody></table></div></section>';
     return $block;
 }
Exemplo n.º 9
0
 /**
  *
  * @global wpdb $wpdb
  * @param string $sql_file_to_execute
  * @param string $prefix
  */
 function update_tables($sql_file_to_execute, $prefix)
 {
     // read the sql file
     global $wpdb;
     try {
         $f = fopen($sql_file_to_execute, 'r');
         if ($f === false) {
             error_log("Unable to open " . $sql_file_to_execute, 0);
             trigger_error("Unable to open " . $sql_file_to_execute, E_USER_ERROR);
             throw new Exception("Unable to open " . $sql_file_to_execute);
         } else {
             $sql_file = fread($f, filesize($sql_file_to_execute));
             $sql_array = explode(';', $sql_file);
             $sql_error_code = 0;
             $sql_error_text = null;
             foreach ($sql_array as $stmt) {
                 $stmt = trim($stmt);
                 if (strlen($stmt) > 3 && substr(ltrim($stmt), 0, 2) != '/*') {
                     if ($prefix != null) {
                         $stmt = str_replace('EXISTS rp_', 'EXISTS ' . $prefix . 'rp_', $stmt);
                         $stmt = str_replace('TABLE rp_', 'TABLE ' . $prefix . 'rp_', $stmt);
                         $stmt = str_replace('TRUNCATE rp_', 'TRUNCATE ' . $prefix . 'rp_', $stmt);
                         $stmt = str_replace('INTO rp_', 'INTO ' . $prefix . 'rp_', $stmt);
                     }
                     $result = $wpdb->query($stmt);
                     if ($result === false) {
                         $wpdb->print_error();
                         throw new Exception($stmt);
                     }
                 }
             }
         }
     } catch (Exception $e) {
         error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
         trigger_error($e->getMessage(), E_USER_ERROR);
         throw new Exception($e);
     }
 }
Exemplo n.º 10
0
 /**
  * Reads a file into an array.
  * Validates the contents of the file.
  * Parses the records into a tree of nodes.
  * Parses the tree into objects.
  *
  * @param string $Filename name of file to be parsed
  *
  * @return void
  * @throws FileException
  * @access public
  * @since Method available since Release 0.0.1
  */
 public function parse($_filename, $callback_class = null)
 {
     @ini_set('auto_detect_line_endings', true);
     $this->gedcom_filename = $_filename;
     $callback = $callback_class === null ? $this : $callback_class;
     $line = null;
     try {
         if (($fp = fopen($this->gedcom_filename, 'r')) !== false) {
             $buffer = array();
             $next_line = $this->import_header($fp, array($callback, 'process_header'));
             while (true) {
                 $buffer[] = $this->convert_to_utf8($next_line);
                 while (!feof($fp)) {
                     $line = trim(fgets($fp, 1024));
                     if ($line != '' && $line[0] != '0') {
                         $buffer[] = $this->convert_to_utf8($line);
                     } else {
                         $gedcom_tree = null;
                         $this->create_tree($buffer, 0, 0, $gedcom_tree);
                         $this->parse_tree($gedcom_tree, $callback);
                         unset($buffer);
                         unset($gedcom_tree);
                         set_time_limit(60);
                         $next_line = $line;
                         break;
                     }
                 }
                 if ($line === null) {
                     $line = $next_line;
                 }
                 if (strpos($line, '0 TRLR') !== false) {
                     fclose($fp);
                     break;
                 } else {
                     if (feof($fp)) {
                         fclose($fp);
                         throw new RP_File_Exception('Invalid GEDCOM file: invalid TRLR record.');
                     }
                 }
             }
         } else {
             throw new RP_File_Exception('Cannot open file ' . $this->gedcom_filename);
         }
     } catch (Exception $e) {
         error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
         throw $e;
     }
 }
Exemplo n.º 11
0
 /**
  *
  * @param RP_Persona $persona
  * @param array $options
  * @return array
  */
 public function get_ancestors($persona, $options)
 {
     $uscore = $options['uscore'];
     $ancestors = array();
     $ancestors[1] = $persona;
     if (!empty($persona->father)) {
         $ancestors[2] = $this->get_persona($persona->father, $persona->batch_id, $uscore, $options);
     }
     if (!empty($persona->mother)) {
         $ancestors[3] = $this->get_persona($persona->mother, $persona->batch_id, $uscore, $options);
     }
     if (!empty($ancestors[2])) {
         if (!empty($ancestors[2]->father)) {
             $ancestors[4] = $this->get_persona($ancestors[2]->father, $persona->batch_id, $uscore, $options);
         }
         if (!empty($ancestors[2]->mother)) {
             $ancestors[5] = $this->get_persona($ancestors[2]->mother, $persona->batch_id, $uscore, $options);
         }
     }
     if (!empty($ancestors[3])) {
         if (!empty($ancestors[3]->father)) {
             $ancestors[6] = $this->get_persona($ancestors[3]->father, $persona->batch_id, $uscore, $options);
         }
         if (!empty($ancestors[3]->mother)) {
             $ancestors[7] = $this->get_persona($ancestors[3]->mother, $persona->batch_id, $uscore, $options);
         }
     }
     $isSOR = $options['is_system_of_record'] == '1' ? true : false;
     for ($idx = 1; $idx <= 7; $idx++) {
         if (!isset($ancestors[$idx]) || empty($ancestors[$idx])) {
             $ancestors[$idx] = RP_Persona_Helper::get_unknown($persona, false);
             if ($isSOR === true) {
                 // need to setup edit page logged in
             }
         }
         if (empty($ancestors[$idx]->page)) {
             $ancestors[$idx]->page = $ancestors[1]->page;
         }
     }
     return $ancestors;
 }
 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;
 }
 /**
  *
  * @global WP_Query $wp_query
  * @param array $options
  * @return array
  */
 public function get_options($options, $atts)
 {
     global $wp_query;
     $options['page_nbr'] = isset($wp_query->query_vars['rootsvar']) ? $wp_query->query_vars['rootsvar'] : 1;
     $options['per_page'] = isset($options['per_page']) ? $options['per_page'] : 25;
     $options['home_url'] = home_url();
     $options['uscore'] = RP_Persona_Helper::score_user();
     $options['style'] = isset($atts['style']) ? $atts['style'] : 'paginated';
     return $options;
 }
 /**
  *
  * @param array $options
  * @return array
  */
 public function get_persona_options($options)
 {
     $options['home_url'] = home_url();
     $options['admin_url'] = admin_url();
     $options['plugin_url'] = WP_PLUGIN_URL . '/rootspersona/';
     $options['action'] = $options['home_url'] . '/?page_id=' . RP_Persona_Helper::get_page_id();
     $options['uscore'] = RP_Persona_Helper::score_user();
     $options['hide_banner'] = 0;
     if (isset($options['src_page']) && !empty($options['src_page'])) {
         $page = get_post($options['src_page']);
         $content = $page->post_content;
         for ($i = 1; $i <= 7; $i++) {
             $pf = 'picfile' . $i;
             if (preg_match("/{$pf}/", $content)) {
                 $options[$pf] = @preg_replace('/.*?' . $pf . '=[\'|"](.*)[\'|"].*?/US', '$1', $content);
                 $pc = 'piccap' . $i;
                 if (preg_match("/{$pc}/", $content)) {
                     $options[$pc] = @preg_replace('/.*?' . $pc . '=[\'|"](.*)[\'|"].*?/US', '$1', $content);
                 }
             }
         }
     }
     return $options;
 }
Exemplo n.º 15
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;
         }
     }
 }
Exemplo n.º 16
0
 /**
  *
  * @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>';
     }
 }
 /**
  *
  * @param array $descendants
  * @param array $options
  * @return string
  */
 public static function create($persona, $options)
 {
     $pframe_color = isset($options['pframe_color']) && !empty($options['pframe_color']) ? $options['pframe_color'] : 'brown';
     $block = '<section class="rp_truncate">' . RP_Persona_Helper::get_banner($options, __('Descendancy Chart', 'rootspersona')) . '<div class="rp_descendants" style="padding:10px 4px;">' . RP_Descendancy_Panel_Creator::build_level($persona, $options, 1) . '</div></section>';
     return $block;
 }
Exemplo n.º 18
0
 /**
  *
  * @param RP_Persona $persona
  * @param array $options
  * @return integer
  */
 public static function score_persona($persona, $options)
 {
     $score = RP_Persona_Helper::EXCLUDE;
     if (isset($persona->pscore)) {
         $score = $persona->pscore;
     } else {
         if (isset($persona->privacy) && !empty($persona->privacy) && $persona->privacy != RP_Persona_Helper::DEF) {
             if ($persona->privacy == RP_Persona_Helper::PUB) {
                 $score = RP_Persona_Helper::ANYONE;
             } else {
                 if ($persona->privacy == RP_Persona_Helper::MBR) {
                     $score = RP_Persona_Helper::MBRS_ONLY;
                 } else {
                     if ($persona->privacy == RP_Persona_Helper::PVT) {
                         $score = RP_Persona_Helper::ADM_ONLY;
                     }
                 }
             }
         } else {
             $living_score = $options['privacy_living'];
             if ($living_score === false) {
                 $living_score = RP_Persona_Helper::MBR;
             }
             if ($living_score !== RP_Persona_Helper::DEF) {
                 if (!isset($persona->is_living)) {
                     $persona->is_living = RP_Persona_Helper::is_living($persona);
                 }
                 if ($persona->is_living) {
                     if ($living_score == RP_Persona_Helper::PUB) {
                         $score = RP_Persona_Helper::ANYONE;
                     } else {
                         if ($living_score == RP_Persona_Helper::MBR) {
                             $score = RP_Persona_Helper::MBRS_ONLY;
                         } else {
                             if ($living_score == RP_Persona_Helper::PVT) {
                                 $score = RP_Persona_Helper::ADM_ONLY;
                             }
                         }
                     }
                 }
             }
             if ($living_score === RP_Persona_Helper::DEF || $persona->is_living === false) {
                 $def_score = $options['privacy_default'];
                 if ($def_score === false || $def_score === RP_Persona_Helper::DEF) {
                     $score = RP_Persona_Helper::ANYONE;
                 } else {
                     if ($def_score == RP_Persona_Helper::PUB) {
                         $score = RP_Persona_Helper::ANYONE;
                     } else {
                         if ($def_score == RP_Persona_Helper::MBR) {
                             $score = RP_Persona_Helper::MBRS_ONLY;
                         } else {
                             if ($def_score == RP_Persona_Helper::PVT) {
                                 $score = RP_Persona_Helper::ADM_ONLY;
                             }
                         }
                     }
                 }
             }
         }
     }
     $persona->pscore = $score;
     return $score;
 }
Exemplo n.º 19
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;
 }
 /**
  *
  * @param array $atts
  * @param string $callback
  * @param array $options
  * @return array
  */
 public function get_persona_options($atts, $callback, $options)
 {
     $callback = strtolower($callback);
     $options['home_url'] = home_url();
     $options['plugin_url'] = WP_PLUGIN_URL . '/rootspersona/';
     $options['uscore'] = RP_Persona_Helper::score_user();
     if (empty($callback) || $callback == 'rootspersona') {
         $options['hide_banner'] = 0;
     } else {
         $options['hide_header'] = 1;
         $options['hide_facts'] = 1;
         $options['hide_ancestors'] = 1;
         $options['hide_descendancy'] = 1;
         $options['hide_family_c'] = 1;
         $options['hide_family_s'] = 1;
         $options['hide_pictures'] = 1;
         $options['hide_evidence'] = 1;
         $options['hide_banner'] = 1;
         $options['hide_bio'] = 1;
         $options['hide_edit_links'] = 1;
         if ($callback == 'rootspersonaheader') {
             $options['hide_header'] = 0;
         } else {
             if ($callback == 'rootspersonafacts') {
                 $options['hide_facts'] = 0;
             } else {
                 if ($callback == 'rootspersonaancestors') {
                     $options['hide_ancestors'] = 0;
                 } else {
                     if ($callback == 'rootspersonadescendancy') {
                         $options['hide_descendancy'] = 0;
                     } else {
                         if ($callback == 'rootspersonafamilyc') {
                             $options['hide_family_c'] = 0;
                         } else {
                             if ($callback == 'rootspersonafamilys') {
                                 $options['hide_family_s'] = 0;
                             } else {
                                 if ($callback == 'rootspersonapictures') {
                                     $options['hide_pictures'] = 0;
                                 } else {
                                     if ($callback == 'rootspersonaevidence') {
                                         $options['hide_evidence'] = 0;
                                     } else {
                                         if ($callback == 'rootspersonabio') {
                                             $options['hide_bio'] = 0;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     for ($idx = 1; $idx <= 7; $idx++) {
         $pic = 'picfile' . $idx;
         if (isset($atts[$pic])) {
             $options[$pic] = $atts[$pic];
             $cap = 'piccap' . $idx;
             if (isset($atts[$cap])) {
                 $options[$cap] = $atts[$cap];
             }
         }
     }
     return $options;
 }
 /**
  *
  * @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/>';
 }
 /**
  * @todo Description of function getPersona
  * @param  $id
  * @param  $batchId
  * @return
  */
 public function get_persona($id, $batch_id)
 {
     $persona = null;
     if (!isset($id) || empty($id) || $id == '0') {
         $persona = RP_Persona_Helper::get_unknown();
     } else {
         if (isset(self::$_pcache[$batch_id]) && isset(self::$_pcache[$batch_id][$id])) {
             $persona =& self::$_pcache[$batch_id][$id];
         } else {
             $sql1 = "SELECT ri.id AS id, ri.batch_id AS batch_id," . "IFNULL(rio.privacy_code,'Def') AS privacy" . ",CONCAT_WS(' ', (trim(replace(rnp.personal_name,'/',' '))), NULLIF(rnp.suffix,'')) AS full_name" . ",rnp.prefix AS prefix" . ",rnp.surname AS surname" . ",rnp.given AS given" . ",rnp.nickname AS nickname" . ",rnp.surname_prefix AS surname_prefix" . ",rnp.suffix AS suffix" . ",ri.gender AS gender" . ",rf.spouse1 AS father" . ",rf.spouse2 AS mother" . ",rfc.fam_id AS famc" . ",ri.wp_page_id AS page" . " FROM rp_indi ri" . " LEFT OUTER JOIN rp_indi_option rio ON rio.indi_id = ri.id AND rio.indi_batch_id = ri.batch_id" . " JOIN rp_indi_name rip ON ri.id = rip.indi_id AND ri.batch_id = rip.indi_batch_id AND rip.seq_nbr = 1" . " JOIN rp_name_personal rnp ON rip.name_id = rnp.id" . " LEFT OUTER JOIN rp_fam_child rfc ON ri.id = rfc.child_id AND ri.batch_id = rfc.indi_batch_id" . " LEFT OUTER JOIN rp_fam rf ON rfc.fam_id = rf.id AND rfc.fam_batch_id = rf.batch_id" . " WHERE ri.id = ? AND ri.batch_id = ? " . " AND IFNULL(rio.privacy_code,'Def') != '" . RP_Persona_Helper::EXC . "'";
             $sql_query = new RP_Sql_Query($sql1, $this->prefix);
             $sql_query->set($id);
             $sql_query->set_number($batch_id);
             $persona = $this->get_row($sql_query);
             if (!isset($persona) || empty($persona)) {
                 $persona = RP_Persona_Helper::get_unknown();
             } else {
                 $rows = $this->get_birth_and_death_dates($batch_id, $id);
                 if (isset($rows[0])) {
                     if ($rows[0]['type'] == 'birth') {
                         $persona->birth_date = $rows[0]['date'];
                         $persona->birth_place = $rows[0]['place'];
                         if (isset($rows[1])) {
                             $persona->death_date = $rows[1]['date'];
                             $persona->death_place = $rows[1]['place'];
                         }
                     } else {
                         $persona->death_date = $rows[0]['date'];
                         $persona->death_place = $rows[0]['place'];
                         if (isset($rows[1])) {
                             $persona->birth_date = $rows[1]['date'];
                             $persona->birth_place = $rows[1]['place'];
                         }
                     }
                 }
             }
             if (!isset(self::$_pcache[$batch_id])) {
                 self::$_pcache[$batch_id] = array();
             }
             self::$_pcache[$batch_id][$id] = $persona;
             $persona =& self::$_pcache[$batch_id][$id];
         }
     }
     return $persona;
 }
 /**
  *
  * @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);
 }