fa662803491596442218648b1d0bf8cf9abecc84
[atutor.git] / mods / wiki / plugins / feature / announcements.php
1 <?php
2
3 /*
4 The announcements plugin is a handler that displays pages from a list rather 
5 than the requested page.  I recommend and have configured the default for this 
6 plugin to use the lib/delegator plugin.  A user data plugin is required 
7 for this feature.
8
9 Written By:  Andy Fundinger (Andy@burgiss.com)
10 */
11
12 $ewiki_plugins["delegator"]["LoginDelegator"][]="ewiki_announcements";
13
14 //Add an ordered list of pages to present as announcements 
15 //all pages should have a default value of 0.   This list will be added
16 //to each user as they view announcements for the first time and cannot been
17 //altered after that (except through AdminFullUser or other plugins)
18 $ewiki_config["DefaultNotify"]=  array(EWIKI_PAGE_INDEX => 0);
19
20 function ewiki_announcements($id, $data, $action){
21   global $ewiki_plugins, $ewiki_config;
22
23   if(!isset($GLOBALS['ewiki_auth_user'])){
24     return;
25   }
26
27   $notifyDates=ewiki_get_uservar("NotifyDates",FALSE);
28
29   if(!$notifyDates){
30     $notifyDates=$ewiki_config["DefaultNotify"];
31   }else{
32     $notifyDates=unserialize($notifyDates);
33   }
34
35   foreach($notifyDates as $pageName=>$date){    
36     $data=ewiki_db::GET($pageName);
37
38     if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($pageName, $data, "view")) {
39         continue;
40     }   
41     
42     if($data['lastmodified']>$date){
43       $dispDate=$data['lastmodified'];
44       $dispPage=$pageName;    
45       break;
46     }
47   }
48
49   if(!isset($dispPage))
50     return; 
51     
52   $notifyDates[$dispPage]=$dispDate;
53   ewiki_set_uservar("NotifyDates",serialize($notifyDates));
54   
55   $o=ewiki_page('view/'.$dispPage);
56     
57   //page_final plugins have been run, unset them
58         unset($ewiki_plugins["page_final"]);    
59   
60   return($o);
61
62 }
63
64 ?>