[imp] Patch for performing action on current message

Dan Wilson dan at acucore.com
Mon Mar 10 15:05:24 PST 2003


I got sick of having to click 'Back to INBOX' and the selecting the message I 
was viewing and selecting 'Mark As.. Unseen'.

So I finally figured out the patch to put the functionality into the 
individual message view.

Attached is a patch... feel free to clean up and optimize.

-Dan

-------------- next part --------------
Index: message.php
===================================================================
RCS file: /repository/imp/message.php,v
retrieving revision 2.459
diff -c -r2.459 message.php
*** message.php	28 Feb 2003 01:56:28 -0000	2.459
--- message.php	10 Mar 2003 21:59:44 -0000
***************
*** 162,167 ****
--- 162,190 ----
  
      break;
  
+ case FLAG_MESSAGES:
+     $flag = Horde::getFormData('flag');
+     if (!empty($flag)) {
+         if ($flag[0] == '0') {
+             $_POST['flag'] = '\\' . substr($flag, 1);
+             $set = false;
+         } else {
+             $_POST['flag'] = '\\' . $flag;
+             $set = true;
+         }
+         require_once IMP_BASE . '/lib/Message.php';
+         $imp_message = &new IMP_Message();
+         $imp_message->setMailboxObject($imp_mailbox);
+         $imp_message->flag($_POST['flag'], array($imp_mailbox->getIndex()), $set);
+         if ($prefs->getValue('mailbox_return')) {
+             _returnToMailbox($imp_mailbox->getMessageIndex());
+             require IMP_BASE . '/mailbox.php';
+             exit;
+         }
+         $imp_mailbox->moveNext();
+     }
+     break;
+ 
  case ADD_ADDRESS:
      $newAddress = Horde::getFormData('address');
      if (!($newName = Horde::getFormData('name'))) {
***************
*** 484,495 ****
--- 507,520 ----
      if ($browser->hasFeature('javascript')) {
          require_once IMP_TEMPLATES . '/javascript/open_print_win.js';
      }
+     $navform = 1;
      require IMP_TEMPLATES . '/message/navbar_aux_top.inc';
      require IMP_TEMPLATES . '/message/navbar.inc';
  }
  require IMP_TEMPLATES . '/message/headers.inc';
  require IMP_TEMPLATES . '/message/message.inc';
  if (!$printer_friendly) {
+     $navform = 2;
      require IMP_TEMPLATES . '/message/navbar.inc';
      require IMP_TEMPLATES . '/message/navbar_aux_bottom.inc';
  }
Index: lib/Mailbox.php
===================================================================
RCS file: /repository/imp/lib/Mailbox.php,v
retrieving revision 1.29
diff -c -r1.29 Mailbox.php
*** lib/Mailbox.php	28 Feb 2003 08:19:03 -0000	1.29
--- lib/Mailbox.php	10 Mar 2003 21:59:44 -0000
***************
*** 746,751 ****
--- 746,764 ----
          return $return_array;
      }
  
+     function moveNext()
+     {
+         global $imp;
+         if(($nextindex = $this->messageIndices(1))) {
+             $this->_setIndex($nextindex['index']);
+         } else {
+             $this->_index = null;
+         }
+ 
+         $this->_setArrayIndex();
+         $this->_setLastValidIndex();
+     }
+ 
      /**
       * Returns the current sorted array without the current index message.
       *
Index: templates/message/message.inc
===================================================================
RCS file: /repository/imp/templates/message/message.inc,v
retrieving revision 2.15
diff -c -r2.15 message.inc
*** templates/message/message.inc	15 Jun 2002 05:04:06 -0000	2.15
--- templates/message/message.inc	10 Mar 2003 21:59:44 -0000
***************
*** 2,4 ****
--- 2,5 ----
  <table border="0" align="center" width="100%" cellpadding="2" cellspacing="3">
  <?php echo $msgText ?>
  </table></td></tr></table>
+ <input type="hidden" name="flag" value="" />
Index: templates/message/navbar.inc
===================================================================
RCS file: /repository/imp/templates/message/navbar.inc,v
retrieving revision 2.97
diff -c -r2.97 navbar.inc
*** templates/message/navbar.inc	26 Feb 2003 17:37:29 -0000	2.97
--- templates/message/navbar.inc	10 Mar 2003 21:59:44 -0000
***************
*** 1,6 ****
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="2">
  <tr class="control">
! <td align="left">
  <?php if ($imp_headers->getFlag('deleted')): ?>
  <?php echo Horde::widget(Horde::addParameter($self_link, 'actionID', UNDELETE_MESSAGES), _("Undelete"), 'widget', '', '', _("Undelete"), 2) ?>
  <?php else: ?>
--- 1,6 ----
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="2">
  <tr class="control">
! <td align="left" colspan="2">
  <?php if ($imp_headers->getFlag('deleted')): ?>
  <?php echo Horde::widget(Horde::addParameter($self_link, 'actionID', UNDELETE_MESSAGES), _("Undelete"), 'widget', '', '', _("Undelete"), 2) ?>
  <?php else: ?>
***************
*** 32,37 ****
--- 32,51 ----
  <?php if (isset($spam_link)): ?>
   | <?php echo Horde::widget($spam_link, _("Report as Spam"), 'widget', '', '', _("Report as Spam"), 2) ?>
  <?php endif; ?>
+ </td>
+ </tr>
+ <tr class="control">
+ <td>
+         <select name="flag<?php echo $navform ?>" onchange="flagMessage(<?php echo $navform ?>);">
+             <option value="" selected="selected"><?php echo _("Mark as:") ?></option>
+             <option value="0Seen"><?php echo _("Unseen") ?></option>
+             <option value="Flagged"><?php echo _("Important") ?></option>
+             <option value="0Flagged"><?php echo _("Not Important") ?></option>
+             <option value="Answered"><?php echo _("Answered") ?></option>
+             <option value="0Answered"><?php echo _("Unanswered") ?></option>
+             <option value="Draft"><?php echo _("Draft") ?></option>
+             <option value="0Draft"><?php echo _("Not Draft") ?></option>
+         </select>
  </td>
  <td align="right" nowrap="nowrap">
  <?php echo Horde::widget($mailbox_link, sprintf(_("Back to %s"), $imp['label']), 'widget', '', '', sprintf(_("Back to %s"), $imp['label']), 2) ?>&nbsp;&nbsp;
Index: templates/message/javascript.inc
===================================================================
RCS file: /repository/imp/templates/message/javascript.inc,v
retrieving revision 2.34
diff -c -r2.34 javascript.inc
*** templates/message/javascript.inc	23 Dec 2002 20:38:46 -0000	2.34
--- templates/message/javascript.inc	10 Mar 2003 21:59:44 -0000
***************
*** 1,6 ****
--- 1,23 ----
  <script language="JavaScript" type="text/javascript">
  <!--
  
+ <?php if (!strstr($imp['protocol'], 'pop3')): ?>
+ function flagMessage(whichForm)
+ {
+     if ((whichForm == 1 && document.messages.flag1.options[document.messages.flag1.selectedIndex].value != "") ||
+         (whichForm == 2 && document.messages.flag2.options[document.messages.flag2.selectedIndex].value != "")) {
+         if (whichForm == 1) {
+             document.messages.flag.value = document.messages.flag1.options[document.messages.flag1.selectedIndex].value;
+         } else {
+             document.messages.flag.value = document.messages.flag2.options[document.messages.flag2.selectedIndex].value;
+         }
+ 
+         document.messages.actionID.value = <?php echo FLAG_MESSAGES ?>;
+         document.messages.submit();
+     }
+ }
+ <?php endif; ?>
+ 
  function Transfer(actID, form)
  {
      if (form == 1) {


More information about the imp mailing list