Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

base-crons.inc.php

Go to the documentation of this file.
00001 <?
00008 class BaseCrons extends MyModule
00009 {
00016     public function init($page = null, $vars = null)
00017     {
00018         global $me;
00019         
00020         $this->setTemplate(new BlankTemplate());
00021 
00022         //admins can run crons manually...
00023         if ($me->isAdmin() || $_SERVER["REMOTE_ADDR"] == Config::get('cron_request_ip'))
00024             parent::init($page, $vars);
00025         else
00026             throw new PageError("You cannot run crons, sorry $_SERVER[REMOTE_ADDR].");
00027     }
00028     
00032     public function draw()
00033     {
00034         echo $this->pageTitle . "\n\n";
00035         parent::draw();
00036         echo "\n\nCron run!";
00037     }
00038 
00046     protected function getAdmins()
00047     {
00048         $adminRs = dbQuery("
00049             SELECT *
00050             FROM users
00051             WHERE is_admin = 1
00052         ");
00053         while ($adminAr = dbFetchAssoc($adminRs))
00054             $admins[] = new User($adminAr);
00055         
00056         return $admins;
00057     }
00058 
00065     public function emailAdmins($subject, $body)
00066     {
00067         $admins = $this->getAdmins();
00068         if (count($admins))
00069             foreach ($admins AS $admin)
00070                 $admin->mail($subject, $body);
00071     }
00072 }
00073 ?>

Generated on Fri Oct 27 12:26:40 2006 for BaseJumper by doxygen 1.3.9.1