[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] felamimail/inc hook_home.inc.php
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] felamimail/inc hook_home.inc.php |
Date: |
Sat, 22 Sep 2007 13:45:42 +0000 |
CVSROOT: /sources/phpgroupware
Module name: felamimail
Changes by: Dave Hall <skwashd> 07/09/22 13:45:42
Modified files:
inc : hook_home.inc.php
Log message:
merge fixes from 16 so hook home actually works and doesn't depend on
'email' app
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/felamimail/inc/hook_home.inc.php?cvsroot=phpgroupware&r1=1.10&r2=1.11
Patches:
Index: hook_home.inc.php
===================================================================
RCS file: /sources/phpgroupware/felamimail/inc/hook_home.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- hook_home.inc.php 20 Dec 2006 13:56:26 -0000 1.10
+++ hook_home.inc.php 22 Sep 2007 13:45:42 -0000 1.11
@@ -9,45 +9,185 @@
* option) any later version. *
\**************************************************************************/
- /* $Id: hook_home.inc.php,v 1.10 2006/12/20 13:56:26 sigurdne Exp $ */
+ /* $Id: hook_home.inc.php,v 1.11 2007/09/22 13:45:42 skwashd Exp $ */
- $d1 = strtolower(substr(PHPGW_APP_INC,0,3));
+ $d1 =
strtolower(substr($GLOBALS['phpgw_info']['server']['app_inc'],0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
- echo 'Failed attempt to break in via an old Security
Hole!<br>'."\n";
+ echo "Failed attempt to break in via an old Security Hole!<br
/>\n";
$GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
- $tmp_app_inc = $GLOBALS['phpgw']->common->get_inc_dir('felamimail');
-# if
($GLOBALS['phpgw_info']['user']['preferences']['felamimail']['mainscreen_showmail']
== True)
-# {
-# // ---- Create the base email Msg Class -----
- $GLOBALS['phpgw']->translation->add_app('felamimail');
- $GLOBALS['phpgw']->msg = CreateObject("email.mail_msg");
-# $args_array = Array();
-# $args_array['folder'] = 'INBOX';
-# $args_array['do_login'] = True;
-# $GLOBALS['phpgw']->msg->begin_request($args_array);
-
-# if (!$GLOBALS['phpgw']->msg->mailsvr_stream)
-# {
-# $error_msg = '<b>Mail error:</b> Can not open
connection to mail server';
-# echo "\r\n"
-# .'<tr>'."\r\n"
-# .'<td align="left">'."\r\n"
-# .'<!-- start Mailbox info -->'."\r\n"
-# .$error_msg."\r\n"
-# .'<!-- ends Mailox info -->'."\r\n"
-# .'</td>'."\r\n"
-# .'</tr>'."\r\n";
-# //$GLOBALS['phpgw']->common->phpgw_exit(True);
-# }
-# else
-# {
- $title = '<font
color="#FFFFFF">'.lang('felamimail').'</font>';
+ // does this array item actually exist before we create the mail_msg,
where is it created?
+ //if
($GLOBALS['phpgw_info']['user']['preferences']['email']['mainscreen_showmail']
== True)
+ $debug_hook_home = 0;
+ //$debug_hook_home = 3;
+
+ $prev_currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
+ $GLOBALS['phpgw_info']['flags']['currentapp'] = 'email';
+
+ // create a msg object just to have access to the prefs
+ $my_msg_bootstrap = '';
+ $my_msg_bootstrap = CreateObject('email.msg_bootstrap');
+ // NO LOGIN if we are only checking preferences
+ //$my_msg_bootstrap->set_do_login(False);
+ //$my_msg_bootstrap->set_do_login(BS_LOGIN_ONLY_IF_NEEDED);
+ $my_msg_bootstrap->set_do_login(BS_LOGIN_NEVER);
+ // never *should* still allow a later login after we determine we need
to show messages here
+ $my_msg_bootstrap->ensure_mail_msg_exists('email.hook_home',
$debug_hook_home);
+ // DO NOT FORGET TO END_REQUEST since we created the msg object, it
needs that even if we did not login,
+ // because the backwards compat code for sessions_db does its bulk save
to the DB in the "end_request" function.
+
+ // does account 0 (default, main account) have this pref set
+ // this pref is either set for "ON", of not set which represents a "no"
+ // other accounts can be shown by (1) giving the extra accounts access
to this pref item, and
+ // (2) by doing a loop testing for accounts other then just account 0
+ if ($GLOBALS['phpgw']->msg->get_isset_pref('mainscreen_showmail', 0))
+ {
+ // from here on, msg objects opens streams on demand if requied
+ $data = Array();
+
+ /* class mail_msg "new_message_check()"
+ // this is the structure you will get
+ $inbox_data['is_imap'] boolean - pop3 server do not know what
is "new" or not
+ $inbox_data['folder_checked'] string - the folder checked, as
processed by the msg class
+ $inbox_data['alert_string'] string - what to show the user
about this inbox check
+ $inbox_data['number_new'] integer - for IMAP is number
"unseen"; for pop3 is number messages
+ $inbox_data['number_all'] integer - for IMAP and pop3 is
total number messages in that inbox
+ */
+ $inbox_data = Array();
+ $inbox_data = $GLOBALS['phpgw']->msg->new_message_check();
+ //if ($debug_hook_home > 2) { echo 'hook_home('.__LINE__.'):
$inbox_data dump:<pre>'; print_r($inbox_data); echo '</pre>'; }
+
+ $title = '<font color="#FFFFFF">'.lang('EMail').'
'.$inbox_data['alert_string'].'</font>';
+
+ if($inbox_data['number_all'] >= 5)
+ {
+ $check_msgs = 5;
+ }
+ else
+ {
+ $check_msgs = $inbox_data['number_all'];
+ }
+ if ($inbox_data['number_all'] > 0)
+ {
+ $msgball_list = array();
+ $msgball_list =
$GLOBALS['phpgw']->msg->get_msgball_list();
+ }
+ //if ($debug_hook_home > 2) { echo 'hook_home('.__LINE__.'):
call to "get_msgball_list" returns $msgball_list dump:<pre>';
print_r($msgball_list); echo '</pre>'; }
+ for($i=0; $i<$check_msgs; $i++)
+ {
+ $this_loop_msgball =
$GLOBALS['phpgw']->msg->ball_data_parse_str($msgball_list[$i]);
+ //if ($debug_hook_home > 1) { echo ' *
hook_home('.__LINE__.'): $msgball_list['.$i.'] ['.$msgball_list[$i].'];
$this_loop_msgball: ['.serialize($this_loop_msgball).']<br />'; }
+ $msg_headers =
$GLOBALS['phpgw']->msg->phpgw_header($this_loop_msgball);
+ $subject =
$GLOBALS['phpgw']->msg->get_subject($msg_headers,'');
+ if(strlen($subject) > 65)
+ {
+ $subject = substr($subject,0,65).' ...';
+ }
+ $data[] = array(
+ 'text' => $subject,
+ 'link' => $GLOBALS['phpgw']->link(
+ '/index.php',
+
'menuaction=email.uimessage.message'
+ .'&'.$this_loop_msgball['uri']
+ )
+ );
+ }
+
+ // COMPOSE NEW email link
+ $compose_link = $GLOBALS['phpgw']->link(
+ '/index.php',
+ 'menuaction=email.uicompose.compose'
+ // this data tells us where to return
to after sending a message
+ // since we started from home page,
send can not (at this time) take us back there
+ // so instead take user to INBOX for
the default account (acctnum 0) after clicking the send button
+ .'&fldball[folder]=INBOX'
+ .'&fldball[acctnum]=0'
+ );
+ $compose_href = '<a href="'.$compose_link.'">'.lang('Compose
New').'</a>'."\r\n";
+
+ // ADD FOLDER LISTBOX TO HOME PAGE (Needs to be TEMPLATED)
+ // Does This Mailbox Support Folders (i.e. more than just
INBOX)?
+ if($GLOBALS['phpgw']->msg->get_mailsvr_supports_folders() ==
False)
+ {
+ $extra_data = ' '.$compose_href;
+ }
+ else
+ {
+ // build the $feed_args array for the
all_folders_listbox function
+ // anything not specified will be replace with a
default value if the function has one for that param
+ /*
+ $feed_args = Array(
+ 'mailsvr_stream' => '',
+ 'pre_select_folder' => '',
+ 'skip_folder' => '',
+ 'show_num_new' =>
$GLOBALS['phpgw_info']['user']['preferences']['email']['newmsg_combobox'],
+ 'widget_name' => 'fldball_fake_uri',
+ 'folder_key_name' => 'folder',
+ 'acctnum_key_name' => 'acctnum',
+ 'on_change' =>
'document.switchbox.submit()',
+ 'first_line_txt' => lang('switch current
folder to')
+ );
+ // get you custom built HTML listbox (a.k.a. selectbox)
widget
+ $switchbox_listbox =
$GLOBALS['phpgw']->msg->all_folders_listbox($feed_args);
+ // make it another TR we can insert into the home page
portal object
+ // and surround it in FORM tags so the submit will work
+ $switchbox_action = $GLOBALS['phpgw']->link(
+ '/index.php',
+ 'menuaction=email.uiindex.index'
+ );
+ $extra_data = '<form name="switchbox"
action="'.$switchbox_action.'" method="post">'."\r\n"
+ .'<td align="left">'."\r\n"
+ .' <strong>'.lang('E-Mail
Folders').':</strong> '.$switchbox_listbox."\r\n"
+ .' '.$compose_href."\r\n"
+ .'</td>'."\r\n"
+ .'</form>'."\r\n";
+ */
+ // REPLACE all the above with some high levels calls to
the widget class
+ // WHY does not lang inbox work here? It is called in
the base class and works fine except from "home" page.
+ $my_widgets = CreateObject('email.html_widgets');
+ $my_widgets->new_form();
+ $my_widgets->set_form_name('switchbox');
+
$my_widgets->set_form_action($GLOBALS['phpgw']->link('/index.php','menuaction=email.uiindex.index'));
+ $my_widgets->set_form_method('post');
+ $form_folder_switch_opentag = $my_widgets->get_form();
+ $folder_switch_combobox =
$my_widgets->all_folders_combobox('switchbox');
+ $form_folder_switch_closetag =
$my_widgets->form_closetag();
+ $extra_data =
+ $form_folder_switch_opentag
+ .'<td align="left">'."\r\n"
+ .' <strong>'.lang('E-Mail
Folders').':</strong> '
+ .$folder_switch_combobox
+ .' '.$compose_href
+ .'</td>'."\r\n"
+ .$form_folder_switch_closetag;
+ }
+
+ // how to display this data
+ if (is_object($GLOBALS['phpgw']->xslttpl))
+ {
+ $phpgw_before_xslt = False;
+ }
+ else
+ {
+ $phpgw_before_xslt = True;
+ }
+
+ // now display according to the version of the template system
in use
+ if ($phpgw_before_xslt == True)
+ {
+ // the is the OLD, pre-xslt way to display pref items
+ // reset the currentapp to whatever it was
+ if ((isset($prev_currentapp))
+ && ($prev_currentapp)
+ && ($GLOBALS['phpgw_info']['flags']['currentapp'] !=
$prev_currentapp))
+ {
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
$prev_currentapp;
+ }
$portalbox = CreateObject('phpgwapi.listbox',
Array(
'title' => $title,
@@ -59,8 +199,7 @@
'header_background_image' =>
$GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
)
);
-
- $app_id =
$GLOBALS['phpgw']->applications->name2id('felamimail');
+ $app_id =
$GLOBALS['phpgw']->applications->name2id('email');
$GLOBALS['portal_order'][] = $app_id;
$var = Array(
'up' => Array('url' => '/set_box.php',
'app' => $app_id),
@@ -75,88 +214,95 @@
$portalbox->set_controls($key,$value);
}
- $portalbox->data = Array();
+ $portalbox->data = $data;
+
+ // output the portalbox and below it (1) the folders
listbox (if applicable) and (2) Compose New mail link
+ echo "\n".'<!-- BEGIN Mailbox info
-->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
+ }
+ else
+ {
+ // this is the xslt template era
+ // adjust the title for no html tags
+ $title = lang('EMail').' '.$inbox_data['alert_string'];
+
+ $GLOBALS['phpgw']->translation->add_app('email');
+ //$GLOBALS['phpgw']->translation->add_app('E-Mail');
+ $app_id =
$GLOBALS['phpgw']->applications->name2id('email');
+ $GLOBALS['portal_order'][] = $app_id;
-# /* // this is the structure you will get
-# $inbox_data['is_imap'] boolean - pop3 server do not
know what is "new" or not
-# $inbox_data['folder_checked'] string - the folder
checked, as processed by the msg class
-# $inbox_data['alert_string'] string - what to show the
user about this inbox check
-# $inbox_data['number_new'] integer - for IMAP is
number "unseen"; for pop3 is number messages
-# $inbox_data['number_all'] integer - for IMAP and pop3
is total number messages in that inbox
-# */
-# $inbox_data = Array();
-# $inbox_data =
$GLOBALS['phpgw']->msg->new_message_check();
-#
-# if($inbox_data['number_all'] >= 5)
-# {
-# $check_msgs = 5;
-# }
-# else
-# {
-# $check_msgs = $inbox_data['number_all'];
-# }
-
-# if ($inbox_data['number_all'] > 0)
-# {
-# $msg_array = array();
-# $msg_array =
$GLOBALS['phpgw']->msg->get_message_list();
-# }
-# for($i=0; $i<$check_msgs; $i++)
-# {
-# $msg =
$GLOBALS['phpgw']->dcom->header($GLOBALS['phpgw']->msg->mailsvr_stream,$msg_array[$i]);
-# $subject =
$GLOBALS['phpgw']->msg->get_subject($msg,'');
-# if (strlen($subject) > 65)
-# {
-# $subject = substr($subject,0,65).' ...';
-# }
-# $linkData = array
-# (
-# 'mailbox' =>
$GLOBALS['phpgw']->msg->prep_folder_out(''),
-# 'passed_id' => $msg_array[$i],
-# 'startMessage' => 1,
-# 'show_more' => 0
-## );
-# $data[] = array(
-# 'data' => $subject,
-# 'link' =>
$GLOBALS['phpgw']->link('/felamimail/read_body.php',$linkData)
-# );
-# }
-# // ADD FOLDER LISTBOX TO HOME PAGE (Needs to be
TEMPLATED)
-# // Does This Mailbox Support Folders (i.e. more than
just INBOX)?
-# if
($GLOBALS['phpgw']->msg->get_mailsvr_supports_folders() == False)
-# {
-# $extra_data = '';
-# }
-# else
-# {
-# // FUTURE: this will pick up the user option to
show num unseen msgs in dropdown list
-# //$listbox_show_unseen = True;
-# $listbox_show_unseen = False;
-# $switchbox_listbox = '<select name="mailbox"
onChange="document.switchbox.submit()">'
-# . '<option>' . lang('switch
current folder to') . ':'
-# .
$GLOBALS['phpgw']->msg->all_folders_listbox('','','',$listbox_show_unseen)
-# . '</select>';
-# // make it another TR we can insert
-# $switchbox_action =
$GLOBALS['phpgw']->link('/felamimail/index.php');
-# $extra_data = '<form name="switchbox"
action="'.$switchbox_action.'" method="post">'."\r\n"
-# .'<td align="left">'."\r\n"
-# .' <strong>'.lang('E-Mail
Folders').':</strong> '.$switchbox_listbox
-# .'<input type="hidden"
name="startMessage" value="1">'
-# .'</td>'."\r\n"
-# .'</form>'."\r\n";
-# }
-# $GLOBALS['phpgw']->msg->end_request();
-#
- if(isset($data) && $data)
+ $GLOBALS['phpgw']->portalbox->set_params(
+ array(
+ 'app_id' => $app_id,
+ 'title' => $title
+ )
+ );
+ // assemble the data BRUTE FORCE
+ // FIXME apparently needs an xsl file called
"portal.xsl"
+ /*
+ $main_data = '<table border="0" width="100%">'."\r\n";
+ for($i=0; $i<count($data); $i++)
{
- $portalbox->data = $data;
+ $main_data .=
+ '<tr>'
+ .'<td width="2%" align="right">
</td>'
+ .'<td width="98%" align="left">'
+ .'<a
href="'.$data[$i]['link'].'">'.$data[$i]['text'].'</a>'
+ .'</td>'
+ .'</tr>'."\r\n";
+ }
+ $main_data .=
+ '<td width="2%"> </td>'
+ .$form_folder_switch_opentag
+ .'<td width="98%" align="left">'."\r\n"
+ .' <strong>'.lang('E-Mail
Folders').':</strong> '
+ .$folder_switch_combobox
+ .' '.$compose_href
+ .'</td>'."\r\n"
+ .$form_folder_switch_closetag;
+
+ $main_data .= '</table>'."\r\n";
+ */
+ $main_data =
+ '<table border="0" width="100%">'
+ .'<tr>'."\r\n"
+ .'<td width="100%" align="left">'."\r\n"
+ .'<ul>'."\r\n";
+ for($i=0; $i<count($data); $i++)
+ {
+ $main_data .= '<li>'.'<a
href="'.$data[$i]['link'].'">'.$data[$i]['text'].'</a>'.'</li>'."\r\n";
+ }
+ $main_data .=
+ '</ul>'."\r\n"
+ .'</td>'."\r\n"
+ .'</tr>'."\r\n"
+ .'<tr><td><hr /></td></tr>'."\r\n"
+ .'<tr>'."\r\n"
+ .$form_folder_switch_opentag
+ .'<td width="100%" align="left">'."\r\n"
+ .' <strong>'.lang('E-Mail
Folders').':</strong> '
+ .$folder_switch_combobox
+ .' '.$compose_href
+ .'</td>'."\r\n"
+ .$form_folder_switch_closetag
+ .'</tr>'."\r\n"
+ .'</table>'."\r\n";
+
+ $GLOBALS['phpgw']->portalbox->draw($main_data);
+
+ // reset the currentapp to whatever it was
+ if ((isset($prev_currentapp))
+ && ($prev_currentapp)
+ && ($GLOBALS['phpgw_info']['flags']['currentapp'] !=
$prev_currentapp))
+ {
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
$prev_currentapp;
}
- // output the portalbox and below it (1) the folders
listbox (if applicable) and (2) Compose New mail link
- echo "\r\n".'<!-- start Mailbox info -->'."\r\n"
-
.$portalbox->draw(isset($extra_data)?$extra_data:'')
- .'<!-- ends Mailox info -->'."\r\n";
-# }
-# }
+ }
+ }
+
+ // we create the msg object initially so we can have access to the
multi-account preferences,
+ // so even if we did not output any data here, we still must call this
"end_request" function, it is kind of like a destructor
+ $GLOBALS['phpgw']->msg->end_request();
+
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] felamimail/inc hook_home.inc.php,
Dave Hall <=