Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmail/user/maillist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: maillist.php 7641 2001-10-03 08:44:34Z fh $
5 //
6 // Created on: <19-Mar-2000 20:25:22 fh>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlocale.php" );
30 // include_once( "ezuser/classes/ezuser.php" );
31 // include_once( "classes/ezhttptool.php" );
32
33 // include_once( "ezmail/classes/ezmailaccount.php" );
34 // include_once( "ezmail/classes/ezmail.php" );
35 // include_once( "ezmail/classes/ezmailfolder.php" );
36
37 // include_once( "classes/ezlist.php" );
38 // include_once( "ezsession/classes/ezpreferences.php" );
39
40 // check that the folder beeing viewed is your folder
41 if ( !eZMailFolder::isOwner( eZUser::currentUser(), $FolderID ) )
42 {
43 eZHTTPTool::header( "Location: /error/403/" );
44 exit();
45 }
46
47
48 if ( isset( $NewFolder ) )
49 {
50 eZHTTPTool::header( "Location: /mail/folderedit/" );
51 exit();
52 }
53
54 if ( isset( $Move ) && $FolderSelectID != -1 && count( $MailArrayID ) > 0 ) // really move to other folder
55 {
56 $folder = new eZMailFolder( $FolderSelectID );
57 foreach ( $MailArrayID as $mailitemID )
58 $folder->addMail( $mailitemID );
59 }
60
61 $ini =& eZINI::instance( 'site.ini' );
62 if( isset( $NumMessages ) )
63 {
64 eZPreferences::setVariable( "eZMail_MessagesPerPage", $NumMessages );
65 }
66 else
67 {
68 $NumMessages = eZPreferences::variable( "eZMail_MessagesPerPage" );
69 if( !$NumMessages )
70 {
71 $NumMessages = $ini->variable( "eZMailMain", "MailPerPageDefault" );
72 if( !$NumMessages )
73 $NumMessages = 20; // hardcoded default in case all other fails.
74 }
75 }
76
77 $Language = $ini->variable( "eZMailMain", "Language" );
78 $t = new eZTemplate( "kernel/ezmail/user/" . $ini->variable( "eZMailMain", "TemplateDir" ),
79 "kernel/ezmail/user/intl/", $Language, "maillist.php" );
80 $t->setAllStrings();
81
82 $t->set_file( "mail_list_page_tpl", "maillist.tpl" );
83
84 $t->set_var( "site_style", $SiteDesign );
85 $t->set_block( "mail_list_page_tpl", "mail_item_tpl", "mail_item" );
86 $t->set_block( "mail_item_tpl", "mail_edit_item_tpl", "mail_edit_item" );
87 $t->set_block( "mail_list_page_tpl", "mail_item_unread_tpl", "mail_item_unread" );
88 $t->set_block( "mail_list_page_tpl", "mail_render_tpl", "mail_render" );
89 $t->set_block( "mail_list_page_tpl", "folder_item_tpl", "folder_item" );
90 $t->set_block( "mail_list_page_tpl", "num_mail_element_tpl", "num_mail_element" );
91 $t->set_var( "mail_edit_item", "" );
92 $t->set_var( "mail_item", "" );
93 $t->set_var( "mail_item_unread", "" );
94 $t->set_var( "mail_render", "" );
95
96 // set the pic blocks..
97 $t->set_block( "mail_item_tpl", "mail_unread_tpl", "mail_unread" );
98 $t->set_block( "mail_item_tpl", "mail_read_tpl", "mail_read" );
99 $t->set_block( "mail_item_tpl", "mail_forwarded_tpl", "mail_forwarded" );
100 $t->set_block( "mail_item_tpl", "mail_replied_tpl", "mail_replied" );
101 $t->set_block( "mail_item_tpl", "mail_repliedall_tpl", "mail_repliedall" );
102 $t->set_block( "mail_item_tpl", "mail_status_renderer_tpl", "mail_status_renderer" );
103 $t->set_var( "mail_unread", "" );
104 $t->set_var( "mail_read", "" );
105 $t->set_var( "mail_forwarded", "" );
106 $t->set_var( "mail_replied", "" );
107 $t->set_var( "mail_repliedall", "" );
108 $t->set_var( "mail_status_renderer", "" );
109
110 $user =& eZUser::currentUser();
111
112 $limit_array = array_unique( array( 20, 30, 40, 50, 60, 80, 100, 150, 200, $NumMessages ) );
113 $currentMethod = eZPreferences::variable( "eZMail_MessagesPerPage" );
114 sort( $limit_array );
115 foreach ( $limit_array as $element_number )
116 {
117 $t->set_var( "messages_number", $element_number );
118 if ( $element_number == $NumMessages )
119 $t->set_var( "is_selected", "selected" );
120 else
121 $t->set_var( "is_selected", "" );
122 $t->parse( "num_mail_element", "num_mail_element_tpl", true );
123 }
124
125
126 $folder = new eZMailFolder( $FolderID );
127 $isDraftsFolder = false;
128 if ( $folder->folderType() == DRAFTS )
129 $isDraftsFolder = true;
130
131
132 // check if the sort mode is changed...
133 $preferences = new eZPreferences();
134 if ( isset( $SortMethod ) ) // the sorting method has changed..
135 {
136 $currentMethod = $preferences->variable( "MailSortMethod" );
137 $newMethod = "";
138 switch ( $SortMethod )
139 {
140 case "subject" :
141 {
142 $newMethod = ( $currentMethod == "subject_asc" ) ? "subject_desc" : "subject_asc";
143 }
144 break;
145 case "from" :
146 {
147 $newMethod = ( $currentMethod == "from_asc" ) ? "from_desc" : "from_asc";
148 }
149 break;
150 case "date" :
151 {
152 $newMethod = ( $currentMethod == "date_asc" ) ? "date_desc" : "date_asc";
153 }
154 break;
155 case "size" :
156 {
157 $newMethod = ( $currentMethod == "size_asc" ) ? "size_desc" : "size_asc";
158 }
159 break;
160 default :
161 {
162 $newMethod = "date_asc";
163 }
164 }
165
166 $preferences->setVariable( "MailSortMethod", $newMethod );
167 }
168
169 $t->set_var( "current_folder_id", $FolderID );
170 $t->set_var( "current_folder_name", htmlspecialchars( $folder->name() ) );
171
172 $sort = $preferences->variable( "MailSortMethod");
173 $mail = $folder->mail( $sort, $Offset, $NumMessages );
174 $mailCount = $folder->mailCount();
175 $i = 0;
176 foreach ( $mail as $mailItem )
177 {
178 $t->set_var( "mail_id", $mailItem->id() );
179 $t->set_var( "mail_subject", htmlspecialchars( $mailItem->subject() ), "-" );
180 $t->set_var( "mail_sender", htmlspecialchars( $mailItem->sender() ) );
181
182 switch ( $mailItem->status() )
183 {
184 case 0 : $t->parse( "mail_status_renderer", "mail_unread_tpl", false ); break;
185 case 1 : $t->parse( "mail_status_renderer", "mail_read_tpl", false ); break;
186 case 2 : $t->parse( "mail_status_renderer", "mail_replied_tpl", false ); break;
187 case 3 : $t->parse( "mail_status_renderer", "mail_forwarded_tpl", false ); break;
188 case 4 : $t->parse( "mail_status_renderer", "mail_read_tpl", false ); break;
189 }
190
191 $siSize = $mailItem->siSize();
192 $t->set_var( "mail_size" , $siSize["size-string"] . $siSize["unit"] );
193 $t->set_var( "mail_date", date("D M d H:i Y ", $mailItem->uDate() ) );
194 ( $i % 2 ) ? $t->set_var( "td_class", "bgdark" ) : $t->set_var( "td_class", "bglight" );
195
196 if ( $mailItem->status() == UNREAD )
197 $t->parse( "mail_render", "mail_item_unread_tpl", true );
198 else
199 {
200 $isDraftsFolder ? $t->parse( "mail_edit_item", "mail_edit_item_tpl", false ) : $t->set_var( "mail_edit_item", "&nbsp;" );
201 $t->parse( "mail_render", "mail_item_tpl", true );
202 }
203
204 $i++;
205 }
206
207 /* insert the standard folders first */
208 foreach ( array( INBOX, SENT, DRAFTS, TRASH ) as $specialfolder )
209 {
210 $folderItem = eZMailFolder::getSpecialFolder( $specialfolder );
211 $t->set_var( "folder_id", $folderItem->id() );
212 $t->set_var( "folder_name", $folderItem->name() );
213 $t->parse( "folder_item", "folder_item_tpl", true );
214 }
215
216 $folders = eZMailFolder::getByUser();
217 foreach ( $folders as $folderItem )
218 {
219 $t->set_var( "folder_id", $folderItem->id() );
220 $t->set_var( "folder_name", $folderItem->name() );
221 $t->parse( "folder_item", "folder_item_tpl", true );
222 }
223
224 eZList::drawNavigator( $t, $mailCount, $NumMessages, $Offset, "mail_list_page_tpl" );
225
226 $t->pparse( "output", "mail_list_page_tpl" );
227
228 ?>
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZMailFolder
Definition: ezmailfolder.php:49
eZMailFolder\getByUser
static getByUser( $user=false, $withSpecialFolders=false, $parentFolder=-1)
Definition: ezmailfolder.php:328
eZMailFolder\getSpecialFolder
static getSpecialFolder( $specialType, $user=false)
Definition: ezmailfolder.php:477
eZMailFolder\isOwner
static isOwner( $user, $folderID)
Definition: ezmailfolder.php:571
eZPreferences
Definition: ezpreferences.php:62
eZPreferences\variable
static variable( $name, $group=false)
Definition: ezpreferences.php:95
eZPreferences\setVariable
static setVariable( $name, $value, $group=false)
Definition: ezpreferences.php:128
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$currentMethod
$currentMethod
Definition: ezmail/user/maillist.php:113
$folders
foreach( $mail as $mailItem) foreach(array(INBOX, SENT, DRAFTS, TRASH) as $specialfolder) $folders
Definition: ezmail/user/maillist.php:216
$mailCount
$mailCount
Definition: ezmail/user/maillist.php:174
$folder
foreach( $limit_array as $element_number) $folder
Definition: ezmail/user/maillist.php:126
$t
$t
Definition: ezmail/user/maillist.php:78
$limit_array
$limit_array
Definition: ezmail/user/maillist.php:112
$user
$user
Definition: ezmail/user/maillist.php:110
$isDraftsFolder
$isDraftsFolder
Definition: ezmail/user/maillist.php:127
$sort
$sort
Definition: ezmail/user/maillist.php:172
$preferences
$preferences
Definition: ezmail/user/maillist.php:133
$i
$i
Definition: ezmail/user/maillist.php:175
$ini
if(!eZMailFolder::isOwner(eZUser::currentUser(), $FolderID)) if(isset( $NewFolder)) if(isset( $Move) && $FolderSelectID !=-1 &&count( $MailArrayID) > 0) $ini
Definition: ezmail/user/maillist.php:61
$Language
if(! $NumMessages) $Language
Definition: ezmail/user/maillist.php:77
$mail
$mail
Definition: ezmail/user/maillist.php:173
UNREAD
const UNREAD
Definition: ezmail.php:50
SENT
const SENT
Definition: ezmailfolder.php:45
DRAFTS
const DRAFTS
Definition: ezmailfolder.php:44
INBOX
const INBOX
Definition: ezmailfolder.php:43
TRASH
const TRASH
Definition: ezmailfolder.php:46
exit
exit
Definition: folder.php:81
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.