root/trunk/artists.php

Revision 1748, 6.3 kB (checked in by vollmerk, 2 months ago)

Commit, still no internet paying for it.. curse you free.fr

Line 
1<?php
2/*
3
4 Copyright (c) Ampache.org
5 All Rights Reserved
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License v2
9 as published by the Free Software Foundation.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20*/
21
22require_once 'lib/init.php';
23
24show_header(); 
25
26/**
27 * Display Switch
28 */
29switch($_REQUEST['action']) {
30        case 'show':
31                $artist = new Artist($_REQUEST['artist']);
32                $artist->format(); 
33                $object_ids = $artist->get_albums(); 
34                $object_type = 'album'; 
35                require_once Config::get('prefix') . '/templates/show_artist.inc.php';
36                break;
37        case 'show_all_songs':
38                $artist = new Artist($_REQUEST['artist']);
39                $artist->format();
40                $object_type = 'song'; 
41                $object_ids = $artist->get_songs(); 
42                require_once Config::get('prefix') . '/templates/show_artist.inc.php';
43        break;
44        case 'update_from_tags':
45
46                $type           = 'artist'; 
47                $object_id      = intval($_REQUEST['artist']); 
48                $target_url     = Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $object_id; 
49                require_once Config::get('prefix') . '/templates/show_update_items.inc.php'; 
50        break;
51        case 'rename_similar':
52                if (!$user->has_access('100')) { access_denied(); }
53                $count = 0;
54                if (isset($_REQUEST['artist']) && is_numeric($_REQUEST['artist']) && isset($_REQUEST['artists']) && is_array($_REQUEST['artists'])) {
55                        $artist = new Artist($_REQUEST['artist']);
56                        if ($artist->id)
57                        foreach ($_REQUEST['artists'] as $artist_id) {
58                                if (is_numeric($artist_id)) {
59                                        $that_artist = new Artist($artist_id);
60                                        if ($that_artist->id) {
61                                                $that_artist->merge($artist->id);
62                                                $count++;
63                                        } else
64                                                $GLOBALS['error']->add_error('general',"Error: No such artist '$artist_id'");
65                                } else {
66                                        $GLOBALS['error']->add_error('general',"Error: '$artist_id' is not a valid ID");
67                                }
68                        }
69                        else
70                                $GLOBALS['error']->add_error('general',"Error: No such artist '" . $_REQUEST['artist'] . "'");
71                } else {
72                        $GLOBALS['error']->add_error('general',"Error: Errenous request");
73                }
74                if ($count > 0) {
75                        show_confirmation (
76                                "Renamed artist(s)",
77                                "$count artists have been merged with " . $artist->name,
78                                conf('web_path') . "/artists.php?action=show&artist=" . $artist->id
79                        );
80                } else {
81                        $GLOBALS['error']->print_error('general');
82                }
83               
84        break;
85        case 'show_similar':
86                if (!$GLOBALS['user']->has_access('75')) { 
87                        access_denied(); 
88                        exit; 
89                }
90               
91                $artist = new Artist($_REQUEST['artist']);
92                //options
93                $similar_artists = $artist->get_similar_artists(
94                                                make_bool($_POST['n_rep_uml']),
95                                                $_POST['n_filter'],
96                                                $_POST['n_ignore'],
97                                                $_POST['c_mode'],
98                                                $_POST['c_count_w'],
99                                                $_POST['c_percent_w'],
100                                                $_POST['c_distance_l'],
101                                                make_bool($_POST['c_ignins_l']));
102                $artist_id = $artist->id;
103                $artist_name = $artist->name;
104                require Config::get('prefix') . '/templates/show_similar_artists.inc.php';
105                 
106        break;
107        case 'rename':
108                //die if not enough permissions
109                if (!$user->has_access('100')) { access_denied(); }
110                       
111                /* Get the artist */
112                $artist = new Artist($_REQUEST['artist']);
113                $catalog = new Catalog();
114               
115                //check if we've been given a target
116                if ((isset($_POST['artist_id']) && $_POST['artist_id'] != $artist->id ) || (isset($_POST['artist_name']) &&  $_POST['artist_name'] != "")) {
117               
118                        //if we want to update id3 tags, then get the array of ids now, it's too late afterwards
119                        if (make_bool($_POST['update_id3']))
120                                $songs = $artist->get_songs(); 
121                       
122                        $ret = 0;
123                        //the manual rename takes priority, but if they tested out the insert thing ignore
124                        if ($_POST['artist_name'] != "" && $_POST['artist_name'] != $artist->name) {
125                                //then just change the name of the artist in the db
126                                $ret = $artist->rename($_POST['artist_name']);
127                                $newid = $ret;
128                                $newname = $_POST['artist_name'];
129                        }
130                        //new id?
131                        elseif ($_POST['artist_id'] != $artist->id) {
132                                //merge with other artist
133                                $ret = $artist->merge($_POST['artist_id']);
134                                $newid = $_POST['artist_id'];
135                                $newname = $ret;
136                        } // elseif different artist and id
137                        //if no changes, no changes
138                       
139                        //now flag for id3tag update if selected, and something actually happaned
140                        if ($ret && make_bool($_POST['update_id3'])) {
141                       
142                                /* Set the rename information in the db */
143                                foreach ($songs as $song) {
144                                        $flag = new Flag();
145                                        $flag->add($song->id,"song","retag","Renamed artist, retag");
146                                        $flag_qstring = "REPLACE INTO flagged " . 
147                                                "SET type = 'setid3', song = '" . $song->id . "', date = '" . time() . "', user = '" . $GLOBALS['user']->username . "'";
148                                        mysql_query($flag_qstring, dbh()); 
149                                }
150                               
151                        } // end if they wanted to update
152                       
153                        // show something other than a blank screen after this                 
154                        if ($ret) {
155                                show_confirmation (
156                                        "Renamed artist",
157                                        $artist->name . " is now known as " . $newname,
158                                        conf('web_path') . "/artists.php?action=show&artist=" . $newid
159                                );
160                        }
161               
162                }  // if we've got the needed variables
163
164                /* Else we've got an error! But be lenient, and just show the form again */
165                else { 
166                        require (conf('prefix') . '/templates/show_rename_artist.inc.php');
167                }
168        break; 
169        case 'show_rename':
170                $artist = new Artist($_REQUEST['artist']);
171                require (conf('prefix') . '/templates/show_rename_artist.inc.php'); 
172        break;
173        case 'match':
174        case 'Match':
175                $match = scrub_in($_REQUEST['match']);
176                if ($match == "Browse" || $match == "Show_all") { $chr = ""; }
177                else { $chr = $match; } 
178                /* Enclose this in the purty box! */
179                require (conf('prefix') . '/templates/show_box_top.inc.php'); 
180                show_alphabet_list('artists','artists.php',$match);
181                show_alphabet_form($chr,_('Show Artists starting with'),"artists.php?action=match");
182                require (conf('prefix') . '/templates/show_box_bottom.inc.php');
183
184                if ($match === "Browse") {
185                        show_artists();
186                }
187                elseif ($match === "Show_all") {
188                        $offset_limit = 999999;
189                        show_artists();
190                }               
191                else {
192                        if ($chr == '') {
193                                show_artists('A');
194                        }
195                        else {
196                                show_artists($chr);
197                        }
198                }
199        break; 
200} // end switch
201
202show_footer();
203?>
Note: See TracBrowser for help on using the browser.