Index: branches/liquidthreads/extensions/LqtPages.php |
— | — | @@ -15,6 +15,11 @@ |
16 | 16 | require_once('LqtBaseView.php'); |
17 | 17 | require_once('LqtI18N.php'); |
18 | 18 | |
| 19 | +$wgExtensionFunctions[] = 'wfLqtSpecialDeleteThread'; |
| 20 | +$wgExtensionFunctions[] = 'wfLqtSpecialMoveThreadToAnotherPage'; |
| 21 | +$wgExtensionFunctions[] = 'wfLqtSpecialNewMessages'; |
| 22 | +$wgHooks['BeforeWatchlist'][] = 'wfLqtBeforeWatchlistHook'; |
| 23 | + |
19 | 24 | class TalkpageView extends LqtView { |
20 | 25 | /* Added to SkinTemplateTabs hook in TalkpageView::show(). */ |
21 | 26 | function customizeTabs( $skintemplate, $content_actions ) { |
— | — | @@ -630,12 +635,6 @@ |
631 | 636 | } |
632 | 637 | |
633 | 638 | |
634 | | -/* We have to do this goofy wgExtensionFunctions run-around because |
635 | | - the files required by SpecialPage aren't required_onced() yet by |
636 | | - the time this file is. Don't ask me why. */ |
637 | | - |
638 | | -$wgExtensionFunctions[] = 'wfLqtSpecialMoveThreadToAnotherPage'; |
639 | | - |
640 | 639 | function wfLqtSpecialMoveThreadToAnotherPage() { |
641 | 640 | global $wgMessageCache; |
642 | 641 | |
— | — | @@ -767,9 +766,6 @@ |
768 | 767 | } |
769 | 768 | |
770 | 769 | |
771 | | - |
772 | | -$wgExtensionFunctions[] = 'wfLqtSpecialDeleteThread'; |
773 | | - |
774 | 770 | function wfLqtSpecialDeleteThread() { |
775 | 771 | global $wgMessageCache; |
776 | 772 | |
— | — | @@ -900,4 +896,78 @@ |
901 | 897 | } |
902 | 898 | |
903 | 899 | |
| 900 | + |
| 901 | +class NewUserMessagesView extends LqtView { |
| 902 | + |
| 903 | + function addJSandCSS() { |
| 904 | + global $wgJsMimeType, $wgStylePath; // TODO globals. |
| 905 | + $s = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/lqt.js\"><!-- lqt js --></script>\n"; |
| 906 | + $this->output->addScript($s); |
| 907 | + } |
| 908 | + |
| 909 | + function postDivClass($thread) { |
| 910 | + |
| 911 | + } |
| 912 | + |
| 913 | + function show() { |
| 914 | + $this->addJSandCSS(); |
| 915 | + |
| 916 | + $threads = NewMessages::newUserMessages($this->user); |
| 917 | + foreach($threads as $t) { |
| 918 | + $this->showThread($t); |
| 919 | + } |
| 920 | + return false; |
| 921 | + } |
| 922 | +} |
| 923 | + |
| 924 | +function wfLqtSpecialNewMessages() { |
| 925 | + global $wgMessageCache; |
| 926 | + |
| 927 | + require_once('SpecialPage.php'); |
| 928 | + |
| 929 | + $wgMessageCache->addMessage( 'newmessages', 'New Messages' ); |
| 930 | + |
| 931 | + class SpecialNewMessages extends SpecialPage { |
| 932 | + |
| 933 | + function __construct() { |
| 934 | + SpecialPage::SpecialPage( 'Newmessages' ); |
| 935 | + SpecialPage::$mStripSubpages = false; |
| 936 | + $this->includable( true ); |
| 937 | + } |
| 938 | + |
| 939 | + |
| 940 | + function execute( $par = null ) { |
| 941 | + global $wgOut, $wgRequest, $wgUser; |
| 942 | + |
| 943 | + $this->setHeaders(); |
| 944 | + |
| 945 | + $title = $this->getTitle(); |
| 946 | + $view = new NewUserMessagesView( $wgOut, new Article($title), $title, $wgUser, $wgRequest ); |
| 947 | + return $view->show(); |
| 948 | + |
| 949 | + // and then the same for the other talkpage messagess. |
| 950 | + } |
| 951 | + } |
| 952 | + |
| 953 | + SpecialPage::addPage( new SpecialNewMessages() ); |
| 954 | +} |
| 955 | + |
| 956 | + |
| 957 | +function wfLqtBeforeWatchlistHook( $options, $user ) { |
| 958 | + global $wgOut; |
| 959 | + |
| 960 | + $user_messages = NewMessages::newUserMessages($user); |
| 961 | + $n = count($user_messages); |
| 962 | + |
| 963 | + $wgOut->addHTML(<<< HTML |
| 964 | + <div class="lqt_watchlist_messages_notice"> |
| 965 | + There are $n messages for you. |
| 966 | + </div> |
| 967 | +HTML |
| 968 | + ); |
| 969 | + |
| 970 | + return true; |
| 971 | +} |
| 972 | + |
| 973 | + |
904 | 974 | ?> |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -986,4 +986,30 @@ |
987 | 987 | } |
988 | 988 | } |
989 | 989 | |
| 990 | + |
| 991 | +class NewMessages { |
| 992 | + |
| 993 | + static function newUserMessages($user) { |
| 994 | +/* $article_clause = Threads::articleClause(new Article($user->getUserPage())) |
| 995 | + $sql = <<< SQL |
| 996 | + select * from thread, page, recentchanges |
| 997 | + where thread_root = rc_cur_id |
| 998 | + and $article_clause |
| 999 | +SQL; |
| 1000 | + $dbr = wfGetDB( DB_SLAVE ); |
| 1001 | + res = $dbr->query($sql); |
| 1002 | + while ( $line = $dbr->fetchObject($res) ) { |
| 1003 | + |
| 1004 | + }*/ |
| 1005 | + |
| 1006 | + $ts = Threads::where( array('thread.thread_root = rc_cur_id', |
| 1007 | + Threads::articleClause(new Article($user->getUserPage()))), |
| 1008 | + array(), array('recentchanges') ); |
| 1009 | + return $ts; |
| 1010 | + } |
| 1011 | + |
| 1012 | + |
| 1013 | + |
| 1014 | +} |
| 1015 | + |
990 | 1016 | ?> |
Index: branches/liquidthreads/extensions/LqtBaseView.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | var_dump($value); |
23 | 23 | $tmp=ob_get_contents(); |
24 | 24 | ob_end_clean(); |
25 | | - $output->addHTML('<pre>' . htmlspecialchars($tmp,ENT_QUOTES) . '</pre>'); |
| 25 | + $output->addHTML(/*'<pre>' . htmlspecialchars($tmp,ENT_QUOTES) . '</pre>'*/ $tmp); |
26 | 26 | } |
27 | 27 | |
28 | 28 | |
Index: branches/liquidthreads/includes/EditPage.php |
— | — | @@ -325,8 +325,8 @@ |
326 | 326 | } |
327 | 327 | |
328 | 328 | $permErrors = $this->mArticle->getTitle()->getUserPermissionsErrors( 'edit', $wgUser); |
329 | | - if( !$this->mTitle->exists() ) |
330 | | - $permErrors += $this->mTitle->getUserPermissionsErrors( 'create', $wgUser); |
| 329 | + if( !$this->mArticle->getTitle()->exists() ) |
| 330 | + $permErrors += $this->mArticle->getTitle()->getUserPermissionsErrors( 'create', $wgUser); |
331 | 331 | |
332 | 332 | # Ignore some permissions errors. |
333 | 333 | $remove = array(); |
Index: branches/liquidthreads/includes/SpecialWatchlist.php |
— | — | @@ -122,6 +122,10 @@ |
123 | 123 | wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); |
124 | 124 | wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults); |
125 | 125 | |
| 126 | + if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser)) ) { |
| 127 | + return; |
| 128 | + } |
| 129 | + |
126 | 130 | if ( $days <= 0 ) { |
127 | 131 | $andcutoff = ''; |
128 | 132 | } else { |