+
+function update_1145() {
+ $r = q("alter table profile add howlong datetime not null default '0000-00-00 00:00:00' after `with`");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
+}
+
+function update_1146() {
+ $r = q("alter table profile add hometown char(255) not null after `country-name`, add index ( `hometown` ) ");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
+}
+
+function update_1147() {
+ $r1 = q("ALTER TABLE `sign` ALTER `iid` SET DEFAULT '0'");
+ $r2 = q("ALTER TABLE `sign` ADD `retract_iid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `iid`");
+ $r3 = q("ALTER TABLE `sign` ADD INDEX ( `retract_iid` )");
+ if((! $r1) || (! $r2) || (! $r3))
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
+}
+
+function update_1148() {
+ $r = q("ALTER TABLE photo ADD type CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER filename");
+ if (!$r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+
+function update_1149() {
+ $r1 = q("ALTER TABLE profile ADD likes text NOT NULL after prv_keywords");
+ $r2 = q("ALTER TABLE profile ADD dislikes text NOT NULL after likes");
+ if (! ($r1 && $r2))
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+
+function update_1150() {
+ $r = q("ALTER TABLE event ADD summary text NOT NULL after finish, add index ( uid ), add index ( cid ), add index ( uri ), add index ( `start` ), add index ( finish ), add index ( `type` ), add index ( adjust ) ");
+ if(! $r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+
+function update_1151() {
+ $r = q("CREATE TABLE IF NOT EXISTS locks (
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+ name CHAR( 128 ) NOT NULL ,
+ locked TINYINT( 1 ) NOT NULL DEFAULT '0'
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+function update_1152() {
+ $r = q("CREATE TABLE IF NOT EXISTS `term` (
+ `tid` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+ `oid` INT UNSIGNED NOT NULL ,
+ `otype` TINYINT( 3 ) UNSIGNED NOT NULL ,
+ `type` TINYINT( 3 ) UNSIGNED NOT NULL ,
+ `term` CHAR( 255 ) NOT NULL ,
+ `url` CHAR( 255 ) NOT NULL,
+ KEY `oid` ( `oid` ),
+ KEY `otype` ( `otype` ),
+ KEY `type` ( `type` ),
+ KEY `term` ( `term` )
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+function update_1153() {
+ $r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'");
+
+ if(!$r) return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+function update_1154() {
+ $r = q("ALTER TABLE `event` ADD `ignore` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `adjust` , ADD INDEX ( `ignore` )");
+
+ if(!$r) return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+function update_1155() {
+ $r1 = q("ALTER TABLE `item_id` DROP PRIMARY KEY");
+ $r2 = q("ALTER TABLE `item_id` ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
+ $r3 = q("ALTER TABLE `item_id` ADD INDEX ( `iid` ) ");
+
+ if($r1 && $r2 && $r3)
+ return UPDATE_SUCCESS;
+
+ return UPDATE_FAILED;
+}
+
+function update_1156() {
+ $r = q("ALTER TABLE `photo` ADD `datasize` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `width` ,
+ADD INDEX ( `datasize` ) ");
+
+ if(!$r) return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
+}
+
+function update_1157() {
+ $r = q("CREATE TABLE IF NOT EXISTS `dsprphotoq` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `uid` int(11) NOT NULL,
+ `msg` mediumtext NOT NULL,
+ `attempt` tinyint(4) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8"
+ );
+
+ if($r)
+ return UPDATE_SUCCESS;
+}
+
+function update_1158() {
+ set_config('system', 'maintenance', 1);
+
+ // Wait for 15 seconds for current requests to
+ // clear before locking up the database
+ sleep(15);
+
+ $r = q("CREATE INDEX event_id ON item(`event-id`)");
+ set_config('system', 'maintenance', 0);
+
+ if($r)
+ return UPDATE_SUCCESS;
+
+ return UPDATE_FAILED;
+}
+
+function update_1159() {
+ $r = q("ALTER TABLE `term` ADD `aid` int(10) unsigned NOT NULL DEFAULT '0',
+ ADD `uid` int(10) unsigned NOT NULL DEFAULT '0',
+ ADD INDEX (`uid`),
+ ADD INDEX (`aid`)");
+
+ if(!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1160() {
+ set_config('system', 'maintenance', 1);
+
+ // Wait for 15 seconds for current requests to
+ // clear before locking up the database
+ sleep(15);
+
+ $r = q("ALTER TABLE `item` ADD `mention` TINYINT(1) NOT NULL DEFAULT '0', ADD INDEX (`mention`)");
+ set_config('system', 'maintenance', 0);
+
+ if(!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1161() {
+ $r = q("ALTER TABLE `pconfig` ADD INDEX (`cat`)");
+
+ if(!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1162() {
+ require_once('include/tags.php');
+ update_items();
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1163() {
+ set_config('system', 'maintenance', 1);
+
+ $r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL");
+
+ set_config('system', 'maintenance', 0);
+ if(!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+function update_1164() {
+ set_config('system', 'maintenance', 1);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_DFRN);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_DFRN, NETWORK_DFRN);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_ZOT, NETWORK_ZOT);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_OSTATUS, NETWORK_OSTATUS);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_FEED, NETWORK_FEED);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_DIASPORA, NETWORK_DIASPORA);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_MAIL, NETWORK_MAIL);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_MAIL2, NETWORK_MAIL2);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_FACEBOOK, NETWORK_FACEBOOK);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_LINKEDIN, NETWORK_LINKEDIN);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_XMPP, NETWORK_XMPP);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_MYSPACE, NETWORK_MYSPACE);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_GPLUS, NETWORK_GPLUS);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_PUMPIO, NETWORK_PUMPIO);
+
+ $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
+ NETWORK_TWITTER, NETWORK_TWITTER);
+
+ set_config('system', 'maintenance', 0);
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1165() {
+ $r = q("CREATE TABLE IF NOT EXISTS `push_subscriber` (
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `uid` INT NOT NULL,
+ `callback_url` CHAR( 255 ) NOT NULL,
+ `topic` CHAR( 255 ) NOT NULL,
+ `nickname` CHAR( 255 ) NOT NULL,
+ `push` INT NOT NULL,
+ `last_update` DATETIME NOT NULL,
+ `secret` CHAR( 255 ) NOT NULL
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1166() {
+ $r = q("CREATE TABLE IF NOT EXISTS `unique_contacts` (
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `url` CHAR(255) NOT NULL,
+ `nick` CHAR(255) NOT NULL,
+ `name` CHAR(255) NOT NULL,
+ `avatar` CHAR(255) NOT NULL,
+ INDEX (`url`)
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1167() {
+ $r = q("ALTER TABLE `contact` ADD `notify_new_posts` TINYINT(1) NOT NULL DEFAULT '0'");
+ if (!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1168() {
+ $r = q("ALTER TABLE `contact` ADD `fetch_further_information` TINYINT(1) NOT NULL DEFAULT '0'");
+ if (!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1169() {
+ $r = q("CREATE TABLE IF NOT EXISTS `thread` (
+ `iid` int(10) unsigned NOT NULL DEFAULT '0',
+ `uid` int(10) unsigned NOT NULL DEFAULT '0',
+ `contact-id` int(11) unsigned NOT NULL DEFAULT '0',
+ `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `wall` tinyint(1) NOT NULL DEFAULT '0',
+ `private` tinyint(1) NOT NULL DEFAULT '0',
+ `pubmail` tinyint(1) NOT NULL DEFAULT '0',
+ `moderated` tinyint(1) NOT NULL DEFAULT '0',
+ `visible` tinyint(1) NOT NULL DEFAULT '0',
+ `spam` tinyint(1) NOT NULL DEFAULT '0',
+ `starred` tinyint(1) NOT NULL DEFAULT '0',
+ `bookmark` tinyint(1) NOT NULL DEFAULT '0',
+ `unseen` tinyint(1) NOT NULL DEFAULT '1',
+ `deleted` tinyint(1) NOT NULL DEFAULT '0',
+ `origin` tinyint(1) NOT NULL DEFAULT '0',
+ `forum_mode` tinyint(1) NOT NULL DEFAULT '0',
+ `mention` tinyint(1) NOT NULL DEFAULT '0',
+ `network` char(32) NOT NULL,
+ PRIMARY KEY (`iid`),
+ KEY `created` (`created`),
+ KEY `commented` (`commented`),
+ KEY `uid_network_commented` (`uid`,`network`,`commented`),
+ KEY `uid_network_created` (`uid`,`network`,`created`),
+ KEY `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
+ KEY `uid_contactid_created` (`uid`,`contact-id`,`created`),
+ KEY `wall_private_received` (`wall`,`private`,`received`),
+ KEY `uid_created` (`uid`,`created`),
+ KEY `uid_commented` (`uid`,`commented`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
+ if (!$r)
+ return UPDATE_FAILED;
+
+ proc_run(PRIORITY_LOW, "include/threadupdate.php");
+
+ return UPDATE_SUCCESS;
+}
+
+/*
+==========
+ATTENTION!
+==========
+
+All following update functions are ONLY for jobs that need to run AFTER the database changes are applied.
+
+Database changes are ONLY applied in the file include/dbstructure.php.
+*/
+
+function update_1177() {
+ require_once("mod/profiles.php");
+
+ $profiles = q("SELECT `uid`, `about`, `locality`, `pub_keywords`, `gender` FROM `profile` WHERE `is-default`");
+
+ foreach ($profiles AS $profile) {
+ if ($profile["about"].$profile["locality"].$profile["pub_keywords"].$profile["gender"] == "")
+ continue;
+
+ $profile["pub_keywords"] = profile_clean_keywords($profile["pub_keywords"]);
+
+ $r = q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
+ dbesc($profile["about"]),
+ dbesc($profile["locality"]),
+ dbesc($profile["pub_keywords"]),
+ dbesc($profile["gender"]),
+ intval($profile["uid"])
+ );
+ }
+}
+
+function update_1178() {
+ if (get_config('system','no_community_page'))
+ set_config('system','community_page_style', CP_NO_COMMUNITY_PAGE);
+
+ // Update the central item storage with uid=0
+ proc_run(PRIORITY_LOW, "include/threadupdate.php");
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1180() {
+
+ // Fill the new fields in the term table.
+ proc_run(PRIORITY_LOW, "include/tagupdate.php");
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1188() {
+
+ if (strlen(get_config('system','directory_submit_url')) AND
+ !strlen(get_config('system','directory'))) {
+ set_config('system','directory', dirname(get_config('system','directory_submit_url')));
+ del_config('system','directory_submit_url');
+ }
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1190() {
+
+ require_once('include/plugin.php');
+
+ set_config('system', 'maintenance', 1);
+
+ if (plugin_enabled('forumlist')) {
+ $plugin = 'forumlist';
+ $plugins = get_config('system','addon');
+ $plugins_arr = array();
+
+ if($plugins) {
+ $plugins_arr = explode(",",str_replace(" ", "",$plugins));
+
+ $idx = array_search($plugin, $plugins_arr);
+ if ($idx !== false){
+ unset($plugins_arr[$idx]);
+ //delete forumlist manually from addon and hook table
+ // since uninstall_plugin() don't work here
+ q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
+ q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
+ set_config('system','addon', implode(", ",$plugins_arr));
+ }
+ }
+ }
+
+ // select old formlist addon entries
+ $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
+ dbesc('forumlist')
+ );
+
+ // convert old forumlist addon entries in new config entries
+ if (count($r)) {
+ foreach ($r as $rr) {
+ $uid = $rr['uid'];
+ $family = $rr['cat'];
+ $key = $rr['k'];
+ $value = $rr['v'];
+
+ if ($key === 'randomise')
+ del_pconfig($uid,$family,$key);
+
+ if ($key === 'show_on_profile') {
+ if ($value)
+ set_pconfig($uid,feature,forumlist_profile,$value);
+
+ del_pconfig($uid,$family,$key);
+ }
+
+ if ($key === 'show_on_network') {
+ if ($value)
+ set_pconfig($uid,feature,forumlist_widget,$value);
+
+ del_pconfig($uid,$family,$key);
+ }
+ }
+ }
+
+ set_config('system', 'maintenance', 0);
+
+ return UPDATE_SUCCESS;
+
+}
+
+function update_1202() {
+ $r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
+ dbesc(ACCOUNT_TYPE_COMMUNITY), dbesc(PAGE_COMMUNITY), dbesc(PAGE_PRVGROUP));
+}