You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

func.inc 58KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/settings/func.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2013, The Roundcube Dev Team |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Provide functionality for user's settings & preferences |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Thomas Bruederli <roundcube@gmail.com> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. if (!$OUTPUT->ajax_call) {
  21. $OUTPUT->set_pagetitle($RCMAIL->gettext('preferences'));
  22. }
  23. // register UI objects
  24. $OUTPUT->add_handlers(array(
  25. 'settingstabs' => 'rcmail_settings_tabs',
  26. 'prefsframe' => 'rcmail_preferences_frame',
  27. 'sectionslist' => 'rcmail_sections_list',
  28. 'identitieslist' => 'rcmail_identities_list',
  29. ));
  30. // register action aliases
  31. $RCMAIL->register_action_map(array(
  32. 'folders' => 'folders.inc',
  33. 'rename-folder' => 'folders.inc',
  34. 'delete-folder' => 'folders.inc',
  35. 'subscribe' => 'folders.inc',
  36. 'unsubscribe' => 'folders.inc',
  37. 'purge' => 'folders.inc',
  38. 'folder-size' => 'folders.inc',
  39. 'add-identity' => 'edit_identity.inc',
  40. 'add-response' => 'edit_response.inc',
  41. 'save-response' => 'edit_response.inc',
  42. 'delete-response' => 'responses.inc',
  43. 'delete-identity' => 'identities.inc',
  44. 'upload-display' => 'upload.inc',
  45. ));
  46. // similar function as /steps/settings/identities.inc::rcmail_identity_frame()
  47. function rcmail_preferences_frame($attrib)
  48. {
  49. global $OUTPUT;
  50. if (!$attrib['id']) {
  51. $attrib['id'] = 'rcmprefsframe';
  52. }
  53. return $OUTPUT->frame($attrib, true);
  54. }
  55. function rcmail_sections_list($attrib)
  56. {
  57. global $RCMAIL;
  58. // add id to message list table if not specified
  59. if (!strlen($attrib['id'])) {
  60. $attrib['id'] = 'rcmsectionslist';
  61. }
  62. list($list, $cols) = rcmail_user_prefs();
  63. // create XHTML table
  64. $out = $RCMAIL->table_output($attrib, $list, $cols, 'id');
  65. // set client env
  66. $RCMAIL->output->add_gui_object('sectionslist', $attrib['id']);
  67. $RCMAIL->output->include_script('list.js');
  68. return $out;
  69. }
  70. function rcmail_identities_list($attrib)
  71. {
  72. global $OUTPUT, $RCMAIL;
  73. // add id to message list table if not specified
  74. if (!strlen($attrib['id'])) {
  75. $attrib['id'] = 'rcmIdentitiesList';
  76. }
  77. // get identities list and define 'mail' column
  78. $list = $RCMAIL->user->list_emails();
  79. foreach ($list as $idx => $row) {
  80. $list[$idx]['mail'] = trim($row['name'] . ' <' . rcube_utils::idn_to_utf8($row['email']) . '>');
  81. }
  82. // get all identites from DB and define list of cols to be displayed
  83. $plugin = $RCMAIL->plugins->exec_hook('identities_list', array(
  84. 'list' => $list,
  85. 'cols' => array('mail')
  86. ));
  87. // @TODO: use <UL> instead of <TABLE> for identities list
  88. // create XHTML table
  89. $out = $RCMAIL->table_output($attrib, $plugin['list'], $plugin['cols'], 'identity_id');
  90. // set client env
  91. $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
  92. return $out;
  93. }
  94. // similar function as in /steps/addressbook/edit.inc
  95. function get_form_tags($attrib, $action, $id = null, $hidden = null)
  96. {
  97. global $EDIT_FORM, $RCMAIL;
  98. $form_start = $form_end = '';
  99. if (empty($EDIT_FORM)) {
  100. $request_key = $action . (isset($id) ? '.'.$id : '');
  101. $form_start = $RCMAIL->output->request_form(array(
  102. 'name' => 'form',
  103. 'method' => 'post',
  104. 'task' => $RCMAIL->task,
  105. 'action' => $action,
  106. 'request' => $request_key,
  107. 'noclose' => true
  108. ) + $attrib);
  109. if (is_array($hidden)) {
  110. $hiddenfields = new html_hiddenfield($hidden);
  111. $form_start .= $hiddenfields->show();
  112. }
  113. $form_end = !strlen($attrib['form']) ? '</form>' : '';
  114. $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form';
  115. $RCMAIL->output->add_gui_object('editform', $EDIT_FORM);
  116. }
  117. return array($form_start, $form_end);
  118. }
  119. function rcmail_user_prefs($current = null)
  120. {
  121. global $RCMAIL;
  122. $sections['general'] = array('id' => 'general', 'section' => $RCMAIL->gettext('uisettings'));
  123. $sections['mailbox'] = array('id' => 'mailbox', 'section' => $RCMAIL->gettext('mailboxview'));
  124. $sections['mailview'] = array('id' => 'mailview','section' => $RCMAIL->gettext('messagesdisplaying'));
  125. $sections['compose'] = array('id' => 'compose', 'section' => $RCMAIL->gettext('messagescomposition'));
  126. $sections['addressbook'] = array('id' => 'addressbook','section' => $RCMAIL->gettext('addressbook'));
  127. $sections['folders'] = array('id' => 'folders', 'section' => $RCMAIL->gettext('specialfolders'));
  128. $sections['server'] = array('id' => 'server', 'section' => $RCMAIL->gettext('serversettings'));
  129. // hook + define list cols
  130. $plugin = $RCMAIL->plugins->exec_hook('preferences_sections_list',
  131. array('list' => $sections, 'cols' => array('section')));
  132. $sections = $plugin['list'];
  133. $config = $RCMAIL->config->all();
  134. $no_override = array_flip((array)$RCMAIL->config->get('dont_override'));
  135. foreach ($sections as $idx => $sect) {
  136. if ($current && $sect['id'] != $current) {
  137. continue;
  138. }
  139. $blocks = array();
  140. switch ($sect['id']) {
  141. // general
  142. case 'general':
  143. $blocks = array(
  144. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  145. 'skin' => array('name' => rcube::Q($RCMAIL->gettext('skin'))),
  146. 'browser' => array('name' => rcube::Q($RCMAIL->gettext('browseroptions'))),
  147. 'advanced'=> array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  148. );
  149. // language selection
  150. if (!isset($no_override['language'])) {
  151. if (!$current) {
  152. continue 2;
  153. }
  154. $a_lang = $RCMAIL->list_languages();
  155. asort($a_lang);
  156. $field_id = 'rcmfd_lang';
  157. $select = new html_select(array('name' => '_language', 'id' => $field_id));
  158. $select->add(array_values($a_lang), array_keys($a_lang));
  159. $blocks['main']['options']['language'] = array(
  160. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('language'))),
  161. 'content' => $select->show($RCMAIL->user->language),
  162. );
  163. }
  164. // timezone selection
  165. if (!isset($no_override['timezone'])) {
  166. if (!$current) {
  167. continue 2;
  168. }
  169. $field_id = 'rcmfd_timezone';
  170. $select = new html_select(array('name' => '_timezone', 'id' => $field_id));
  171. $select->add($RCMAIL->gettext('autodetect'), 'auto');
  172. $zones = array();
  173. foreach (DateTimeZone::listIdentifiers() as $i => $tzs) {
  174. try {
  175. $tz = new DateTimeZone($tzs);
  176. $date = new DateTime(date('Y') . '-12-21', $tz);
  177. $offset = $date->format('Z') + 45000;
  178. $sortkey = sprintf('%06d.%s', $offset, $tzs);
  179. $zones[$sortkey] = array($tzs, $date->format('P'));
  180. }
  181. catch (Exception $e) {}
  182. }
  183. ksort($zones);
  184. foreach ($zones as $zone) {
  185. list($tzs, $offset) = $zone;
  186. $select->add('(GMT ' . $offset . ') ' . strtr($tzs, '_', ' '), $tzs);
  187. }
  188. $blocks['main']['options']['timezone'] = array(
  189. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('timezone'))),
  190. 'content' => $select->show((string)$config['timezone']),
  191. );
  192. }
  193. // date/time formatting
  194. if (!isset($no_override['time_format'])) {
  195. if (!$current) {
  196. continue 2;
  197. }
  198. $reftime = mktime(7,30,0);
  199. $defaults = array('G:i', 'H:i', 'g:i a', 'h:i A');
  200. $formats = (array)$RCMAIL->config->get('time_formats', $defaults);
  201. $field_id = 'rcmfd_time_format';
  202. $select = new html_select(array('name' => '_time_format', 'id' => $field_id));
  203. foreach ($formats as $choice) {
  204. $select->add(date($choice, $reftime), $choice);
  205. }
  206. $blocks['main']['options']['time_format'] = array(
  207. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('timeformat'))),
  208. 'content' => $select->show($RCMAIL->config->get('time_format')),
  209. );
  210. }
  211. if (!isset($no_override['date_format'])) {
  212. if (!$current) {
  213. continue 2;
  214. }
  215. $refdate = mktime(12,30,0,7,24);
  216. $defaults = array('Y-m-d','d-m-Y','Y/m/d','m/d/Y','d/m/Y','d.m.Y','j.n.Y');
  217. $formats = (array)$RCMAIL->config->get('date_formats', $defaults);
  218. $field_id = 'rcmfd_date_format';
  219. $select = new html_select(array('name' => '_date_format', 'id' => $field_id));
  220. foreach ($formats as $choice) {
  221. $select->add(date($choice, $refdate), $choice);
  222. }
  223. $blocks['main']['options']['date_format'] = array(
  224. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('dateformat'))),
  225. 'content' => $select->show($config['date_format']),
  226. );
  227. }
  228. // Show checkbox for toggling 'pretty dates'
  229. if (!isset($no_override['prettydate'])) {
  230. if (!$current) {
  231. continue 2;
  232. }
  233. $field_id = 'rcmfd_prettydate';
  234. $input = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
  235. $blocks['main']['options']['prettydate'] = array(
  236. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('prettydate'))),
  237. 'content' => $input->show($config['prettydate']?1:0),
  238. );
  239. }
  240. if (!isset($no_override['refresh_interval'])) {
  241. if (!$current) {
  242. continue 2;
  243. }
  244. $field_id = 'rcmfd_refresh_interval';
  245. $select = new html_select(array('name' => '_refresh_interval', 'id' => $field_id));
  246. $select->add($RCMAIL->gettext('never'), 0);
  247. foreach (array(1, 3, 5, 10, 15, 30, 60) as $min) {
  248. if (!$config['min_refresh_interval'] || $config['min_refresh_interval'] <= $min * 60) {
  249. $label = $RCMAIL->gettext(array('name' => 'everynminutes', 'vars' => array('n' => $min)));
  250. $select->add($label, $min);
  251. }
  252. }
  253. $blocks['main']['options']['refresh_interval'] = array(
  254. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('refreshinterval'))),
  255. 'content' => $select->show($config['refresh_interval']/60),
  256. );
  257. }
  258. // show drop-down for available skins
  259. if (!isset($no_override['skin'])) {
  260. if (!$current) {
  261. continue 2;
  262. }
  263. $skins = rcmail_get_skins();
  264. if (count($skins) > 1) {
  265. $field_id = 'rcmfd_skin';
  266. $input = new html_radiobutton(array('name'=>'_skin'));
  267. foreach ($skins as $skin) {
  268. $thumbnail = "skins/$skin/thumbnail.png";
  269. $skinname = ucfirst($skin);
  270. $author_link = $license_link = '';
  271. $meta = @json_decode(@file_get_contents(INSTALL_PATH . "skins/$skin/meta.json"), true);
  272. if (is_array($meta) && $meta['name']) {
  273. $skinname = $meta['name'];
  274. $author_link = $meta['url'] ? html::a(array('href' => $meta['url'], 'target' => '_blank'), rcube::Q($meta['author'])) : rcube::Q($meta['author']);
  275. $license_link = $meta['license-url'] ? html::a(array('href' => $meta['license-url'], 'target' => '_blank', 'tabindex' => '-1'), rcube::Q($meta['license'])) : rcube::Q($meta['license']);
  276. }
  277. $img = html::img(array(
  278. 'src' => $thumbnail,
  279. 'class' => 'skinthumbnail',
  280. 'alt' => $skin,
  281. 'width' => 64,
  282. 'height' => 64,
  283. 'onerror' => "this.src = rcmail.assets_path('program/resources/blank.gif')",
  284. ));
  285. $skinnames[] = mb_strtolower($skinname);
  286. $blocks['skin']['options'][$skin]['content'] = html::label(array('class' => 'skinselection'),
  287. html::span('skinitem', $input->show($config['skin'], array('value' => $skin, 'id' => $field_id.$skin))) .
  288. html::span('skinitem', $img) .
  289. html::span('skinitem', html::span('skinname', rcube::Q($skinname)) . html::br() .
  290. html::span('skinauthor', $author_link ? 'by ' . $author_link : '') . html::br() .
  291. html::span('skinlicense', $license_link ? $RCMAIL->gettext('license').':&nbsp;' . $license_link : ''))
  292. );
  293. }
  294. array_multisort($blocks['skin']['options'], SORT_ASC, SORT_STRING, $skinnames);
  295. }
  296. }
  297. // standard_windows option decides if new windows should be
  298. // opened as popups or standard windows (which can be handled by browsers as tabs)
  299. if (!isset($no_override['standard_windows'])) {
  300. if (!$current) {
  301. continue 2;
  302. }
  303. $field_id = 'rcmfd_standard_windows';
  304. $checkbox = new html_checkbox(array('name' => '_standard_windows', 'id' => $field_id, 'value' => 1));
  305. $blocks['browser']['options']['standard_windows'] = array(
  306. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('standardwindows'))),
  307. 'content' => $checkbox->show($config['standard_windows']?1:0),
  308. );
  309. }
  310. if ($current) {
  311. $product_name = $RCMAIL->config->get('product_name', 'Roundcube Webmail');
  312. $RCMAIL->output->add_script(sprintf("%s.check_protocol_handler('%s', '#mailtoprotohandler');",
  313. rcmail_output::JS_OBJECT_NAME, rcube::JQ($product_name)), 'docready');
  314. }
  315. $blocks['browser']['options']['mailtoprotohandler'] = array(
  316. 'content' => html::a(array(
  317. 'href' => '#',
  318. 'id' => 'mailtoprotohandler'
  319. ),
  320. rcube::Q($RCMAIL->gettext('mailtoprotohandler'))) .
  321. html::span('mailtoprotohandler-status', ''),
  322. );
  323. break;
  324. // Mailbox view (mail screen)
  325. case 'mailbox':
  326. $blocks = array(
  327. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  328. 'new_message' => array('name' => rcube::Q($RCMAIL->gettext('newmessage'))),
  329. 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  330. );
  331. // show config parameter for preview pane
  332. if (!isset($no_override['preview_pane'])) {
  333. if (!$current) {
  334. continue 2;
  335. }
  336. $field_id = 'rcmfd_preview';
  337. $input = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1,
  338. 'onchange' => "$('#rcmfd_preview_pane_mark_read').prop('disabled', !this.checked)"));
  339. $blocks['main']['options']['preview_pane'] = array(
  340. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('previewpane'))),
  341. 'content' => $input->show($config['preview_pane']?1:0),
  342. );
  343. }
  344. // show config parameter for preview pane auto mark as read delay
  345. if (!isset($no_override['preview_pane_mark_read'])) {
  346. if (!$current) {
  347. continue 2;
  348. }
  349. // apply default if config option is not set at all
  350. $config['preview_pane_mark_read'] = $RCMAIL->config->get('preview_pane_mark_read', 0);
  351. $field_id = 'rcmfd_preview_pane_mark_read';
  352. $select = new html_select(array('name' => '_preview_pane_mark_read', 'id' => $field_id,
  353. 'disabled' => $config['preview_pane']?0:1));
  354. $select->add($RCMAIL->gettext('never'), '-1');
  355. $select->add($RCMAIL->gettext('immediately'), 0);
  356. foreach (array(5, 10, 20, 30) as $sec) {
  357. $label = $RCMAIL->gettext(array('name' => 'afternseconds', 'vars' => array('n' => $sec)));
  358. $select->add($label, $sec);
  359. }
  360. $blocks['main']['options']['preview_pane_mark_read'] = array(
  361. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('previewpanemarkread'))),
  362. 'content' => $select->show(intval($config['preview_pane_mark_read'])),
  363. );
  364. }
  365. if (!isset($no_override['mdn_requests'])) {
  366. if (!$current) {
  367. continue 2;
  368. }
  369. $field_id = 'rcmfd_mdn_requests';
  370. $select = new html_select(array('name' => '_mdn_requests', 'id' => $field_id));
  371. $select->add($RCMAIL->gettext('askuser'), 0);
  372. $select->add($RCMAIL->gettext('autosend'), 1);
  373. $select->add($RCMAIL->gettext('autosendknown'), 3);
  374. $select->add($RCMAIL->gettext('autosendknownignore'), 4);
  375. $select->add($RCMAIL->gettext('ignorerequest'), 2);
  376. $blocks['main']['options']['mdn_requests'] = array(
  377. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('mdnrequests'))),
  378. 'content' => $select->show($config['mdn_requests']),
  379. );
  380. }
  381. if (!isset($no_override['autoexpand_threads'])) {
  382. if (!$current) {
  383. continue 2;
  384. }
  385. $storage = $RCMAIL->get_storage();
  386. $supported = $storage->get_capability('THREAD');
  387. if ($supported) {
  388. $field_id = 'rcmfd_autoexpand_threads';
  389. $select = new html_select(array('name' => '_autoexpand_threads', 'id' => $field_id));
  390. $select->add($RCMAIL->gettext('never'), 0);
  391. $select->add($RCMAIL->gettext('do_expand'), 1);
  392. $select->add($RCMAIL->gettext('expand_only_unread'), 2);
  393. $blocks['main']['options']['autoexpand_threads'] = array(
  394. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autoexpand_threads'))),
  395. 'content' => $select->show($config['autoexpand_threads']),
  396. );
  397. }
  398. }
  399. // show page size selection
  400. if (!isset($no_override['mail_pagesize'])) {
  401. if (!$current) {
  402. continue 2;
  403. }
  404. $field_id = 'rcmfd_mail_pagesize';
  405. $input = new html_inputfield(array('name' => '_mail_pagesize', 'id' => $field_id, 'size' => 5));
  406. $size = intval($config['mail_pagesize'] ?: $config['pagesize']);
  407. $blocks['main']['options']['pagesize'] = array(
  408. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('pagesize'))),
  409. 'content' => $input->show($size ?: 50),
  410. );
  411. }
  412. if (!isset($no_override['check_all_folders'])) {
  413. if (!$current) {
  414. continue 2;
  415. }
  416. $field_id = 'rcmfd_check_all_folders';
  417. $input = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1));
  418. $blocks['new_message']['options']['check_all_folders'] = array(
  419. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('checkallfolders'))),
  420. 'content' => $input->show($config['check_all_folders']?1:0),
  421. );
  422. }
  423. break;
  424. // Message viewing
  425. case 'mailview':
  426. $blocks = array(
  427. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  428. 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  429. );
  430. // show checkbox to open message view in new window
  431. if (!isset($no_override['message_extwin'])) {
  432. if (!$current) {
  433. continue 2;
  434. }
  435. $field_id = 'rcmfd_message_extwin';
  436. $input = new html_checkbox(array('name' => '_message_extwin', 'id' => $field_id, 'value' => 1));
  437. $blocks['main']['options']['message_extwin'] = array(
  438. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showinextwin'))),
  439. 'content' => $input->show($config['message_extwin']?1:0),
  440. );
  441. }
  442. // show checkbox to show email instead of name
  443. if (!isset($no_override['message_show_email'])) {
  444. if (!$current) {
  445. continue 2;
  446. }
  447. $field_id = 'rcmfd_message_show_email';
  448. $input = new html_checkbox(array('name' => '_message_show_email', 'id' => $field_id, 'value' => 1));
  449. $blocks['main']['options']['message_show_email'] = array(
  450. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showemail'))),
  451. 'content' => $input->show($config['message_show_email']?1:0),
  452. );
  453. }
  454. // show checkbox for HTML/plaintext messages
  455. if (!isset($no_override['prefer_html'])) {
  456. if (!$current) {
  457. continue 2;
  458. }
  459. $field_id = 'rcmfd_htmlmsg';
  460. $input = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1,
  461. 'onchange' => "$('#rcmfd_show_images').prop('disabled', !this.checked).val(0)"));
  462. $blocks['main']['options']['prefer_html'] = array(
  463. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('preferhtml'))),
  464. 'content' => $input->show($config['prefer_html']?1:0),
  465. );
  466. }
  467. if (!isset($no_override['default_charset'])) {
  468. if (!$current) {
  469. continue 2;
  470. }
  471. $field_id = 'rcmfd_default_charset';
  472. $blocks['advanced']['options']['default_charset'] = array(
  473. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('defaultcharset'))),
  474. 'content' => $RCMAIL->output->charset_selector(array(
  475. 'id' => $field_id, 'name' => '_default_charset', 'selected' => $config['default_charset']
  476. )));
  477. }
  478. if (!isset($no_override['show_images'])) {
  479. if (!$current) {
  480. continue 2;
  481. }
  482. $field_id = 'rcmfd_show_images';
  483. $input = new html_select(array('name' => '_show_images', 'id' => $field_id,
  484. 'disabled' => !$config['prefer_html']));
  485. $input->add($RCMAIL->gettext('never'), 0);
  486. $input->add($RCMAIL->gettext('fromknownsenders'), 1);
  487. $input->add($RCMAIL->gettext('always'), 2);
  488. $blocks['main']['options']['show_images'] = array(
  489. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showremoteimages'))),
  490. 'content' => $input->show($config['prefer_html'] ? $config['show_images'] : 0),
  491. );
  492. }
  493. if (!isset($no_override['inline_images'])) {
  494. if (!$current) {
  495. continue 2;
  496. }
  497. $field_id = 'rcmfd_inline_images';
  498. $input = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1));
  499. $blocks['main']['options']['inline_images'] = array(
  500. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showinlineimages'))),
  501. 'content' => $input->show($config['inline_images']?1:0),
  502. );
  503. }
  504. // "display after delete" checkbox
  505. if (!isset($no_override['display_next'])) {
  506. if (!$current) {
  507. continue 2;
  508. }
  509. $field_id = 'rcmfd_displaynext';
  510. $input = new html_checkbox(array('name' => '_display_next', 'id' => $field_id, 'value' => 1));
  511. $blocks['main']['options']['display_next'] = array(
  512. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('displaynext'))),
  513. 'content' => $input->show($config['display_next']?1:0),
  514. );
  515. }
  516. break;
  517. // Mail composition
  518. case 'compose':
  519. $blocks = array(
  520. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  521. 'sig' => array('name' => rcube::Q($RCMAIL->gettext('signatureoptions'))),
  522. 'spellcheck' => array('name' => rcube::Q($RCMAIL->gettext('spellcheckoptions'))),
  523. 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  524. );
  525. // show checkbox to compose messages in a new window
  526. if (!isset($no_override['compose_extwin'])) {
  527. if (!$current) {
  528. continue 2;
  529. }
  530. $field_id = 'rcmfdcompose_extwin';
  531. $input = new html_checkbox(array('name' => '_compose_extwin', 'id' => $field_id, 'value' => 1));
  532. $blocks['main']['options']['compose_extwin'] = array(
  533. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('composeextwin'))),
  534. 'content' => $input->show($config['compose_extwin']?1:0),
  535. );
  536. }
  537. if (!isset($no_override['htmleditor'])) {
  538. if (!$current) {
  539. continue 2;
  540. }
  541. $field_id = 'rcmfd_htmleditor';
  542. $select = new html_select(array('name' => '_htmleditor', 'id' => $field_id));
  543. $select->add($RCMAIL->gettext('never'), 0);
  544. $select->add($RCMAIL->gettext('htmlonreply'), 2);
  545. $select->add($RCMAIL->gettext('htmlonreplyandforward'), 3);
  546. $select->add($RCMAIL->gettext('always'), 1);
  547. $select->add($RCMAIL->gettext('alwaysbutplain'), 4);
  548. $blocks['main']['options']['htmleditor'] = array(
  549. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('htmleditor'))),
  550. 'content' => $select->show(intval($config['htmleditor'])),
  551. );
  552. }
  553. if (!isset($no_override['draft_autosave'])) {
  554. if (!$current) {
  555. continue 2;
  556. }
  557. $field_id = 'rcmfd_autosave';
  558. $select = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox'])));
  559. $select->add($RCMAIL->gettext('never'), 0);
  560. foreach (array(1, 3, 5, 10) as $i => $min) {
  561. $label = $RCMAIL->gettext(array('name' => 'everynminutes', 'vars' => array('n' => $min)));
  562. $select->add($label, $min*60);
  563. }
  564. $blocks['main']['options']['draft_autosave'] = array(
  565. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autosavedraft'))),
  566. 'content' => $select->show($config['draft_autosave']),
  567. );
  568. }
  569. if (!isset($no_override['mime_param_folding'])) {
  570. if (!$current) {
  571. continue 2;
  572. }
  573. $field_id = 'rcmfd_param_folding';
  574. $select = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id));
  575. $select->add($RCMAIL->gettext('2231folding'), 0);
  576. $select->add($RCMAIL->gettext('miscfolding'), 1);
  577. $select->add($RCMAIL->gettext('2047folding'), 2);
  578. $blocks['advanced']['options']['mime_param_folding'] = array(
  579. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('mimeparamfolding'))),
  580. 'content' => $select->show($config['mime_param_folding']),
  581. );
  582. }
  583. if (!isset($no_override['force_7bit'])) {
  584. if (!$current) {
  585. continue 2;
  586. }
  587. $field_id = 'rcmfd_force_7bit';
  588. $input = new html_checkbox(array('name' => '_force_7bit', 'id' => $field_id, 'value' => 1));
  589. $blocks['advanced']['options']['force_7bit'] = array(
  590. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('force7bit'))),
  591. 'content' => $input->show($config['force_7bit']?1:0),
  592. );
  593. }
  594. if (!isset($no_override['mdn_default'])) {
  595. if (!$current) {
  596. continue 2;
  597. }
  598. $field_id = 'rcmfd_mdn_default';
  599. $input = new html_checkbox(array('name' => '_mdn_default', 'id' => $field_id, 'value' => 1));
  600. $blocks['main']['options']['mdn_default'] = array(
  601. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('reqmdn'))),
  602. 'content' => $input->show($config['mdn_default']?1:0),
  603. );
  604. }
  605. if (!isset($no_override['dsn_default']) && $RCMAIL->config->get('smtp_server')) {
  606. if (!$current) {
  607. continue 2;
  608. }
  609. $field_id = 'rcmfd_dsn_default';
  610. $input = new html_checkbox(array('name' => '_dsn_default', 'id' => $field_id, 'value' => 1));
  611. $blocks['main']['options']['dsn_default'] = array(
  612. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('reqdsn'))),
  613. 'content' => $input->show($config['dsn_default']?1:0),
  614. );
  615. }
  616. if (!isset($no_override['reply_same_folder'])) {
  617. if (!$current) {
  618. continue 2;
  619. }
  620. $field_id = 'rcmfd_reply_same_folder';
  621. $input = new html_checkbox(array('name' => '_reply_same_folder', 'id' => $field_id, 'value' => 1));
  622. $blocks['main']['options']['reply_same_folder'] = array(
  623. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('replysamefolder'))),
  624. 'content' => $input->show($config['reply_same_folder']?1:0),
  625. );
  626. }
  627. if (!isset($no_override['reply_mode'])) {
  628. if (!$current) {
  629. continue 2;
  630. }
  631. $field_id = 'rcmfd_reply_mode';
  632. $select = new html_select(array('name' => '_reply_mode', 'id' => $field_id));
  633. $select->add($RCMAIL->gettext('replyempty'), -1);
  634. $select->add($RCMAIL->gettext('replybottomposting'), 0);
  635. $select->add($RCMAIL->gettext('replytopposting'), 1);
  636. $blocks['main']['options']['reply_mode'] = array(
  637. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('whenreplying'))),
  638. 'content' => $select->show(intval($config['reply_mode'])),
  639. );
  640. }
  641. if (!isset($no_override['spellcheck_before_send']) && $config['enable_spellcheck']) {
  642. if (!$current) {
  643. continue 2;
  644. }
  645. $field_id = 'rcmfd_spellcheck_before_send';
  646. $input = new html_checkbox(array('name' => '_spellcheck_before_send', 'id' => $field_id, 'value' => 1));
  647. $blocks['spellcheck']['options']['spellcheck_before_send'] = array(
  648. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('spellcheckbeforesend'))),
  649. 'content' => $input->show($config['spellcheck_before_send']?1:0),
  650. );
  651. }
  652. if ($config['enable_spellcheck']) {
  653. if (!$current) {
  654. continue 2;
  655. }
  656. foreach (array('syms', 'nums', 'caps') as $key) {
  657. $key = 'spellcheck_ignore_'.$key;
  658. if (!isset($no_override[$key])) {
  659. $input = new html_checkbox(array('name' => '_'.$key, 'id' => 'rcmfd_'.$key, 'value' => 1));
  660. $blocks['spellcheck']['options'][$key] = array(
  661. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext(str_replace('_', '', $key)))),
  662. 'content' => $input->show($config[$key]?1:0),
  663. );
  664. }
  665. }
  666. }
  667. if (!isset($no_override['show_sig'])) {
  668. if (!$current) {
  669. continue 2;
  670. }
  671. $field_id = 'rcmfd_show_sig';
  672. $select = new html_select(array('name' => '_show_sig', 'id' => $field_id));
  673. $select->add($RCMAIL->gettext('never'), 0);
  674. $select->add($RCMAIL->gettext('always'), 1);
  675. $select->add($RCMAIL->gettext('newmessageonly'), 2);
  676. $select->add($RCMAIL->gettext('replyandforwardonly'), 3);
  677. $blocks['sig']['options']['show_sig'] = array(
  678. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autoaddsignature'))),
  679. 'content' => $select->show($RCMAIL->config->get('show_sig', 1)),
  680. );
  681. }
  682. if (!isset($no_override['sig_below'])) {
  683. if (!$current) {
  684. continue 2;
  685. }
  686. $field_id = 'rcmfd_sig_below';
  687. $input = new html_checkbox(array('name' => '_sig_below', 'id' => $field_id, 'value' => 1));
  688. $blocks['sig']['options']['sig_below'] = array(
  689. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('sigbelow'))),
  690. 'content' => $input->show($RCMAIL->config->get('sig_below') ? 1 : 0),
  691. );
  692. }
  693. if (!isset($no_override['strip_existing_sig'])) {
  694. if (!$current) {
  695. continue 2;
  696. }
  697. $field_id = 'rcmfd_strip_existing_sig';
  698. $input = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1));
  699. $blocks['sig']['options']['strip_existing_sig'] = array(
  700. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('replyremovesignature'))),
  701. 'content' => $input->show($config['strip_existing_sig']?1:0),
  702. );
  703. }
  704. if (!isset($no_override['sig_separator'])) {
  705. if (!$current) {
  706. continue 2;
  707. }
  708. $field_id = 'rcmfd_sig_separator';
  709. $input = new html_checkbox(array('name' => '_sig_separator', 'id' => $field_id, 'value' => 1));
  710. $blocks['sig']['options']['sig_separator'] = array(
  711. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('sigseparator'))),
  712. 'content' => $input->show($RCMAIL->config->get('sig_separator') ? 1 : 0),
  713. );
  714. }
  715. if (!isset($no_override['forward_attachment'])) {
  716. if (!$current) {
  717. continue 2;
  718. }
  719. $field_id = 'rcmfd_forward_attachment';
  720. $select = new html_select(array('name' => '_forward_attachment', 'id' => $field_id));
  721. $select->add($RCMAIL->gettext('inline'), 0);
  722. $select->add($RCMAIL->gettext('asattachment'), 1);
  723. $blocks['main']['options']['forward_attachment'] = array(
  724. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('forwardmode'))),
  725. 'content' => $select->show(intval($config['forward_attachment'])),
  726. );
  727. }
  728. if (!isset($no_override['default_font']) || !isset($no_override['default_font_size'])) {
  729. if (!$current) {
  730. continue 2;
  731. }
  732. // Default font size
  733. $field_id = 'rcmfd_default_font_size';
  734. $select_default_font_size = new html_select(array('name' => '_default_font_size', 'id' => $field_id));
  735. $fontsizes = array('', '8pt', '10pt', '12pt', '14pt', '18pt', '24pt', '36pt');
  736. foreach ($fontsizes as $size) {
  737. $select_default_font_size->add($size, $size);
  738. }
  739. // Default font
  740. $field_id = 'rcmfd_default_font';
  741. $select_default_font = new html_select(array('name' => '_default_font', 'id' => $field_id));
  742. $select_default_font->add('', '');
  743. $fonts = rcmail::font_defs();
  744. foreach (array_keys($fonts) as $fname) {
  745. $select_default_font->add($fname, $fname);
  746. }
  747. $blocks['main']['options']['default_font'] = array(
  748. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('defaultfont'))),
  749. 'content' => $select_default_font->show($RCMAIL->config->get('default_font', 1)) .
  750. $select_default_font_size->show($RCMAIL->config->get('default_font_size', 1))
  751. );
  752. }
  753. if (!isset($no_override['reply_all_mode'])) {
  754. if (!$current) {
  755. continue 2;
  756. }
  757. $field_id = 'rcmfd_reply_all_mode';
  758. $select = new html_select(array('name' => '_reply_all_mode', 'id' => $field_id));
  759. $select->add($RCMAIL->gettext('replyalldefault'), 0);
  760. $select->add($RCMAIL->gettext('replyalllist'), 1);
  761. $blocks['main']['options']['reply_all_mode'] = array(
  762. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('replyallmode'))),
  763. 'content' => $select->show(intval($config['reply_all_mode'])),
  764. );
  765. }
  766. if (!isset($no_override['compose_save_localstorage'])) {
  767. if (!$current) {
  768. continue 2;
  769. }
  770. $field_id = 'rcmfd_compose_save_localstorage';
  771. $input = new html_checkbox(array('name' => '_compose_save_localstorage', 'id' => $field_id, 'value' => 1));
  772. $blocks['advanced']['options']['compose_save_localstorage'] = array(
  773. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('savelocalstorage'))),
  774. 'content' => $input->show($config['compose_save_localstorage']?1:0),
  775. );
  776. }
  777. break;
  778. // Addressbook config
  779. case 'addressbook':
  780. $blocks = array(
  781. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  782. 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  783. );
  784. if (!isset($no_override['default_addressbook'])
  785. && (!$current || ($books = $RCMAIL->get_address_sources(true, true)))
  786. ) {
  787. if (!$current) {
  788. continue 2;
  789. }
  790. $field_id = 'rcmfd_default_addressbook';
  791. $select = new html_select(array('name' => '_default_addressbook', 'id' => $field_id));
  792. foreach ($books as $book) {
  793. $select->add(html_entity_decode($book['name'], ENT_COMPAT, 'UTF-8'), $book['id']);
  794. }
  795. $blocks['main']['options']['default_addressbook'] = array(
  796. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('defaultabook'))),
  797. 'content' => $select->show($config['default_addressbook']),
  798. );
  799. }
  800. // show addressbook listing mode selection
  801. if (!isset($no_override['addressbook_name_listing'])) {
  802. if (!$current) {
  803. continue 2;
  804. }
  805. $field_id = 'rcmfd_addressbook_name_listing';
  806. $select = new html_select(array('name' => '_addressbook_name_listing', 'id' => $field_id));
  807. $select->add($RCMAIL->gettext('name'), 0);
  808. $select->add($RCMAIL->gettext('firstname') . ' ' . $RCMAIL->gettext('surname'), 1);
  809. $select->add($RCMAIL->gettext('surname') . ' ' . $RCMAIL->gettext('firstname'), 2);
  810. $select->add($RCMAIL->gettext('surname') . ', ' . $RCMAIL->gettext('firstname'), 3);
  811. $blocks['main']['options']['list_name_listing'] = array(
  812. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('listnamedisplay'))),
  813. 'content' => $select->show($config['addressbook_name_listing']),
  814. );
  815. }
  816. // show addressbook sort column
  817. if (!isset($no_override['addressbook_sort_col'])) {
  818. if (!$current) {
  819. continue 2;
  820. }
  821. $field_id = 'rcmfd_addressbook_sort_col';
  822. $select = new html_select(array('name' => '_addressbook_sort_col', 'id' => $field_id));
  823. $select->add($RCMAIL->gettext('name'), 'name');
  824. $select->add($RCMAIL->gettext('firstname'), 'firstname');
  825. $select->add($RCMAIL->gettext('surname'), 'surname');
  826. $blocks['main']['options']['sort_col'] = array(
  827. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('listsorting'))),
  828. 'content' => $select->show($config['addressbook_sort_col']),
  829. );
  830. }
  831. // show addressbook page size selection
  832. if (!isset($no_override['addressbook_pagesize'])) {
  833. if (!$current) {
  834. continue 2;
  835. }
  836. $field_id = 'rcmfd_addressbook_pagesize';
  837. $input = new html_inputfield(array('name' => '_addressbook_pagesize', 'id' => $field_id, 'size' => 5));
  838. $size = intval($config['addressbook_pagesize'] ?: $config['pagesize']);
  839. $blocks['main']['options']['pagesize'] = array(
  840. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('pagesize'))),
  841. 'content' => $input->show($size ?: 50),
  842. );
  843. }
  844. if (!isset($no_override['autocomplete_single'])) {
  845. if (!$current) {
  846. continue 2;
  847. }
  848. $field_id = 'rcmfd_autocomplete_single';
  849. $checkbox = new html_checkbox(array('name' => '_autocomplete_single', 'id' => $field_id, 'value' => 1));
  850. $blocks['main']['options']['autocomplete_single'] = array(
  851. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autocompletesingle'))),
  852. 'content' => $checkbox->show($config['autocomplete_single']?1:0),
  853. );
  854. }
  855. break;
  856. // Special IMAP folders
  857. case 'folders':
  858. $blocks = array(
  859. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  860. 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  861. );
  862. if (!isset($no_override['show_real_foldernames'])) {
  863. if (!$current) {
  864. continue 2;
  865. }
  866. $field_id = 'show_real_foldernames';
  867. $input = new html_checkbox(array('name' => '_show_real_foldernames', 'id' => $field_id, 'value' => 1));
  868. $blocks['main']['options']['show_real_foldernames'] = array(
  869. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('show_real_foldernames'))),
  870. 'content' => $input->show($config['show_real_foldernames']?1:0),
  871. );
  872. }
  873. // Configure special folders
  874. $set = array('drafts_mbox', 'sent_mbox', 'junk_mbox', 'trash_mbox');
  875. if ($current && count(array_intersect($no_override, $set)) < 4) {
  876. $select = $RCMAIL->folder_selector(array(
  877. 'noselection' => '---',
  878. 'realnames' => true,
  879. 'maxlength' => 30,
  880. 'folder_filter' => 'mail',
  881. 'folder_rights' => 'w',
  882. ));
  883. // #1486114, #1488279, #1489219
  884. $onchange = "if ($(this).val() == 'INBOX') $(this).val('')";
  885. }
  886. if (!isset($no_override['drafts_mbox'])) {
  887. if (!$current) {
  888. continue 2;
  889. }
  890. $blocks['main']['options']['drafts_mbox'] = array(
  891. 'title' => rcube::Q($RCMAIL->gettext('drafts')),
  892. 'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox", 'onchange' => $onchange)),
  893. );
  894. }
  895. if (!isset($no_override['sent_mbox'])) {
  896. if (!$current) {
  897. continue 2;
  898. }
  899. $blocks['main']['options']['sent_mbox'] = array(
  900. 'title' => rcube::Q($RCMAIL->gettext('sent')),
  901. 'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox", 'onchange' => '')),
  902. );
  903. }
  904. if (!isset($no_override['junk_mbox'])) {
  905. if (!$current) {
  906. continue 2;
  907. }
  908. $blocks['main']['options']['junk_mbox'] = array(
  909. 'title' => rcube::Q($RCMAIL->gettext('junk')),
  910. 'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox", 'onchange' => $onchange)),
  911. );
  912. }
  913. if (!isset($no_override['trash_mbox'])) {
  914. if (!$current) {
  915. continue 2;
  916. }
  917. $blocks['main']['options']['trash_mbox'] = array(
  918. 'title' => rcube::Q($RCMAIL->gettext('trash')),
  919. 'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox", 'onchange' => $onchange)),
  920. );
  921. }
  922. break;
  923. // Server settings
  924. case 'server':
  925. $blocks = array(
  926. 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))),
  927. 'maintenance' => array('name' => rcube::Q($RCMAIL->gettext('maintenance'))),
  928. 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
  929. );
  930. if (!isset($no_override['read_when_deleted'])) {
  931. if (!$current) {
  932. continue 2;
  933. }
  934. $field_id = 'rcmfd_read_deleted';
  935. $input = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1));
  936. $blocks['main']['options']['read_when_deleted'] = array(
  937. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('readwhendeleted'))),
  938. 'content' => $input->show($config['read_when_deleted']?1:0),
  939. );
  940. }
  941. if (!isset($no_override['flag_for_deletion'])) {
  942. if (!$current) {
  943. continue 2;
  944. }
  945. $field_id = 'rcmfd_flag_for_deletion';
  946. $input = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1));
  947. $blocks['main']['options']['flag_for_deletion'] = array(
  948. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('flagfordeletion'))),
  949. 'content' => $input->show($config['flag_for_deletion']?1:0),
  950. );
  951. }
  952. // don't show deleted messages
  953. if (!isset($no_override['skip_deleted'])) {
  954. if (!$current) {
  955. continue 2;
  956. }
  957. $field_id = 'rcmfd_skip_deleted';
  958. $input = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1));
  959. $blocks['main']['options']['skip_deleted'] = array(
  960. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('skipdeleted'))),
  961. 'content' => $input->show($config['skip_deleted']?1:0),
  962. );
  963. }
  964. if (!isset($no_override['delete_always'])) {
  965. if (!$current) {
  966. continue 2;
  967. }
  968. $field_id = 'rcmfd_delete_always';
  969. $input = new html_checkbox(array('name' => '_delete_always', 'id' => $field_id, 'value' => 1));
  970. $blocks['main']['options']['delete_always'] = array(
  971. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('deletealways'))),
  972. 'content' => $input->show($config['delete_always']?1:0),
  973. );
  974. }
  975. if (!isset($no_override['delete_junk'])) {
  976. if (!$current) {
  977. continue 2;
  978. }
  979. $field_id = 'rcmfd_delete_junk';
  980. $input = new html_checkbox(array('name' => '_delete_junk', 'id' => $field_id, 'value' => 1));
  981. $blocks['main']['options']['delete_junk'] = array(
  982. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('deletejunk'))),
  983. 'content' => $input->show($config['delete_junk']?1:0),
  984. );
  985. }
  986. // Trash purging on logout
  987. if (!isset($no_override['logout_purge'])) {
  988. if (!$current) {
  989. continue 2;
  990. }
  991. $field_id = 'rcmfd_logout_purge';
  992. $input = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
  993. $blocks['maintenance']['options']['logout_purge'] = array(
  994. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('logoutclear'))),
  995. 'content' => $input->show($config['logout_purge']?1:0),
  996. );
  997. }
  998. // INBOX compacting on logout
  999. if (!isset($no_override['logout_expunge'])) {
  1000. if (!$current) {
  1001. continue 2;
  1002. }
  1003. $field_id = 'rcmfd_logout_expunge';
  1004. $input = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
  1005. $blocks['maintenance']['options']['logout_expunge'] = array(
  1006. 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('logoutcompact'))),
  1007. 'content' => $input->show($config['logout_expunge']?1:0),
  1008. );
  1009. }
  1010. }
  1011. $found = false;
  1012. $data = $RCMAIL->plugins->exec_hook('preferences_list',
  1013. array('section' => $sect['id'], 'blocks' => $blocks, 'current' => $current));
  1014. $advanced_prefs = (array) $RCMAIL->config->get('advanced_prefs');
  1015. // create output
  1016. foreach ($data['blocks'] as $key => $block) {
  1017. if (!empty($block['content']) || !empty($block['options'])) {
  1018. $found = true;
  1019. }
  1020. // move some options to the 'advanced' block as configured by admin
  1021. if ($key != 'advanced') {
  1022. foreach ($advanced_prefs as $opt) {
  1023. if ($block['options'][$opt]) {
  1024. $data['blocks']['advanced']['options'][$opt] = $block['options'][$opt];
  1025. unset($data['blocks'][$key]['options'][$opt]);
  1026. }
  1027. }
  1028. }
  1029. }
  1030. // move 'advanced' block to the end of the list
  1031. if (!empty($data['blocks']['advanced'])) {
  1032. $adv = $data['blocks']['advanced'];
  1033. unset($data['blocks']['advanced']);
  1034. $data['blocks']['advanced'] = $adv;
  1035. }
  1036. if (!$found)
  1037. unset($sections[$idx]);
  1038. else
  1039. $sections[$idx]['blocks'] = $data['blocks'];
  1040. // allow plugins to add a header to each section
  1041. $data = $RCMAIL->plugins->exec_hook('preferences_section_header',
  1042. array('section' => $sect['id'], 'header' => '', 'current' => $current));
  1043. if (!empty($data['header'])) {
  1044. $sections[$idx]['header'] = $data['header'];
  1045. }
  1046. }
  1047. return array($sections, $plugin['cols']);
  1048. }
  1049. function rcmail_get_skins()
  1050. {
  1051. $path = RCUBE_INSTALL_PATH . 'skins';
  1052. $skins = array();
  1053. $dir = opendir($path);
  1054. if (!$dir) {
  1055. return false;
  1056. }
  1057. while (($file = readdir($dir)) !== false) {
  1058. $filename = $path.'/'.$file;
  1059. if (!preg_match('/^\./', $file) && is_dir($filename) && is_readable($filename)) {
  1060. $skins[] = $file;
  1061. }
  1062. }
  1063. closedir($dir);
  1064. return $skins;
  1065. }
  1066. function rcmail_folder_options($mailbox)
  1067. {
  1068. global $RCMAIL;
  1069. $options = $RCMAIL->get_storage()->folder_info($mailbox);
  1070. $options['protected'] = $options['is_root'] || ($options['special'] && $RCMAIL->config->get('protect_default_folders'));
  1071. return $options;
  1072. }
  1073. /**
  1074. * Updates (or creates) folder row in the subscriptions table
  1075. *
  1076. * @param string $name Folder name
  1077. * @param string $oldname Old folder name (for update)
  1078. * @param bool $subscribe Checks subscription checkbox
  1079. * @param string $class CSS class name for folder row
  1080. */
  1081. function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class_name=null)
  1082. {
  1083. global $RCMAIL, $OUTPUT;
  1084. $protect_folders = $RCMAIL->config->get('protect_default_folders');
  1085. $storage = $RCMAIL->get_storage();
  1086. $delimiter = $storage->get_hierarchy_delimiter();
  1087. $name_utf8 = rcube_charset::convert($name, 'UTF7-IMAP');
  1088. $protected = $protect_folders && $storage->is_special_folder($name);
  1089. $foldersplit = explode($delimiter, $storage->mod_folder($name));
  1090. $level = count($foldersplit) - 1;
  1091. $display_name = $protected ? $RCMAIL->localize_foldername($name) : rcube_charset::convert($foldersplit[$level], 'UTF7-IMAP');
  1092. $class_name = trim($class_name . ' mailbox');
  1093. if ($oldname === null) {
  1094. $OUTPUT->command('add_folder_row', $name, $name_utf8, $display_name, $protected, $subscribe,
  1095. $class_name);
  1096. }
  1097. else {
  1098. $OUTPUT->command('replace_folder_row', $oldname, $name, $name_utf8, $display_name, $protected, $class_name);
  1099. }
  1100. }
  1101. /**
  1102. * Render the list of settings sections (AKA tabs)
  1103. */
  1104. function rcmail_settings_tabs($attrib)
  1105. {
  1106. global $RCMAIL, $OUTPUT;
  1107. // add default attributes
  1108. $attrib += array('tagname' => 'span', 'idprefix' => 'settingstab', 'selclass' => 'selected');
  1109. $default_actions = array(
  1110. array('command' => 'preferences', 'type' => 'link', 'label' => 'preferences', 'title' => 'editpreferences'),
  1111. array('command' => 'folders', 'type' => 'link', 'label' => 'folders', 'title' => 'managefolders'),
  1112. array('command' => 'identities', 'type' => 'link', 'label' => 'identities', 'title' => 'manageidentities'),
  1113. array('command' => 'responses', 'type' => 'link', 'label' => 'responses', 'title' => 'manageresponses'),
  1114. );
  1115. // get all identites from DB and define list of cols to be displayed
  1116. $plugin = $RCMAIL->plugins->exec_hook('settings_actions', array(
  1117. 'actions' => $default_actions,
  1118. 'attrib' => $attrib,
  1119. ));
  1120. $attrib = $plugin['attrib'];
  1121. $tagname = $attrib['tagname'];
  1122. $tabs = array();
  1123. foreach ($plugin['actions'] as $action) {
  1124. if (!$action['command'] && !$action['href'] && $action['action']) {
  1125. $action['href'] = $RCMAIL->url(array('_action' => $action['action']));
  1126. }
  1127. $button = $OUTPUT->button($action);
  1128. $attr = $attrib;
  1129. $cmd = $action['action'] ?: $action['command'];
  1130. $id = $action['id'] ?: $cmd;
  1131. if (!empty($id)) {
  1132. $attr['id'] = preg_replace('/[^a-z0-9]/i', '', $attrib['idprefix'] . $id);
  1133. }
  1134. $classnames = array($attrib['class']);
  1135. if (!empty($action['class'])) {
  1136. $classnames[] = $action['class'];
  1137. }
  1138. else if (!empty($cmd)) {
  1139. $classnames[] = $cmd;
  1140. }
  1141. if ($RCMAIL->action == $cmd) {
  1142. $classnames[] = $attrib['selclass'];
  1143. }
  1144. $attr['class'] = join(' ', $classnames);
  1145. $tabs[] = html::tag($tagname, $attr, $button, html::$common_attrib);
  1146. }
  1147. return join('', $tabs);
  1148. }