3 use Friendica\Core\Addon;
4 use Friendica\Core\Config;
5 use Friendica\Core\PConfig;
6 use Friendica\Core\Worker;
7 use Friendica\Database\DBM;
8 use Friendica\Model\Photo;
9 use Friendica\Object\Image;
13 * update.php - automatic system update
15 * This function is responsible for doing post update changes to the data
16 * (not the structure) in the database.
18 * Database structure changes are done in src/Database/DBStructure.php
20 * If there is a need for a post process to a structure change, update this file
21 * by adding a new function at the end with the number of the new DB_UPDATE_VERSION.
23 * The numbered script in this file has to be exactly like the DB_UPDATE_VERSION
26 * You are currently on version 4711 and you are preparing changes that demand an update script.
28 * 1. Create a function "update_4712()" here in the update.php
29 * 2. Apply the needed structural changes in src/Database/DBStructure.php
30 * 3. Set DB_UPDATE_VERSION in boot.php to 4712.
33 function update_1178() {
34 require_once 'mod/profiles.php';
36 $profiles = q("SELECT `uid`, `about`, `locality`, `pub_keywords`, `gender` FROM `profile` WHERE `is-default`");
38 foreach ($profiles AS $profile) {
39 if ($profile["about"].$profile["locality"].$profile["pub_keywords"].$profile["gender"] == "")
42 $profile["pub_keywords"] = profile_clean_keywords($profile["pub_keywords"]);
44 $r = q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
45 dbesc($profile["about"]),
46 dbesc($profile["locality"]),
47 dbesc($profile["pub_keywords"]),
48 dbesc($profile["gender"]),
49 intval($profile["uid"])
54 function update_1179() {
55 if (Config::get('system','no_community_page'))
56 Config::set('system','community_page_style', CP_NO_COMMUNITY_PAGE);
58 // Update the central item storage with uid=0
59 Worker::add(PRIORITY_LOW, "threadupdate");
61 return UPDATE_SUCCESS;
64 function update_1181() {
66 // Fill the new fields in the term table.
67 Worker::add(PRIORITY_LOW, "TagUpdate");
69 return UPDATE_SUCCESS;
72 function update_1189() {
74 if (strlen(Config::get('system','directory_submit_url')) &&
75 !strlen(Config::get('system','directory'))) {
76 Config::set('system','directory', dirname(Config::get('system','directory_submit_url')));
77 Config::delete('system','directory_submit_url');
80 return UPDATE_SUCCESS;
83 function update_1191() {
85 require_once 'include/plugin.php';
87 Config::set('system', 'maintenance', 1);
89 if (Addon::isEnabled('forumlist')) {
90 $plugin = 'forumlist';
91 $plugins = Config::get('system','addon');
95 $plugins_arr = explode(",",str_replace(" ", "",$plugins));
97 $idx = array_search($plugin, $plugins_arr);
99 unset($plugins_arr[$idx]);
100 //delete forumlist manually from addon and hook table
101 // since Addon::uninstall() don't work here
102 q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
103 q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
104 Config::set('system','addon', implode(", ",$plugins_arr));
109 // select old formlist addon entries
110 $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
114 // convert old forumlist addon entries in new config entries
115 if (DBM::is_result($r)) {
116 foreach ($r as $rr) {
118 $family = $rr['cat'];
122 if ($key === 'randomise')
123 PConfig::delete($uid,$family,$key);
125 if ($key === 'show_on_profile') {
127 PConfig::set($uid,feature,forumlist_profile,$value);
129 PConfig::delete($uid,$family,$key);
132 if ($key === 'show_on_network') {
134 PConfig::set($uid,feature,forumlist_widget,$value);
136 PConfig::delete($uid,$family,$key);
141 Config::set('system', 'maintenance', 0);
143 return UPDATE_SUCCESS;
147 function update_1203() {
148 $r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
149 dbesc(ACCOUNT_TYPE_COMMUNITY), dbesc(PAGE_COMMUNITY), dbesc(PAGE_PRVGROUP));