root/trunk/preferences.php

Revision 1657, 3.6 kB (checked in by vollmerk, 5 months ago)

fixed a preferences issue due to a typo and updated german translation

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 'lib/init.php';
23
24// Switch on the action
25switch($_REQUEST['action']) { 
26        case 'update_preferences':
27                if ($_REQUEST['method'] == 'admin' && !Access::check('interface','100')) { 
28                        access_denied(); 
29                        exit; 
30                } 
31
32                if (!Core::form_verify('update_preference','post')) { 
33                        access_denied(); 
34                        exit; 
35                } 
36               
37                /* Reset the Theme */
38                if ($_REQUEST['method'] == 'admin') { 
39                        $user_id = '-1'; 
40                        $fullname = _('Server'); 
41                        $_REQUEST['action'] = 'admin'; 
42                }
43                else { 
44                        $user_id = $GLOBALS['user']->id; 
45                        $fullname = $GLOBALS['user']->fullname; 
46                } 
47
48                /* Update and reset preferences */
49                update_preferences($user_id);   
50                Preference::init();
51
52                $preferences = $GLOBALS['user']->get_preferences($user_id,$_REQUEST['tab']);           
53        break;
54        case 'admin_update_preferences': 
55                // Make sure only admins here
56                if (!Access::check('interface','100')) { 
57                        access_denied(); 
58                        exit; 
59                } 
60
61                if (!Core::form_verify('update_preference','post')) {
62                        access_denied();
63                        exit;
64                }
65
66                update_preferences($_REQUEST['user_id']); 
67                header("Location: " . Config::get('web_path') . "/admin/users.php?action=show_preferences&user_id=" . scrub_out($_REQUEST['user_id'])); 
68        break;
69        case 'admin': 
70                // Make sure only admins here
71                if (!Access::check('interface','100')) { 
72                        access_denied(); 
73                        exit;
74                } 
75                $fullname= _('Server');
76                $preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']); 
77        break;
78        case 'user':
79                if (!Access::check('interface','100')) { 
80                        access_denied(); 
81                        exit; 
82                } 
83                $client = new User($_REQUEST['user_id']); 
84                $fullname = $client->fullname; 
85                $preferences = $client->get_preferences(0,$_REQUEST['tab']); 
86        break; 
87        case 'update_user': 
88                // Make sure we're a user and they came from the form
89                if (!Access::check('interface','25')) { 
90                        access_denied(); 
91                        exit; 
92                } 
93
94                if (!Core::form_verify('update_user','post')) {
95                        access_denied();
96                        exit;
97                }
98
99                // Remove the value
100                unset($_SESSION['forms']['account']); 
101
102                // Don't let them change access, or username here
103                unset($_POST['access']); 
104                $_POST['username'] = $GLOBALS['user']->username; 
105
106                if (!$GLOBALS['user']->update($_POST)) { 
107                        Error::add('general',_('Error Update Failed')); 
108                } 
109                else { 
110                        $_REQUEST['action'] = 'confirm'; 
111                        $title = _('Updated'); 
112                        $text = _('Your Account has been updated'); 
113                        $next_url = Config::get('web_path') . '/preferences.php?tab=account'; 
114                } 
115        break;
116        default: 
117                $fullname = $GLOBALS['user']->fullname; 
118                $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']); 
119        break;
120} // End Switch Action
121
122show_header(); 
123
124/**
125 * switch on the view
126 */
127switch ($_REQUEST['action']) { 
128        case 'confirm': 
129                show_confirmation($title,$text,$next_url,$cancel); 
130        break;
131        default: 
132                // Show the default preferences page
133                require Config::get('prefix') . '/templates/show_preferences.inc.php';
134        break;
135} // end switch on action
136
137show_footer();
138?>
Note: See TracBrowser for help on using the browser.