Source for file functions.php

Documentation is available at functions.php

  1. <?php
  2.  
  3. /**
  4.  * SquirrelMail Preview Pane Plugin
  5.  *
  6.  * @copyright 1999-2020 The SquirrelMail Project Team
  7.  * @author Paul Lesniewski <[email protected]>
  8.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9.  * @version $Id: functions.php 14845 2020-01-07 08:09:34Z pdontthink $
  10.  * @package plugins
  11.  * @subpackage preview_pane
  12.  */
  13.  
  14.  
  15. /**
  16.  * Build user options for display on "Display Preferences" page
  17.  */
  18. {
  19.  
  20.    if (!checkForJavascript()) return;
  21.  
  22.    global $data_dir$username;
  23.    $use_previewPane getPref($data_dir$username'use_previewPane'0);
  24.    $previewPane_vertical_split getPref($data_dir$username'previewPane_vertical_split'0);
  25.    $previewPane_size getPref($data_dir$username'previewPane_size'300);
  26.    $pp_refresh_message_list getPref($data_dir$username'pp_refresh_message_list'1);
  27.    $previewPane_autohide getPref($data_dir$username'previewPane_autohide'0);
  28.  
  29.  
  30.    global $optpage_data;
  31.    $optpage_data['vals'][1][array(
  32.       'name'          => 'use_previewPane',
  33.       'caption'       => _("Show Message Preview Pane"),
  34.       'type'          => SMOPT_TYPE_BOOLEAN,
  35.       'initial_value' => $use_previewPane,
  36.       'refresh'       => SMOPT_REFRESH_ALL,
  37.    );
  38.    $optpage_data['vals'][1][array(
  39.       'name'          => 'previewPane_vertical_split',
  40.       'caption'       => _("Split Preview Pane Vertically"),
  41.       'type'          => SMOPT_TYPE_BOOLEAN,
  42.       'initial_value' => $previewPane_vertical_split,
  43.       'refresh'       => SMOPT_REFRESH_ALL,
  44.    );
  45.    $optpage_data['vals'][1][array(
  46.       'name'          => 'previewPane_size',
  47.       'caption'       => _("Message Preview Pane Size"),
  48.       'type'          => SMOPT_TYPE_INTEGER,
  49.       'initial_value' => $previewPane_size,
  50.       'refresh'       => SMOPT_REFRESH_ALL,
  51.       'size'          => SMOPT_SIZE_TINY,
  52.    );
  53.    $optpage_data['vals'][1][array(
  54.       'name'          => 'pp_refresh_message_list',
  55.       'caption'       => _("Always Refresh Message List<br />When Using Preview Pane"),
  56.       'type'          => SMOPT_TYPE_BOOLEAN,
  57.       'initial_value' => $pp_refresh_message_list,
  58.       'refresh'       => SMOPT_REFRESH_NONE,
  59.    );
  60.    $optpage_data['vals'][1][array(
  61.       'name'          => 'previewPane_autohide',
  62.       'caption'       => _("Automatically Hide Preview Pane<br />When Not Reading Messages"),
  63.       'type'          => SMOPT_TYPE_BOOLEAN,
  64.       'initial_value' => $previewPane_autohide,
  65.       'refresh'       => SMOPT_REFRESH_ALL,
  66.    );
  67.  
  68. }
  69.  
  70.  
  71. /**
  72.  * This function determines if the preview pane is in use
  73.  * (and JavaScript is available)
  74.  *
  75.  * @return boolean TRUE if the preview pane should be showing currently.
  76.  */
  77. function show_preview_pane(
  78. {
  79.    global $data_dir$username;
  80.    $use_previewPane getPref($data_dir$username'use_previewPane'0);
  81.    return (checkForJavascript(&& $use_previewPane);
  82. }
  83.  
  84.  
  85. /**
  86.  * Adds preview pane open/close (and clear) buttons next to
  87.  * "provider link"
  88.  */
  89. {
  90.  
  91.    if (!show_preview_pane()) return;
  92.  
  93.    global $data_dir$username$base_uri$oTemplate;
  94.    $previewPane_vertical_split getPref($data_dir$username'previewPane_vertical_split'0);
  95.    if ($previewPane_vertical_split)
  96.    {
  97.       $orientation 'cols';
  98.       $up_arrow '&larr;';
  99.       $down_arrow '&rarr;';
  100.    }
  101.    else
  102.    {
  103.       $orientation 'rows';
  104.       $up_arrow '&uarr;';
  105.       $down_arrow '&darr;';
  106.    }
  107.  
  108.  
  109.    $previewPane_size getPref($data_dir$username'previewPane_size'300);
  110.  
  111.    $oTemplate->assign('previewPane_size'$previewPane_size);
  112.    $oTemplate->assign('base_uri'$base_uri);
  113.    $oTemplate->assign('orientation'$orientation);
  114.    $oTemplate->assign('down_arrow'$down_arrowFALSE);
  115.    $oTemplate->assign('up_arrow'$up_arrowFALSE);
  116.  
  117.    $output $oTemplate->fetch('plugins/preview_pane/collapse_buttons.tpl');
  118.  
  119.    return array('provider_link_before' => $output);
  120.  
  121. }
  122.  
  123.  
  124. /**
  125.  * Construct button that clears out any preview pane
  126.  * contents and inserts JavaScript function used by
  127.  * message subject link onclick handler.  Also disallows
  128.  * the message list to be loaded into the bottom frame.
  129.  */
  130. {
  131.  
  132.    if (!checkForJavascript()) return;
  133.  
  134.    // globalize $pp_refresh_top, $pp_forceTopURL and $pp_noPageHeader to synch
  135.    // with other plugins (sent_confirmation, for example)
  136.    //
  137.    global $plugins$archive_mail_button_has_been_printed,
  138.           $username$data_dir$PHP_SELF$base_uri$pp_refresh_top
  139.           $pp_forceTopURL$pp_noPageHeader;
  140.  
  141.  
  142.    sqgetGlobalVar('pp_refresh_top'$pp_refresh_topSQ_GET);
  143.    $output '';
  144.    $use_previewPane getPref($data_dir$username'use_previewPane'0);
  145.  
  146.  
  147.    // add refresh function called from code built in function
  148.    // preview_pane_change_message_target_do()
  149.    //
  150.    if ($use_previewPane == 1)
  151. // Bah, let's put this in anyway (even when the "always refresh thing is off),
  152. // in case someone else wants to use it
  153. //    && getPref($data_dir, $username, 'pp_refresh_message_list', 1) == 1)
  154.    {
  155. //      sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
  156.       $request_uri $PHP_SELF;
  157.       $output .= "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\n function pp_refresh() { document.location = '$request_uri'; }\n// -->\n</script>\n";
  158.    }
  159.  
  160.  
  161.    if ($use_previewPane == 1)
  162.    {
  163.       // why isn't this already available?
  164.       include_once(SM_PATH 'functions/forms.php');
  165.  
  166.       $output .= addButton(_("Clear Preview")'clear_preview',
  167.                            array('onclick' => 'parent.bottom.document.location=\''
  168.                                             . $base_uri 'plugins/preview_pane/empty_frame.php\'; '))
  169.  
  170.  
  171.  
  172.       // don't let message list load into preview pane at all
  173.       //
  174.          . "\n<script language='JavaScript' type='text/javascript'>\n"
  175.          . "<!--\n"
  176.          . "\n"
  177.          . "   if (self.name == 'bottom')\n"
  178.          . "   {\n";
  179.  
  180. // NOTE: we can also force the top frame to the URL that was being
  181. //       loaded in the bottom, but this is usually overkill...
  182. //       unless another plugin told us to do so (such as sent_confirmation)
  183.       if ($pp_forceTopURL == 'yes')
  184.       {
  185. //         $output .= "      parent.right.document.location = '" . $_SERVER['REQUEST_URI'] . "&pp=yes';\n";
  186.          $output .= "      parent.right.document.location = '" $PHP_SELF "&pp=yes';\n";
  187.       }
  188.  
  189.  
  190.       // if someone else asks for it, force the message list to reload 
  191.       //
  192.       else if ($pp_refresh_top)
  193.          $output.= "      if (typeof(parent.right.pp_refresh) != 'undefined')\n"
  194.                  . "         parent.right.pp_refresh()\n\n";
  195.  
  196.  
  197.       $output .= "      document.location = '" $base_uri "plugins/preview_pane/empty_frame.php'\n"
  198.          . "   }\n"
  199.          . "//-->\n"
  200.          . "</script>\n";
  201.    }
  202.  
  203.    return array('mailbox_index_after' => $output);
  204.  
  205. }
  206.  
  207.  
  208. /**
  209.  * Points message targets to open in the preview pane
  210.  * (and possibly refresh message list as well)
  211.  */
  212. {
  213.  
  214.    if (!checkForJavascript()) return;
  215.  
  216.    global $data_dir$username$target$onclick$PHP_SELF;
  217. //   sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
  218.    $request_uri $PHP_SELF;
  219.  
  220.  
  221.    if (getPref($data_dir$username'use_previewPane'0== 1)
  222.    {
  223.       $pp_refresh_message_list getPref($data_dir$username'pp_refresh_message_list'1);
  224.       $aMsg $args[3];
  225.  
  226.       $target 'bottom';
  227.  
  228.  
  229.       // introduce a delay so read messages actually 
  230.       // refresh after they are read, but only if they
  231.       // have not already been seen
  232.       //
  233.       if ($pp_refresh_message_list && empty($aMsg['FLAGS']['\seen']))
  234. // old code without refresh delay 
  235. //         $onclick .= ' onclick="document.location=\'' . $request_uri . '\'; " ';
  236.          $onclick .= ' setTimeout(\'pp_refresh()\', 500); ';
  237.    }
  238.  
  239. }

Documentation generated on Mon, 13 Jan 2020 04:22:32 +0100 by phpDocumentor 1.4.3