Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/views/users/edit.thtml
blob: 30302647f07b16374c50fafc46ac5c01871f6e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is addons.mozilla.org site.
 *
 * The Initial Developer of the Original Code is
 * The Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2006
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Frederic Wenzel <fwenzel@mozilla.com> (Original Author)
 *   Wil Clouser <clouserw@mozilla.com>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */


/* Prepare translation box element */
// Retrieve language arrays from bootstrap.
global $valid_languages, $native_languages;
foreach (array_keys($valid_languages) as $key) {
    $languages[$key] = $native_languages[$key]['native'];
}
ksort($languages);
$this->translationBox = array(
    'defaultLocale' => LANG,
    'languages' => $languages,
    'table' => 'User',
    'loaded' => false
);
?>

<div class="secondary" role="complementary">
    <?=$this->renderElement('amo2009/categories')?>
</div>

<div class="primary" role="main">
    <?=$this->renderElement('amo2009/search')?>

<?php if (isset($confirmation_page) && $confirmation_page): ?>

    <?= $this->renderElement('notification', array('type' => 'success', 'msg' => $confirmation_message))?>

    <?php if (isset($newemail) && $newemail): ?>
        <?= $this->renderElement('notification', array('type' => 'success', 'description' => sprintf(___('An email has been sent to %1$s to confirm your new email address. For the change to take effect, you need to click on the link provided in this email. Until then, you can keep logging in with your current email address.'), $newemail)));?>
    <?php endif; ?>

<?php endif; ?>

<?php if(isset($errorMessage)): ?>
    <?= $this->renderElement('notification', array('type' => 'error', 'msg' => ___('There are errors in this form. Please correct them and resubmit.')));?>
<p></p>
<?php endif; ?>


<h1><?php printf(___('Edit user profile for %s'), $this->data['User']['email']); ?></h1>

<form enctype="multipart/form-data" action="<?=$html->entities($html->url())?>" method="post" class="amo-form" id="profile-user-form">
    <?=$html->hiddenSession() ?>

<div id="tabbed-editor" class="flora">
    <ul class="tabs-nav">
        <li><a href="#profile-user"><span><?=___('User Profile');?></span></a></li>
        <li><a href="#profile-collections"><span><?=___('Collections', 'user_tab_collections');?></span></a></li>
        <li><a href="#profile-notifications"><span><?=___('Notifications');?></span></a></li>
        <li><a href="#profile-change-pw-email"><span><?=___('Change Password or Email'); ?></span></a></li>
        <li><a href="#profile-other"><span><?=___('Other Actions');?></span></a></li>
    </ul>

    <div id="profile-user">
        <h3 class="hidden"><?=___('User Profile');?></h3>
        <div class="line">
            <label class="amo-label-large" for="UserFirstname"><?=___('First name')?></label>
            <?=$html->input('User/firstname') ?>
            <?=$html->tagErrorMsg('User/firstname', ___('This field must not be empty.'))?>
            <?=___('A first name, last name or nickname is required.')?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserLastname"><?=___('Last name')?></label>
            <?=$html->input('User/lastname') ?>
            <?=$html->tagErrorMsg('User/lastname', ___('This field must not be empty.'))?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserNickname"><?=___('Nickname')?></label>
            <?=$html->input('User/nickname') ?>
            <?=$html->tagErrorMsg('User/nickname', ___('This nickname is already taken.'))?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserLocation"><?=___('Location', 'user_form_location')?></label>
            <?=$html->input('User/location') ?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserOccupation"><?=___('Occupation', 'user_form_occupation')?></label>
            <?=$html->input('User/occupation') ?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserHomepage"><?=___('Website URL')?></label>
            <?=$html->input('User/homepage') ?>
            <?=$html->tagErrorMsg('User/homepage', ___('This URL has an invalid format. Valid URLs look like http://example.com/my_page.'))?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserEmailhidden"><?=___('Hide email address')?></label>
            <?=$html->checkBox('User/emailhidden') ?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserPictureData"><?=___('Picture')?></label>
            <div class="edit-picture">
                <img src="<?=$html->url("/user/{$user_id}/picture?{$this->data['User']['picture_hash']}{$_how_much_cake_sucks_on_a_scale_of_1_to_10}")?>" alt="<?=empty($this->data['User']['picture_data']) ? ___('No photo') : sprintf(___('Picture of %1$s'), $this->data['User']['email'])?>" class="avatar photo-large photo" />
                <br />
                <?php if(!empty($this->data['User']['picture_data'])): ?>
                    <label for="UserRemovepicture"><?=___('Remove this picture?')?></label>
                    <?=$html->checkBox('User/removepicture') ?><br />
                <?php endif; ?>
                <label for="UserRemovepicture"><?=___('Upload a new picture?')?></label>
                <?=$html->file('User/picture_data') ?>
                <?=$html->tagErrorMsg('User/picture_data', @$picture_error)?>
            </div>
        </div>
        <div class="line clearboth">
            <?php
            echo $this->renderElement('translationbox', array(
                'field' => 'bio',
                'translations' => $translations['bio'],
                'height' => '100',
                'maxLength' => '500',
                'displayName' => ___('About me'),
                'description' => ___('Introduce yourself to the community, if you like! This text will appear publicly on your user info page. Line breaks will be preserved, but no HTML is allowed.'),
            ));
            ?>
        </div>
    </div>

    <div id="profile-collections">
        <h3 class="hidden"><?=___('Collections', 'user_tab_collections');?></h3>
        <div class="line">
            <?=$html->checkbox('User/display_collections') ?>
            <label for="UserDisplayCollections"><?=___('Display the collections I have created in my user profile')?></label>
        </div>
        <div class="line">
            <?=$html->checkbox('User/display_collections_fav') ?>
            <label for="UserDisplayCollectionsFav"><?=___('Display my favorite collections in my user profile')?></label>
        </div>
    </div>

    <div id="profile-notifications">
        <h3 class="hidden"><?=___('Notifications');?></h3>
        <?php if (empty($userAddons) && empty($userVersionThreads)): ?>
            <p><?=___('There are currently no notifications available for you to configure.')?></p>
        <?php endif; ?>
        <?php if (!empty($userAddons)): ?>
            <p><?=___('From time to time, Mozilla may send you email about upcoming releases and add-on events. Please select the topics you are interested in below:')?></p>
            <ul>
                <li><label for="UserNotifycompat"><?=$html->checkbox('User/notifycompat')?>&nbsp;<?=___('Add-on Compatibility (strongly recommended)')?></label></li>
                <li><label for="UserNotifyevents"><?=$html->checkbox('User/notifyevents')?>&nbsp;<?=___('Upcoming events and contests')?></label></li>
            </ul>

            <p><?=___('Mozilla reserves the right to contact you individually about specific concerns with your hosted add-ons.')?></p>
        <?php endif; ?>
        <?php if (!empty($userVersionThreads)): ?>
            <div class="line">
                <div class="graybox rounded spaced">
                    <h4><?=___('Editor Review Discussions')?></h4>
                    <p><?=___('You will be notified when there is activity in any of the following discussions. Please uncheck those you wish to unsubscribe from.')?></p>

                    <table id="editor-subscriptions">
                    <thead>
                        <tr>
                            <th><?php /* jquery will add a check/uncheck all box here */ ?></th>
                            <th><?=___('Add-on', 'user_notifications_th_addon')?></th>
                            <th><?=___('Subject', 'user_notifications_th_subject')?></th>
                            <th><?=___('Subscription Date')?></th>
                        </tr>
                    </thead>
                    <tbody><?php foreach ($userVersionThreads as $thread): ?>
                        <tr>
                            <td><?=$html->checkbox("Subscriptions/{$thread['Subscription']['comment_id']}", null, array('value' => '1'))?></td>
                            <td><label for="Subscriptions<?=$thread['Subscription']['comment_id']?>"><?=$thread['Addon']['Translation']['name']['string']?> <?=$thread['Version']['version']?></label></td>
                            <td><?=$html->link($thread['Versioncomment']['subject'], "/editors/review/{$thread['Version']['id']}#editorComment{$thread['Versioncomment']['id']}")?></td>
                            <td><?=strftime(___('%B %e, %Y, %I:%M %p'), strtotime($thread['Subscription']['modified']))?></td>
                        </tr><?php endforeach; ?>
                    </tbody>
                    </table>
                </div>
            </div>
        <?php endif; ?>
    </div>

    <div id="profile-change-pw-email">
        <h3><?=___('Change password'); ?></h3>
        <div class="line">
            <label class="amo-label-large" for="UserPassword"><?=___('Old password')?></label>
            <?=$html->password('User/password', array('autocomplete'=>'off')) ?>
            <?=$html->tagErrorMsg('User/password', ___('Wrong password entered!'))?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserNewpassword"><?=___('New password')?></label>
            <?=$html->password('User/newpassword', array('autocomplete'=>'off')) ?>
            <?=$html->tagErrorMsg('User/newpassword', 'error_field_required')?>
        </div>
        <div class="line">
            <label class="amo-label-large" for="UserConfirmpw"><?=___('Confirm password')?></label>
            <?=$html->password('User/confirmpw', array('autocomplete'=>'off')) ?>
            <?=$html->tagErrorMsg('User/confirmpw', ___('The passwords did not match.'))?>
        </div>
        <h3><?=___('Change Email Address');?></h3>
        <div class="line">
            <label class="amo-label-large" for="UserEmail"><?=___('Email address', 'user_form_email')?></label>
            <?=$html->input('User/email') ?>
            <?php if (isset($error_email_notunique))
                    echo '<div class="error_message">'.___('This email address is already taken by another user.').'</div>';
                elseif (isset($error_email_empty))
                    echo '<div class="error_message">'.___('This field must not be empty.').'</div>';
                else
                    echo $html->tagErrorMsg('User/email', ___('This is not a valid email address.'));
            ?>
        </div>
    </div>

    <div id="profile-other">
        <h3 class="hidden"><?=___('Other Actions');?></h3>
        <p><?=$html->link(___('Delete user account'), '/users/delete');?></p>
    </div>
</div><!-- /#tabbed-editor -->

    <?=$html->submit(___('Save'), array('class'=>'amo-submit')); ?>
</form>

</div><!-- /.primary -->

<script type="text/javascript">
    $(document).ready(function(){
        $("#tabbed-editor > ul").tabs();
        $('#editor-subscriptions th:first').append(
            // add check/uncheck all box to notification management table
            $('<input type="checkbox"/>')
                .attr('checked', 'checked')
                .change(function(){
                    $('input:checkbox', $(this).closest('table')).attr('checked', $(this).is(':checked'));
                })
            );
        $('#profile-user-form').submit(function() {
            var validImages = "<?= implode(', ', $this->controller->Developers->imageExtensions); ?>";
            var regex = new RegExp('(' + validImages.split(', ').join('|') + ')$');
            var ext = checkInputFileExtensions('#UserPictureData', regex);
            if (ext != true)
                alert(sprintf("<?= ___('That file extension (%1$s) is not allowed for an icon. Please use one of the following: %2$s'); ?>", ext, validImages));
            return ext == true;
        });
    });
</script>