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.

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