]> git.mxchange.org Git - friendica.git/blob - update.php
Remove require
[friendica.git] / update.php
1 <?php
2
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;
10
11 /**
12  *
13  * update.php - automatic system update
14  *
15  * This function is responsible for doing post update changes to the data
16  * (not the structure) in the database.
17  *
18  * Database structure changes are done in src/Database/DBStructure.php
19  *
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.
22  *
23  * The numbered script in this file has to be exactly like the DB_UPDATE_VERSION
24  *
25  * Example:
26  * You are currently on version 4711 and you are preparing changes that demand an update script.
27  *
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.
31  */
32
33 function update_1178() {
34         require_once 'mod/profiles.php';
35
36         $profiles = q("SELECT `uid`, `about`, `locality`, `pub_keywords`, `gender` FROM `profile` WHERE `is-default`");
37
38         foreach ($profiles AS $profile) {
39                 if ($profile["about"].$profile["locality"].$profile["pub_keywords"].$profile["gender"] == "")
40                         continue;
41
42                 $profile["pub_keywords"] = profile_clean_keywords($profile["pub_keywords"]);
43
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"])
50                         );
51         }
52 }
53
54 function update_1179() {
55         if (Config::get('system','no_community_page'))
56                 Config::set('system','community_page_style', CP_NO_COMMUNITY_PAGE);
57
58         // Update the central item storage with uid=0
59         Worker::add(PRIORITY_LOW, "threadupdate");
60
61         return UPDATE_SUCCESS;
62 }
63
64 function update_1181() {
65
66         // Fill the new fields in the term table.
67         Worker::add(PRIORITY_LOW, "TagUpdate");
68
69         return UPDATE_SUCCESS;
70 }
71
72 function update_1189() {
73
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');
78         }
79
80         return UPDATE_SUCCESS;
81 }
82
83 function update_1191() {
84
85         Config::set('system', 'maintenance', 1);
86
87         if (Addon::isEnabled('forumlist')) {
88                 $plugin = 'forumlist';
89                 $plugins = Config::get('system','addon');
90                 $plugins_arr = [];
91
92                 if ($plugins) {
93                         $plugins_arr = explode(",",str_replace(" ", "",$plugins));
94
95                         $idx = array_search($plugin, $plugins_arr);
96                         if ($idx !== false){
97                                 unset($plugins_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(", ",$plugins_arr));
103                         }
104                 }
105         }
106
107         // select old formlist addon entries
108         $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
109                 dbesc('forumlist')
110         );
111
112         // convert old forumlist addon entries in new config entries
113         if (DBM::is_result($r)) {
114                 foreach ($r as $rr) {
115                         $uid = $rr['uid'];
116                         $family = $rr['cat'];
117                         $key = $rr['k'];
118                         $value = $rr['v'];
119
120                         if ($key === 'randomise')
121                                 PConfig::delete($uid,$family,$key);
122
123                         if ($key === 'show_on_profile') {
124                                 if ($value)
125                                         PConfig::set($uid,feature,forumlist_profile,$value);
126
127                                 PConfig::delete($uid,$family,$key);
128                         }
129
130                         if ($key === 'show_on_network') {
131                                 if ($value)
132                                         PConfig::set($uid,feature,forumlist_widget,$value);
133
134                                 PConfig::delete($uid,$family,$key);
135                         }
136                 }
137         }
138
139         Config::set('system', 'maintenance', 0);
140
141         return UPDATE_SUCCESS;
142
143 }
144
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));
148 }