forumlist: dbupdate
authorrabuzarus <>
Wed, 11 Nov 2015 22:39:14 +0000 (23:39 +0100)
committerrabuzarus <>
Wed, 11 Nov 2015 22:39:14 +0000 (23:39 +0100)
boot.php
include/dbstructure.php
include/forums.php
update.php
view/global.css
view/templates/widget_forumlist.tpl

index d1f0d70..6e9e458 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -19,7 +19,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Lily of the valley');
 define ( 'FRIENDICA_VERSION',      '3.4.2' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1190      );
+define ( 'DB_UPDATE_VERSION',      1191      );
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
 
index 0dd74ab..7d8f89d 100644 (file)
@@ -2,7 +2,7 @@
 require_once("boot.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
index 4756580..e604a31 100644 (file)
@@ -2,20 +2,20 @@
 
 /**
  * @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 boolean $showhidden
- *     show frorums which are not hidden
+ *     Show frorums which are not hidden
  * @param boolean $lastitem
- *     sort by lastitem
+ *     Sort by lastitem
  * @param boolean $showprivate
- *     show private groups
+ *     Show private groups
  * 
  * @returns array
  *     'url'   => forum url
@@ -27,11 +27,11 @@ function get_forumlist($uid, $showhidden = true, $lastitem, $showprivate = false
 
        $forumlist = array();
 
-       $order = (($showhidden) ? '' : " AND `hidden` = 0 ");
+       $order = (($showhidden) ? '' : ' AND `hidden` = 0 ');
        $order .= (($lastitem) ? ' ORDER BY `last-item` ASC ' : ' ORDER BY `name` ASC ');
-       $select = "`forum` = 1";
+       $select = '`forum` = 1';
        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 
@@ -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
  * 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');
 
                $o .= replace_macros($tpl,array(
-                       '$title'        => t("Forums"),
+                       '$title'        => t('Forums'),
                        '$forums'       => $entries,
                        '$link_desc'    => t('External link to forum'),
                        '$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
  * the advanced profile.
@@ -145,4 +145,4 @@ function forumlist_profile_advanced($uid) {
        if(count($contacts) > 0)
                $o .= $forumlist;
                return $o;
-}
\ No newline at end of file
+}
index 33b4560..b6faa85 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1190 );
+define( 'UPDATE_VERSION' , 1191 );
 
 /**
  *
@@ -1659,3 +1659,51 @@ function update_1188() {
 
        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);
+               }
+       }
+}
index 2937394..24d0819 100644 (file)
@@ -312,4 +312,4 @@ ul.credits li {
 .forumlist-img {
   height: 20px;
   width: 20px;
-}
\ No newline at end of file
+}
index 0306332..4d155fd 100644 (file)
@@ -42,4 +42,4 @@ function showHideForumlist() {
        </ul>
        {{/if}}
 
-</div>
\ No newline at end of file
+</div>