summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/ampache.cfg.php.dist8
-rwxr-xr-xdocs/CHANGELOG3
-rw-r--r--images/icon_comment.pngbin0 -> 413 bytes
-rw-r--r--lib/class/shoutbox.class.php177
-rw-r--r--lib/class/user.class.php3
-rw-r--r--shout.php50
-rw-r--r--templates/show_add_shout.inc.php46
-rw-r--r--templates/show_album_row.inc.php7
-rw-r--r--templates/show_index.inc.php14
-rw-r--r--templates/show_recently_played.inc.php1
-rw-r--r--templates/show_shoutbox.inc.php44
-rw-r--r--templates/show_song_row.inc.php10
-rw-r--r--themes/classic/templates/default.css2
13 files changed, 359 insertions, 6 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index d31728fc..ad6bb7c1 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -205,6 +205,14 @@ use_auth = "yes"
; DEFAULT: true
ratings = "true"
+; ShoutBox
+; Enabling this will allow any user to 'tag' an item and post
+; a comment about it which will then be put on the main pages
+; shoutbox. Admins are allowed to create 'sticky' shoutbox items
+; POSSIBLE VALUES: false true
+; DEFAULT: false
+;shoutbox = "false"
+
; This options will turn on/off Demo Mode
; If Demo mode is on you can not play songs or update your catalog
; in other words.. leave this commented out
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index df233630..01516521 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,9 @@
--------------------------------------------------------------------------
v.3.4-Alpha4
+ - Added Basic ShoutBox functionality, needs formating fixes
+ and needs to be moved to a better spot in classic theme it
+ must be turned on in the /config/ampache.cfg.php
- Fixed Mail functions, some features from old mail are missing for
now.
- Fixed Delete Disabled & Sort Files command line scripts
diff --git a/images/icon_comment.png b/images/icon_comment.png
new file mode 100644
index 00000000..7bc9233e
--- /dev/null
+++ b/images/icon_comment.png
Binary files differ
diff --git a/lib/class/shoutbox.class.php b/lib/class/shoutbox.class.php
new file mode 100644
index 00000000..3cea772b
--- /dev/null
+++ b/lib/class/shoutbox.class.php
@@ -0,0 +1,177 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+class shoutBox {
+
+ public $id;
+
+ /**
+ * Constructor
+ * This pulls the shoutbox information from the database and returns
+ * a constructed object, uses user_shout table
+ */
+ public function __construct($shout_id) {
+
+ // Load the data from the database
+ $this->_get_info($shout_id);
+
+ return true;
+
+ } // Constructor
+
+ /**
+ * _get_info
+ * does the db call, reads from the user_shout table
+ */
+ private function _get_info($shout_id) {
+
+ $sticky_id = Dba::escape($shout_id);
+
+ $sql = "SELECT * FROM `user_shout` WHERE `id`='$shout_id'";
+ $db_results = Dba::query($sql);
+
+ $data = Dba::fetch_assoc($db_results);
+
+ foreach ($data as $key=>$value) {
+ $this->$key = $value;
+ }
+
+ return true;
+
+ } // _get_info
+
+ /**
+ * get_top
+ * This returns the top user_shouts, shoutbox objects are always shown regardless and count against the total
+ * number of objects shown
+ */
+ public static function get_top($limit) {
+
+ $shouts = self::get_sticky();
+
+ // If we've already got too many stop here
+ if (count($shouts) > $limit) {
+ $shouts = array_slice(0,$limit,$shouts);
+ return $shouts;
+ }
+
+ // Only get as many as we need
+ $limit = intval($limit) - count($shouts);
+ $sql = "SELECT * FROM `user_shout` WHERE `sticky`='0' ORDER BY `date` DESC LIMIT $limit";
+ $db_results = Dba::query($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $shouts[] = $row['id'];
+ }
+
+ return $shouts;
+
+ } // get_top
+
+ /**
+ * get_sticky
+ * This returns all current sticky shoutbox items
+ */
+ public static function get_sticky() {
+
+ $sql = "SELECT * FROM `user_shout` WHERE `sticky`='1' ORDER BY `date` DESC";
+ $db_results = Dba::query($sql);
+
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
+
+ return $results;
+
+ } // get_sticky
+
+ /**
+ * get_object
+ * This takes a type and an ID and returns a created object
+ */
+ public static function get_object($type,$object_id) {
+
+ $allowed_objects = array('song','genre','album','artist','radio');
+
+ if (!in_array($type,$allowed_objects)) {
+ return false;
+ }
+
+ $object = new $type($object_id);
+
+ return $object;
+
+ } // get_object
+
+ /**
+ * get_image
+ * This returns an image tag if the type of object we're currently rolling with
+ * has an image assoicated with it
+ */
+ public function get_image() {
+
+ switch ($this->object_type) {
+ case 'album':
+ $image_string = "<img height=\"75\" width=\"75\" src=\"" . Config::get('web_path') . "/image.php?id=" . $this->object_id . "&amp;thumb=1\" />";
+ break;
+ case 'artist':
+
+ break;
+ case 'song':
+ $song = new Song($this->object_id);
+ $image_string = "<img height=\"75\" width=\"75\" src=\"" . Config::get('web_path') . "/image.php?id=" . $song->album . "&amp;thumb=1\" />";
+ break;
+ default:
+ // Rien a faire
+ break;
+ } // end switch
+
+ return $image_string;
+
+ } // get_image
+
+ /**
+ * create
+ * This takes a key'd array of data as input and inserts a new shoutbox entry, it returns the auto_inc id
+ */
+ public static function create($data) {
+
+ $user = Dba::escape($GLOBALS['user']->id);
+ $text = Dba::escape(strip_tags($data['comment']));
+ $date = time();
+ $sticky = make_bool($data['sticky']);
+ $object_id = Dba::escape($data['object_id']);
+ $object_type = Dba::escape($data['object_type']);
+
+ $sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`) " .
+ "VALUES ('$user','$date','$text','$sticky','$object_id','$object_type')";
+ $db_results = Dba::query($sql);
+
+ $insert_id = Dba::insert_id();
+
+ return $insert_id;
+
+ } // create
+
+} // shoutBox class
+?>
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index f8d34c5c..1755aa11 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -620,6 +620,9 @@ class User {
if (!$this->create_date) { $this->f_create_date = _('Unknown'); }
else { $this->f_create_date = date("m\/d\/Y - H:i",$this->create_date); }
+ // Base link
+ $this->f_link = '<a href="' . Config::get('web_path') . '/stats.php?action=show_user&user_id=' . $this->id . '">' . $this->fullname . '</a>';
+
/* Calculate their total Bandwidth Useage */
$sql = "SELECT `song`.`size` FROM `song` LEFT JOIN `object_count` ON `song`.`id`=`object_count`.`object_id` " .
"WHERE `object_count`.`user`='$this->id' AND `object_count`.`object_type`='song'";
diff --git a/shout.php b/shout.php
new file mode 100644
index 00000000..ba7ba796
--- /dev/null
+++ b/shout.php
@@ -0,0 +1,50 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+require_once 'lib/init.php';
+
+show_header();
+
+// Switch on the incomming action
+switch ($_REQUEST['action']) {
+ case 'add_shout':
+ // Must be at least a user to do this
+ if (!Access::check('interface','25')) {
+ access_denied();
+ exit;
+ }
+
+ $shout_id = shoutBox::create($_POST);
+
+ break;
+ case 'show_add_shout':
+ // Get our object first
+ $object = shoutBox::get_object($_REQUEST['type'],$_REQUEST['id']);
+
+ // Now go ahead and display the page where we let them add a comment etc
+ require_once Config::get('prefix') . '/templates/show_add_shout.inc.php';
+ break;
+ default:
+
+ break;
+} // end switch on action
+
+show_footer();
+?>
diff --git a/templates/show_add_shout.inc.php b/templates/show_add_shout.inc.php
new file mode 100644
index 00000000..9d1ead88
--- /dev/null
+++ b/templates/show_add_shout.inc.php
@@ -0,0 +1,46 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; version 2
+ of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+<?php show_box_top(_('Post to Shoutbox')); ?>
+<form method="post" enctype="multipart/form-data" action="<?php echo Config::get('web_path'); ?>/shout.php?action=add_shout">
+<table class="tabledata" cellpadding="0" cellspacing="0">
+<tr>
+ <td><strong>Comment:</strong>
+</tr>
+<tr>
+ <td><textarea rows="5" cols="70" name="comment"></textarea></td>
+</tr>
+<?php if (Access::check('interface','50')) { ?>
+<tr>
+ <td><input type="checkbox" name="sticky" value="0" /> <strong><?php echo _('Make Sticky'); ?></strong></td>
+</tr>
+<?php } ?>
+<tr>
+ <td>
+ <input type="hidden" name="object_id" value="<?php echo $object->id; ?>" />
+ <input type="hidden" name="object_type" value="<?php echo strtolower(get_class($object)); ?>" />
+ <input type="submit" value="<?php echo _('Create'); ?>" />
+ </td>
+</tr>
+</table>
+</form>
+<?php show_box_bottom(); ?>
diff --git a/templates/show_album_row.inc.php b/templates/show_album_row.inc.php
index 791f7b8a..338ebf01 100644
--- a/templates/show_album_row.inc.php
+++ b/templates/show_album_row.inc.php
@@ -35,12 +35,17 @@
<td class="cel_songs"><?php echo $album->song_count; ?></td>
<td class="cel_year"><?php echo $album->year; ?></td>
<td class="cel_action">
+ <?php if (Config::get('shoutbox')) { ?>
+ <a href="<?php echo Config::get('web_path'); ?>/shout.php?action=show_add_shout&amp;type=album&amp;id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('comment',_('Post Shout')); ?>
+ </a>
+ <?php } ?>
<?php if (Access::check_function('batch_download')) { ?>
<a href="<?php echo Config::get('web_path'); ?>/batch.php?action=album&amp;id=<?php echo $album->id; ?>">
<?php echo get_user_icon('batch_download',_('Batch Download')); ?>
</a>
<?php } ?>
- <?php if ($GLOBALS['user']->has_access('50')) { ?>
+ <?php if (Access::check('interface','50')) { ?>
<?php echo Ajax::button('?action=show_edit_object&type=album&id=' . $album->id,'edit',_('Edit'),'edit_album_' . $album->id); ?>
<?php } ?>
</td>
diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php
index 3e656024..5dbdf08b 100644
--- a/templates/show_index.inc.php
+++ b/templates/show_index.inc.php
@@ -28,13 +28,25 @@ if (isset($_REQUEST['xspf']) && isset ($_REQUEST['play_info'])){
<div id="now_playing">
<?php show_now_playing(); ?>
</div> <!-- Close Now Playing Div -->
-<!-- Recently Played -->
+<!-- Sticky Objects, if sticky is enabled -->
+<?php if (Config::get('shoutbox')) { ?>
+<div id="shout_objects">
+ <?php
+ $shouts = shoutBox::get_top('5');
+ if (count($shouts)) {
+ require_once Config::get('prefix') . '/templates/show_shoutbox.inc.php';
+ }
+ ?>
+</div>
+<?php } ?>
+<!-- Randomly selected albums of the moment -->
<div id="random_selection">
<?php
$albums = get_random_albums('6');
if (count($albums)) { require_once Config::get('prefix') . '/templates/show_random_albums.inc.php'; }
?>
</div>
+<!-- Recently Played -->
<div id="recently_played">
<?php
$data = get_recently_played();
diff --git a/templates/show_recently_played.inc.php b/templates/show_recently_played.inc.php
index f35f64cf..b3b91020 100644
--- a/templates/show_recently_played.inc.php
+++ b/templates/show_recently_played.inc.php
@@ -86,6 +86,7 @@ $time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days a
</tr>
<?php } ?>
<tr class="th-bottom">
+ <th class="cel_add"><?php echo _('Add'); ?></th>
<th class="cel_username"><?php echo _('Username'); ?></th>
<th class="cel_song"><?php echo _('Song'); ?></th>
<th class="cel_album"><?php echo _('Album'); ?></th>
diff --git a/templates/show_shoutbox.inc.php b/templates/show_shoutbox.inc.php
new file mode 100644
index 00000000..8274f716
--- /dev/null
+++ b/templates/show_shoutbox.inc.php
@@ -0,0 +1,44 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+<?php show_box_top(_('Shoutbox')); ?>
+<table class="tabledata" cellpadding="0" cellspacing="0">
+<?php foreach ($shouts as $shout_id) {
+ $shout = new shoutBox($shout_id);
+ $object = shoutBox::get_object($shout->object_type,$shout->object_id);
+ $object->format();
+ $client = new User($shout->user);
+ $client->format();
+?>
+<tr>
+ <td class="cel_image">
+ <?php echo $shout->get_image(); ?><br />
+ <strong><?php echo ucfirst($shout->object_type); ?>:</strong> <?php echo $object->f_link; ?><br />
+ </td>
+ <td valign="top" class="cel_comment">
+ <?php echo scrub_out($shout->text); ?>
+ <br />
+ <span class="information">- <?php echo $client->f_link; ?> <?php echo date("d/m/Y H:i",$shout->date); ?></span>
+ </td>
+</tr>
+<?php } ?>
+</table>
+<?php show_box_bottom(); ?>
diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php
index fb3b69ae..1cf863e9 100644
--- a/templates/show_song_row.inc.php
+++ b/templates/show_song_row.inc.php
@@ -32,13 +32,17 @@
<td class="cel_rating" id="rating_<?php echo $song->id; ?>_song"><?php Rating::show($song->id,'song'); ?></td>
<?php } ?>
<td class="cel_action">
+ <?php if (Config::get('shoutbox')) { ?>
+ <a href="<?php echo Config::get('web_path'); ?>/shout.php?action=show_add_shout&amp;type=song&amp;id=<?php echo $song->id; ?>">
+ <?php echo get_user_icon('comment',_('Post Shout')); ?>
+ </a>
+ <?php } ?>
<?php if ($GLOBALS['user']->prefs['download']) { ?>
<a href="<?php echo Config::get('web_path'); ?>/stream.php?action=download&amp;song_id=<?php echo $song->id; ?>">
<?php echo get_user_icon('download',_('Download')); ?>
</a>
<?php } ?>
-
- <?php if ($GLOBALS['user']->has_access(100)) { ?>
- <?php echo Ajax::button('?action=show_edit_object&type=song&id=' . $song->id,'edit',_('Edit'),'edit_song_' . $song->id); ?>
+ <?php if (Access::check('interface','75')) { ?>
+ <?php echo Ajax::button('?action=show_edit_object&type=song&id=' . $song->id,'edit',_('Edit'),'edit_song_' . $song->id); ?>
<?php } ?>
</td>
diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css
index b45857ee..80e09acf 100644
--- a/themes/classic/templates/default.css
+++ b/themes/classic/templates/default.css
@@ -687,7 +687,7 @@ a.button{padding:1px 3px;}
text-indent:-9999em;
}
-.information {
+.information,.information a {
font-size: 0.9em;
font-style: italic;
color: #c0c0c0;