From 8448a0fc84ba25e6fd949b8162e3d1c96948d808 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 17 Dec 2007 05:26:11 +0000 Subject: added shoutbox functionality, only linked from song and album right now also interface for adding could use some improvement and also needs some management stuff to remove stickies etc --- config/ampache.cfg.php.dist | 8 ++ docs/CHANGELOG | 3 + images/icon_comment.png | Bin 0 -> 413 bytes lib/class/shoutbox.class.php | 177 +++++++++++++++++++++++++++++++++ lib/class/user.class.php | 3 + shout.php | 50 ++++++++++ templates/show_add_shout.inc.php | 46 +++++++++ templates/show_album_row.inc.php | 7 +- templates/show_index.inc.php | 14 ++- templates/show_recently_played.inc.php | 1 + templates/show_shoutbox.inc.php | 44 ++++++++ templates/show_song_row.inc.php | 10 +- themes/classic/templates/default.css | 2 +- 13 files changed, 359 insertions(+), 6 deletions(-) create mode 100644 images/icon_comment.png create mode 100644 lib/class/shoutbox.class.php create mode 100644 shout.php create mode 100644 templates/show_add_shout.inc.php create mode 100644 templates/show_shoutbox.inc.php 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 Binary files /dev/null and b/images/icon_comment.png 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 @@ +_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 = ""; + break; + case 'artist': + + break; + case 'song': + $song = new Song($this->object_id); + $image_string = ""; + 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 = '' . $this->fullname . ''; + /* 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 @@ + 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 @@ + + +
+ + + + + + + + + + + + + + +
Comment: +
+ + + +
+
+ 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 @@ song_count; ?> year; ?> + + + + + - has_access('50')) { ?> + id,'edit',_('Edit'),'edit_album_' . $album->id); ?> 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'])){
- + + +
+ +
+ +
+
+ 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 @@ + + + +object_type,$shout->object_id); + $object->format(); + $client = new User($shout->user); + $client->format(); +?> + + + + + +
+ get_image(); ?>
+ object_type); ?>: f_link; ?>
+
+ text); ?> +
+ - f_link; ?> date); ?> +
+ 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 @@ id,'song'); ?> + + + + + prefs['download']) { ?> - - has_access(100)) { ?> - id,'edit',_('Edit'),'edit_song_' . $song->id); ?> + + id,'edit',_('Edit'),'edit_song_' . $song->id); ?> 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; -- cgit