2003-05-19 15:23:04 +00:00
< ? php
2005-04-09 12:26:45 +00:00
/**
*
* @ package ucp
* @ version $Id $
* @ copyright ( c ) 2005 phpBB Group
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
*
*/
2003-05-19 15:23:04 +00:00
2005-04-09 12:26:45 +00:00
/**
* @ package ucp
* ucp_main
* UCP Front Panel
*/
2005-10-04 21:31:35 +00:00
class ucp_main
2003-05-19 15:23:04 +00:00
{
2005-10-04 21:31:35 +00:00
var $p_master ;
function ucp_main ( & $p_master )
{
$this -> p_master = & $p_master ;
}
function main ( $id , $mode )
2003-05-19 15:23:04 +00:00
{
2004-02-21 12:47:35 +00:00
global $config , $db , $user , $auth , $SID , $template , $phpbb_root_path , $phpEx ;
2003-05-19 15:23:04 +00:00
2003-10-01 17:24:53 +00:00
switch ( $mode )
2003-05-19 15:23:04 +00:00
{
case 'front' :
2004-05-26 20:16:20 +00:00
$user -> add_lang ( 'memberlist' );
2005-10-19 18:00:10 +00:00
$sql_from = TOPICS_TABLE . ' t ' ;
$sql_select = '' ;
if ( $config [ 'load_db_track' ])
{
$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON ( tp . topic_id = t . topic_id
AND tp . user_id = ' . $user->data[' user_id '] . ' ) ' ;
$sql_select .= ', tp.topic_posted' ;
}
if ( $config [ 'load_db_lastread' ])
{
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON ( tt . topic_id = t . topic_id
AND tt . user_id = ' . $user->data[' user_id '] . ' ) ' ;
$sql_select .= ', tt.mark_time' ;
}
2003-06-23 14:00:57 +00:00
2003-05-19 15:23:04 +00:00
$topic_type = $user -> lang [ 'VIEW_TOPIC_ANNOUNCEMENT' ];
$folder = 'folder_announce' ;
$folder_new = $folder . '_new' ;
2004-07-09 12:31:33 +00:00
// Determine first forum the user is able to read into - for global announcement link
$forum_ary = $auth -> acl_getf ( 'f_read' );
$g_forum_id = 0 ;
foreach ( $forum_ary as $forum_id => $allowed )
{
if ( ! $allowed [ 'f_read' ])
{
unset ( $forum_ary [ $forum_id ]);
}
}
$forum_ary = array_unique ( array_keys ( $forum_ary ));
$sql = ' SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . '
AND forum_id IN ( ' . implode(' , ', $forum_ary) . ' ) ' ;
$result = $db -> sql_query_limit ( $sql , 1 );
$g_forum_id = ( int ) $db -> sql_fetchfield ( 'forum_id' , 0 , $result );
$db -> sql_freeresult ( $result );
2003-05-19 15:23:04 +00:00
$sql = " SELECT t.* $sql_select
2003-06-23 14:00:57 +00:00
FROM $sql_from
2003-05-19 15:23:04 +00:00
WHERE t . forum_id = 0
2003-06-23 14:00:57 +00:00
AND t . topic_type = " . POST_GLOBAL . '
2003-05-19 15:23:04 +00:00
ORDER BY t . topic_last_post_time DESC ' ;
2003-06-23 14:00:57 +00:00
$result = $db -> sql_query ( $sql );
2003-05-19 15:23:04 +00:00
2005-10-19 18:00:10 +00:00
$topic_list = $rowset = array ();
2003-05-19 15:23:04 +00:00
while ( $row = $db -> sql_fetchrow ( $result ))
{
2005-10-19 18:00:10 +00:00
$topic_list [] = $row [ 'topic_id' ];
$rowset [ $row [ 'topic_id' ]] = $row ;
}
$db -> sql_freeresult ( $result );
$topic_tracking_info = get_topic_tracking ( 0 , $topic_list , $rowset , array ( 0 => false ), $topic_list );
foreach ( $topic_list as $topic_id )
{
$row = & $rowset [ $topic_id ];
2003-05-19 15:23:04 +00:00
$forum_id = $row [ 'forum_id' ];
$topic_id = $row [ 'topic_id' ];
2005-10-19 18:00:10 +00:00
$unread_topic = ( isset ( $topic_tracking_info [ $topic_id ]) && $row [ 'topic_last_post_time' ] > $topic_tracking_info [ $topic_id ]) ? true : false ;
2003-05-19 15:23:04 +00:00
if ( $row [ 'topic_status' ] == ITEM_LOCKED )
{
$topic_type = $user -> lang [ 'VIEW_TOPIC_LOCKED' ];
$folder = 'folder_locked' ;
$folder_new = 'folder_locked_new' ;
}
$folder_img = ( $unread_topic ) ? $folder_new : $folder ;
$folder_alt = ( $unread_topic ) ? 'NEW_POSTS' : (( $row [ 'topic_status' ] == ITEM_LOCKED ) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS' );
// Posted image?
2005-10-19 18:00:10 +00:00
if ( ! empty ( $row [ 'topic_posted' ]) && $row [ 'topic_posted' ])
2003-05-19 15:23:04 +00:00
{
$folder_img .= '_posted' ;
}
$template -> assign_block_vars ( 'topicrow' , array (
'FORUM_ID' => $forum_id ,
'TOPIC_ID' => $topic_id ,
'LAST_POST_TIME' => $user -> format_date ( $row [ 'topic_last_post_time' ]),
2005-11-17 17:32:25 +00:00
'LAST_POST_AUTHOR' => ( $row [ 'topic_last_poster_id' ] == ANONYMOUS ) ? (( $row [ 'topic_last_poster_name' ] != '' ) ? $row [ 'topic_last_poster_name' ] . ' ' : $user -> lang [ 'GUEST' ] . ' ' ) : $row [ 'topic_last_poster_name' ],
2004-02-21 12:47:35 +00:00
'TOPIC_TITLE' => censor_text ( $row [ 'topic_title' ]),
2003-05-19 15:23:04 +00:00
'TOPIC_TYPE' => $topic_type ,
2005-11-17 17:32:25 +00:00
'LAST_POST_IMG' => $user -> img ( 'icon_post_latest' , 'VIEW_LATEST_POST' ),
'NEWEST_POST_IMG' => $user -> img ( 'icon_post_newest' , 'VIEW_NEWEST_POST' ),
2003-05-19 15:23:04 +00:00
'TOPIC_FOLDER_IMG' => $user -> img ( $folder_img , $folder_alt ),
2003-11-04 22:05:38 +00:00
'ATTACH_ICON_IMG' => ( $auth -> acl_gets ( 'f_download' , 'u_download' , $forum_id ) && $row [ 'topic_attachment' ]) ? $user -> img ( 'icon_attach' , '' ) : '' ,
2003-05-19 15:23:04 +00:00
2005-11-17 17:32:25 +00:00
'S_USER_POSTED' => ( ! empty ( $row [ 'topic_posted' ]) && $row [ 'topic_posted' ]) ? true : false ,
'S_UNREAD' => $unread_topic ,
2003-05-19 15:23:04 +00:00
2005-11-17 17:32:25 +00:00
'U_LAST_POST' => " { $phpbb_root_path } viewtopic. $phpEx $SID &f= $g_forum_id &t= $topic_id &p= " . $row [ 'topic_last_post_id' ] . '#' . $row [ 'topic_last_post_id' ],
'U_LAST_POST_AUTHOR' => ( $row [ 'topic_last_poster_id' ] != ANONYMOUS ) ? " { $phpbb_root_path } memberlist. $phpEx $SID &mode=viewprofile&u= " . $row [ 'topic_last_poster_id' ] : '' ,
'U_NEWEST_POST' => " { $phpbb_root_path } viewtopic. $phpEx $SID &f= $g_forum_id &t= $topic_id &view=unread#unread " ,
'U_VIEW_TOPIC' => " { $phpbb_root_path } viewtopic. $phpEx $SID &f= $g_forum_id &t= $topic_id " )
2003-05-19 15:23:04 +00:00
);
}
2004-05-26 20:16:20 +00:00
$post_count_ary = $auth -> acl_getf ( 'f_postcount' );
$forum_ary = array ();
foreach ( $post_count_ary as $forum_id => $allowed )
{
2004-07-09 12:31:33 +00:00
if ( $allowed [ 'f_read' ] && $allowed [ 'f_postcount' ])
2004-05-26 20:16:20 +00:00
{
$forum_ary [] = $forum_id ;
}
}
2003-05-26 23:53:34 +00:00
2004-05-26 20:16:20 +00:00
$post_count_sql = ( sizeof ( $forum_ary )) ? 'AND f.forum_id IN (' . implode ( ', ' , $forum_ary ) . ')' : '' ;
unset ( $forum_ary , $post_count_ary );
2003-05-26 23:53:34 +00:00
2004-05-26 20:16:20 +00:00
if ( $post_count_sql )
{
2004-06-15 17:56:37 +00:00
// NOTE: The following three queries could be a problem for big boards
2004-05-26 20:16:20 +00:00
// Grab all the relevant data
$sql = ' SELECT COUNT ( p . post_id ) AS num_posts
FROM ' . POSTS_TABLE . ' p , ' . FORUMS_TABLE . ' f
WHERE p . poster_id = ' . $user->data[' user_id ' ] . "
AND f . forum_id = p . forum_id
$post_count_sql " ;
$result = $db -> sql_query ( $sql );
2003-05-26 23:53:34 +00:00
2004-05-26 20:16:20 +00:00
$num_real_posts = min ( $user -> data [ 'user_posts' ], $db -> sql_fetchfield ( 'num_posts' , 0 , $result ));
$db -> sql_freeresult ( $result );
2003-05-26 23:53:34 +00:00
2004-05-26 20:16:20 +00:00
$sql = ' SELECT f . forum_id , f . forum_name , COUNT ( post_id ) AS num_posts
FROM ' . POSTS_TABLE . ' p , ' . FORUMS_TABLE . ' f
WHERE p . poster_id = ' . $user->data[' user_id ' ] . "
AND f . forum_id = p . forum_id
$post_count_sql
GROUP BY f . forum_id , f . forum_name
ORDER BY num_posts DESC " ;
$result = $db -> sql_query_limit ( $sql , 1 );
2003-05-26 23:53:34 +00:00
2004-05-26 20:16:20 +00:00
$active_f_row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
$sql = ' SELECT t . topic_id , t . topic_title , COUNT ( p . post_id ) AS num_posts
FROM ' . POSTS_TABLE . ' p , ' . TOPICS_TABLE . ' t , ' . FORUMS_TABLE . ' f
WHERE p . poster_id = ' . $user->data[' user_id ' ] . "
AND t . topic_id = p . topic_id
AND f . forum_id = t . forum_id
$post_count_sql
GROUP BY t . topic_id , t . topic_title
ORDER BY num_posts DESC " ;
$result = $db -> sql_query_limit ( $sql , 1 );
$active_t_row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
}
else
{
$num_real_posts = 0 ;
$active_f_row = $active_t_row = array ();
}
2003-05-26 23:53:34 +00:00
// Do the relevant calculations
2003-10-01 17:24:53 +00:00
$memberdays = max ( 1 , round (( time () - $user -> data [ 'user_regdate' ]) / 86400 ));
$posts_per_day = $user -> data [ 'user_posts' ] / $memberdays ;
2003-05-26 23:53:34 +00:00
$percentage = ( $config [ 'num_posts' ]) ? min ( 100 , ( $num_real_posts / $config [ 'num_posts' ]) * 100 ) : 0 ;
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '' ;
if ( ! empty ( $active_f_row [ 'num_posts' ]))
{
$active_f_name = $active_f_row [ 'forum_name' ];
$active_f_id = $active_f_row [ 'forum_id' ];
$active_f_count = $active_f_row [ 'num_posts' ];
2005-01-02 19:12:56 +00:00
$active_f_pct = ( $user -> data [ 'user_posts' ]) ? ( $active_f_count / $user -> data [ 'user_posts' ]) * 100 : 0 ;
2003-05-26 23:53:34 +00:00
}
unset ( $active_f_row );
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '' ;
if ( ! empty ( $active_t_row [ 'num_posts' ]))
{
$active_t_name = $active_t_row [ 'topic_title' ];
$active_t_id = $active_t_row [ 'topic_id' ];
$active_t_count = $active_t_row [ 'num_posts' ];
2005-01-02 19:12:56 +00:00
$active_t_pct = ( $user -> data [ 'user_posts' ]) ? ( $active_t_count / $user -> data [ 'user_posts' ]) * 100 : 0 ;
2003-05-26 23:53:34 +00:00
}
unset ( $active_t_row );
$template -> assign_vars ( array (
2003-07-07 23:43:57 +00:00
'USER_COLOR' => ( ! empty ( $user -> data [ 'user_colour' ])) ? $user -> data [ 'user_colour' ] : '' ,
'JOINED' => $user -> format_date ( $user -> data [ 'user_regdate' ], $user -> lang [ 'DATE_FORMAT' ]),
'VISITED' => ( empty ( $last_visit )) ? ' - ' : $user -> format_date ( $last_visit , $user -> lang [ 'DATE_FORMAT' ]),
2003-10-01 17:24:53 +00:00
'POSTS' => ( $user -> data [ 'user_posts' ]) ? $user -> data [ 'user_posts' ] : 0 ,
2003-05-26 23:53:34 +00:00
'POSTS_DAY' => sprintf ( $user -> lang [ 'POST_DAY' ], $posts_per_day ),
'POSTS_PCT' => sprintf ( $user -> lang [ 'POST_PCT' ], $percentage ),
'ACTIVE_FORUM' => $active_f_name ,
2005-01-21 09:48:46 +00:00
'ACTIVE_FORUM_POSTS' => ( $active_f_count == 1 ) ? sprintf ( $user -> lang [ 'USER_POST' ], 1 ) : sprintf ( $user -> lang [ 'USER_POSTS' ], $active_f_count ),
'ACTIVE_FORUM_PCT' => sprintf ( $user -> lang [ 'POST_PCT' ], $active_f_pct ),
2003-05-26 23:53:34 +00:00
'ACTIVE_TOPIC' => $active_t_name ,
'ACTIVE_TOPIC_POSTS' => ( $active_t_count == 1 ) ? sprintf ( $user -> lang [ 'USER_POST' ], 1 ) : sprintf ( $user -> lang [ 'USER_POSTS' ], $active_t_count ),
2005-01-21 09:48:46 +00:00
'ACTIVE_TOPIC_PCT' => sprintf ( $user -> lang [ 'POST_PCT' ], $active_t_pct ),
2003-05-26 23:53:34 +00:00
'OCCUPATION' => ( ! empty ( $row [ 'user_occ' ])) ? $row [ 'user_occ' ] : '' ,
'INTERESTS' => ( ! empty ( $row [ 'user_interests' ])) ? $row [ 'user_interests' ] : '' ,
2004-05-26 20:16:20 +00:00
// 'S_GROUP_OPTIONS' => $group_options,
2003-05-26 23:53:34 +00:00
2005-11-17 17:32:25 +00:00
'U_SEARCH_USER' => ( $auth -> acl_get ( 'u_search' )) ? " { $phpbb_root_path } search. $phpEx $SID &search_author= " . urlencode ( $user -> data [ 'username' ]) . " &show_results=posts " : '' ,
'U_ACTIVE_FORUM' => " { $phpbb_root_path } viewforum. $phpEx $SID &f= $active_f_id " ,
'U_ACTIVE_TOPIC' => " { $phpbb_root_path } viewtopic. $phpEx $SID &t= $active_t_id " ,)
2003-05-26 23:53:34 +00:00
);
2003-05-19 15:23:04 +00:00
break ;
2003-10-01 17:24:53 +00:00
case 'subscribed' :
2003-05-19 15:23:04 +00:00
2004-10-13 19:30:02 +00:00
include ( $phpbb_root_path . 'includes/functions_display.' . $phpEx );
$user -> add_lang ( 'viewforum' );
$unwatch = ( isset ( $_POST [ 'unwatch' ])) ? true : false ;
if ( $unwatch )
2003-05-19 15:23:04 +00:00
{
$forums = ( isset ( $_POST [ 'f' ])) ? implode ( ', ' , array_map ( 'intval' , array_keys ( $_POST [ 'f' ]))) : false ;
$topics = ( isset ( $_POST [ 't' ])) ? implode ( ', ' , array_map ( 'intval' , array_keys ( $_POST [ 't' ]))) : false ;
if ( $forums || $topics )
{
$l_unwatch = '' ;
if ( $forums )
{
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . "
WHERE forum_id IN ( $forums )
AND user_id = " . $user->data ['user_id'];
$db -> sql_query ( $sql );
$l_unwatch .= '_FORUMS' ;
}
if ( $topics )
{
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . "
WHERE topic_id IN ( $topics )
AND user_id = " . $user->data ['user_id'];
$db -> sql_query ( $sql );
$l_unwatch .= '_TOPICS' ;
}
2004-10-13 19:30:02 +00:00
$message = $user -> lang [ 'UNWATCHED' . $l_unwatch ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_UCP' ], " <a href= \" ucp. $phpEx $SID &i= $id &mode=subscribed \" > " , '</a>' );
2003-05-19 15:23:04 +00:00
2004-10-13 19:30:02 +00:00
meta_refresh ( 3 , " ucp. $phpEx $SID &i= $id &mode=subscribed " );
2003-05-19 15:23:04 +00:00
trigger_error ( $message );
}
}
if ( $config [ 'load_db_lastread' ])
{
2005-10-19 18:00:10 +00:00
$sql_from = '(' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user -> data [ 'user_id' ] . ' AND ft.forum_id = f.forum_id))' ;
2003-05-19 15:23:04 +00:00
$lastread_select = ', ft.mark_time ' ;
}
else
{
2003-06-23 14:00:57 +00:00
$sql_from = FORUMS_TABLE . ' f ' ;
$lastread_select = '' ;
2003-05-19 15:23:04 +00:00
2003-06-23 14:00:57 +00:00
$tracking_topics = ( isset ( $_COOKIE [ $config [ 'cookie_name' ] . '_track' ])) ? unserialize ( stripslashes ( $_COOKIE [ $config [ 'cookie_name' ] . '_track' ])) : array ();
2003-05-19 15:23:04 +00:00
}
$sql = " SELECT f.* $lastread_select
2003-06-23 14:00:57 +00:00
FROM $sql_from , " . FORUMS_WATCH_TABLE . ' fw
2003-05-19 15:23:04 +00:00
WHERE fw . user_id = ' . $user->data[' user_id '] . '
AND f . forum_id = fw . forum_id
ORDER BY left_id ' ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
{
$forum_id = $row [ 'forum_id' ];
2005-10-19 18:00:10 +00:00
if ( $config [ 'load_db_lastread' ])
2003-05-19 15:23:04 +00:00
{
2005-10-19 18:00:10 +00:00
$forum_check = ( ! empty ( $row [ 'mark_time' ])) ? $row [ 'mark_time' ] : $user -> data [ 'user_lastmark' ];
2003-05-19 15:23:04 +00:00
}
2005-10-19 18:00:10 +00:00
else
{
$forum_check = ( isset ( $tracking_topics [ 'f' ][ $forum_id ])) ? base_convert ( $tracking_topics [ 'f' ][ $forum_id ], 36 , 10 ) + $config [ 'board_startdate' ] : $user -> data [ 'user_lastmark' ];
}
$unread_forum = ( $row [ 'forum_last_post_time' ] > $forum_check ) ? true : false ;
2003-05-19 15:23:04 +00:00
// Which folder should we display?
if ( $row [ 'forum_status' ] == ITEM_LOCKED )
{
$folder_image = ( $unread_forum ) ? 'folder_locked_new' : 'folder_locked' ;
$folder_alt = 'FORUM_LOCKED' ;
}
else
{
$folder_image = ( $unread_forum ) ? 'folder_new' : 'folder' ;
$folder_alt = ( $unread_forum ) ? 'NEW_POSTS' : 'NO_NEW_POSTS' ;
}
// Create last post link information, if appropriate
if ( $row [ 'forum_last_post_id' ])
{
$last_post_time = $user -> format_date ( $row [ 'forum_last_post_time' ]);
$last_poster = ( $row [ 'forum_last_poster_name' ] != '' ) ? $row [ 'forum_last_poster_name' ] : $user -> lang [ 'GUEST' ];
2005-11-17 17:32:25 +00:00
$last_poster_url = ( $row [ 'forum_last_poster_id' ] == ANONYMOUS ) ? '' : " { $phpbb_root_path } memberlist. $phpEx $SID &mode=viewprofile&u= " . $row [ 'forum_last_poster_id' ];
2003-05-19 15:23:04 +00:00
2005-11-17 17:32:25 +00:00
$last_post_url = " { $phpbb_root_path } viewtopic. $phpEx $SID &f= $forum_id &p= " . $row [ 'forum_last_post_id' ] . '#' . $row [ 'forum_last_post_id' ];
2003-05-19 15:23:04 +00:00
}
else
{
$last_post_time = $last_poster = $last_poster_url = $last_post_url = '' ;
}
$template -> assign_block_vars ( 'forumrow' , array (
'FORUM_ID' => $forum_id ,
'FORUM_FOLDER_IMG' => $user -> img ( $folder_image , $folder_alt ),
2005-04-30 14:16:21 +00:00
'FORUM_FOLDER_IMG_SRC' => $user -> img ( $folder_image , $folder_alt , false , '' , 'src' ),
2003-05-19 15:23:04 +00:00
'FORUM_NAME' => $row [ 'forum_name' ],
2005-01-21 09:48:46 +00:00
'LAST_POST_IMG' => $user -> img ( 'icon_post_latest' , 'VIEW_LATEST_POST' ),
2003-05-19 15:23:04 +00:00
'LAST_POST_TIME' => $last_post_time ,
'LAST_POST_AUTHOR' => $last_poster ,
'U_LAST_POST_AUTHOR' => $last_poster_url ,
'U_LAST_POST' => $last_post_url ,
2005-11-17 17:32:25 +00:00
'U_VIEWFORUM' => " { $phpbb_root_path } viewforum. $phpEx $SID &f= " . $row [ 'forum_id' ])
2003-05-19 15:23:04 +00:00
);
}
$db -> sql_freeresult ( $result );
// Subscribed Topics
2004-10-13 19:30:02 +00:00
$start = request_var ( 'start' , 0 );
$sql = ' SELECT COUNT ( topic_id ) as topics_count
FROM ' . TOPICS_WATCH_TABLE . '
WHERE user_id = ' . $user->data[' user_id ' ];
$result = $db -> sql_query ( $sql );
$topics_count = ( int ) $db -> sql_fetchfield ( 'topics_count' , 0 , $result );
$db -> sql_freeresult ( $result );
if ( $topics_count )
{
$template -> assign_vars ( array (
'PAGINATION' => generate_pagination ( " ucp. $phpEx $SID &i= $id &mode= $mode " , $topics_count , $config [ 'topics_per_page' ], $start ),
'PAGE_NUMBER' => on_page ( $topics_count , $config [ 'topics_per_page' ], $start ),
'TOTAL_TOPICS' => ( $topics_count == 1 ) ? $user -> lang [ 'VIEW_FORUM_TOPIC' ] : sprintf ( $user -> lang [ 'VIEW_FORUM_TOPICS' ], $topics_count ))
);
}
2005-10-19 18:00:10 +00:00
$sql_f_tracking = ( $config [ 'load_db_lastread' ]) ? 'LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.forum_id = t.forum_id AND ft.user_id = ' . $user -> data [ 'user_id' ] . ')' : '' ;
$sql_f_select = ( $config [ 'load_db_lastread' ]) ? ', ft.mark_time AS forum_mark_time' : '' ;
$sql_from = TOPICS_TABLE . ' t' ;
$sql_t_select = '' ;
if ( $config [ 'load_db_track' ])
{
$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON ( tp . topic_id = t . topic_id
AND tp . user_id = ' . $user->data[' user_id '] . ' ) ' ;
$sql_t_select .= ', tp.topic_posted' ;
}
if ( $config [ 'load_db_lastread' ])
{
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON ( tt . topic_id = t . topic_id
AND tt . user_id = ' . $user->data[' user_id '] . ' ) ' ;
$sql_t_select .= ', tt.mark_time' ;
}
2003-05-19 15:23:04 +00:00
$sql = " SELECT t.* $sql_f_select $sql_t_select
2005-01-21 09:48:46 +00:00
FROM $sql_from $sql_f_tracking , " . TOPICS_WATCH_TABLE . ' tw
2003-05-19 15:23:04 +00:00
WHERE tw . user_id = ' . $user->data[' user_id '] . '
AND t . topic_id = tw . topic_id
ORDER BY t . topic_last_post_time DESC ' ;
2004-10-13 19:30:02 +00:00
$result = $db -> sql_query_limit ( $sql , $config [ 'topics_per_page' ], $start );
2003-05-19 15:23:04 +00:00
2005-10-19 18:00:10 +00:00
$topic_list = $global_announce_list = $rowset = array ();
2003-05-19 15:23:04 +00:00
while ( $row = $db -> sql_fetchrow ( $result ))
{
2005-10-19 18:00:10 +00:00
$topic_list [] = $row [ 'topic_id' ];
$rowset [ $row [ 'topic_id' ]] = $row ;
if ( $row [ 'topic_type' ] == POST_GLOBAL )
2003-05-19 15:23:04 +00:00
{
2005-10-19 18:00:10 +00:00
$global_announce_list [] = $row [ 'topic_id' ];
2003-05-19 15:23:04 +00:00
}
2005-10-19 18:00:10 +00:00
}
$db -> sql_freeresult ( $result );
2003-05-19 15:23:04 +00:00
2005-10-19 18:00:10 +00:00
/**
* @ todo get_topic_tracking able to fetch from multiple forums
*/
$topic_tracking_info = get_topic_tracking ( 0 , $topic_list , $rowset , array ( 0 => false ), $global_announce_list );
foreach ( $topic_list as $topic_id )
{
$row = & $rowset [ $topic_id ];
$forum_id = $row [ 'forum_id' ];
$topic_id = $row [ 'topic_id' ];
$unread_topic = ( isset ( $topic_tracking_info [ $topic_id ]) && $row [ 'topic_last_post_time' ] > $topic_tracking_info [ $topic_id ]) ? true : false ;
2003-05-19 15:23:04 +00:00
2004-10-13 19:30:02 +00:00
// Replies
$replies = ( $auth -> acl_get ( 'm_approve' , $forum_id )) ? $row [ 'topic_replies_real' ] : $row [ 'topic_replies' ];
2003-05-19 15:23:04 +00:00
2004-10-13 19:30:02 +00:00
if ( $row [ 'topic_status' ] == ITEM_MOVED )
2003-05-19 15:23:04 +00:00
{
2004-10-13 19:30:02 +00:00
$topic_id = $row [ 'topic_moved_id' ];
2003-05-19 15:23:04 +00:00
}
2004-10-13 19:30:02 +00:00
// Get folder img, topic status/type related informations
$folder_img = $folder_alt = $topic_type = '' ;
2005-10-19 18:00:10 +00:00
topic_status ( $row , $replies , $unread_topic , $folder_img , $folder_alt , $topic_type );
2004-10-13 19:30:02 +00:00
2003-05-19 15:23:04 +00:00
$view_topic_url = " viewtopic. $phpEx $SID &f= $forum_id &t= $topic_id " ;
2004-10-13 19:30:02 +00:00
// Send vars to template
2003-05-19 15:23:04 +00:00
$template -> assign_block_vars ( 'topicrow' , array (
'FORUM_ID' => $forum_id ,
'TOPIC_ID' => $topic_id ,
2004-10-13 19:30:02 +00:00
'TOPIC_AUTHOR' => topic_topic_author ( $row ),
'FIRST_POST_TIME' => $user -> format_date ( $row [ 'topic_time' ]),
2003-05-19 15:23:04 +00:00
'LAST_POST_TIME' => $user -> format_date ( $row [ 'topic_last_post_time' ]),
2004-10-13 19:30:02 +00:00
'LAST_VIEW_TIME' => $user -> format_date ( $row [ 'topic_last_view_time' ]),
'LAST_POST_AUTHOR' => ( $row [ 'topic_last_poster_name' ] != '' ) ? $row [ 'topic_last_poster_name' ] : $user -> lang [ 'GUEST' ],
'PAGINATION' => topic_generate_pagination ( $replies , " viewtopic. $phpEx $SID &f= " . (( $row [ 'forum_id' ]) ? $row [ 'forum_id' ] : $forum_id ) . " &t= $topic_id " ),
'REPLIES' => $replies ,
'VIEWS' => $row [ 'topic_views' ],
2004-02-21 12:47:35 +00:00
'TOPIC_TITLE' => censor_text ( $row [ 'topic_title' ]),
2003-05-19 15:23:04 +00:00
'TOPIC_TYPE' => $topic_type ,
2004-10-13 19:30:02 +00:00
'LAST_POST_IMG' => $user -> img ( 'icon_post_latest' , 'VIEW_LATEST_POST' ),
2005-11-17 17:32:25 +00:00
'NEWEST_POST_IMG' => $user -> img ( 'icon_post_newest' , 'VIEW_NEWEST_POST' ),
2003-05-19 15:23:04 +00:00
'TOPIC_FOLDER_IMG' => $user -> img ( $folder_img , $folder_alt ),
2005-04-30 14:16:21 +00:00
'TOPIC_FOLDER_IMG_SRC' => $user -> img ( $folder_img , $folder_alt , false , '' , 'src' ),
'TOPIC_ICON_IMG' => ( ! empty ( $icons [ $row [ 'icon_id' ]])) ? $icons [ $row [ 'icon_id' ]][ 'img' ] : '' ,
'TOPIC_ICON_IMG_WIDTH' => ( ! empty ( $icons [ $row [ 'icon_id' ]])) ? $icons [ $row [ 'icon_id' ]][ 'width' ] : '' ,
'TOPIC_ICON_IMG_HEIGHT' => ( ! empty ( $icons [ $row [ 'icon_id' ]])) ? $icons [ $row [ 'icon_id' ]][ 'height' ] : '' ,
'ATTACH_ICON_IMG' => ( $auth -> acl_gets ( 'f_download' , 'u_download' , $forum_id ) && $row [ 'topic_attachment' ]) ? $user -> img ( 'icon_attach' , $user -> lang [ 'TOTAL_ATTACHMENTS' ]) : '' ,
2003-05-19 15:23:04 +00:00
2004-10-13 19:30:02 +00:00
'S_TOPIC_TYPE' => $row [ 'topic_type' ],
2005-10-19 18:00:10 +00:00
'S_USER_POSTED' => ( ! empty ( $row [ 'topic_posted' ])) ? true : false ,
2004-10-13 19:30:02 +00:00
'S_UNREAD_TOPIC' => $unread_topic ,
2003-05-19 15:23:04 +00:00
2005-11-17 17:32:25 +00:00
'U_NEWEST_POST' => " { $phpbb_root_path } viewtopic. $phpEx $SID &f= $forum_id &t= $topic_id &view=unread#unread " ,
2004-10-13 19:30:02 +00:00
'U_LAST_POST' => $view_topic_url . '&p=' . $row [ 'topic_last_post_id' ] . '#' . $row [ 'topic_last_post_id' ],
2005-11-17 17:32:25 +00:00
'U_LAST_POST_AUTHOR' => ( $row [ 'topic_last_poster_id' ] != ANONYMOUS && $row [ 'topic_last_poster_id' ]) ? " { $phpbb_root_path } memberlist. $phpEx $SID &mode=viewprofile&u= { $row [ 'topic_last_poster_id' ] } " : '' ,
2003-05-19 15:23:04 +00:00
'U_VIEW_TOPIC' => $view_topic_url )
);
2004-10-13 19:30:02 +00:00
2003-05-19 15:23:04 +00:00
}
$db -> sql_freeresult ( $result );
2003-09-04 18:30:20 +00:00
break ;
2004-06-06 21:44:49 +00:00
case 'bookmarks' :
if ( ! $config [ 'allow_bookmarks' ])
{
$template -> assign_vars ( array (
'S_NO_DISPLAY_BOOKMARKS' => true )
);
break ;
}
2004-10-13 19:30:02 +00:00
include ( $phpbb_root_path . 'includes/functions_display.' . $phpEx );
$user -> add_lang ( 'viewforum' );
2004-06-06 21:44:49 +00:00
$move_up = request_var ( 'move_up' , 0 );
$move_down = request_var ( 'move_down' , 0 );
$sql = 'SELECT MAX(order_id) as max_order_id FROM ' . BOOKMARKS_TABLE . '
WHERE user_id = ' . $user->data[' user_id ' ];
$result = $db -> sql_query ( $sql );
$max_order_id = $db -> sql_fetchfield ( 'max_order_id' , 0 , $result );
$db -> sql_freeresult ( $result );
if ( $move_up || $move_down )
{
if (( $move_up && $move_up != 1 ) || ( $move_down && $move_down != $max_order_id ))
{
$order = ( $move_up ) ? $move_up : $move_down ;
$order_total = $order * 2 + (( $move_up ) ? - 1 : 1 );
$sql = 'UPDATE ' . BOOKMARKS_TABLE . "
SET order_id = $order_total - order_id
WHERE order_id IN ( $order , " . (( $move_up ) ? $order - 1 : $order + 1) . ')
AND user_id = ' . $user->data[' user_id ' ];
$db -> sql_query ( $sql );
}
}
if ( isset ( $_POST [ 'unbookmark' ]))
{
$s_hidden_fields = '<input type="hidden" name="unbookmark" value="1" />' ;
$topics = ( isset ( $_POST [ 't' ])) ? array_map ( 'intval' , array_keys ( $_POST [ 't' ])) : array ();
2005-11-17 17:32:25 +00:00
$url = " { $phpbb_root_path } ucp. $phpEx $SID &i= $id &mode= $mode " ;
2004-06-06 21:44:49 +00:00
if ( ! sizeof ( $topics ))
{
trigger_error ( 'NO_BOOKMARKS_SELECTED' );
}
foreach ( $topics as $topic_id )
{
$s_hidden_fields .= '<input type="hidden" name="t[' . $topic_id . ']" value="1" />' ;
}
if ( confirm_box ( true ))
{
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
WHERE user_id = ' . $user->data[' user_id '] . '
AND topic_id IN ( ' . implode(' , ', $topics) . ' ) ' ;
$db -> sql_query ( $sql );
// Re-Order bookmarks (possible with one query? This query massaker is not really acceptable...)
$sql = 'SELECT topic_id FROM ' . BOOKMARKS_TABLE . '
WHERE user_id = ' . $user->data[' user_id '] . '
ORDER BY order_id ASC ' ;
$result = $db -> sql_query ( $sql );
$i = 1 ;
while ( $row = $db -> sql_fetchrow ( $result ))
{
$db -> sql_query ( 'UPDATE ' . BOOKMARKS_TABLE . "
SET order_id = $i
WHERE topic_id = { $row [ 'topic_id' ]}
AND user_id = { $user -> data [ 'user_id' ]} " );
$i ++ ;
}
$db -> sql_freeresult ( $result );
meta_refresh ( 3 , $url );
$message = $user -> lang [ 'BOOKMARKS_REMOVED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_UCP' ], '<a href="' . $url . '">' , '</a>' );
trigger_error ( $message );
}
else
{
confirm_box ( false , 'REMOVE_SELECTED_BOOKMARKS' , $s_hidden_fields );
}
}
// We grab deleted topics here too...
// NOTE: At the moment bookmarks are not removed with topics, might be useful later (not really sure how though. :D)
// But since bookmarks are sensible to the user, they should not be deleted without notice.
$sql = ' SELECT b . order_id , b . topic_id as b_topic_id , t .* , f . forum_name
FROM ' . BOOKMARKS_TABLE . ' b
LEFT JOIN ' . TOPICS_TABLE . ' t ON b . topic_id = t . topic_id
LEFT JOIN ' . FORUMS_TABLE . ' f ON t . forum_id = f . forum_id
WHERE b . user_id = ' . $user->data[' user_id '] . '
ORDER BY b . order_id ASC ' ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
{
$forum_id = $row [ 'forum_id' ];
$topic_id = $row [ 'b_topic_id' ];
2004-07-11 15:20:35 +00:00
$replies = ( $auth -> acl_get ( 'm_approve' , $forum_id )) ? $row [ 'topic_replies_real' ] : $row [ 'topic_replies' ];
2004-06-06 21:44:49 +00:00
2004-10-13 19:30:02 +00:00
// Get folder img, topic status/type related informations
$folder_img = $folder_alt = $topic_type = '' ;
$unread_topic = topic_status ( $row , $replies , time (), time (), $folder_img , $folder_alt , $topic_type );
2004-06-06 21:44:49 +00:00
$view_topic_url = " viewtopic. $phpEx $SID &f= $forum_id &t= $topic_id " ;
$template -> assign_block_vars ( 'topicrow' , array (
'FORUM_ID' => $forum_id ,
'TOPIC_ID' => $topic_id ,
'S_DELETED_TOPIC' => ( ! $row [ 'topic_id' ]) ? true : false ,
'TOPIC_TITLE' => censor_text ( $row [ 'topic_title' ]),
'TOPIC_TYPE' => $topic_type ,
'FORUM_NAME' => $row [ 'forum_name' ],
2004-10-13 19:30:02 +00:00
'TOPIC_AUTHOR' => topic_topic_author ( $row ),
'FIRST_POST_TIME' => $user -> format_date ( $row [ 'topic_time' ]),
'LAST_POST_TIME' => $user -> format_date ( $row [ 'topic_last_post_time' ]),
'LAST_VIEW_TIME' => $user -> format_date ( $row [ 'topic_last_view_time' ]),
'LAST_POST_AUTHOR' => ( $row [ 'topic_last_poster_name' ] != '' ) ? $row [ 'topic_last_poster_name' ] : $user -> lang [ 'GUEST' ],
'PAGINATION' => topic_generate_pagination ( $replies , " viewtopic. $phpEx $SID &f= " . (( $row [ 'forum_id' ]) ? $row [ 'forum_id' ] : $forum_id ) . " &t= $topic_id " ),
2004-06-06 21:44:49 +00:00
'POSTED_AT' => $user -> format_date ( $row [ 'topic_time' ]),
2004-10-13 19:30:02 +00:00
'TOPIC_FOLDER_IMG' => $user -> img ( $folder_img , $folder_alt ),
2004-06-06 21:44:49 +00:00
'ATTACH_ICON_IMG' => ( $auth -> acl_gets ( 'f_download' , 'u_download' , $forum_id ) && $row [ 'topic_attachment' ]) ? $user -> img ( 'icon_attach' , '' ) : '' ,
2004-10-13 19:30:02 +00:00
'LAST_POST_IMG' => $user -> img ( 'icon_post_latest' , 'VIEW_LATEST_POST' ),
2004-06-06 21:44:49 +00:00
2004-10-13 19:30:02 +00:00
'U_LAST_POST' => $view_topic_url . '&p=' . $row [ 'topic_last_post_id' ] . '#' . $row [ 'topic_last_post_id' ],
2005-11-17 17:32:25 +00:00
'U_LAST_POST_AUTHOR' => ( $row [ 'topic_last_poster_id' ] != ANONYMOUS && $row [ 'topic_last_poster_id' ]) ? " { $phpbb_root_path } memberlist. $phpEx $SID &mode=viewprofile&u= { $row [ 'topic_last_poster_id' ] } " : '' ,
2004-06-06 21:44:49 +00:00
'U_VIEW_TOPIC' => $view_topic_url ,
2004-10-13 19:30:02 +00:00
'U_VIEW_FORUM' => " { $phpbb_root_path } viewforum. $phpEx $SID &f= $forum_id } " ,
2004-06-06 21:44:49 +00:00
'U_MOVE_UP' => ( $row [ 'order_id' ] != 1 ) ? " { $phpbb_root_path } ucp. $phpEx $SID &i=main&mode=bookmarks&move_up= { $row [ 'order_id' ] } " : '' ,
2004-07-08 22:41:04 +00:00
'U_MOVE_DOWN' => ( $row [ 'order_id' ] != $max_order_id ) ? " { $phpbb_root_path } ucp. $phpEx $SID &i=main&mode=bookmarks&move_down= { $row [ 'order_id' ] } " : '' )
2004-06-06 21:44:49 +00:00
);
}
break ;
2003-09-04 18:30:20 +00:00
case 'drafts' :
2004-05-02 13:06:57 +00:00
2005-10-04 21:31:35 +00:00
$pm_drafts = ( $this -> p_master -> p_name == 'pm' ) ? true : false ;
2004-05-02 13:06:57 +00:00
$user -> add_lang ( 'posting' );
2003-09-04 18:30:20 +00:00
$edit = ( isset ( $_REQUEST [ 'edit' ])) ? true : false ;
$submit = ( isset ( $_POST [ 'submit' ])) ? true : false ;
$draft_id = ( $edit ) ? intval ( $_REQUEST [ 'edit' ]) : 0 ;
2004-07-09 12:31:33 +00:00
$delete = ( isset ( $_POST [ 'delete' ])) ? true : false ;
2003-09-04 18:30:20 +00:00
$s_hidden_fields = ( $edit ) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : '' ;
2003-11-16 21:53:56 +00:00
$draft_subject = $draft_message = '' ;
2003-09-04 18:30:20 +00:00
2004-07-09 12:31:33 +00:00
if ( $delete )
2003-09-04 18:30:20 +00:00
{
2003-11-16 21:53:56 +00:00
$drafts = ( isset ( $_POST [ 'd' ])) ? implode ( ', ' , array_map ( 'intval' , array_keys ( $_POST [ 'd' ]))) : '' ;
2003-09-04 18:30:20 +00:00
2004-01-10 12:19:10 +00:00
if ( $drafts )
2003-09-04 18:30:20 +00:00
{
$sql = 'DELETE FROM ' . DRAFTS_TABLE . "
WHERE draft_id IN ( $drafts )
AND user_id = " . $user->data ['user_id'];
$db -> sql_query ( $sql );
2003-10-01 17:24:53 +00:00
$message = $user -> lang [ 'DRAFTS_DELETED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_UCP' ], " <a href= \" ucp. $phpEx $SID &i= $id &mode= $mode\ " > " , '</a>');
2003-09-04 18:30:20 +00:00
2003-10-01 17:24:53 +00:00
meta_refresh ( 3 , " ucp. $phpEx $SID &i= $id &mode= $mode " );
2003-09-04 18:30:20 +00:00
trigger_error ( $message );
}
}
if ( $submit && $edit )
{
2005-05-15 20:17:35 +00:00
$draft_subject = request_var ( 'subject' , '' , true );
$draft_message = request_var ( 'message' , '' , true );
2003-09-04 18:30:20 +00:00
2004-01-10 12:19:10 +00:00
if ( $draft_message && $draft_subject )
2003-09-04 18:30:20 +00:00
{
$draft_row = array (
2003-11-16 21:53:56 +00:00
'draft_subject' => $draft_subject ,
'draft_message' => $draft_message
2003-09-04 18:30:20 +00:00
);
$sql = 'UPDATE ' . DRAFTS_TABLE . '
SET ' . $db->sql_build_array(' UPDATE ' , $draft_row ) . "
WHERE draft_id = $draft_id
AND user_id = " . $user->data ['user_id'];
$db -> sql_query ( $sql );
2003-10-01 17:24:53 +00:00
$message = $user -> lang [ 'DRAFT_UPDATED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_UCP' ], " <a href= \" ucp. $phpEx $SID &i= $id &mode= $mode\ " > " , '</a>');
2003-09-04 18:30:20 +00:00
2003-10-01 17:24:53 +00:00
meta_refresh ( 3 , " ucp. $phpEx $SID &i= $id &mode= $mode " );
2003-09-04 18:30:20 +00:00
trigger_error ( $message );
}
else
{
2003-11-16 21:53:56 +00:00
$template -> assign_var ( 'ERROR' , ( $draft_message == '' ) ? $user -> lang [ 'EMPTY_DRAFT' ] : (( $draft_subject == '' ) ? $user -> lang [ 'EMPTY_DRAFT_TITLE' ] : '' ));
2003-09-04 18:30:20 +00:00
}
}
2004-05-02 13:06:57 +00:00
if ( ! $pm_drafts )
{
$sql = ' SELECT d .* , f . forum_name
FROM ' . DRAFTS_TABLE . ' d , ' . FORUMS_TABLE . ' f
WHERE d . user_id = ' . $user->data[' user_id '] . ' ' .
(( $edit ) ? " AND d.draft_id = $draft_id " : '' ) . '
AND f . forum_id = d . forum_id
ORDER BY d . save_time DESC ' ;
}
else
{
$sql = 'SELECT * FROM ' . DRAFTS_TABLE . '
WHERE user_id = ' . $user->data[' user_id '] . ' ' .
(( $edit ) ? " AND draft_id = $draft_id " : '' ) . '
AND forum_id = 0
AND topic_id = 0
ORDER BY save_time DESC ' ;
}
2003-09-04 18:30:20 +00:00
$result = $db -> sql_query ( $sql );
2003-11-16 21:53:56 +00:00
$draftrows = $topic_ids = array ();
2003-09-04 18:30:20 +00:00
while ( $row = $db -> sql_fetchrow ( $result ))
{
if ( $row [ 'topic_id' ])
{
$topic_ids [] = ( int ) $row [ 'topic_id' ];
}
$draftrows [] = $row ;
}
$db -> sql_freeresult ( $result );
if ( sizeof ( $topic_ids ))
{
$sql = ' SELECT topic_id , forum_id , topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id IN ( ' . implode(' , ', array_unique($topic_ids)) . ' ) ' ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
{
$topic_rows [ $row [ 'topic_id' ]] = $row ;
}
$db -> sql_freeresult ( $result );
}
unset ( $topic_ids );
2004-01-10 12:19:10 +00:00
$template -> assign_var ( 'S_EDIT_DRAFT' , $edit );
2003-09-04 18:30:20 +00:00
2004-01-10 12:19:10 +00:00
$row_count = 0 ;
foreach ( $draftrows as $draft )
2003-09-04 18:30:20 +00:00
{
2004-05-02 13:06:57 +00:00
$link_topic = $link_forum = $link_pm = false ;
2004-01-10 12:19:10 +00:00
$insert_url = $view_url = $title = '' ;
2003-11-16 21:53:56 +00:00
2004-01-10 12:19:10 +00:00
if ( isset ( $topic_rows [ $draft [ 'topic_id' ]]) && $auth -> acl_get ( 'f_read' , $topic_rows [ $draft [ 'topic_id' ]][ 'forum_id' ]))
{
$link_topic = true ;
2005-11-17 17:32:25 +00:00
$view_url = " { $phpbb_root_path } viewtopic. $phpEx $SID &f= " . $topic_rows [ $draft [ 'topic_id' ]][ 'forum_id' ] . " &t= " . $draft [ 'topic_id' ];
2004-01-10 12:19:10 +00:00
$title = $topic_rows [ $draft [ 'topic_id' ]][ 'topic_title' ];
2003-11-16 21:53:56 +00:00
2005-11-17 17:32:25 +00:00
$insert_url = " { $phpbb_root_path } posting. $phpEx $SID &f= " . $topic_rows [ $draft [ 'topic_id' ]][ 'forum_id' ] . '&t=' . $draft [ 'topic_id' ] . '&mode=reply&d=' . $draft [ 'draft_id' ];
2004-01-10 12:19:10 +00:00
}
else if ( $auth -> acl_get ( 'f_read' , $draft [ 'forum_id' ]))
{
$link_forum = true ;
2005-11-17 17:32:25 +00:00
$view_url = " { $phpbb_root_path } viewforum. $phpEx $SID &f= " . $draft [ 'forum_id' ];
2004-01-10 12:19:10 +00:00
$title = $draft [ 'forum_name' ];
2003-09-04 18:30:20 +00:00
2005-11-17 17:32:25 +00:00
$insert_url = " { $phpbb_root_path } posting. $phpEx $SID &f= " . $draft [ 'forum_id' ] . '&mode=post&d=' . $draft [ 'draft_id' ];
2004-01-10 12:19:10 +00:00
}
2004-05-02 13:06:57 +00:00
else if ( $pm_drafts )
{
$link_pm = true ;
2005-11-17 17:32:25 +00:00
$insert_url = " { $phpbb_root_path } ucp. $phpEx $SID &i= $id &mode=compose&d= " . $draft [ 'draft_id' ];
2004-05-02 13:06:57 +00:00
}
2003-11-16 21:53:56 +00:00
2004-01-10 12:19:10 +00:00
$template_row = array (
'DATE' => $user -> format_date ( $draft [ 'save_time' ]),
'DRAFT_MESSAGE' => ( $submit ) ? $draft_message : $draft [ 'draft_message' ],
'DRAFT_SUBJECT' => ( $submit ) ? $draft_subject : $draft [ 'draft_subject' ],
'TITLE' => $title ,
'DRAFT_ID' => $draft [ 'draft_id' ],
'FORUM_ID' => $draft [ 'forum_id' ],
'TOPIC_ID' => $draft [ 'topic_id' ],
'U_VIEW' => $view_url ,
2005-11-17 17:32:25 +00:00
'U_VIEW_EDIT' => " { $phpbb_root_path } ucp. $phpEx $SID &i= $id &mode= $mode &edit= " . $draft [ 'draft_id' ],
2004-01-10 12:19:10 +00:00
'U_INSERT' => $insert_url ,
'S_LINK_TOPIC' => $link_topic ,
'S_LINK_FORUM' => $link_forum ,
2004-05-02 13:06:57 +00:00
'S_LINK_PM' => $link_pm ,
2004-01-10 12:19:10 +00:00
'S_HIDDEN_FIELDS' => $s_hidden_fields
);
2004-07-08 22:41:04 +00:00
$row_count ++ ;
2003-09-04 18:30:20 +00:00
2004-01-10 12:19:10 +00:00
( $edit ) ? $template -> assign_vars ( $template_row ) : $template -> assign_block_vars ( 'draftrow' , $template_row );
}
if ( ! $edit )
{
2004-05-02 13:06:57 +00:00
$template -> assign_var ( 'S_DRAFT_ROWS' , $row_count );
2003-09-04 18:30:20 +00:00
}
2005-10-04 21:31:35 +00:00
break ;
2003-05-19 15:23:04 +00:00
}
$template -> assign_vars ( array (
2004-05-26 20:16:20 +00:00
'L_TITLE' => $user -> lang [ 'UCP_MAIN_' . strtoupper ( $mode )],
2003-05-19 15:23:04 +00:00
2004-05-26 20:16:20 +00:00
'S_DISPLAY_MARK_ALL' => ( $mode == 'watched' || ( $mode == 'drafts' && ! isset ( $_GET [ 'edit' ]))) ? true : false ,
'S_HIDDEN_FIELDS' => ( isset ( $s_hidden_fields )) ? $s_hidden_fields : '' ,
'S_UCP_ACTION' => $phpbb_root_path . " ucp. $phpEx $SID &i= $id &mode= $mode " )
2003-05-19 15:23:04 +00:00
);
2005-10-04 21:31:35 +00:00
// Set desired template
$this -> tpl_name = 'ucp_main_' . $mode ;
2003-05-19 15:23:04 +00:00
}
}
2005-11-17 17:32:25 +00:00
/**
* @ package module_install
*/
class ucp_main_info
{
function module ()
{
return array (
'filename' => 'ucp_main' ,
'title' => 'UCP_MAIN' ,
'version' => '1.0.0' ,
'modes' => array (
'front' => array ( 'title' => 'UCP_MAIN_FRONT' , 'auth' => '' ),
'subscribed' => array ( 'title' => 'UCP_MAIN_SUBSCRIBED' , 'auth' => '' ),
'bookmarks' => array ( 'title' => 'UCP_MAIN_BOOKMARKS' , 'auth' => 'cfg_allow_bookmarks' ),
'drafts' => array ( 'title' => 'UCP_MAIN_DRAFTS' , 'auth' => '' ),
),
);
}
function install ()
{
}
function uninstall ()
{
}
}
2003-05-19 15:23:04 +00:00
?>