From: Eloi G. <ada...@us...> - 2006-02-23 06:16:44
|
Update of /cvsroot/phpwsbb/phpwsbb/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24050/class Modified Files: Forum.php Manager.php Runtime.php Thread.php Log Message: Feature Request [ 1034602 ] "view posts since last visit" - Still need an icon for the button, though... Index: Thread.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Thread.php,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** Thread.php 4 Feb 2006 04:14:51 -0000 1.80 --- Thread.php 23 Feb 2006 06:16:37 -0000 1.81 *************** *** 316,319 **** --- 316,321 ---- $tags['MYPROFILE'] = $this->createLink($mysettings, array('PHPWSBB_MAN_OP'=>'usersettings', 'PHPWS_MAN_ITEMS[]'=>$this->getId()), 'mysettings.png', 16, 16); + $newposts = $_SESSION['translate']->it('View New Posts'); + $tags['NEW_POSTS'] = $this->createLink($newposts, array('PHPWSBB_MAN_OP'=>'getnew'), 'xxxx.png', 16, 16); } Index: Manager.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Manager.php,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** Manager.php 4 Feb 2006 04:14:51 -0000 1.65 --- Manager.php 23 Feb 2006 06:16:36 -0000 1.66 *************** *** 228,231 **** --- 228,239 ---- */ var $message = NULL; + + /** + * Internal flag to determine when the user logs in as a member + * + * @var PHPWSBB_Message + * @access public + */ + var $logged_in = NULL; function PHPWSBB_Manager() { *************** *** 258,261 **** --- 266,273 ---- // Default page $this->last_viewed = array('PHPWSBB_MAN_OP'=>'list'); + if($_SESSION['OBJ_user']->username) + $this->_update_userlog(); + else + $this->logged_in = false; }// END FUNC PHPWSBB_Manager *************** *** 271,275 **** $tags['FORUM_ADMIN'] = 1; } ! if($_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_forums')) $tags['ADD_FORUM'] = '<a href="index.php?module=phpwsbb&PHPWSBB_MAN_OP=editforum">'.$addForum.'</a>'; --- 283,287 ---- $tags['FORUM_ADMIN'] = 1; } ! if($_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_forums')) $tags['ADD_FORUM'] = '<a href="index.php?module=phpwsbb&PHPWSBB_MAN_OP=editforum">'.$addForum.'</a>'; *************** *** 277,281 **** if($_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_settings')) $tags['SETTINGS'] = '<a href="index.php?module=phpwsbb&PHPWSBB_MAN_OP=getsettings">'.$settings.'</a>'; ! $tags['LIST'] = PHPWS_Text::moduleLink($_SESSION['translate']->it('Forums'), 'phpwsbb', array('PHPWSBB_MAN_OP'=>'list')); --- 289,293 ---- if($_SESSION['OBJ_user']->allow_access('phpwsbb', 'edit_settings')) $tags['SETTINGS'] = '<a href="index.php?module=phpwsbb&PHPWSBB_MAN_OP=getsettings">'.$settings.'</a>'; ! $tags['LIST'] = PHPWS_Text::moduleLink($_SESSION['translate']->it('Forums'), 'phpwsbb', array('PHPWSBB_MAN_OP'=>'list')); *************** *** 319,326 **** } ! /* "Edit Profile" button */ if($_SESSION['OBJ_user']->user_id) { $mysettings = $_SESSION['translate']->it('Settings'); $tags['MYPROFILE'] = PHPWSBB_Thread::createLink($mysettings, array('PHPWSBB_MAN_OP'=>'usersettings'), 'mysettings.png', 16, 16); } --- 331,340 ---- } ! /* "Edit Profile" and "All New Posts" button */ if($_SESSION['OBJ_user']->user_id) { $mysettings = $_SESSION['translate']->it('Settings'); $tags['MYPROFILE'] = PHPWSBB_Thread::createLink($mysettings, array('PHPWSBB_MAN_OP'=>'usersettings'), 'mysettings.png', 16, 16); + $newposts = $_SESSION['translate']->it('View New Posts'); + $tags['NEW_POSTS'] = PHPWSBB_Thread::createLink($newposts, array('PHPWSBB_MAN_OP'=>'getnew'), 'xxxx.png', 16, 16); } *************** *** 361,364 **** --- 375,397 ---- + function _listNewThreads($since) { + if(!$_SESSION['OBJ_user']->username) { + $GLOBALS['CNT_phpwsbb']['title'] = $_SESSION['translate']->it('Please Register'); + $GLOBALS['CNT_phpwsbb']['content'] .= $_SESSION['translate']->it('The "New Posts" feature is only available to registered users of this site. You must log-in to view this page.'); + return FALSE; + } + + $this->setClass('PHPWSBB_Thread'); + $this->setTable('mod_phpwsbb_threads'); + $this->setOrder('sticky DESC, lastpost DESC'); + if(!$_SESSION['OBJ_user']->allow_access('phpwsbb', 'hide_threads')) + $this->setSort('lastpost > '.$since.' AND hidden=0'); + else + $this->setSort('lastpost > '.$since); + + return PHPWS_Text::profanityFilter($this->getList('threads', NULL, FALSE)); + }// END FUNC _listNewThreads + + function _categories() { if(!$this->_allow_anon_view && !$_SESSION['OBJ_user']->username) { *************** *** 629,632 **** --- 662,667 ---- }// END FUNC _updateAllThreads + + /** * Show user settings form *************** *** 1382,1385 **** --- 1417,1427 ---- $GLOBALS['CNT_phpwsbb']['content'] = $_SESSION['translate']->it('All user post counts have been reset.'); break; + + case 'getnew': + if (!$since = $GLOBALS['core']->getOne('SELECT last_on FROM mod_phpwsbb_user_info WHERE user_id = '.$_SESSION['OBJ_user']->user_id, 1)) + $since = time(); + $GLOBALS['CNT_phpwsbb']['title'] = $_SESSION['translate']->it('New Posts Since My Last Visit on [var1]', date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $since)); + $GLOBALS['CNT_phpwsbb']['content'] = $this->_menu() . $this->_listNewThreads($since); + break; } *************** *** 1419,1446 **** } elseif(is_array($id) && !empty($id['user_id'])) { $result = $id; ! } elseif(!$result = $GLOBALS['core']->getRow('SELECT * FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_user_info AS i LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_users AS u ON ( u.user_id = i.user_id ) LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_user_uservar AS v ON ( v.user_id = u.user_id AND v.varName="MOD_phpwsbb") WHERE i.user_id = '.$id)) { ! // If no record was found, create one ! $result = array(); ! ! // Develop correct user post counts ! $posts = $GLOBALS['core']->getRow('SELECT COUNT(owner_id) FROM mod_phpwsbb_messages WHERE owner_id='.$id, 1); ! $result['posts'] = $posts['COUNT(owner_id)']; ! ! // If the user has uservars set for this module... ! $monitordefault = $_SESSION['OBJ_user']->getUserVar('monitordefault', NULL, 'phpwsbb'); ! if ($monitordefault!=NULL) { ! // transfer the values to the table ! $result['monitordefault'] = $monitordefault; ! $result['suspendmonitors'] = $_SESSION['OBJ_user']->getUserVar('suspendmonitors', NULL, 'phpwsbb'); ! } ! else { ! $result['monitordefault'] = '0'; ! $result['suspendmonitors'] = '0'; ! } ! ! $result['user_id'] = $id; ! $GLOBALS['core']->sqlInsert($result, 'mod_phpwsbb_user_info', FALSE, FALSE, FALSE, FALSE); ! $result['location'] = $result['avatar'] = $result['signature'] = $result['monitordefault'] = $result['suspendmonitors'] = null; ! } // If user's post count is set to 0, recalculate it. --- 1461,1466 ---- } elseif(is_array($id) && !empty($id['user_id'])) { $result = $id; ! } else ! $result = $GLOBALS['core']->getRow('SELECT * FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_user_info AS i LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_users AS u ON ( u.user_id = i.user_id ) LEFT JOIN ' . $GLOBALS['core']->tbl_prefix . 'mod_user_uservar AS v ON ( v.user_id = u.user_id AND v.varName="MOD_phpwsbb") WHERE i.user_id = '.$id); // If user's post count is set to 0, recalculate it. *************** *** 1487,1490 **** --- 1507,1529 ---- } + /** + * Updates a user's log data. + * + * @author Eloi George <el...@NO...> + * @module PHPWSBB + * @param none + * @return none + */ + function _update_userlog() { + // If no user record exists, create one + if(!$result = $GLOBALS['core']->getRow('SELECT * FROM ' . $GLOBALS['core']->tbl_prefix . 'mod_phpwsbb_user_info WHERE user_id = '.$_SESSION['OBJ_user']->user_id)) { + $arr['session_start'] = time(); + $arr['user_id'] = $_SESSION['OBJ_user']->user_id; + $GLOBALS['core']->sqlInsert($arr, 'mod_phpwsbb_user_info', FALSE, FALSE, FALSE, FALSE); + } + $GLOBALS['core']->query('UPDATE mod_phpwsbb_user_info SET last_on = session_start, session_start = '.time().' WHERE user_id ='.$_SESSION['OBJ_user']->user_id, 1, 1); + $this->logged_in = true; + }// END FUNC _update_userlog + } ?> \ No newline at end of file Index: Forum.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Forum.php,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Forum.php 4 Feb 2006 04:14:51 -0000 1.41 --- Forum.php 23 Feb 2006 06:16:36 -0000 1.42 *************** *** 195,198 **** --- 195,200 ---- $tags['MYPROFILE'] = PHPWSBB_Thread::createLink($mysettings, array('PHPWSBB_MAN_OP'=>'usersettings', 'PHPWS_MAN_ITEMS[]'=>$this->getId()), 'mysettings.png', 16, 16); + $newposts = $_SESSION['translate']->it('View New Posts'); + $tags['NEW_POSTS'] = PHPWSBB_Thread::createLink($newposts, array('PHPWSBB_MAN_OP'=>'getnew'), 'xxxx.png', 16, 16); } if(!empty($this->_moderators)) { Index: Runtime.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Runtime.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Runtime.php 4 Feb 2006 04:14:51 -0000 1.17 --- Runtime.php 23 Feb 2006 06:16:37 -0000 1.18 *************** *** 109,113 **** $GLOBALS['CNT_phpwsbb_latestthreadsblock']['title'] = $latestthreadsblocktitle; $GLOBALS['CNT_phpwsbb_latestthreadsblock']['content'] = $block; ! } } }// END FUNC showLatestThreadsBlock --- 109,115 ---- $GLOBALS['CNT_phpwsbb_latestthreadsblock']['title'] = $latestthreadsblocktitle; $GLOBALS['CNT_phpwsbb_latestthreadsblock']['content'] = $block; ! if($_SESSION['OBJ_user']->username) ! $GLOBALS['CNT_phpwsbb_latestthreadsblock']['footer'] = '<a href="index.php?module=phpwsbb&PHPWSBB_MAN_OP=getnew">'.$_SESSION['translate']->it('View All New Posts').'</a>'; ! } } }// END FUNC showLatestThreadsBlock |