librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1280] Advertise groups feature.


From: Toby Inkster
Subject: [Librefm-commits] [1280] Advertise groups feature.
Date: Thu, 07 May 2009 16:09:06 +0000

Revision: 1280
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1280
Author:   tobyink
Date:     2009-05-07 16:09:06 +0000 (Thu, 07 May 2009)
Log Message:
-----------
Advertise groups feature.

Modified Paths:
--------------
    trunk/nixtape/data/Group.php
    trunk/nixtape/templating.php
    trunk/nixtape/themes/librefm/templates/footer.tpl

Modified: trunk/nixtape/data/Group.php
===================================================================
--- trunk/nixtape/data/Group.php        2009-05-07 15:36:50 UTC (rev 1279)
+++ trunk/nixtape/data/Group.php        2009-05-07 16:09:06 UTC (rev 1280)
@@ -73,12 +73,51 @@
                        $this->owner        = new User($row['owner']);
                        $this->count        = -1;
                        $this->users        = array();
-
                        if (! preg_match('/\:/', $this->id))
                                $this->id = $base.'/group/' . 
rawurlencode($this->name) . '#group';
                }               
        }
+       
+       /**
+        * Selects a random nixtape group.
+        *
+        * @return object a Group object on success, a PEAR_Error object on 
error, or FALSE if there are no groups existing.
+        * @author tobyink
+        */
+       static function random ()
+       {
+               global $mdb2;
+               
+               if ( strtolower(substr($mdb2->phptype, 0, 5)) == 'mysql'  )
+               {
+                       $random = 'RAND';
+               }
+               elseif ( strtolower(substr($mdb2->phptype, 0, 5)) == 'mssql'  )
+               {
+                       $random = 'NEWID';  // I don't think we try to support 
MSSQL, but here's how it's done theoretically anyway
+               }
+               else
+               {
+                       $random = 'RANDOM';  // postgresql, sqlite, possibly 
others
+               }
 
+               $res = $mdb2->query("SELECT * FROM Groups ORDER BY {$random}() 
LIMIT 1");
+               if (PEAR::isError($res))
+               {
+                       return $res;
+               }
+               elseif ($res->numRows())
+               {
+                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
+                       return (new Group($row['groupname'], $row));
+               }
+               else
+               {
+                       // No groups found.
+                       return false;
+               }
+       }
+
        /**
         * Create a new nixtape group.
         *

Modified: trunk/nixtape/templating.php
===================================================================
--- trunk/nixtape/templating.php        2009-05-07 15:36:50 UTC (rev 1279)
+++ trunk/nixtape/templating.php        2009-05-07 16:09:06 UTC (rev 1280)
@@ -22,6 +22,7 @@
 require_once('config.php');
 require_once('auth.php');
 require_once('smarty/Smarty.class.php');
+require_once('data/Group.php');
 
 $smarty = new Smarty();
 
@@ -43,6 +44,12 @@
        $smarty->assign('this_user', $this_user);
 }
 
+$random_group = Group::random();
+if ($random_group!==false && !PEAR::isError($random_group))
+{
+       $smarty->assign('random_group', $random_group);
+}
+
 header("Content-Type: text/html; charset=utf-8");
 
 function insert_getMenu($lidsid, $smrt) {

Modified: trunk/nixtape/themes/librefm/templates/footer.tpl
===================================================================
--- trunk/nixtape/themes/librefm/templates/footer.tpl   2009-05-07 15:36:50 UTC 
(rev 1279)
+++ trunk/nixtape/themes/librefm/templates/footer.tpl   2009-05-07 16:09:06 UTC 
(rev 1280)
@@ -24,11 +24,22 @@
            
            </div>
 
-
+       {if $random_group}
+           <h4>Featured group</h4>
+           <p>
+               <img src="{$random_group->getAvatar()}" alt=""
+               height="32" width="32" style="margin: 0 0.67em 0.33em 
0;float:left" />
+               <a href="{$random_group->getURL()|escape:'html':'UTF-8'}"
+                       
><b>{$random_group->fullname|escape:'html':'UTF-8'}</b></a>
+               <br />
+               <small>{$random_group->bio|escape:'html':'UTF-8'}</small>
+               <br style="clear:left" />
+           </p>
+       {/if}
+       
            <h4>Coming soon</h4>
 
            <ul>
-           <li>Groups</li>
            <li>Improved streaming support</li>
            <li>Events</li>
            <li>Improved artist pages</li>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]