forumlist: dbupdate

This commit is contained in:
rabuzarus 2015-11-11 23:39:14 +01:00
parent 862ccb95d2
commit 902735f6d4
6 changed files with 65 additions and 17 deletions

View file

@ -19,7 +19,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Lily of the valley'); define ( 'FRIENDICA_CODENAME', 'Lily of the valley');
define ( 'FRIENDICA_VERSION', '3.4.2' ); define ( 'FRIENDICA_VERSION', '3.4.2' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1190 ); define ( 'DB_UPDATE_VERSION', 1191 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View file

@ -2,7 +2,7 @@
require_once("boot.php"); require_once("boot.php");
require_once("include/text.php"); require_once("include/text.php");
define('NEW_UPDATE_ROUTINE_VERSION', 1170); define('NEW_UPDATE_ROUTINE_VERSION', 1191);
/* /*
* send the email and do what is needed to do on update fails * send the email and do what is needed to do on update fails

View file

@ -2,20 +2,20 @@
/** /**
* @file include/forums.php * @file include/forums.php
* @brief functions related to forum functionality * * @brief Functions related to forum functionality *
*/ */
/** /**
* @brief function to list all forums a user is connected with * @brief Function to list all forums a user is connected with
* *
* @param int $uid of the profile owner * @param int $uid of the profile owner
* @param boolean $showhidden * @param boolean $showhidden
* show frorums which are not hidden * Show frorums which are not hidden
* @param boolean $lastitem * @param boolean $lastitem
* sort by lastitem * Sort by lastitem
* @param boolean $showprivate * @param boolean $showprivate
* show private groups * Show private groups
* *
* @returns array * @returns array
* 'url' => forum url * 'url' => forum url
@ -27,11 +27,11 @@ function get_forumlist($uid, $showhidden = true, $lastitem, $showprivate = false
$forumlist = array(); $forumlist = array();
$order = (($showhidden) ? '' : " AND `hidden` = 0 "); $order = (($showhidden) ? '' : ' AND `hidden` = 0 ');
$order .= (($lastitem) ? ' ORDER BY `last-item` ASC ' : ' ORDER BY `name` ASC '); $order .= (($lastitem) ? ' ORDER BY `last-item` ASC ' : ' ORDER BY `name` ASC ');
$select = "`forum` = 1"; $select = '`forum` = 1';
if ($showprivate) { if ($showprivate) {
$select = "( `forum` = 1 OR `prv` = 1 )"; $select = '( `forum` = 1 OR `prv` = 1 )';
} }
$contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` FROM contact $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` FROM contact
@ -54,7 +54,7 @@ function get_forumlist($uid, $showhidden = true, $lastitem, $showprivate = false
/** /**
* @brief forumlist widget * @brief Forumlist widget
* *
* Sidebar widget to show subcribed friendica forums. If activated * Sidebar widget to show subcribed friendica forums. If activated
* in the settings, it appears at the notwork page sidebar * in the settings, it appears at the notwork page sidebar
@ -95,7 +95,7 @@ function widget_forumlist($a) {
$tpl = get_markup_template('widget_forumlist.tpl'); $tpl = get_markup_template('widget_forumlist.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$title' => t("Forums"), '$title' => t('Forums'),
'$forums' => $entries, '$forums' => $entries,
'$link_desc' => t('External link to forum'), '$link_desc' => t('External link to forum'),
'$total' => $total, '$total' => $total,
@ -108,7 +108,7 @@ function widget_forumlist($a) {
} }
/** /**
* @brief format forumlist as contact block * @brief Format forumlist as contact block
* *
* This function is used to show the forumlist in * This function is used to show the forumlist in
* the advanced profile. * the advanced profile.
@ -145,4 +145,4 @@ function forumlist_profile_advanced($uid) {
if(count($contacts) > 0) if(count($contacts) > 0)
$o .= $forumlist; $o .= $forumlist;
return $o; return $o;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1190 ); define( 'UPDATE_VERSION' , 1191 );
/** /**
* *
@ -1659,3 +1659,51 @@ function update_1188() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }
function update_1190() {
require_once('/include/plugins.php');
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]);
uninstall_plugin($plugin);
set_config('system','addon', implode(', ',$plugins_arr));
}
}
}
$r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%d' ",
dbesc('forumlist')
);
foreach ($r as $rr) {
$uid = $rr['uid'];
$family = $rr['cat'];
$key = $rr['k'];
$value = $rr['v'];
if ($key === 'randomize')
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,$value);
del_pconfig($uid,$family,$key);
}
}
}

View file

@ -312,4 +312,4 @@ ul.credits li {
.forumlist-img { .forumlist-img {
height: 20px; height: 20px;
width: 20px; width: 20px;
} }

View file

@ -42,4 +42,4 @@ function showHideForumlist() {
</ul> </ul>
{{/if}} {{/if}}
</div> </div>