public function get_sources_with_pages($batch_id)
 {
     $sql = "SELECT rs.id AS id, rs.batch_id AS batch_id" . ",rs.abbr AS abbr" . ",rs.wp_page_id AS page" . " FROM rp_source rs" . " WHERE rs.wp_page_id IS NOT NULL AND rs.batch_id = ?";
     $sql_query = new RP_Sql_Query($sql, $this->prefix);
     $sql_query->set_number($batch_id);
     $rows = RP_Query_Executor::execute($sql_query);
     $cnt = count($rows);
     $sources = null;
     if ($cnt > 0) {
         $sources = array();
         for ($idx = 0; $idx < $cnt; $idx++) {
             $s = array();
             $s['id'] = $rows[$idx]['id'];
             $s['batch_id'] = $rows[$idx]['batch_id'];
             $s['title'] = $rows[$idx]['abbr'];
             $s['page_id'] = $rows[$idx]['page'];
             $sources[$idx] = $s;
         }
     }
     return $sources;
 }
 /**
  * @todo Description of function executeInsert
  * @param  $sqlQuery
  * @param  $credentials[optional]        default value : null
  * @return
  */
 public static function execute_insert($sql_query, $credentials = null)
 {
     RP_Query_Executor::execute_update($sql_query, $credentials);
     return is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"])) ? false : $___mysqli_res;
 }
 public function get_persons_with_pages($batch_id)
 {
     $sql = "SELECT ri.id AS id, ri.batch_id AS batch_id" . ",CONCAT_WS(' ', (trim(replace(rnp.personal_name,'/',' '))), NULLIF(rnp.suffix,'')) AS fullname" . ",ri.wp_page_id AS page" . " FROM rp_indi ri" . " 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" . " WHERE ri.wp_page_id IS NOT NULL AND ri.batch_id=?";
     $sql_query = new RP_Sql_Query($sql, $this->prefix);
     $sql_query->set_number($batch_id);
     $rows = RP_Query_Executor::execute($sql_query);
     $cnt = count($rows);
     $persons = array();
     if ($cnt > 0) {
         for ($idx = 0; $idx < $cnt; $idx++) {
             $p = array();
             $p['id'] = $rows[$idx]['id'];
             $p['batch_id'] = $rows[$idx]['batch_id'];
             $p['name'] = $rows[$idx]['fullname'];
             $p['page_id'] = $rows[$idx]['page'];
             $persons[$idx] = $p;
         }
     }
     return $persons;
 }
Esempio n. 4
0
 protected function execute_insert($sql_query)
 {
     return RP_Query_Executor::execute_insert($sql_query);
 }
Esempio n. 5
0
 /**
  *
  * @global wpdb $wpdb
  */
 function persona_activate()
 {
     global $wpdb;
     try {
         $options = get_option('persona_plugin');
         $installer = new RP_Persona_Installer();
         if (function_exists('is_multisite') && is_multisite()) {
             // check if it is a network activation - if so, run the activation function for each blog id
             if (isset($_GET['networkwide']) && $_GET['networkwide'] == 1) {
                 $old_blog = $wpdb->blogid;
                 // Get all blog ids
                 $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs}"));
                 foreach ($blogids as $blog_id) {
                     switch_to_blog($blog_id);
                     $installer->persona_install(WP_PLUGIN_DIR . '/rootspersona/', $this->persona_version, $options, $wpdb->prefix);
                 }
                 switch_to_blog($old_blog);
                 return;
             }
         }
         $installer->persona_install(WP_PLUGIN_DIR . '/rootspersona/', $this->persona_version, $options, $wpdb->prefix);
     } catch (Exception $e) {
         error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
         trigger_error($e->getMessage(), E_USER_ERROR);
         throw new Exception($e);
     }
     $sql = "SELECT COUNT(1) FROM information_schema.tables WHERE table_schema='" . DB_NAME . "' AND table_name='" . $wpdb->prefix . "rp_fam'";
     $sql_query = new RP_Sql_Query($sql, $wpdb->prefix);
     $tab = RP_Query_Executor::execute($sql_query, $this->credentials);
     if ($tab[0][0] !== "1") {
         error_log("RootsPersona tables not created.", 0);
         trigger_error("RootsPersona tables not created.", E_USER_ERROR);
         throw new Exception("RootsPersona tables not created.");
     }
 }
 public function query_by_src($src_id, $src_batch_id)
 {
     $sql = 'SELECT DISTINCT source_page, source_description' . ' FROM rp_source_cite' . ' WHERE source_id = ? and source_batch_id = ?' . ' ORDER BY source_page';
     $sql_query = new RP_Sql_Query($sql, $this->prefix);
     $sql_query->set($src_id);
     $sql_query->set_number($src_batch_id);
     $rows = RP_Query_Executor::execute($sql_query);
     $sources = null;
     if ($rows > 0) {
         $sources = array();
         $cnt = count($rows);
         for ($idx = 0; $idx < $cnt; $idx++) {
             $src = new RP_Source_Cite();
             $src->source_page = $rows[$idx]['source_page'];
             $src->source_description = $rows[$idx]['source_description'];
             $sources[$idx] = $src;
         }
     }
     return $sources;
 }