]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/prefs.php
3 class Pref_Prefs
extends Handler_Protected
{
5 private $pref_help = array ();
6 private $pref_sections = array ();
8 function csrf_ignore ( $method ) {
9 $csrf_ignored = array ( "index" , "updateself" , "customizecss" , "editprefprofiles" );
11 return array_search ( $method , $csrf_ignored ) !== false ;
14 function __construct ( $link , $args ) {
15 parent
:: __construct ( $link , $args );
17 $this -> pref_sections
= array (
24 $this -> pref_help
= array (
25 "ALLOW_DUPLICATE_POSTS" => array ( __ ( "Allow duplicate articles" ), "" ),
26 "AUTO_ASSIGN_LABELS" => array ( __ ( "Assign articles to labels automatically" ), "" ),
27 "BLACKLISTED_TAGS" => array ( __ ( "Blacklisted tags" ), __ ( "When auto-detecting tags in articles these tags will not be applied (comma-separated list)." )),
28 "CDM_AUTO_CATCHUP" => array ( __ ( "Automatically mark articles as read" ), __ ( "This option enables marking articles as read automatically while you scroll article list." )),
29 "CDM_EXPANDED" => array ( __ ( "Automatically expand articles in combined mode" ), "" ),
30 "COMBINED_DISPLAY_MODE" => array ( __ ( "Combined feed display" ), __ ( "Display expanded list of feed articles, instead of separate displays for headlines and article content" )),
31 "CONFIRM_FEED_CATCHUP" => array ( __ ( "Confirm marking feed as read" ), "" ),
32 "DEFAULT_ARTICLE_LIMIT" => array ( __ ( "Amount of articles to display at once" ), "" ),
33 "DEFAULT_UPDATE_INTERVAL" => array ( __ ( "Default interval between feed updates" ), "" ),
34 "DIGEST_CATCHUP" => array ( __ ( "Mark articles in e-mail digest as read" ), "" ),
35 "DIGEST_ENABLE" => array ( __ ( "Enable e-mail digest" ), __ ( "This option enables sending daily digest of new (and unread) headlines on your configured e-mail address" )),
36 "DIGEST_PREFERRED_TIME" => array ( __ ( "Try to send digests around specified time" ), __ ( "Uses UTC timezone" )),
37 "ENABLE_API_ACCESS" => array ( __ ( "Enable API access" ), __ ( "Allows external clients to access this account through the API" )),
38 "ENABLE_FEED_CATS" => array ( __ ( "Enable feed categories" ), "" ),
39 "FEEDS_SORT_BY_UNREAD" => array ( __ ( "Sort feeds by unread articles count" ), "" ),
40 "FRESH_ARTICLE_MAX_AGE" => array ( __ ( "Maximum age of fresh articles (in hours)" ), "" ),
41 "HIDE_READ_FEEDS" => array ( __ ( "Hide feeds with no unread articles" ), "" ),
42 "HIDE_READ_SHOWS_SPECIAL" => array ( __ ( "Show special feeds when hiding read feeds" ), "" ),
43 "LONG_DATE_FORMAT" => array ( __ ( "Long date format" ), "" ),
44 "ON_CATCHUP_SHOW_NEXT_FEED" => array ( __ ( "On catchup show next feed" ), __ ( "Automatically open next feed with unread articles after marking one as read" )),
45 "PURGE_OLD_DAYS" => array ( __ ( "Purge articles after this number of days (0 - disables)" ), "" ),
46 "PURGE_UNREAD_ARTICLES" => array ( __ ( "Purge unread articles" ), "" ),
47 "REVERSE_HEADLINES" => array ( __ ( "Reverse headline order (oldest first)" ), "" ),
48 "SHORT_DATE_FORMAT" => array ( __ ( "Short date format" ), "" ),
49 "SHOW_CONTENT_PREVIEW" => array ( __ ( "Show content preview in headlines list" ), "" ),
50 "SORT_HEADLINES_BY_FEED_DATE" => array ( __ ( "Sort headlines by feed date" ), __ ( "Use feed-specified date to sort headlines instead of local import date." )),
51 "SSL_CERT_SERIAL" => array ( __ ( "Login with an SSL certificate" ), __ ( "Click to register your SSL client certificate with tt-rss" )),
52 "STRIP_IMAGES" => array ( __ ( "Do not embed images in articles" ), "" ),
53 "STRIP_UNSAFE_TAGS" => array ( __ ( "Strip unsafe tags from articles" ), __ ( "Strip all but most common HTML tags when reading articles." )),
54 "USER_STYLESHEET" => array ( __ ( "Customize stylesheet" ), __ ( "Customize CSS stylesheet to your liking" )),
55 "USER_TIMEZONE" => array ( __ ( "User timezone" ), "" ),
56 "VFEED_GROUP_BY_FEED" => array ( __ ( "Group headlines in virtual feeds" ), __ ( "Special feeds, labels, and categories are grouped by originating feeds" )),
57 "USER_CSS_THEME" => array ( __ ( "Select theme" ), __ ( "Select one of the available CSS themes" ))
61 function changepassword () {
63 $old_pw = $_POST [ "old_password" ];
64 $new_pw = $_POST [ "new_password" ];
65 $con_pw = $_POST [ "confirm_password" ];
68 print "ERROR: " . __ ( "Old password cannot be blank." );
73 print "ERROR: " . __ ( "New password cannot be blank." );
77 if ( $new_pw != $con_pw ) {
78 print "ERROR: " . __ ( "Entered passwords do not match." );
83 $authenticator = $pluginhost -> get_plugin ( $_SESSION [ "auth_module" ]);
85 if ( method_exists ( $authenticator , "change_password" )) {
86 print $authenticator -> change_password ( $_SESSION [ "uid" ], $old_pw , $new_pw );
88 print "ERROR: " . __ ( "Function not supported by authentication module." );
92 function saveconfig () {
94 $_SESSION [ "prefs_cache" ] = false ;
96 $boolean_prefs = explode ( "," , $_POST [ "boolean_prefs" ]);
98 foreach ( $boolean_prefs as $pref ) {
99 if (! isset ( $_POST [ $pref ])) $_POST [ $pref ] = 'false' ;
102 foreach ( array_keys ( $_POST ) as $pref_name ) {
104 $pref_name = db_escape_string ( $this -> link
, $pref_name );
105 $value = db_escape_string ( $this -> link
, $_POST [ $pref_name ]);
107 if ( $pref_name == 'DIGEST_PREFERRED_TIME' ) {
108 if ( get_pref ( $this -> link
, 'DIGEST_PREFERRED_TIME' ) != $value ) {
110 db_query ( $this -> link
, "UPDATE ttrss_users SET
111 last_digest_sent = NULL WHERE id = " . $_SESSION [ 'uid' ]);
116 set_pref ( $this -> link
, $pref_name , $value );
120 print __ ( "The configuration was saved." );
125 $pref_name = db_escape_string ( $this -> link
, $_REQUEST [ "pn" ]);
127 $result = db_query ( $this -> link
, "SELECT help_text FROM ttrss_prefs
128 WHERE pref_name = ' $pref_name '" );
130 if ( db_num_rows ( $result ) > 0 ) {
131 $help_text = db_fetch_result ( $result , 0 , "help_text" );
134 printf ( __ ( "Unknown option: %s " ), $pref_name );
138 function changeemail () {
140 $email = db_escape_string ( $this -> link
, $_POST [ "email" ]);
141 $full_name = db_escape_string ( $this -> link
, $_POST [ "full_name" ]);
143 $active_uid = $_SESSION [ "uid" ];
145 db_query ( $this -> link
, "UPDATE ttrss_users SET email = ' $email ',
146 full_name = ' $full_name ' WHERE id = ' $active_uid '" );
148 print __ ( "Your personal data has been saved." );
153 function resetconfig () {
155 $_SESSION [ "prefs_op_result" ] = "reset-to-defaults" ;
157 if ( $_SESSION [ "profile" ]) {
158 $profile_qpart = "profile = '" . $_SESSION [ "profile" ] . "'" ;
160 $profile_qpart = "profile IS NULL" ;
163 db_query ( $this -> link
, "DELETE FROM ttrss_user_prefs
164 WHERE $profile_qpart AND owner_uid = " . $_SESSION [ "uid" ]);
166 initialize_user_prefs ( $this -> link
, $_SESSION [ "uid" ], $_SESSION [ "profile" ]);
171 global $access_level_names ;
173 $prefs_blacklist = array ( "STRIP_UNSAFE_TAGS" , "REVERSE_HEADLINES" ,
174 "SORT_HEADLINES_BY_FEED_DATE" , "DEFAULT_ARTICLE_LIMIT" );
176 /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */
178 $profile_blacklist = array ( "ALLOW_DUPLICATE_POSTS" , "PURGE_OLD_DAYS" ,
179 "PURGE_UNREAD_ARTICLES" , "DIGEST_ENABLE" , "DIGEST_CATCHUP" ,
180 "BLACKLISTED_TAGS" , "ENABLE_API_ACCESS" , "UPDATE_POST_ON_CHECKSUM_CHANGE" ,
181 "DEFAULT_UPDATE_INTERVAL" , "USER_TIMEZONE" , "SORT_HEADLINES_BY_FEED_DATE" ,
182 "SSL_CERT_SERIAL" , "DIGEST_PREFERRED_TIME" );
185 $_SESSION [ "prefs_op_result" ] = "" ;
187 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
188 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Personal data / Authentication' ). " \" >" ;
190 print "<form dojoType= \" dijit.form.Form \" id= \" changeUserdataForm \" >" ;
192 print "<script type= \" dojo/method \" event= \" onSubmit \" args= \" evt \" >
193 evt.preventDefault();
194 if (this.validate()) {
195 notify_progress('Saving data...', true);
197 new Ajax.Request('backend.php', {
198 parameters: dojo.objectToQuery(this.getValues()),
199 onComplete: function(transport) {
200 notify_callback2(transport);
206 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
208 print "<h2>" . __ ( "Personal data" ) . "</h2>" ;
210 $result = db_query ( $this -> link
, "SELECT email,full_name,otp_enabled,
211 access_level FROM ttrss_users
212 WHERE id = " . $_SESSION [ "uid" ]);
214 $email = htmlspecialchars ( db_fetch_result ( $result , 0 , "email" ));
215 $full_name = htmlspecialchars ( db_fetch_result ( $result , 0 , "full_name" ));
216 $otp_enabled = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "otp_enabled" ));
218 print "<tr><td width= \" 40% \" >" . __ ( 'Full name' ). "</td>" ;
219 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" name= \" full_name \" required= \" 1 \"
220 value= \" $full_name\" ></td></tr>" ;
222 print "<tr><td width= \" 40% \" >" . __ ( 'E-mail' ). "</td>" ;
223 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" name= \" email \" required= \" 1 \" value= \" $email\" ></td></tr>" ;
225 if (! SINGLE_USER_MODE
&& ! $_SESSION [ "hide_hello" ]) {
227 $access_level = db_fetch_result ( $result , 0 , "access_level" );
228 print "<tr><td width= \" 40% \" >" . __ ( 'Access level' ). "</td>" ;
229 print "<td>" . $access_level_names [ $access_level ] . "</td></tr>" ;
234 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-prefs \" >" ;
235 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" changeemail \" >" ;
237 print "<p><button dojoType= \" dijit.form.Button \" type= \" submit \" >" .
238 __ ( "Save data" ). "</button>" ;
242 if ( $_SESSION [ "auth_module" ]) {
245 $authenticator = $pluginhost -> get_plugin ( $_SESSION [ "auth_module" ]);
248 $authenticator = false ;
251 if ( $authenticator && method_exists ( $authenticator , "change_password" )) {
253 print "<h2>" . __ ( "Password" ) . "</h2>" ;
255 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_users
256 WHERE id = " . $_SESSION [ "uid" ]. " AND pwd_hash
257 = 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'" );
259 if ( db_num_rows ( $result ) != 0 ) {
260 print format_warning ( __ ( "Your password is at default value, please change it." ), "default_pass_warning" );
263 print "<form dojoType= \" dijit.form.Form \" >" ;
265 print "<script type= \" dojo/method \" event= \" onSubmit \" args= \" evt \" >
266 evt.preventDefault();
267 if (this.validate()) {
268 notify_progress('Changing password...', true);
270 new Ajax.Request('backend.php', {
271 parameters: dojo.objectToQuery(this.getValues()),
272 onComplete: function(transport) {
274 if (transport.responseText.indexOf('ERROR: ') == 0) {
275 notify_error(transport.responseText.replace('ERROR: ', ''));
277 notify_info(transport.responseText);
278 var warn = $('default_pass_warning');
279 if (warn) Element.hide(warn);
287 print_notice ( __ ( "Changing your current password will disable OTP." ));
290 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
292 print "<tr><td width= \" 40% \" >" . __ ( "Old password" ). "</td>" ;
293 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" type= \" password \" required= \" 1 \" name= \" old_password \" ></td></tr>" ;
295 print "<tr><td width= \" 40% \" >" . __ ( "New password" ). "</td>" ;
297 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" type= \" password \" required= \" 1 \"
298 name= \" new_password \" ></td></tr>" ;
300 print "<tr><td width= \" 40% \" >" . __ ( "Confirm password" ). "</td>" ;
302 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" type= \" password \" required= \" 1 \" name= \" confirm_password \" ></td></tr>" ;
306 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-prefs \" >" ;
307 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" changepassword \" >" ;
309 print "<p><button dojoType= \" dijit.form.Button \" type= \" submit \" >" .
310 __ ( "Change password" ). "</button>" ;
314 if ( $_SESSION [ "auth_module" ] == "auth_internal" ) {
316 print "<h2>" . __ ( "One time passwords / Authenticator" ) . "</h2>" ;
320 print_notice ( __ ( "One time passwords are currently enabled. Enter your current password below to disable." ));
322 print "<form dojoType= \" dijit.form.Form \" >" ;
324 print "<script type= \" dojo/method \" event= \" onSubmit \" args= \" evt \" >
325 evt.preventDefault();
326 if (this.validate()) {
327 notify_progress('Disabling OTP', true);
329 new Ajax.Request('backend.php', {
330 parameters: dojo.objectToQuery(this.getValues()),
331 onComplete: function(transport) {
333 if (transport.responseText.indexOf('ERROR: ') == 0) {
334 notify_error(transport.responseText.replace('ERROR: ', ''));
336 window.location.reload();
343 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
345 print "<tr><td width= \" 40% \" >" . __ ( "Enter your password" ). "</td>" ;
347 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" type= \" password \" required= \" 1 \"
348 name= \" password \" ></td></tr>" ;
352 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-prefs \" >" ;
353 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" otpdisable \" >" ;
355 print "<p><button dojoType= \" dijit.form.Button \" type= \" submit \" >" .
356 __ ( "Disable OTP" ). "</button>" ;
362 print "<p>" . __ ( "You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP." ) . "</p>" ;
364 print "<p>" . __ ( "Scan the following code by the Authenticator application:" ). "</p>" ;
366 $csrf_token = $_SESSION [ "csrf_token" ];
368 print "<img src= \" backend.php?op=pref-prefs&method=otpqrcode&csrf_token= $csrf_token\" >" ;
370 print "<form dojoType= \" dijit.form.Form \" id= \" changeOtpForm \" >" ;
372 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-prefs \" >" ;
373 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" otpenable \" >" ;
375 print "<script type= \" dojo/method \" event= \" onSubmit \" args= \" evt \" >
376 evt.preventDefault();
377 if (this.validate()) {
378 notify_progress('Saving data...', true);
380 new Ajax.Request('backend.php', {
381 parameters: dojo.objectToQuery(this.getValues()),
382 onComplete: function(transport) {
384 if (transport.responseText.indexOf('ERROR: ') == 0) {
385 notify_error(transport.responseText.replace('ERROR: ', ''));
387 window.location.reload();
394 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
396 print "<tr><td width= \" 40% \" >" . __ ( "Enter your password" ). "</td>" ;
398 print "<td class= \" prefValue \" ><input dojoType= \" dijit.form.ValidationTextBox \" type= \" password \" required= \" 1 \"
399 name= \" password \" ></td></tr>" ;
401 print "<tr><td colspan= \" 2 \" >" ;
403 print "<input dojoType= \" dijit.form.CheckBox \" required= \" 1 \"
404 type= \" checkbox \" id= \" enable_otp \" name= \" enable_otp \" /> " ;
405 print "<label for= \" enable_otp \" >" . __ ( "I have scanned the code and would like to enable OTP" ). "</label>" ;
407 print "</td></tr><tr><td colspan= \" 2 \" >" ;
412 print "<p><button dojoType= \" dijit.form.Button \" type= \" submit \" >" .
413 __ ( "Enable OTP" ). "</button>" ;
423 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
424 "hook_prefs_tab_section" , "prefPrefsAuth" );
426 print "</div>" ; #pane
428 print "<div dojoType= \" dijit.layout.AccordionPane \" selected= \" true \" title= \" " . __ ( 'Preferences' ). " \" >" ;
430 print "<form dojoType= \" dijit.form.Form \" id= \" changeSettingsForm \" >" ;
432 print "<script type= \" dojo/method \" event= \" onSubmit \" args= \" evt, quit \" >
433 if (evt) evt.preventDefault();
434 if (this.validate()) {
435 console.log(dojo.objectToQuery(this.getValues()));
437 new Ajax.Request('backend.php', {
438 parameters: dojo.objectToQuery(this.getValues()),
439 onComplete: function(transport) {
440 var msg = transport.responseText;
442 if (quit) gotoMain();
447 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
449 print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">' ;
451 if ( $_SESSION [ "profile" ]) {
452 print_notice ( __ ( "Some preferences are only available in default profile." ));
455 if ( $_SESSION [ "profile" ]) {
456 initialize_user_prefs ( $this -> link
, $_SESSION [ "uid" ], $_SESSION [ "profile" ]);
457 $profile_qpart = "profile = '" . $_SESSION [ "profile" ] . "'" ;
459 initialize_user_prefs ( $this -> link
, $_SESSION [ "uid" ]);
460 $profile_qpart = "profile IS NULL" ;
463 /* if ($_SESSION["prefs_show_advanced"])
464 $access_query = "true";
466 $access_query = "(access_level = 0 AND section_id != 3)"; */
468 $access_query = 'true' ;
470 $result = db_query ( $this -> link
, "SELECT DISTINCT
471 ttrss_user_prefs.pref_name,value,type_name,
472 ttrss_prefs_sections.order_id,
474 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
475 WHERE type_id = ttrss_prefs_types.id AND
477 section_id = ttrss_prefs_sections.id AND
478 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
480 owner_uid = " . $_SESSION [ "uid" ]. "
481 ORDER BY ttrss_prefs_sections.order_id,pref_name" );
485 $active_section = "" ;
487 $listed_boolean_prefs = array ();
489 while ( $line = db_fetch_assoc ( $result )) {
491 if ( in_array ( $line [ "pref_name" ], $prefs_blacklist )) {
495 $type_name = $line [ "type_name" ];
496 $pref_name = $line [ "pref_name" ];
497 $section_name = $this -> getSectionName ( $line [ "section_id" ]);
498 $value = $line [ "value" ];
500 $short_desc = $this -> getShortDesc ( $pref_name );
501 $help_text = $this -> getHelpText ( $pref_name );
503 if (! $short_desc ) continue ;
505 if ( $_SESSION [ "profile" ] && in_array ( $line [ "pref_name" ],
506 $profile_blacklist )) {
510 if ( $active_section != $line [ "section_id" ]) {
512 if ( $active_section != "" ) {
516 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
518 $active_section = $line [ "section_id" ];
520 print "<tr><td colspan= \" 3 \" ><h3>" . $section_name . "</h3></td></tr>" ;
527 print "<td width= \" 40% \" class= \" prefName \" id= \" $pref_name\" >" ;
528 print "<label for='CB_ $pref_name '>" ;
532 if ( $help_text ) print "<div class= \" prefHelp \" >" . __ ( $help_text ). "</div>" ;
536 print "<td class= \" prefValue \" >" ;
538 if ( $pref_name == "USER_TIMEZONE" ) {
540 $timezones = explode ( " \n " , file_get_contents ( "lib/timezones.txt" ));
542 print_select ( $pref_name , $value , $timezones , 'dojoType="dijit.form.FilteringSelect"' );
543 } else if ( $pref_name == "USER_STYLESHEET" ) {
545 print "<button dojoType= \" dijit.form.Button \"
546 onclick= \" customizeCSS() \" >" . __ ( 'Customize' ) . "</button>" ;
548 } else if ( $pref_name == "USER_CSS_THEME" ) {
550 $themes = array_map ( "basename" , glob ( "themes/*.css" ));
552 print_select ( $pref_name , $value , $themes ,
553 'dojoType="dijit.form.Select"' );
556 } else if ( $pref_name == "DEFAULT_UPDATE_INTERVAL" ) {
558 global $update_intervals_nodefault ;
560 print_select_hash ( $pref_name , $value , $update_intervals_nodefault ,
561 'dojoType="dijit.form.Select"' );
563 } else if ( $type_name == "bool" ) {
565 array_push ( $listed_boolean_prefs , $pref_name );
567 $checked = ( $value == "true" ) ?
"checked= \" checked \" " : "" ;
569 if ( $pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE
!= 0 ) {
570 $disabled = "disabled= \" 1 \" " ;
571 $checked = "checked= \" checked \" " ;
576 print "<input type='checkbox' name=' $pref_name ' $checked $disabled
577 dojoType='dijit.form.CheckBox' id='CB_ $pref_name ' value='1'>" ;
579 } else if ( array_search ( $pref_name , array ( 'FRESH_ARTICLE_MAX_AGE' ,
580 'PURGE_OLD_DAYS' , 'LONG_DATE_FORMAT' , 'SHORT_DATE_FORMAT' )) !== false ) {
582 $regexp = ( $type_name == 'integer' ) ?
'regexp="^\d*$"' : '' ;
584 if ( $pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE
!= 0 ) {
585 $disabled = "disabled= \" 1 \" " ;
586 $value = FORCE_ARTICLE_PURGE
;
591 print "<input dojoType= \" dijit.form.ValidationTextBox \"
592 required= \" 1 \" $regexp $disabled
593 name= \" $pref_name\" value= \" $value\" >" ;
595 } else if ( $pref_name == "SSL_CERT_SERIAL" ) {
597 print "<input dojoType= \" dijit.form.ValidationTextBox \"
598 id= \" SSL_CERT_SERIAL \" readonly= \" 1 \"
599 name= \" $pref_name\" value= \" $value\" >" ;
601 $cert_serial = htmlspecialchars ( get_ssl_certificate_id ());
602 $has_serial = ( $cert_serial ) ?
"false" : "true" ;
604 print " <button dojoType= \" dijit.form.Button \" disabled= \" $has_serial\"
605 onclick= \" insertSSLserial(' $cert_serial ') \" >" .
606 __ ( 'Register' ) . "</button>" ;
608 print " <button dojoType= \" dijit.form.Button \"
609 onclick= \" insertSSLserial('') \" >" .
610 __ ( 'Clear' ) . "</button>" ;
612 } else if ( $pref_name == 'DIGEST_PREFERRED_TIME' ) {
613 print "<input dojoType= \" dijit.form.ValidationTextBox \"
614 id= \" $pref_name\" regexp= \" [012]?\d:\d\d \" placeHolder= \" 12:00 \"
615 name= \" $pref_name\" value= \" $value\" ><div class= \" insensitive \" >" .
616 T_sprintf ( "Current server time: %s (UTC)" , date ( "H:i" )) . "</div>" ;
618 $regexp = ( $type_name == 'integer' ) ?
'regexp="^\d*$"' : '' ;
620 print "<input dojoType= \" dijit.form.ValidationTextBox \"
622 name= \" $pref_name\" value= \" $value\" >" ;
634 $listed_boolean_prefs = htmlspecialchars ( join ( "," , $listed_boolean_prefs ));
636 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" boolean_prefs \" value= \" $listed_boolean_prefs\" >" ;
639 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
640 "hook_prefs_tab_section" , "prefPrefsPrefsInside" );
642 print '</div>' ; # inside pane
643 print '<div dojoType="dijit.layout.ContentPane" region="bottom">' ;
645 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-prefs \" >" ;
646 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" saveconfig \" >" ;
648 print "<div dojoType= \" dijit.form.ComboButton \" type= \" submit \" >
649 <span>" . __ ( 'Save configuration' ). "</span>
650 <div dojoType= \" dijit.DropDownMenu \" >
651 <div dojoType= \" dijit.MenuItem \"
652 onclick= \" dijit.byId('changeSettingsForm').onSubmit(null, true) \" >" .
653 __ ( "Save and exit preferences" ). "</div>
657 print "<button dojoType= \" dijit.form.Button \" onclick= \" return editProfiles() \" >" .
658 __ ( 'Manage profiles' ). "</button> " ;
660 print "<button dojoType= \" dijit.form.Button \" onclick= \" return validatePrefsReset() \" >" .
661 __ ( 'Reset to defaults' ). "</button>" ;
665 /* $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
667 print "<input onclick='toggleAdvancedPrefs()'
668 id='prefs_show_advanced'
669 dojoType=\"dijit.form.CheckBox\"
671 type=\"checkbox\"></input>
672 <label for='prefs_show_advanced'>" .
673 __("Show additional preferences") . "</label>"; */
676 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
677 "hook_prefs_tab_section" , "prefPrefsPrefsOutside" );
680 print '</div>' ; # inner pane
681 print '</div>' ; # border container
683 print "</div>" ; #pane
685 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Plugins' ). " \" >" ;
687 print "<h2>" . __ ( "Plugins" ). "</h2>" ;
689 print "<p>" . __ ( "You will need to reload Tiny Tiny RSS for plugin changes to take effect." ) . "</p>" ;
691 print_notice ( __ ( "Download more plugins at tt-rss.org <a class= \" visibleLink \" target= \" _blank \" href= \" http://tt-rss.org/forum/viewforum.php?f=22 \" >forums</a> or <a target= \" _blank \" class= \" visibleLink \" href= \" http://tt-rss.org/wiki/Plugins \" >wiki</a>." ));
693 print "<form dojoType= \" dijit.form.Form \" id= \" changePluginsForm \" >" ;
695 print "<script type= \" dojo/method \" event= \" onSubmit \" args= \" evt \" >
696 evt.preventDefault();
697 if (this.validate()) {
698 notify_progress('Saving data...', true);
700 new Ajax.Request('backend.php', {
701 parameters: dojo.objectToQuery(this.getValues()),
702 onComplete: function(transport) {
704 if (confirm(__('Selected plugins have been enabled. Reload?'))) {
705 window.location.reload();
712 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-prefs \" >" ;
713 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" setplugins \" >" ;
715 print "<table width='100%' class='prefPluginsList'>" ;
717 print "<tr><td colspan='4'><h3>" . __ ( "System plugins" ). "</h3></td></tr>" ;
719 print "<tr class= \" title \" >
720 <td width= \" 5% \" > </td>
721 <td width='10%'>" . __ ( 'Plugin' ). "</td>
722 <td width=''>" . __ ( 'Description' ). "</td>
723 <td width='5%'>" . __ ( 'Version' ). "</td>
724 <td width='10%'>" . __ ( 'Author' ). "</td></tr>" ;
726 $system_enabled = array_map ( "trim" , explode ( "," , PLUGINS
));
727 $user_enabled = array_map ( "trim" , explode ( "," , get_pref ( $this -> link
, "_ENABLED_PLUGINS" )));
729 $tmppluginhost = new PluginHost ( $this -> link
);
730 $tmppluginhost -> load_all ( $tmppluginhost :: KIND_ALL
, $_SESSION [ "uid" ]);
731 $tmppluginhost -> load_data ( true );
733 foreach ( $tmppluginhost -> get_plugins () as $name => $plugin ) {
734 $about = $plugin -> about ();
736 if ( $about [ 3 ] && strpos ( $name , "example" ) === FALSE ) {
737 if ( in_array ( $name , $system_enabled )) {
738 $checked = "checked='1'" ;
745 print "<td align='center'><input disabled='1'
746 dojoType= \" dijit.form.CheckBox \" $checked
747 type= \" checkbox \" ></td>" ;
749 print "<td> $name </td>" ;
750 print "<td>" . htmlspecialchars ( $about [ 1 ]);
752 print " — <a target= \" _blank \" class= \" visibleLink \"
753 href= \" " . htmlspecialchars ( $about [ 4 ]). " \" >" . __ ( "more info" ). "</a>" ;
756 print "<td>" . htmlspecialchars ( sprintf ( "%.2f" , $about [ 0 ])) . "</td>" ;
757 print "<td>" . htmlspecialchars ( $about [ 2 ]) . "</td>" ;
759 if ( count ( $tmppluginhost -> get_all ( $plugin )) > 0 ) {
760 if ( in_array ( $name , $system_enabled )) {
761 print "<td><a href='#' onclick= \" clearPluginData(' $name ') \"
762 class='visibleLink'>" . __ ( "Clear data" ). "</a></td>" ;
771 print "<tr><td colspan='4'><h3>" . __ ( "User plugins" ). "</h3></td></tr>" ;
773 print "<tr class= \" title \" >
774 <td width= \" 5% \" > </td>
775 <td width='10%'>" . __ ( 'Plugin' ). "</td>
776 <td width=''>" . __ ( 'Description' ). "</td>
777 <td width='5%'>" . __ ( 'Version' ). "</td>
778 <td width='10%'>" . __ ( 'Author' ). "</td></tr>" ;
781 foreach ( $tmppluginhost -> get_plugins () as $name => $plugin ) {
782 $about = $plugin -> about ();
784 if (! $about [ 3 ] && strpos ( $name , "example" ) === FALSE ) {
786 if ( in_array ( $name , $system_enabled )) {
787 $checked = "checked='1'" ;
788 $disabled = "disabled='1'" ;
790 } else if ( in_array ( $name , $user_enabled )) {
791 $checked = "checked='1'" ;
793 $rowclass = "Selected" ;
800 print "<tr class=' $rowclass '>" ;
802 print "<td align='center'><input id='FPCHK- $name ' name='plugins[]' value=' $name ' onclick='toggleSelectRow2(this);'
803 dojoType= \" dijit.form.CheckBox \" $checked $disabled
804 type= \" checkbox \" ></td>" ;
806 print "<td><label for='FPCHK- $name '> $name </label></td>" ;
807 print "<td><label for='FPCHK- $name '>" . htmlspecialchars ( $about [ 1 ]) . "</label>" ;
809 print " — <a target= \" _blank \" class= \" visibleLink \"
810 href= \" " . htmlspecialchars ( $about [ 4 ]). " \" >" . __ ( "more info" ). "</a>" ;
814 print "<td>" . htmlspecialchars ( sprintf ( "%.2f" , $about [ 0 ])) . "</td>" ;
815 print "<td>" . htmlspecialchars ( $about [ 2 ]) . "</td>" ;
817 if ( count ( $tmppluginhost -> get_all ( $plugin )) > 0 ) {
818 if ( in_array ( $name , $system_enabled ) ||
in_array ( $name , $user_enabled )) {
819 print "<td><a href='#' onclick= \" clearPluginData(' $name ') \" class='visibleLink'>" . __ ( "Clear data" ). "</a></td>" ;
833 print "<p><button dojoType= \" dijit.form.Button \" type= \" submit \" >" .
834 __ ( "Enable selected plugins" ). "</button></p>" ;
838 print "</div>" ; #pane
841 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
842 "hook_prefs_tab" , "prefPrefs" );
844 print "</div>" ; #container
847 function toggleAdvanced () {
848 $_SESSION [ "prefs_show_advanced" ] = ! $_SESSION [ "prefs_show_advanced" ];
851 function otpqrcode () {
852 require_once "lib/otphp/vendor/base32.php" ;
853 require_once "lib/otphp/lib/otp.php" ;
854 require_once "lib/otphp/lib/totp.php" ;
855 require_once "lib/phpqrcode/phpqrcode.php" ;
857 $result = db_query ( $this -> link
, "SELECT login,salt,otp_enabled
859 WHERE id = " . $_SESSION [ "uid" ]);
861 $base32 = new Base32 ();
863 $login = db_fetch_result ( $result , 0 , "login" );
864 $otp_enabled = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "otp_enabled" ));
867 $secret = $base32 -> encode ( sha1 ( db_fetch_result ( $result , 0 , "salt" )));
868 $topt = new \OTPHP\
TOTP ( $secret );
869 print QRcode
:: png ( $topt -> provisioning_uri ( $login ));
873 function otpenable () {
874 $password = db_escape_string ( $this -> link
, $_REQUEST [ "password" ]);
875 $enable_otp = $_REQUEST [ "enable_otp" ] == "on" ;
878 $authenticator = $pluginhost -> get_plugin ( $_SESSION [ "auth_module" ]);
880 if ( $authenticator -> check_password ( $_SESSION [ "uid" ], $password )) {
883 db_query ( $this -> link
, "UPDATE ttrss_users SET otp_enabled = true WHERE
884 id = " . $_SESSION [ "uid" ]);
889 print "ERROR: " . __ ( "Incorrect password" );
894 function otpdisable () {
895 $password = db_escape_string ( $this -> link
, $_REQUEST [ "password" ]);
898 $authenticator = $pluginhost -> get_plugin ( $_SESSION [ "auth_module" ]);
900 if ( $authenticator -> check_password ( $_SESSION [ "uid" ], $password )) {
902 db_query ( $this -> link
, "UPDATE ttrss_users SET otp_enabled = false WHERE
903 id = " . $_SESSION [ "uid" ]);
907 print "ERROR: " . __ ( "Incorrect password" );
912 function setplugins () {
913 if ( is_array ( $_REQUEST [ "plugins" ]))
914 $plugins = join ( "," , $_REQUEST [ "plugins" ]);
918 set_pref ( $this -> link
, "_ENABLED_PLUGINS" , $plugins );
921 function clearplugindata () {
922 $name = db_escape_string ( $this -> link
, $_REQUEST [ "name" ]);
925 $pluginhost -> clear_data ( $pluginhost -> get_plugin ( $name ));
928 function customizeCSS () {
929 $value = get_pref ( $this -> link
, "USER_STYLESHEET" );
931 $value = str_replace ( "<br/>" , " \n " , $value );
933 print_notice ( T_sprintf ( "You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target= \" _blank \" class= \" visibleLink \" href= \" %s\" >This file</a> can be used as a baseline." , "tt-rss.css" ));
935 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" rpc \" >" ;
936 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" setpref \" >" ;
937 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" key \" value= \" USER_STYLESHEET \" >" ;
939 print "<table width='100%'><tr><td>" ;
940 print "<textarea dojoType= \" dijit.form.SimpleTextarea \"
941 style='font-size : 12px; width : 100%; height: 200px;'
942 placeHolder='body#ttrssMain { font-size : 14px; };'
943 name='value'> $value </textarea>" ;
944 print "</td></tr></table>" ;
946 print "<div class='dlgButtons'>" ;
947 print "<button dojoType= \" dijit.form.Button \"
948 onclick= \" dijit.byId('cssEditDlg').execute() \" >" . __ ( 'Save' ). "</button> " ;
949 print "<button dojoType= \" dijit.form.Button \"
950 onclick= \" dijit.byId('cssEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>" ;
955 function editPrefProfiles () {
956 print "<div dojoType= \" dijit.Toolbar \" >" ;
958 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
959 "<span>" . __ ( 'Select' ). "</span>" ;
960 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
961 print "<div onclick= \" selectTableRows('prefFeedProfileList', 'all') \"
962 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
963 print "<div onclick= \" selectTableRows('prefFeedProfileList', 'none') \"
964 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
965 print "</div></div>" ;
967 print "<div style= \" float : right \" >" ;
969 print "<input name= \" newprofile \" dojoType= \" dijit.form.ValidationTextBox \"
971 <button dojoType= \" dijit.form.Button \"
972 onclick= \" dijit.byId('profileEditDlg').addProfile() \" >" .
973 __ ( 'Create profile' ). "</button></div>" ;
977 $result = db_query ( $this -> link
, "SELECT title,id FROM ttrss_settings_profiles
978 WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER BY title" );
980 print "<div class= \" prefProfileHolder \" >" ;
982 print "<form id= \" profile_edit_form \" onsubmit= \" return false \" >" ;
984 print "<table width= \" 100% \" class= \" prefFeedProfileList \"
985 cellspacing= \" 0 \" id= \" prefFeedProfileList \" >" ;
987 print "<tr class= \" placeholder \" id= \" FCATR-0 \" >" ; #odd
989 print "<td width='5%' align='center'><input
991 onclick='toggleSelectRow2(this);'
992 dojoType= \" dijit.form.CheckBox \"
993 type= \" checkbox \" ></td>" ;
995 if (! $_SESSION [ "profile" ]) {
996 $is_active = __ ( "(active)" );
1001 print "<td><span>" .
1002 __ ( "Default profile" ) . " $is_active </span></td>" ;
1008 while ( $line = db_fetch_assoc ( $result )) {
1010 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1012 $profile_id = $line [ "id" ];
1013 $this_row_id = "id= \" FCATR- $profile_id\" " ;
1015 print "<tr class= \" placeholder \" $this_row_id >" ;
1017 $edit_title = htmlspecialchars ( $line [ "title" ]);
1019 print "<td width='5%' align='center'><input
1020 onclick='toggleSelectRow2(this);'
1021 id='FCATC- $profile_id '
1022 dojoType= \" dijit.form.CheckBox \"
1023 type= \" checkbox \" ></td>" ;
1025 if ( $_SESSION [ "profile" ] == $line [ "id" ]) {
1026 $is_active = __ ( "(active)" );
1031 print "<td><span dojoType= \" dijit.InlineEditBox \"
1032 width= \" 300px \" autoSave= \" false \"
1033 profile-id= \" $profile_id\" >" . $edit_title .
1034 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1038 content: {op: 'rpc', method: 'saveprofile',
1040 id: this.srcNodeRef.getAttribute('profile-id')},
1041 load: function(response) {
1042 elem.attr('value', response);
1046 </span> $is_active </td>" ;
1057 print "<div class='dlgButtons'>
1058 <div style='float : left'>
1059 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('profileEditDlg').removeSelected() \" >" .
1060 __ ( 'Remove selected profiles' ). "</button>
1061 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('profileEditDlg').activateProfile() \" >" .
1062 __ ( 'Activate profile' ). "</button>
1065 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('profileEditDlg').hide() \" >" .
1066 __ ( 'Close this window' ). "</button>" ;
1071 private function getShortDesc ( $pref_name ) {
1072 if ( isset ( $this -> pref_help
[ $pref_name ])) {
1073 return $this -> pref_help
[ $pref_name ][ 0 ];
1078 private function getHelpText ( $pref_name ) {
1079 if ( isset ( $this -> pref_help
[ $pref_name ])) {
1080 return $this -> pref_help
[ $pref_name ][ 1 ];
1085 private function getSectionName ( $id ) {
1086 if ( isset ( $this -> pref_sections
[ $id ])) {
1087 return $this -> pref_sections
[ $id ];