Merge lp:~vierbergenlars/remotecp-panel/edit-user-lang into lp:remotecp-panel/1.x

Proposed by Lars Vierbergen
Status: Merged
Approved by: Lars Vierbergen
Approved revision: 101
Merged at revision: 101
Proposed branch: lp:~vierbergenlars/remotecp-panel/edit-user-lang
Merge into: lp:remotecp-panel/1.x
Diff against target: 294 lines (+222/-5)
3 files modified
inc/languageCodes.php (+188/-0)
scripts/permanent/ajax.js (+10/-2)
system/user_props.php (+24/-3)
To merge this branch: bzr merge lp:~vierbergenlars/remotecp-panel/edit-user-lang
Reviewer Review Type Date Requested Status
Lars Vierbergen ui Approve
Review via email: mp+53163@code.launchpad.net

Commit message

To post a comment you must log in.
Revision history for this message
Lars Vierbergen (vierbergenlars) wrote :

There should be a label to the list and the selectbox

review: Needs Fixing (ui)
Revision history for this message
Lars Vierbergen (vierbergenlars) wrote :

> There should be a label to the list and the selectbox
Fixed now

review: Approve (ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'inc/languageCodes.php'
2--- inc/languageCodes.php 1970-01-01 00:00:00 +0000
3+++ inc/languageCodes.php 2011-03-14 20:16:10 +0000
4@@ -0,0 +1,188 @@
5+<?php
6+$languageCodes = array(
7+ "aa" => "Afar",
8+ "ab" => "Abkhazian",
9+ "ae" => "Avestan",
10+ "af" => "Afrikaans",
11+ "ak" => "Akan",
12+ "am" => "Amharic",
13+ "an" => "Aragonese",
14+ "ar" => "Arabic",
15+ "as" => "Assamese",
16+ "av" => "Avaric",
17+ "ay" => "Aymara",
18+ "az" => "Azerbaijani",
19+ "ba" => "Bashkir",
20+ "be" => "Belarusian",
21+ "bg" => "Bulgarian",
22+ "bh" => "Bihari",
23+ "bi" => "Bislama",
24+ "bm" => "Bambara",
25+ "bn" => "Bengali",
26+ "bo" => "Tibetan",
27+ "br" => "Breton",
28+ "bs" => "Bosnian",
29+ "ca" => "Catalan",
30+ "ce" => "Chechen",
31+ "ch" => "Chamorro",
32+ "co" => "Corsican",
33+ "cr" => "Cree",
34+ "cs" => "Czech",
35+ "cu" => "Church Slavic",
36+ "cv" => "Chuvash",
37+ "cy" => "Welsh",
38+ "da" => "Danish",
39+ "de" => "German",
40+ "dv" => "Divehi",
41+ "dz" => "Dzongkha",
42+ "ee" => "Ewe",
43+ "el" => "Greek",
44+ "en" => "English",
45+ "eo" => "Esperanto",
46+ "es" => "Spanish",
47+ "et" => "Estonian",
48+ "eu" => "Basque",
49+ "fa" => "Persian",
50+ "ff" => "Fulah",
51+ "fi" => "Finnish",
52+ "fj" => "Fijian",
53+ "fo" => "Faroese",
54+ "fr" => "French",
55+ "fy" => "Western Frisian",
56+ "ga" => "Irish",
57+ "gd" => "Scottish Gaelic",
58+ "gl" => "Galician",
59+ "gn" => "Guarani",
60+ "gu" => "Gujarati",
61+ "gv" => "Manx",
62+ "ha" => "Hausa",
63+ "he" => "Hebrew",
64+ "hi" => "Hindi",
65+ "ho" => "Hiri Motu",
66+ "hr" => "Croatian",
67+ "ht" => "Haitian",
68+ "hu" => "Hungarian",
69+ "hy" => "Armenian",
70+ "hz" => "Herero",
71+ "ia" => "Interlingua (International Auxiliary Language Association)",
72+ "id" => "Indonesian",
73+ "ie" => "Interlingue",
74+ "ig" => "Igbo",
75+ "ii" => "Sichuan Yi",
76+ "ik" => "Inupiaq",
77+ "io" => "Ido",
78+ "is" => "Icelandic",
79+ "it" => "Italian",
80+ "iu" => "Inuktitut",
81+ "ja" => "Japanese",
82+ "jv" => "Javanese",
83+ "ka" => "Georgian",
84+ "kg" => "Kongo",
85+ "ki" => "Kikuyu",
86+ "kj" => "Kwanyama",
87+ "kk" => "Kazakh",
88+ "kl" => "Kalaallisut",
89+ "km" => "Khmer",
90+ "kn" => "Kannada",
91+ "ko" => "Korean",
92+ "kr" => "Kanuri",
93+ "ks" => "Kashmiri",
94+ "ku" => "Kurdish",
95+ "kv" => "Komi",
96+ "kw" => "Cornish",
97+ "ky" => "Kirghiz",
98+ "la" => "Latin",
99+ "lb" => "Luxembourgish",
100+ "lg" => "Ganda",
101+ "li" => "Limburgish",
102+ "ln" => "Lingala",
103+ "lo" => "Lao",
104+ "lt" => "Lithuanian",
105+ "lu" => "Luba-Katanga",
106+ "lv" => "Latvian",
107+ "mg" => "Malagasy",
108+ "mh" => "Marshallese",
109+ "mi" => "Maori",
110+ "mk" => "Macedonian",
111+ "ml" => "Malayalam",
112+ "mn" => "Mongolian",
113+ "mr" => "Marathi",
114+ "ms" => "Malay",
115+ "mt" => "Maltese",
116+ "my" => "Burmese",
117+ "na" => "Nauru",
118+ "nb" => "Norwegian Bokmal",
119+ "nd" => "North Ndebele",
120+ "ne" => "Nepali",
121+ "ng" => "Ndonga",
122+ "nl" => "Dutch",
123+ "nn" => "Norwegian Nynorsk",
124+ "no" => "Norwegian",
125+ "nr" => "South Ndebele",
126+ "nv" => "Navajo",
127+ "ny" => "Chichewa",
128+ "oc" => "Occitan",
129+ "oj" => "Ojibwa",
130+ "om" => "Oromo",
131+ "or" => "Oriya",
132+ "os" => "Ossetian",
133+ "pa" => "Panjabi",
134+ "pi" => "Pali",
135+ "pl" => "Polish",
136+ "ps" => "Pashto",
137+ "pt" => "Portuguese",
138+ "qu" => "Quechua",
139+ "rm" => "Raeto-Romance",
140+ "rn" => "Kirundi",
141+ "ro" => "Romanian",
142+ "ru" => "Russian",
143+ "rw" => "Kinyarwanda",
144+ "sa" => "Sanskrit",
145+ "sc" => "Sardinian",
146+ "sd" => "Sindhi",
147+ "se" => "Northern Sami",
148+ "sg" => "Sango",
149+ "si" => "Sinhala",
150+ "sk" => "Slovak",
151+ "sl" => "Slovenian",
152+ "sm" => "Samoan",
153+ "sn" => "Shona",
154+ "so" => "Somali",
155+ "sq" => "Albanian",
156+ "sr" => "Serbian",
157+ "ss" => "Swati",
158+ "st" => "Southern Sotho",
159+ "su" => "Sundanese",
160+ "sv" => "Swedish",
161+ "sw" => "Swahili",
162+ "ta" => "Tamil",
163+ "te" => "Telugu",
164+ "tg" => "Tajik",
165+ "th" => "Thai",
166+ "ti" => "Tigrinya",
167+ "tk" => "Turkmen",
168+ "tl" => "Tagalog",
169+ "tn" => "Tswana",
170+ "to" => "Tonga",
171+ "tr" => "Turkish",
172+ "ts" => "Tsonga",
173+ "tt" => "Tatar",
174+ "tw" => "Twi",
175+ "ty" => "Tahitian",
176+ "ug" => "Uighur",
177+ "uk" => "Ukrainian",
178+ "ur" => "Urdu",
179+ "uz" => "Uzbek",
180+ "ve" => "Venda",
181+ "vi" => "Vietnamese",
182+ "vo" => "Volapuk",
183+ "wa" => "Walloon",
184+ "wo" => "Wolof",
185+ "xh" => "Xhosa",
186+ "yi" => "Yiddish",
187+ "yo" => "Yoruba",
188+ "za" => "Zhuang",
189+ "zh" => "Chinese",
190+ "zu" => "Zulu"
191+);
192+?>
193\ No newline at end of file
194
195=== modified file 'scripts/permanent/ajax.js'
196--- scripts/permanent/ajax.js 2011-03-11 16:42:13 +0000
197+++ scripts/permanent/ajax.js 2011-03-14 20:16:10 +0000
198@@ -21,12 +21,16 @@
199 return resp;
200 }
201 else if(page.status==500) {
202- return '<strong>SERVER ERROR:</strong> PHP Errors.\n<hr>'+resp;
203+ console.error(resp);
204+ return 'false|PHP error';
205 }
206 else if(resp=='') {
207+ console.warning('Server returned empty page');
208 return '<strong>Sorry,</strong> the server decided to say nothing.';
209 }
210 else {
211+ console.warning('WTF??? Nothing?');
212+ console.debug(page);
213 return '<strong>OOPS</strong> Something went wrong...';
214 }
215 },
216@@ -42,12 +46,16 @@
217 return resp;
218 }
219 else if(page.status==500) {
220- return '<strong>SERVER ERROR:</strong> PHP Errors.\n<hr>'+resp;
221+ console.error(resp);
222+ return 'false|PHP error';
223 }
224 else if(resp=='') {
225+ console.warning('Server returned empty page');
226 return '<strong>Sorry,</strong> the server decided to say nothing.';
227 }
228 else {
229+ console.warning('WTF??? Nothing?');
230+ console.debug(page);
231 return '<strong>OOPS</strong> Something went wrong...';
232 }
233 },
234
235=== modified file 'system/user_props.php'
236--- system/user_props.php 2011-02-01 17:53:44 +0000
237+++ system/user_props.php 2011-03-14 20:16:10 +0000
238@@ -1,7 +1,7 @@
239 <?php //@./system/user_props.php ?>
240 <!-- HEADERS >
241 <AJAX_SCRIPTLOC>account_scripts.js</AJAX_SCRIPTLOC>
242-<AJAX_SCRIPTEVAL>NULL</AJAX_SCRIPTEVAL>
243+<AJAX_SCRIPTEVAL>setTimeout('$("#user_edit_language").sortable().removeClass("ui-state-disabled");',1)</AJAX_SCRIPTEVAL>
244 < HEADERS --><?php
245 /**
246 * user_props.php - Jquery UI control panel (?control=userinfo)||(?control=useredit)
247@@ -48,6 +48,7 @@
248 }
249 }
250 else if($_GET['control']=="useredit") {
251+ require('inc/languageCodes.php');
252 if(!isset($_POST['currpass'])&&!isset($_POST['email'])) {?>
253 <fieldset><form name="pass_edit" method='POST' onsubmit="if(this.newpass.value!=this.newpass2.value){$(this).prepend(message.error('<?php echo $t->_('Repeated password does not match'); ?>')); return false;} success=ajax.post('?control=useredit','currpass='+this.currpass.value+'&newpass='+this.newpass.value); this.reset(); if(success=='true'){$(this).prepend(message.info('<?php echo $t->_('Password saved'); ?>'));} else if(success=='false') {$(this).prepend(message.error('<?php echo $t->_('Password could not be saved'); ?>'));} else {$(this).prepend(success);} return false;">
254 <?php echo $t->_('Current password') ?>:<input type="password" name="currpass" maxlength="30">
255@@ -57,9 +58,25 @@
256 <input value="<?php echo $t->_('Change password') ?>" type="submit">
257 </form></fieldset>
258 <br>
259- <form method='POST' onsubmit="success=ajax.post('?control=useredit','email='+this.email.value);success=success.split('|');if(success[0]=='true') {$(this).prepend(message.info('<?php echo $t->_('Settings changed'); ?>'));}else if(success[0]=='false') {success[0]='<?php echo $t->_('Settings not changed<br>Errors'); ?>:';success.join('<br>');$(this).prepend(message.error(success));}else {success.join('|');$(this).prepend(success);} return false;"><fieldset>
260+ <form method='POST' onsubmit="success=ajax.post('?control=useredit','email='+this.email.value+'&language='+$(this).find('ul').sortable('toArray').join(',')); success=success.split('|');if(success[0]=='true') {$(message.info('<?php echo $t->_('Settings changed'); ?>')).prependTo(this);}else if(success[0]=='false') {success[0]='<?php echo $t->_('Settings not changed<br>Errors'); ?>:';success.join('<br>');$(this).prepend(message.error(success));}else {success.join('|');$(this).prepend(success);} return false;"><fieldset>
261 <?php echo $t->_('E-mail address'); ?>:<input type="text" name="email" maxlength="50" value="<?php echo $session->userinfo['email'];?>">
262 <br>
263+ <?php
264+ echo $t->_('Language').':';
265+ $languages=unserialize($session->userinfo['lang']);
266+ $languagestr=implode(',',$languages);
267+ ?>
268+ <ul id='user_edit_language' class='ui-state-disabled'>
269+ <?php foreach($languages as $language) { ?>
270+ <li class='ui-state-default' id='user_edit_language_<?php echo $language; ?>'><?php echo $language.': '.$languageCodes[$language]; ?></li>
271+ <?php } ?>
272+ </ul>
273+ <label><?php echo $t->_('Add language'); ?><select onclick='this.blur()' onchange='$(this).prev().append("<li class=\"ui-state-default\" id=\"user_edit_language_"+this.value+"\">"+this.options[this.selectedIndex].innerHTML+"</li>").sortable("refresh")'>
274+ <option disabled><?php echo $t->_('Select additional language'); ?></option>
275+ <?php foreach($languageCodes as $code=>$name) {
276+ echo '<option value="'.$code.'">'.$code.': '.$name.'</option>';
277+ } ?>
278+ </select></label>
279 <input type="submit" value="<?php echo $t->_('Submit settings') ?>">
280 </fieldset>
281 </form>
282@@ -80,7 +97,11 @@
283 }
284 elseif(isset($_POST['email'])) {
285 $retval = $session->editAccount(false,false,$_POST['email']);
286-
287+ $langs=explode(',',$_POST['language']);
288+ foreach($langs as &$lang) {
289+ $lang=substr($lang,-2);
290+ }
291+ $local_connection->query('UPDATE `users` SET `lang`=\''.serialize($langs).'\' WHERE `username`=\''.$session->username.'\'');
292 /* Account edit successful */
293 if($retval){
294 echo "true";

Subscribers

People subscribed via source and target branches

to all changes: