Example #1
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // New modules (charts) have been added.
     Module::getInstalledModules('enabled');
     // Delete old/unused settings
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('COMMON_NAMES_ADD', 'COMMON_NAMES_REMOVE', 'COMMON_NAMES_THRESHOLD')");
 }
Example #2
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     $index_dir = Site::getPreference('INDEX_DIRECTORY');
     // Due to the language code changes in 1.7.0, we need to update some other settings
     foreach ($this->languages as $old => $new) {
         try {
             Database::prepare("UPDATE `##site_setting` SET setting_name = REPLACE(setting_name, :old, :new) " . "WHERE setting_name LIKE 'WELCOME_TEXT_AUTH_MODE_%'")->execute(array('old' => $old, 'new' => $new));
         } catch (PDOException $ex) {
             // Duplicate key? Already done?
         }
         Database::prepare("UPDATE `##block_setting` SET setting_value = REPLACE(setting_value, :old, :new) " . "WHERE setting_name = 'languages'")->execute(array('old' => $old, 'new' => $new));
         // Historical fact files
         if (file_exists($index_dir . 'histo.' . $old . '.php') && !file_exists($index_dir . 'histo.' . $new . '.php')) {
             rename($index_dir . 'histo.' . $old . '.php', $index_dir . 'histo.' . $new . '.php');
         }
         // Language files
         if (file_exists($index_dir . 'language/' . $old . '.php') && !file_exists($index_dir . 'language/' . $new . '.php')) {
             rename($index_dir . 'language/' . $old . '.php', $index_dir . 'language/' . $new . '.php');
         }
         if (file_exists($index_dir . 'language/' . $old . '.csv') && !file_exists($index_dir . 'language/' . $new . '.csv')) {
             rename($index_dir . 'language/' . $old . '.csv', $index_dir . 'language/' . $new . '.csv');
         }
         if (file_exists($index_dir . 'language/' . $old . '.mo') && !file_exists($index_dir . 'language/' . $new . '.mo')) {
             rename($index_dir . 'language/' . $old . '.mo', $index_dir . 'language/' . $new . '.mo');
         }
     }
 }
Example #3
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // IPv6 addresses can be up to 45 characters.
     Database::exec("ALTER TABLE `##log`     CHANGE ip_address ip_address VARCHAR(45) NOT NULL");
     Database::exec("ALTER TABLE `##message` CHANGE ip_address ip_address VARCHAR(45) NOT NULL");
     Database::exec("ALTER TABLE `##session` CHANGE ip_address ip_address VARCHAR(45) NOT NULL");
 }
Example #4
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Update config data defining theme selection
     Database::exec("UPDATE `##gedcom_setting` SET setting_value=TRIM(LEADING 'themes/' FROM TRIM(TRAILING '/' FROM setting_value)) WHERE setting_name='THEME_DIR'");
     Database::exec("UPDATE `##user_setting` SET setting_value=TRIM(LEADING 'themes/' FROM TRIM(TRAILING '/' FROM setting_value)) WHERE setting_name='THEME_DIR'");
     Database::exec("UPDATE `##user_gedcom_setting` SET setting_value=TRIM(LEADING 'themes/' FROM TRIM(TRAILING '/' FROM setting_value)) WHERE setting_name='THEME_DIR'");
 }
Example #5
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Delete old configuration setting
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('SEARCH_FACTS_DEFAULT', 'DISPLAY_JEWISH_GERESHAYIM', 'DISPLAY_JEWISH_THOUSANDS')");
     // Increase the password column from 64 to 128 characters
     Database::exec("ALTER TABLE `##user` CHANGE password password VARCHAR(128) COLLATE utf8_unicode_ci NOT NULL");
 }
Example #6
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         foreach ($options as $option) {
             foreach ($option as $key => $value) {
                 if ($key == 'USE_FTV_THUMBS') {
                     $option['RESIZE_THUMBS'] = $value;
                     unset($option[$key]);
                 }
                 if ($key == 'COUNTRY') {
                     unset($option[$key]);
                 }
             }
             $option['USE_GEDCOM_PLACES'] = '1';
             $option['THUMB_RESIZE_FORMAT'] = '2';
             $new_options[] = $option;
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
Example #7
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // - delete unused settings and update indexes
     Database::exec("DELETE FROM `##site_setting` WHERE setting_name IN ('WELCOME_TEXT_CUST_HEAD')");
     // Modern versions of Internet Explorer use a different user-agent string
     Database::exec("INSERT IGNORE INTO `##site_access_rule` (user_agent_pattern, rule, comment) VALUES" . " ('Mozilla/% (Windows%; Trident%; rv:%) like Gecko', 'allow', 'Modern Internet Explorer')");
 }
Example #8
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Use LONGTEXT instead of TEXT and MEDIUMTEXT, and make NOT NULL.
     Database::exec("UPDATE `##news`   SET body          = '' WHERE body          IS NULL");
     Database::exec("UPDATE `##other`  SET o_gedcom      = '' WHERE o_gedcom      IS NULL");
     Database::exec("UPDATE `##places` SET p_std_soundex = '' WHERE p_std_soundex IS NULL");
     Database::exec("UPDATE `##places` SET p_dm_soundex  = '' WHERE p_dm_soundex  IS NULL");
     Database::exec("ALTER TABLE `##block_setting`  CHANGE setting_value setting_value LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##change`         CHANGE new_gedcom    new_gedcom    LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##change`         CHANGE old_gedcom    old_gedcom    LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##families`       CHANGE f_gedcom      f_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##individuals`    CHANGE i_gedcom      i_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##log`            CHANGE log_message   log_message   LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##media`          CHANGE m_gedcom      m_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##message`        CHANGE body          body          LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##module_setting` CHANGE setting_value setting_value LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##news`           CHANGE body          body          LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##other`          CHANGE o_gedcom      o_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##places`         CHANGE p_std_soundex p_std_soundex LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##places`         CHANGE p_dm_soundex  p_dm_soundex  LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     Database::exec("ALTER TABLE `##sources`        CHANGE s_gedcom      s_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
     // Use LONGBLOB instead of MEDIUMBLOB.
     Database::exec("ALTER TABLE `##gedcom_chunk`   CHANGE chunk_data    chunk_data    LONGBLOB NOT NULL");
     Database::exec("ALTER TABLE `##session`        CHANGE session_data  session_data  LONGBLOB NOT NULL");
 }
Example #9
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // add key 'LINK' to FTV_SETTINGS
     // change options to multidimensional array with array key = tree id.
     $module_settings = 'FTV_SETTINGS';
     $ftv_settings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne();
     $settings = unserialize($ftv_settings);
     if (!empty($settings)) {
         foreach ($settings as $setting) {
             if (!array_key_exists('LINK', $setting)) {
                 $setting['LINK'] = I18N::translate('Descendants of the %s family', $setting['SURNAME']);
                 $new_settings[] = $setting;
             }
         }
         if (isset($new_settings)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_settings), $module_settings));
         }
         unset($new_settings);
     }
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         $show_places = array_key_exists('SHOW_PLACES', $options) ? $options['SHOW_PLACES'] : '1';
         $country = array_key_exists('COUNTRY', $options) ? $options['COUNTRY'] : '';
         $show_occu = array_key_exists('SHOW_OCCU', $options) ? $options['SHOW_OCCU'] : '1';
         foreach (Tree::getAll() as $tree) {
             $new_options[$tree->getTreeId()] = array('SHOW_PLACES' => $show_places, 'COUNTRY' => $country, 'SHOW_OCCU' => $show_occu);
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
Example #10
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // Add new columns
     try {
         Database::exec("ALTER TABLE `##news`" . " ADD user_id INTEGER NULL AFTER n_id," . " ADD gedcom_id INTEGER NULL AFTER user_id," . " ADD updated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP," . " ADD KEY news_ix1 (user_id, updated)," . " ADD KEY news_ix2 (gedcom_id, updated)");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Migrate data from the old columns to the new ones
     try {
         Database::exec("UPDATE `##news` n" . " LEFT JOIN `##gedcom` g ON (n.n_username=g.gedcom_name)" . " LEFT JOIN `##user` u ON (n.n_username=u.user_name)" . " SET n.gedcom_id=g.gedcom_id, n.user_id=u.user_id, updated=FROM_UNIXTIME(n_date)");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Delete orphaned rows
     try {
         Database::exec("DELETE FROM `##news` WHERE user_id IS NULL AND gedcom_id IS NULL");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Delete/rename old columns
     try {
         Database::exec("ALTER TABLE `##news`" . " DROP n_username, DROP n_date," . " CHANGE n_id news_id INTEGER NOT NULL AUTO_INCREMENT," . " CHANGE n_title subject VARCHAR(255) COLLATE utf8_unicode_ci," . " CHANGE n_text body TEXT COLLATE utf8_unicode_ci");
     } catch (PDOException $ex) {
         // Already updated?
     }
 }
Example #11
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Tree settings become site settings
     Database::exec("INSERT IGNORE INTO `##site_setting` (setting_name, setting_value)" . " SELECT setting_name, setting_value" . " FROM `##gedcom_setting`" . " WHERE setting_name IN ('SHOW_REGISTER_CAUTION', 'WELCOME_TEXT_CUST_HEAD') OR setting_name LIKE 'WELCOME_TEXT_AUTH_MODE%'" . " GROUP BY setting_name");
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('ALLOW_EDIT_GEDCOM', 'SHOW_REGISTER_CAUTION', 'WELCOME_TEXT_CUST_HEAD') OR setting_name LIKE 'WELCOME_TEXT_AUTH_MODE%'");
     Database::exec("DELETE FROM `##site_setting` WHERE setting_name IN ('STORE_MESSAGES')");
 }
Example #12
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // Add the new columns
     try {
         Database::exec("ALTER TABLE `##favorites`" . " CHANGE fv_id    favorite_id   INTEGER AUTO_INCREMENT NOT NULL," . " CHANGE fv_gid   xref          VARCHAR(20) NULL," . " CHANGE fv_type  favorite_type ENUM('INDI', 'FAM', 'SOUR', 'REPO', 'OBJE', 'NOTE', 'URL') NOT NULL," . " CHANGE fv_url   url           VARCHAR(255) NULL," . " CHANGE fv_title title         VARCHAR(255) NULL," . " CHANGE fv_note  note          VARCHAR(1000) NULL," . " ADD user_id   INTEGER     NULL AFTER favorite_id," . " ADD gedcom_id INTEGER NOT NULL AFTER user_id," . " DROP KEY ix1," . " ADD KEY news_ix1 (gedcom_id, user_id)");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Migrate data from the old columns to the new ones
     try {
         Database::exec("UPDATE `##favorites` f" . " LEFT JOIN `##gedcom` g ON (f.fv_file    =g.gedcom_name)" . " LEFT JOIN `##user`   u ON (f.fv_username=u.user_name)" . " SET f.gedcom_id=g.gedcom_id, f.user_id=u.user_id");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Delete orphaned rows
     try {
         Database::exec("DELETE FROM `##favorites` WHERE user_id IS NULL AND gedcom_id IS NULL");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Delete the old column
     try {
         Database::exec("ALTER TABLE `##favorites` DROP fv_username, DROP fv_file");
     } catch (PDOException $ex) {
         // Already updated?
     }
     // Rename the table
     try {
         Database::exec("RENAME TABLE `##favorites` TO `##favorite`");
     } catch (PDOException $ex) {
         // Already updated?
     }
 }
Example #13
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     try {
         Database::prepare("ALTER TABLE `##site_setting` CHANGE setting_value setting_value VARCHAR(2000) NOT NULL")->execute();
     } catch (PDOException $ex) {
         // Already done?
     }
 }
Example #14
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Delete old config settings
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN('GEDCOM_DEFAULT_TAB', 'LINK_ICONS', 'ZOOM_BOXES')");
     Database::exec("DELETE FROM `##user_setting` WHERE setting_name='default'");
     // There is no way to add a RESN tag to NOTE objects
     Database::exec("UPDATE `##gedcom_setting` SET setting_value='SOUR,RESN' WHERE setting_name='NOTE_FACTS_ADD' AND setting_value='SOUR'");
 }
Example #15
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     try {
         Database::prepare("ALTER TABLE `##site_setting` CHANGE setting_value setting_value VARCHAR(2000) NOT NULL")->execute();
     } catch (PDOException $ex) {
         // Already done?
     }
     Database::prepare("DELETE FROM `##change` WHERE old_gedcom = '' AND new_gedcom = ''")->execute();
 }
 /**
  * {@inhericDoc}
  * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
  */
 public function validatePrerequisites()
 {
     try {
         Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
         return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME));
     } catch (\Exception $ex) {
     }
     return false;
 }
Example #17
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Add support for the persian/jalali calendar
     try {
         Database::exec("ALTER TABLE `##dates` CHANGE d_type d_type ENUM('@#DGREGORIAN@', '@#DJULIAN@', '@#DHEBREW@', '@#DFRENCH R@', '@#DHIJRI@', '@#DROMAN@', '@#DJALALI@')");
     } catch (PDOException $ex) {
         // Already been run?
     }
 }
Example #18
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // Update the tables to support streetview
     try {
         Database::exec("ALTER TABLE `##placelocation` ADD (" . " pl_media      VARCHAR(60)     NULL," . " sv_long       FLOAT           NOT NULL DEFAULT 0," . " sv_lati       FLOAT           NOT NULL DEFAULT 0," . " sv_bearing    FLOAT           NOT NULL DEFAULT 0," . " sv_elevation  FLOAT           NOT NULL DEFAULT 0," . " sv_zoom       FLOAT           NOT NULL DEFAULT 1" . ")");
     } catch (PDOException $ex) {
         // Already done this?
     }
 }
Example #19
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
  */
 public function validatePrerequisites()
 {
     try {
         Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
         return true;
     } catch (\Exception $ex) {
     }
     return false;
 }
Example #20
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Update some indexes, based on analysis of slow-query-logs
     try {
         Database::exec("ALTER TABLE `##places`" . " DROP       KEY ix1," . " DROP       KEY ix2," . " DROP       KEY ix3," . " DROP       KEY ix4," . " DROP       p_level," . " ADD        KEY ix1 (p_file, p_place)," . " ADD UNIQUE KEY ux1 (p_parent_id, p_file, p_place)");
     } catch (PDOException $ex) {
         // Already done?
     }
 }
Example #21
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Remove the i_isdead column
     try {
         Database::exec("ALTER TABLE `##individuals` DROP i_isdead");
     } catch (PDOException $ex) {
         // Already done this?
     }
 }
Example #22
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // An earlier update mistakenly made the fv_note column too short.
     // Add the new constraints
     try {
         Database::exec("ALTER TABLE `##favorite` CHANGE note note VARCHAR(1000) NULL");
     } catch (PDOException $ex) {
         // Already updated?
     }
 }
Example #23
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon()
  */
 public function getPlaceIcon(\Fisharebest\Webtrees\Place $place)
 {
     if (!$place->isEmpty()) {
         $place_details = Database::prepare('SELECT SQL_CACHE pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place')->execute(array($this->getProviderPlaceId($place)))->fetchOneRow();
         if ($place_details) {
             return WT_MODULES_DIR . 'googlemap/' . $place_details->pl_icon;
         }
     }
     return null;
 }
Example #24
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // Delete any data that might violate the new constraints
     Database::exec("DELETE FROM `##news`" . " WHERE user_id   NOT IN (SELECT user_id   FROM `##user`  )" . " OR    gedcom_id NOT IN (SELECT gedcom_id FROM `##gedcom`)");
     // Add the new constraints
     try {
         Database::exec("ALTER TABLE `##news`" . " ADD FOREIGN KEY news_fk1 (user_id  ) REFERENCES `##user`   (user_id)   ON DELETE CASCADE," . " ADD FOREIGN KEY news_fk2 (gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE");
     } catch (PDOException $ex) {
         // Already updated?
     }
 }
Example #25
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // - create the wt_gedcom_chunk table to import gedcoms in
     // blocks of data smaller than the max_allowed_packet restriction.
     Database::exec("CREATE TABLE IF NOT EXISTS `##gedcom_chunk` (" . " gedcom_chunk_id INTEGER AUTO_INCREMENT NOT NULL," . " gedcom_id       INTEGER                NOT NULL," . " chunk_data      MEDIUMBLOB             NOT NULL," . " imported        BOOLEAN                NOT NULL DEFAULT FALSE," . " PRIMARY KEY     (gedcom_chunk_id)," . "         KEY ix1 (gedcom_id, imported)," . " FOREIGN KEY `##gedcom_chunk_fk1` (gedcom_id) REFERENCES `##gedcom` (gedcom_id)" . ") COLLATE utf8_unicode_ci ENGINE=InnoDB");
     try {
         Database::exec("ALTER TABLE `##gedcom` DROP import_gedcom, DROP import_offset");
     } catch (PDOException $ex) {
         // Perhaps we have already deleted these columns?
     }
 }
Example #26
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Add a "default" user, to store default settings
     Database::exec("INSERT IGNORE INTO `##user` (user_id, user_name, real_name, email, password) VALUES (-1, 'DEFAULT_USER', 'DEFAULT_USER', 'DEFAULT_USER', 'DEFAULT_USER')");
     // Add the initial default block settings
     Database::exec("INSERT IGNORE INTO `##block` (user_id, location, block_order, module_name) VALUES (-1, 'main', 1, 'todays_events'), (-1, 'main', 2, 'user_messages'), (-1, 'main', 3, 'user_favorites'), (-1, 'side', 1, 'user_welcome'), (-1, 'side', 2, 'random_media'), (-1, 'side', 3, 'upcoming_events'), (-1, 'side', 4, 'logged_in')");
     // Add a "default" tree, to store default settings
     Database::exec("INSERT IGNORE INTO `##gedcom` (gedcom_id, gedcom_name) VALUES (-1, 'DEFAULT_TREE')");
     // Add the initial default block settings
     Database::exec("INSERT IGNORE INTO `##block` (gedcom_id, location, block_order, module_name) VALUES (-1, 'main', 1, 'gedcom_stats'), (-1, 'main', 2, 'gedcom_news'), (-1, 'main', 3, 'gedcom_favorites'), (-1, 'main', 4, 'review_changes'), (-1, 'side', 1, 'gedcom_block'), (-1, 'side', 2, 'random_media'), (-1, 'side', 3, 'todays_events'), (-1, 'side', 4, 'logged_in')");
     // Some modules (e.g. sitemap) require larger settings
     Database::exec("ALTER TABLE `##module_setting` CHANGE setting_value setting_value MEDIUMTEXT COLLATE utf8_unicode_ci NOT NULL");
 }
Example #27
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Delete old config settings
     // Convert MULTI_MEDIA (0=false, 1=true) to MEDIA_UPLOAD (1=members, 0=managers, -1=nobody)
     try {
         Database::exec("UPDATE `##gedcom_setting` SET setting_name='MEDIA_UPLOAD' WHERE setting_name='MULTI_MEDIA'");
     } catch (PDOException $ex) {
         // This could theoretically cause a duplicate key error, if a MULTI_MEDIA setting already exists
     }
     // Remove old settings
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('SHOW_MEDIA_FILENAME', 'USE_THUMBS_MAIN', 'MULTI_MEDIA')");
     Database::exec("DELETE FROM `##default_resn` WHERE tag_type IN ('_PRIM')");
 }
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     $num = $this->getBlockSetting($block_id, 'num', '10');
     $count_placement = $this->getBlockSetting($block_id, 'count_placement', 'before');
     $block = $this->getBlockSetting($block_id, 'block', '0');
     foreach (array('count_placement', 'num', 'block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
     } else {
         $title = '';
     }
     $title .= $this->getTitle();
     $content = '';
     // load the lines from the file
     $top10 = Database::prepare("SELECT page_parameter, page_count" . " FROM `##hit_counter`" . " WHERE gedcom_id = :tree_id AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT :limit")->execute(array('tree_id' => $WT_TREE->getTreeId(), 'limit' => (int) $num))->fetchAssoc();
     if ($block) {
         $content .= '<table width="90%">';
     } else {
         $content .= '<table>';
     }
     foreach ($top10 as $id => $count) {
         $record = GedcomRecord::getInstance($id, $WT_TREE);
         if ($record && $record->canShow()) {
             $content .= '<tr>';
             if ($count_placement == 'before') {
                 $content .= '<td dir="ltr" style="text-align:right">[' . $count . ']</td>';
             }
             $content .= '<td class="name2" ><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
             if ($count_placement == 'after') {
                 $content .= '<td dir="ltr" style="text-align:right">[' . $count . ']</td>';
             }
             $content .= '</tr>';
         }
     }
     $content .= "</table>";
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Example #29
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     $WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\\./i', '', Filter::server('SERVER_NAME'));
     // Default settings for new trees.  No defaults for:
     // imported, title, CONTACT_USER_ID, WEBMASTER_USER_ID
     // The following settings have defaults, but may need overwriting:
     // LANGUAGE, SURNAME_TRADITION
     Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES" . "(-1, 'ADVANCED_NAME_FACTS', 'NICK,_AKA')," . "(-1, 'ADVANCED_PLAC_FACTS', '')," . "(-1, 'ALLOW_THEME_DROPDOWN', '1')," . "(-1, 'CALENDAR_FORMAT', 'gregorian')," . "(-1, 'CHART_BOX_TAGS', '')," . "(-1, 'COMMON_NAMES_ADD', '')," . "(-1, 'COMMON_NAMES_REMOVE', '')," . "(-1, 'COMMON_NAMES_THRESHOLD', '40')," . "(-1, 'DEFAULT_PEDIGREE_GENERATIONS', '4')," . "(-1, 'EXPAND_RELATIVES_EVENTS', '0')," . "(-1, 'EXPAND_SOURCES', '0')," . "(-1, 'FAM_FACTS_ADD', 'CENS,MARR,RESI,SLGS,MARR_CIVIL,MARR_RELIGIOUS,MARR_PARTNERS,RESN')," . "(-1, 'FAM_FACTS_QUICK', 'MARR,DIV,_NMR')," . "(-1, 'FAM_FACTS_UNIQUE', 'NCHI,MARL,DIV,ANUL,DIVF,ENGA,MARB,MARC,MARS')," . "(-1, 'FAM_ID_PREFIX', 'F')," . "(-1, 'FORMAT_TEXT', 'markdown')," . "(-1, 'FULL_SOURCES', '0')," . "(-1, 'GEDCOM_ID_PREFIX', 'I')," . "(-1, 'GEDCOM_MEDIA_PATH', '')," . "(-1, 'GENERATE_UIDS', '0')," . "(-1, 'HIDE_GEDCOM_ERRORS', '1')," . "(-1, 'HIDE_LIVE_PEOPLE', '1')," . "(-1, 'INDI_FACTS_ADD', 'AFN,BIRT,DEAT,BURI,CREM,ADOP,BAPM,BARM,BASM,BLES,CHRA,CONF,FCOM,ORDN,NATU,EMIG,IMMI,CENS,PROB,WILL,GRAD,RETI,DSCR,EDUC,IDNO,NATI,NCHI,NMR,OCCU,PROP,RELI,RESI,SSN,TITL,BAPL,CONL,ENDL,SLGC,_MILI,ASSO,RESN')," . "(-1, 'INDI_FACTS_QUICK', 'BIRT,BURI,BAPM,CENS,DEAT,OCCU,RESI')," . "(-1, 'INDI_FACTS_UNIQUE', '')," . "(-1, 'KEEP_ALIVE_YEARS_BIRTH', '')," . "(-1, 'KEEP_ALIVE_YEARS_DEATH', '')," . "(-1, 'LANGUAGE', 'en-US')," . "(-1, 'MAX_ALIVE_AGE', '120')," . "(-1, 'MAX_DESCENDANCY_GENERATIONS', '15')," . "(-1, 'MAX_PEDIGREE_GENERATIONS', '10')," . "(-1, 'MEDIA_DIRECTORY', 'media/')," . "(-1, 'MEDIA_ID_PREFIX', 'M')," . "(-1, 'MEDIA_UPLOAD', :MEDIA_UPLOAD)," . "(-1, 'META_DESCRIPTION', '')," . "(-1, 'META_TITLE', :META_TITLE)," . "(-1, 'NOTE_FACTS_ADD', 'SOUR,RESN')," . "(-1, 'NOTE_FACTS_QUICK', '')," . "(-1, 'NOTE_FACTS_UNIQUE', '')," . "(-1, 'NOTE_ID_PREFIX', 'N')," . "(-1, 'NO_UPDATE_CHAN', '0')," . "(-1, 'PEDIGREE_FULL_DETAILS', '1')," . "(-1, 'PEDIGREE_LAYOUT', '1')," . "(-1, 'PEDIGREE_ROOT_ID', '')," . "(-1, 'PEDIGREE_SHOW_GENDER', '0')," . "(-1, 'PREFER_LEVEL2_SOURCES', '1')," . "(-1, 'QUICK_REQUIRED_FACTS', 'BIRT,DEAT')," . "(-1, 'QUICK_REQUIRED_FAMFACTS', 'MARR')," . "(-1, 'REPO_FACTS_ADD', 'PHON,EMAIL,FAX,WWW,RESN')," . "(-1, 'REPO_FACTS_QUICK', '')," . "(-1, 'REPO_FACTS_UNIQUE', 'NAME,ADDR')," . "(-1, 'REPO_ID_PREFIX', 'R')," . "(-1, 'REQUIRE_AUTHENTICATION', '0')," . "(-1, 'SAVE_WATERMARK_IMAGE', '0')," . "(-1, 'SAVE_WATERMARK_THUMB', '0')," . "(-1, 'SHOW_AGE_DIFF', '0')," . "(-1, 'SHOW_COUNTER', '1')," . "(-1, 'SHOW_DEAD_PEOPLE', :SHOW_DEAD_PEOPLE)," . "(-1, 'SHOW_EST_LIST_DATES', '0')," . "(-1, 'SHOW_FACT_ICONS', '1')," . "(-1, 'SHOW_GEDCOM_RECORD', '0')," . "(-1, 'SHOW_HIGHLIGHT_IMAGES', '1')," . "(-1, 'SHOW_LDS_AT_GLANCE', '0')," . "(-1, 'SHOW_LEVEL2_NOTES', '1')," . "(-1, 'SHOW_LIVING_NAMES', :SHOW_LIVING_NAMES)," . "(-1, 'SHOW_MEDIA_DOWNLOAD', '0')," . "(-1, 'SHOW_NO_WATERMARK', :SHOW_NO_WATERMARK)," . "(-1, 'SHOW_PARENTS_AGE', '1')," . "(-1, 'SHOW_PEDIGREE_PLACES', '9')," . "(-1, 'SHOW_PEDIGREE_PLACES_SUFFIX', '0')," . "(-1, 'SHOW_PRIVATE_RELATIONSHIPS', '1')," . "(-1, 'SHOW_RELATIVES_EVENTS', '_BIRT_CHIL,_BIRT_SIBL,_MARR_CHIL,_MARR_PARE,_DEAT_CHIL,_DEAT_PARE,_DEAT_GPAR,_DEAT_SIBL,_DEAT_SPOU')," . "(-1, 'SOURCE_ID_PREFIX', 'S')," . "(-1, 'SOUR_FACTS_ADD', 'NOTE,REPO,SHARED_NOTE,RESN')," . "(-1, 'SOUR_FACTS_QUICK', 'TEXT,NOTE,REPO')," . "(-1, 'SOUR_FACTS_UNIQUE', 'AUTH,ABBR,TITL,PUBL,TEXT')," . "(-1, 'SUBLIST_TRIGGER_I', '200')," . "(-1, 'SURNAME_LIST_STYLE', 'style2')," . "(-1, 'SURNAME_TRADITION', 'paternal')," . "(-1, 'THUMBNAIL_WIDTH', '100')," . "(-1, 'USE_RIN', '0')," . "(-1, 'USE_SILHOUETTE', '1')," . "(-1, 'WATERMARK_THUMB', '0')," . "(-1, 'WEBTREES_EMAIL', :WEBTREES_EMAIL)," . "(-1, 'WORD_WRAPPED_NOTES', '0')")->execute(array('MEDIA_UPLOAD' => Auth::PRIV_USER, 'META_TITLE' => WT_WEBTREES, 'SHOW_DEAD_PEOPLE' => Auth::PRIV_PRIVATE, 'SHOW_LIVING_NAMES' => Auth::PRIV_USER, 'SHOW_NO_WATERMARK' => Auth::PRIV_USER, 'WEBTREES_EMAIL' => $WEBTREES_EMAIL));
     // Previous versions of webtrees allowed this setting to be empty.
     Database::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name  ='WEBTREES_EMAIL' AND setting_value = ''")->execute();
     Database::prepare("INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " SELECT gedcom_id, 'WEBTREES_EMAIL', :WEBTREES_EMAIL" . " FROM `##gedcom` WHERE gedcom_id > 0")->execute(array('WEBTREES_EMAIL' => $WEBTREES_EMAIL));
     // Default restrictions
     Database::prepare("INSERT IGNORE INTO `##default_resn` (gedcom_id, tag_type, resn) VALUES " . "(-1, 'SSN', 'confidential')," . "(-1, 'SOUR', 'privacy')," . "(-1, 'REPO', 'privacy')," . "(-1, 'SUBM', 'confidential')," . "(-1, 'SUBN', 'confidential')")->execute();
 }
Example #30
0
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     // Delete old config settings
     Database::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN('GEDCOM_DEFAULT_TAB', 'LINK_ICONS', 'ZOOM_BOXES', 'SHOW_LIST_PLACES', 'SHOW_CONTEXT_HELP')");
     Database::exec("DELETE FROM `##user_setting` WHERE setting_name='defaulttab'");
     // There is no way to add a RESN tag to NOTE objects
     Database::exec("UPDATE `##gedcom_setting` SET setting_value='SOUR,RESN' WHERE setting_name='NOTE_FACTS_ADD' AND setting_value='SOUR'");
     // This needs to be an absolute URL. If not set, it defaults to the full path to login.php
     Database::exec("DELETE FROM `##site_setting` WHERE setting_name='LOGIN_URL' AND setting_value='login.php'");
     // No need for an empty value
     Database::exec("DELETE FROM `##site_setting` WHERE setting_name='SERVER_URL' AND setting_value=''");
     // Later PHP versions use session IDs longer than 32 chars.
     Database::exec("ALTER TABLE `##session` CHANGE session_id session_id CHAR(128) COLLATE utf8_unicode_ci NOT NULL");
 }