Exemplo n.º 1
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $range = $pl->getParameterValue("range", "AMODULE");
     $dateStart = new ODate();
     if (!in_array($range, array('24h', '7days', 'month'))) {
         $range = '7days';
     }
     switch ($range) {
         case '24h':
             $dateStart->addSeconds(-60 * 60 * 24);
             break;
         case '7days':
             $dateStart->addSeconds(-60 * 60 * 24 * 7);
             break;
         case 'month':
             $dateStart->addSeconds(-60 * 60 * 24 * 31);
             break;
     }
     $q = "SELECT site.site_id, count(*) AS number_changes FROM site, page_revision WHERE page_revision.date_last_edited > '" . $dateStart->getDate() . "' AND site.visible = TRUE AND site.private = FALSE AND site.deleted = FALSE AND site.site_id != 1 AND page_revision.flag_new_site=FALSE AND page_revision.site_id = site.site_id GROUP BY site.site_id ORDER BY number_changes DESC LIMIT 10";
     $db = Database::connection();
     $res = $db->query($q);
     $all = $res->fetchAll();
     if ($all) {
         foreach ($all as &$a) {
             $a['site'] = DB_SitePeer::instance()->selectByPrimaryKey($a['site_id']);
         }
     }
     $runData->contextAdd("res", $all);
     $runData->contextAdd("range", $range);
 }
Exemplo n.º 2
0
 public function deleteOutdatedByPageName($siteId, $pageName)
 {
     $c = new Criteria();
     $c->add("page_unix_name", $pageName);
     $c->add("site_id", $siteId);
     $d = new ODate();
     $c->add("date_last_accessed", $d->addSeconds(-15 * 60), '<');
     $this->delete($c);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     // get recent forum threads
     $pl = $runData->getParameterList();
     $limit = $pl->getParameterValue("limit", "MODULE");
     if ($limit == null || !is_numeric($limit) || $limit < 1 || $limit > 300) {
         $limit = 5;
     }
     $date = new ODate();
     $date->addSeconds(-60 * 60 * 24 * 7);
     // 7 days
     $q = "SELECT forum_thread.thread_id, count(*) AS count FROM forum_thread, forum_post " . "WHERE forum_thread.site_id='" . $site->getSiteId() . "' " . "AND forum_thread.thread_id = forum_post.thread_id " . "AND forum_post.date_posted > '" . $date->getDate() . "' " . "GROUP BY forum_thread.thread_id ORDER BY count DESC LIMIT " . db_escape_string($limit);
     $c = new Criteria();
     $c->setExplicitQuery($q);
     $threads = DB_ForumThreadPeer::instance()->select($c);
     foreach ($threads as &$thread) {
         $thread = DB_ForumThreadPeer::instance()->selectByPrimaryKey($thread->getThreadId());
     }
     $runData->contextAdd("threads", $threads);
 }
Exemplo n.º 4
0
 public function outdate()
 {
     $dateback = new ODate();
     $dateback->addSeconds(-1000000);
     $this->setDateCompiled($dateback);
 }