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 Config::set('system', 'maintenance', 1);
87 if (Addon::isEnabled('forumlist')) {
89 $addons = Config::get('system', 'addon');
93 $addons_arr = explode(",",str_replace(" ", "", $addons));
95 $idx = array_search($addon, $addons_arr);
97 unset($addons_arr[$idx]);
98 //delete forumlist manually from addon and hook table
99 // since Addon::uninstall() don't work here
100 q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
101 q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
102 Config::set('system','addon', implode(", ", $addons_arr));
107 // select old formlist addon entries
108 $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
112 // convert old forumlist addon entries in new config entries
113 if (DBM::is_result($r)) {
114 foreach ($r as $rr) {
116 $family = $rr['cat'];
120 if ($key === 'randomise')
121 PConfig::delete($uid,$family,$key);
123 if ($key === 'show_on_profile') {
125 PConfig::set($uid,feature,forumlist_profile,$value);
127 PConfig::delete($uid,$family,$key);
130 if ($key === 'show_on_network') {
132 PConfig::set($uid,feature,forumlist_widget,$value);
134 PConfig::delete($uid,$family,$key);
139 Config::set('system', 'maintenance', 0);
141 return UPDATE_SUCCESS;
145 function update_1203() {
146 $r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
147 dbesc(ACCOUNT_TYPE_COMMUNITY), dbesc(PAGE_COMMUNITY), dbesc(PAGE_PRVGROUP));