[ PHPXref.com ] [ Generated: Sun Jul 20 16:32:03 2008 ] [ ATutor 1.5.2 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> index.php (source)

   1  <?php
   2  /****************************************************************/
   3  /* ATutor                                                        */
   4  /****************************************************************/
   5  /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg        */
   6  /* Adaptive Technology Resource Centre / University of Toronto  */
   7  /* http://atutor.ca                                                */
   8  /*                                                              */
   9  /* This program is free software. You can redistribute it and/or*/
  10  /* modify it under the terms of the GNU General Public License  */
  11  /* as published by the Free Software Foundation.                */
  12  /****************************************************************/
  13  // $Id: index.php 5866 2005-12-15 16:16:03Z joel $
  14  
  15  define('AT_INCLUDE_PATH', 'include/');
  16  require(AT_INCLUDE_PATH . 'vitals.inc.php');
  17  
  18  if (isset($_GET['cid'])) {
  19      header('Location: '.$_base_href.'content.php?cid='.intval($_GET['cid']));
  20      exit;
  21  }
  22  
  23  require(AT_INCLUDE_PATH . 'lib/test_result_functions.inc.php');
  24      
  25  if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
  26      $course_base_href = 'get.php/';
  27  } else {
  28      $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
  29  }
  30  
  31  require(AT_INCLUDE_PATH . 'header.inc.php');
  32          
  33  /* the "home" links: */
  34  $home_links = get_home_navigation();
  35  $savant->assign('home_links', $home_links);
  36  
  37  /* the news announcements: */
  38  $news = array();
  39  $num_pages = 1;
  40  $page = intval($_GET['p']);
  41  if (!$page) {
  42      $page = 1;
  43  }    
  44  
  45  $module =& $moduleFactory->getModule(AT_MODULE_DIR_STANDARD.'/announcements');
  46  if (!$module->isEnabled()) {
  47      $result = FALSE;
  48      $news = array();
  49  } else {
  50      $sql    = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."news WHERE course_id=$_SESSION[course_id]";
  51      $result = mysql_query($sql, $db);
  52  }
  53  
  54  if ($result && ($row = mysql_fetch_assoc($result))) {
  55      $num_results = $row['cnt'];
  56      $results_per_page = NUM_ANNOUNCEMENTS;
  57      $num_pages = ceil($num_results / $results_per_page);
  58  
  59      $count = (($page-1) * $results_per_page) + 1;
  60  
  61      $offset = ($page-1)*$results_per_page;
  62  
  63      $sql = "SELECT N.* FROM ".TABLE_PREFIX."news N WHERE N.course_id=$_SESSION[course_id] ORDER BY date DESC LIMIT $offset, $results_per_page";
  64      
  65      $result = mysql_query($sql, $db);
  66      while ($row = mysql_fetch_assoc($result)) {
  67          /* this can't be cached because it called _AT */
  68  
  69          $news[$row['news_id']] = array(
  70                          'date'        => AT_date(    _AT('announcement_date_format'), 
  71                                                  $row['date'], 
  72                                                  AT_DATE_MYSQL_DATETIME),
  73                          'title'        => AT_print($row['title'], 'news.title'),
  74                          'body'        => format_content($row['body'], $row['formatting'], $glossary));
  75  
  76      }
  77  }
  78  
  79  $savant->assign('announcements', $news);
  80  $savant->assign('num_pages', $num_pages);
  81  $savant->assign('current_page', $page);
  82  $savant->display('index.tmpl.php');
  83  
  84  require (AT_INCLUDE_PATH.'footer.inc.php');
  85  
  86  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]