diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-03-13 03:15:09 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-03-13 03:15:09 +0000 |
commit | b92109a64fe2fca1520be0536f8092e2f50ef8f4 (patch) | |
tree | 9157861555c44e2135cd42e1aec3d0da28d390cd | |
parent | 8398183bf5a383cee7da656fd116457c799678f7 (diff) | |
download | ampache-b92109a64fe2fca1520be0536f8092e2f50ef8f4.tar.gz ampache-b92109a64fe2fca1520be0536f8092e2f50ef8f4.tar.bz2 ampache-b92109a64fe2fca1520be0536f8092e2f50ef8f4.zip |
put supplemental object support back into the browse object for now, replace later
-rw-r--r-- | democratic.php | 4 | ||||
-rw-r--r-- | images/icon_wand.png | bin | 0 -> 570 bytes | |||
-rw-r--r-- | lib/class/browse.class.php | 35 | ||||
-rw-r--r-- | lib/class/democratic.class.php | 17 | ||||
-rw-r--r-- | lib/class/update.class.php | 10 | ||||
-rw-r--r-- | templates/show_create_democratic.inc.php | 18 | ||||
-rw-r--r-- | templates/show_democratic.inc.php | 14 | ||||
-rw-r--r-- | templates/show_democratic_playlist.inc.php | 9 | ||||
-rw-r--r-- | templates/show_edit_user.inc.php | 24 | ||||
-rw-r--r-- | templates/show_user_row.inc.php | 59 | ||||
-rw-r--r-- | templates/show_users.inc.php | 47 |
11 files changed, 170 insertions, 67 deletions
diff --git a/democratic.php b/democratic.php index 1094f525..6bee39d5 100644 --- a/democratic.php +++ b/democratic.php @@ -31,6 +31,10 @@ show_header(); // Switch on their action switch ($_REQUEST['action']) { + case 'manage': + $democratic = Democratic::get_current_playlist(); + $democratic->set_parent(); + $democratic->format(); case 'show_create': if (!Access::check('interface','75')) { access_denied(); diff --git a/images/icon_wand.png b/images/icon_wand.png Binary files differnew file mode 100644 index 00000000..44ccbf81 --- /dev/null +++ b/images/icon_wand.png diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index 316061ab..f36c47f6 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -66,6 +66,34 @@ class Browse extends Query { } // set_simple_browse /** + * add_supplemental_object + * Legacy function, need to find a better way to do that + */ + public static function add_supplemental_object($class,$uid) { + + $_SESSION['browse']['supplemental'][$class] = intval($uid); + + return true; + + } // add_supplemental_object + + /** + * get_supplemental_objects + * This returns an array of 'class','id' for additional objects that need to be + * created before we start this whole browsing thing + */ + public static function get_supplemental_objects() { + + $objects = $_SESSION['browse']['supplemental']; + + if (!is_array($objects)) { $objects = array(); } + + return $objects; + + } // get_supplemental_objects + + + /** * show_objects * This takes an array of objects * and requires the correct template based on the @@ -89,6 +117,13 @@ class Browse extends Query { $object_ids = array_slice($object_ids,parent::get_start(),parent::get_offset(),TRUE); } + // Load any additional object we need for this + $extra_objects = self::get_supplemental_objects(); + + foreach ($extra_objects as $class_name => $id) { + ${$class_name} = new $class_name($id); + } + // Format any matches we have so we can show them to the masses if ($filter_value = parent::get_filter('alpha_match')) { $match = ' (' . $filter_value . ')'; diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php index 88bd5439..b41e1524 100644 --- a/lib/class/democratic.class.php +++ b/lib/class/democratic.class.php @@ -77,6 +77,18 @@ class Democratic extends tmpPlaylist { } // build_vote_cache /** + * is_enabled + * This function just returns true / false if the current democraitc playlist + * is currently enabled / configured + */ + public function is_enabled() { + + if ($this->tmp_playlist) { return true; } + + return false; + + } // is_enabled + /** * set_parent * This returns the tmpPlaylist for this democratic play instance */ @@ -208,7 +220,6 @@ class Democratic extends tmpPlaylist { // Extra set of data for caching! $this->object_ids[] = $results['object_id']; $this->vote_ids[] = $results['vote_id']; - $this->user_votes[$results['vote_id']][] = $results['user']; // First build a variable that holds the number of votes for an object $name = 'vc_' . $results['object_id']; @@ -226,10 +237,6 @@ class Democratic extends tmpPlaylist { $items[$primary_key][$secondary_key][$results['id']] = array('object_id'=>$results['object_id'],'object_type'=>$results['object_type'],'id'=>$results['id']); } // gather data - foreach ($this->user_votes as $key=>$data) { - parent::add_to_cache('democratic_voters',$key,$data); - } - // Sort highest voted stuff to the top krsort($items); diff --git a/lib/class/update.class.php b/lib/class/update.class.php index bab78216..e850556d 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1720,6 +1720,16 @@ class Update { $sql = "ALTER TABLE `video` ADD `update_time` INT( 11 ) UNSIGNED NULL AFTER `addition_time`"; $db_results = Dba::write($sql); + $sql = "ALTER TABLE `artist_data` ADD INDEX ( `art_mime` )"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `album_data` ADD INDEX ( `art_mime` )"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `tmp_browse` ADD `type` VARCHAR ( 255 ) NOT NULL AFTER `sid`"; + $db_results = Dba::wirte($sql); + + //self::set_version('db_version','350008'); } // update_350008 diff --git a/templates/show_create_democratic.inc.php b/templates/show_create_democratic.inc.php index 3175da2b..64bbf40f 100644 --- a/templates/show_create_democratic.inc.php +++ b/templates/show_create_democratic.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2008 Ampache.org + Copyright (c) Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -19,21 +19,22 @@ */ -show_box_top(_('Create Democratic Playlist')); ?> +show_box_top(_('Configure Democratic Playlist')); ?> <form method="post" action="<?php echo Config::get('web_path'); ?>/democratic.php?action=create" enctype="multipart/form-data"> <table class="tabledata" cellspacing="0" cellpadding="0"> <tr> <td><?php echo _('Name'); ?></td> - <td><input type="text" name="name" value="" /></td> + <td><input type="text" name="name" value="<?php echo scrub_out($democratic->name); ?>" /></td> </tr> <tr> <td><?php echo _('Base Playlist'); ?></td> - <td><?php show_playlist_select('democratic'); ?></td> + <td><?php show_playlist_select('democratic',$democratic->base_playlist); ?></td> </tr> <tr> <td><?php echo _('Cooldown Time'); ?></td> - <td><input type="text" size="4" maxlength="6" name="cooldown" value="5" /><?php echo _('minutes'); ?></td> + <td><input type="text" size="4" maxlength="6" name="cooldown" value="<?php echo $democratic->cooldown; ?>" /><?php echo _('minutes'); ?></td> </tr> +<!-- <tr> <td><?php echo _('Level'); ?></td> <td> @@ -48,9 +49,14 @@ show_box_top(_('Create Democratic Playlist')); ?> <td><?php echo _('Make Default'); ?></td> <td><input type="checkbox" name="make_default" value="1" /></td> </tr> +--> +<tr> + <td><?php echo _('Force Democratic Play'); ?></td> + <td><input type="checkbox" value="1" name="force_democratic" /></td> +</tr> </table> <div class="formValidation"> - <input type="submit" value="<?php echo _('Create'); ?>" /> + <input type="submit" value="<?php echo _('Update'); ?>" /> </div> </form> <?php show_box_bottom(); ?> diff --git a/templates/show_democratic.inc.php b/templates/show_democratic.inc.php index d3e18134..eef1a4f9 100644 --- a/templates/show_democratic.inc.php +++ b/templates/show_democratic.inc.php @@ -18,24 +18,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -show_box_top(sprintf(_('%s Playlist') ,$democratic->name)); +$string = $democratic->is_enabled() ? sprintf(_('%s Playlist') ,$democratic->name) : _('Democratic Playlist'); +show_box_top($string); ?> <div id="information_actions"> <ul> +<?php if ($democratic->is_enabled()) { ?> <li> <?php echo _('Cooldown'); ?>:<?php echo $democratic->f_cooldown; ?> </li> +<?php } ?> <?php if (Access::check('interface','75')) { ?> <li> + <a href="<?php echo Config::get('web_path'); ?>/democratic.php?action=manage"><?php echo get_user_icon('server_lightning'); ?></a> + <?php echo _('Configure Democratic Playlist'); ?> +</li> +<?php if ($democratic->is_enabled()) { ?> +<li> <?php echo Ajax::button('?page=democratic&action=send_playlist&democratic_id=' . scrub_out($democratic->id),'all',_('Play'),'play_democratic'); ?> - <?php echo _('Play'); ?> + <?php echo _('Play Democratic Playlist'); ?> </li> <li> <?php echo Ajax::button('?page=democratic&action=clear_playlist&democratic_id=' . scrub_out($democratic->id),'delete',_('Clear Playlist'),'clear_democratic'); ?> <?php echo _('Clear Playlist'); ?> </li> <?php } ?> +<?php } ?> </ul> </div> diff --git a/templates/show_democratic_playlist.inc.php b/templates/show_democratic_playlist.inc.php index 5bd34434..d19b0dba 100644 --- a/templates/show_democratic_playlist.inc.php +++ b/templates/show_democratic_playlist.inc.php @@ -67,13 +67,6 @@ $democratic->set_parent(); foreach($object_ids as $row_id=>$data) { $media = new $data['object_type']($data['object_id']); $media->format(); - $voters = $democratic->get_voters($row_id); - $voters_string = ''; - foreach ($voters as $client_id) { - $client = new User($client_id); - $voters_string .= $client->fullname . ','; - } - $voters_string = rtrim($voters_string,','); ?> <tr class="<?php echo flip_class(); ?>"> <td class="cel_action"> @@ -83,7 +76,7 @@ foreach($object_ids as $row_id=>$data) { <?php echo Ajax::button('?page=democratic&action=add_vote&object_id=' . $media->id . '&type=' . scrub_out($data['object_type']),'tick',_('Add Vote'),'remove_vote_' . $row_id); ?> <?php } ?> </td> - <td class="cel_votes" >(<?php echo scrub_out($democratic->get_vote($row_id)); ?>) <span class="information"><?php echo scrub_out($voters_string); ?></span></td> + <td class="cel_votes" >(<?php echo scrub_out($democratic->get_vote($row_id)); ?>)</td> <td class="cel_title"><?php echo $media->f_link; ?></td> <td class="cel_album"><?php echo $media->f_album_link; ?></td> <td class="cel_artist"><?php echo $media->f_artist_link; ?></td> diff --git a/templates/show_edit_user.inc.php b/templates/show_edit_user.inc.php index 3ccd7e8d..a0a7e7f7 100644 --- a/templates/show_edit_user.inc.php +++ b/templates/show_edit_user.inc.php @@ -25,6 +25,9 @@ <form name="update_user" enctype="multipart/form-data" method="post" action="<?php echo Config::get('web_path') . "/admin/users.php"; ?>"> <table class="tabledata" cellspacing="0" cellpadding="0"> <tr> + <th colspan="2"><?php echo _('User Properties'); ?></td> +</tr> +<tr> <td> <?php echo _('Username'); ?>: </td> @@ -79,6 +82,27 @@ </select> </td> </tr> +<tr> + <th colspan="2"><?php echo _('Other Options'); ?></th> +</tr> +<tr> + <td><?php echo _('Config Preset'); ?></td> + <td> + <select name="preset"> + <option value=""></option> + <option value="democratic"><?php echo _('Democratic'); ?></option> + <option value="localplay"><?php echo _('Localplay'); ?></option> + <option value="flash"><?php echo _('Flash'); ?></option> + <option value="stream"><?php echo _('Stream'); ?></option> + </select> + </td> +</tr> +<tr> + <td><?php echo _('Prevent Preset Override'); ?></td> + <td> + <input type="checkbox" value="1" name="prevent_override" /><span class="information"> <?php echo _('This Affects all non-Admin accounts'); ?></span> + </td> +</tr> </table> <div class="formValidation"> <input type="hidden" name="action" value="update_user" /> diff --git a/templates/show_user_row.inc.php b/templates/show_user_row.inc.php new file mode 100644 index 00000000..feb5895b --- /dev/null +++ b/templates/show_user_row.inc.php @@ -0,0 +1,59 @@ +<?php +/* + + Copyright (c) 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. + +*/ +?> + <td class="cel_username"> + <a href="<?php echo $web_path; ?>/stats.php?action=show_user&user_id=<?php echo $client->id; ?>"> + <?php echo $client->fullname; ?> (<?php echo $client->username; ?>) + </a> + </td> + <td class="cel_lastseen"><?php echo $last_seen; ?></td> + <td class="cel_registrationdate"><?php echo $create_date; ?></td> + <td class="cel_activity"><?php echo $client->f_useage; ?></td> + <?php if (Config::get('track_user_ip')) { ?> + <td class="cel_lastip"> + <a href="<?php echo $web_path; ?>/admin/users.php?action=show_ip_history&user_id=<?php echo $client->id; ?>"> + <?php echo $client->ip_history; ?> + </a> + </td> + <?php } ?> + <td class="cel_action"> + <a href="<?php echo $web_path; ?>/admin/users.php?action=show_edit&user_id=<?php echo $client->id; ?>"><?php echo get_user_icon('edit'); ?></a> + <a href="<?php echo $web_path; ?>/admin/users.php?action=show_preferences&user_id=<?php echo $client->id; ?>"><?php echo get_user_icon('preferences'); ?></a> + <?php + //FIXME: Fix this for the extra permission levels + if ($client->disabled == '1') { + echo "<a href=\"".$web_path."/admin/users.php?action=enable&user_id=$client->id\">" . get_user_icon('enable') . "</a>"; + } + else { + echo "<a href=\"".$web_path."/admin/users.php?action=disable&user_id=$client->id\">" . get_user_icon('disable') ."</a>"; + } + ?> + <a href="<?php echo $web_path; ?>/admin/users.php?action=delete&user_id=<?php echo $client->id; ?>"><?php echo get_user_icon('delete'); ?></a> + </td> + <?php + if (($client->is_logged_in()) AND ($client->is_online())) { + echo "<td class=\"cel_online user_online\"> </td>"; + } elseif ($client->disabled == 1) { + echo "<td class=\"cel_online user_disabled\"> </td>"; + } else { + echo "<td class=\"cel_online user_offline\"> </td>"; + } +?> diff --git a/templates/show_users.inc.php b/templates/show_users.inc.php index 3cf4ad5a..50aac95a 100644 --- a/templates/show_users.inc.php +++ b/templates/show_users.inc.php @@ -53,51 +53,8 @@ foreach ($object_ids as $user_id) { $last_seen = $client->last_seen ? date("m\/d\/Y - H:i",$client->last_seen) : _('Never'); $create_date = $client->create_date ? date("m\/d\/Y - H:i",$client->create_date) : _('Unknown'); ?> -<tr class="<?php echo flip_class(); ?>" align="center"> - <td class="cel_username"> - <a href="<?php echo $web_path; ?>/stats.php?action=show_user&user_id=<?php echo $client->id; ?>"> - <?php echo $client->fullname; ?> (<?php echo $client->username; ?>) - </a> - </td> - <td class="cel_lastseen"><?php echo $last_seen; ?></td> - <td class="cel_registrationdate"><?php echo $create_date; ?></td> - <td class="cel_activity"><?php echo $client->f_useage; ?></td> - <?php if (Config::get('track_user_ip')) { ?> - <td class="cel_lastip"> - <a href="<?php echo $web_path; ?>/admin/users.php?action=show_ip_history&user_id=<?php echo $client->id; ?>"> - <?php echo $client->ip_history; ?> - </a> - </td> - <?php } ?> - <td class="cel_action"> - <a href="<?php echo $web_path; ?>/admin/users.php?action=show_edit&user_id=<?php echo $client->id; ?>"> - <?php echo get_user_icon('edit'); ?> - </a> - <a href="<?php echo $web_path; ?>/admin/users.php?action=show_preferences&user_id=<?php echo $client->id; ?>"> - <?php echo get_user_icon('preferences'); ?> - </a> - <?php - //FIXME: Fix this for the extra permission levels - if ($client->disabled == '1') { - echo "<a href=\"".$web_path."/admin/users.php?action=enable&user_id=$client->id\">" . get_user_icon('enable') . "</a>"; - } - else { - echo "<a href=\"".$web_path."/admin/users.php?action=disable&user_id=$client->id\">" . get_user_icon('disable') ."</a>"; - } - ?> - <a href="<?php echo $web_path; ?>/admin/users.php?action=delete&user_id=<?php echo $client->id; ?>"> - <?php echo get_user_icon('delete'); ?> - </a> - </td> - <?php - if (($client->is_logged_in()) AND ($client->is_online())) { - echo "<td class=\"cel_online user_online\"> </td>"; - } elseif ($client->disabled == 1) { - echo "<td class=\"cel_online user_disabled\"> </td>"; - } else { - echo "<td class=\"cel_online user_offline\"> </td>"; - } -?> +<tr class="<?php echo flip_class(); ?>" align="center" id="admin_user_<?php echo $client->id; ?>"> + <?php require Config::get('prefix') . '/templates/show_user_row.inc.php'; ?> </tr> <?php } //end foreach users ?> <tr class="th-bottom"> |