Example #1
0
 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $database = App::get('db');
     $queries = array('unpublished' => 0, 'published' => 1, 'archived' => 2, 'draft' => 3);
     foreach ($queries as $key => $state) {
         $database->setQuery("SELECT COUNT(*) FROM `#__courses` WHERE state={$state}");
         $this->{$key} = $database->loadResult();
     }
     $database->setQuery("SELECT enrolled FROM `#__courses_members` ORDER BY enrolled ASC LIMIT 1");
     $first = $database->loadResult();
     $startYear = Date::of($first)->format('Y');
     $startMonth = Date::of($first)->format('m');
     $endYear = Date::of('now')->format('Y');
     $endMonth = Date::of('now')->format('m');
     $totals = array();
     for ($y = $startYear; $y <= $endYear; $y++) {
         if (!isset($totals[$y])) {
             $totals[$y] = array();
         }
         for ($m = 1; $m <= 12; $m++) {
             if ($y == $endYear && $m == $endMonth) {
                 break;
             }
             $n = $m < 12 ? $y . '-' . $this->pad($m + 1) . '-00 00:00:00' : $y + 1 . '-01-00 00:00:00';
             $database->setQuery("SELECT COUNT(*) FROM `#__courses_members` WHERE enrolled > " . $database->quote($y . '-' . $this->pad($m) . '-00 00:00:00') . " AND enrolled < " . $database->quote($n));
             $totals[$y][$m] = $database->loadResult();
         }
     }
     $this->totals = $totals;
     // Get the view
     parent::display();
 }
Example #2
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $type = $this->params->get('type', '1');
     switch ($type) {
         case '0':
             $this->type = 'system';
             break;
         case '1':
             $this->type = 'hub';
             break;
         case '2':
             $this->type = 'project';
             break;
         case '3':
             $this->type = 'partner';
             break;
     }
     $queries = array('visible' => "approved=1 AND discoverability=0", 'hidden' => "approved=1 AND discoverability=1", 'closed' => "join_policy=3", 'invite' => "join_policy=2", 'restricted' => "join_policy=1", 'open' => "join_policy=0", 'approved' => "approved=1", 'pending' => "approved=0");
     $database = App::get('db');
     foreach ($queries as $key => $where) {
         $database->setQuery("SELECT count(*) FROM `#__xgroups` WHERE type='{$type}' AND {$where}");
         $this->{$key} = $database->loadResult();
     }
     // Last 24 hours
     $lastDay = with(new Date('now'))->subtract('1 Day')->toSql();
     //gmdate('Y-m-d', (time() - 24*3600)) . ' 00:00:00';
     $database->setQuery("SELECT count(*) FROM `#__xgroups` WHERE created >= '{$lastDay}' AND type='{$type}'");
     $this->pastDay = $database->loadResult();
     // Get the view
     parent::display();
 }
Example #3
0
 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     // Get the component title div
     if (App::has('ComponentTitle')) {
         $this->title = App::get('ComponentTitle');
     }
     // Get the view
     parent::display();
 }
Example #4
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $database = App::get('db');
     $database->setQuery("SELECT * FROM `#__users` WHERE `approved` = 0");
     $this->unapproved = $database->loadObjectList();
     // Get the view
     parent::display();
 }
Example #5
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!\App::isAdmin()) {
         return;
     }
     $database = \App::get('db');
     $queries = array('unpublished' => 0, 'published' => 1, 'draftUser' => 2, 'pending' => 3, 'removed' => 4, 'draftInternal' => 5);
     foreach ($queries as $key => $state) {
         $database->setQuery("SELECT count(*) FROM `#__resources` WHERE published={$state} AND standalone=1");
         $this->{$key} = $database->loadResult();
     }
     // Get the view
     parent::display();
 }
Example #6
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $database = App::get('db');
     $database->setQuery("SELECT count(u.id) FROM `#__users` AS u, `#__xprofiles` AS m WHERE m.uidNumber=u.id AND m.emailConfirmed < -1");
     $this->unconfirmed = $database->loadResult();
     $database->setQuery("SELECT count(u.id) FROM `#__users` AS u, `#__xprofiles` AS m WHERE m.uidNumber=u.id AND m.emailConfirmed >= 1");
     $this->confirmed = $database->loadResult();
     $database->setQuery("SELECT count(*) FROM `#__users` WHERE registerDate >= " . $database->quote(gmdate('Y-m-d', time() - 24 * 3600) . ' 00:00:00'));
     $this->pastDay = $database->loadResult();
     // Get the view
     parent::display();
 }
Example #7
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!\App::isAdmin()) {
         return;
     }
     // include group page archive model
     require_once Component::path('com_groups') . DS . 'models' . DS . 'page' . DS . 'archive.php';
     // include group module archive model
     require_once Component::path('com_groups') . DS . 'models' . DS . 'module' . DS . 'archive.php';
     // get unapproved pages
     $groupModelPageArchive = new Models\Page\Archive();
     $this->unapprovedPages = $groupModelPageArchive->pages('unapproved', array('state' => array(0, 1)), true);
     // get unapproved modules
     $groupModelModuleArchive = new Models\Module\Archive();
     $this->unapprovedModules = $groupModelModuleArchive->modules('unapproved', array('state' => array(0, 1)), true);
     // Get the view
     parent::display();
 }
Example #8
0
 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $database = App::get('db');
     $queries = array('closed' => "state=1", 'open' => "state=0", 'pastDay' => "created >= " . $database->quote(gmdate('Y-m-d', time() - 24 * 3600) . ' 00:00:00'));
     if ($this->params->get('showMine', 0)) {
         $this->username = User::get('username');
         // My Open
         $queries['myclosed'] = "state=1 AND created_by=" . User::get('id');
         // My Closed
         $queries['myopen'] = "state=0 AND created_by=" . User::get('id');
     }
     foreach ($queries as $key => $where) {
         $database->setQuery("SELECT count(*) FROM `#__answers_questions` WHERE {$where}");
         $this->{$key} = $database->loadResult();
     }
     // Get the view
     parent::display();
 }
Example #9
0
 /**
  * Display module contents
  * 
  * @return  void
  */
 public function display()
 {
     if (!\App::isAdmin()) {
         return;
     }
     $database = \App::get('db');
     $where = "";
     if ($start = Request::getVar('start', '')) {
         $where = "WHERE a.created > " . $database->quote($start);
     }
     $query = "SELECT a.* FROM (\n\t\t\t\t\t(SELECT c.id, c.ticket, c.created, (CASE WHEN `comment` != '' THEN 'comment' ELSE 'change' END) AS 'category' FROM `#__support_comments` AS c)\n\t\t\t\t\tUNION\n\t\t\t\t\t(SELECT '0' AS id, t.id AS ticket, t.created, 'ticket' AS 'category' FROM `#__support_tickets` AS t)\n\t\t\t\t) AS a {$where} ORDER BY a.created DESC LIMIT 0, " . $this->params->get('limit', 25);
     $database->setQuery($query);
     $this->results = $database->loadObjectList();
     $this->feed = Request::getInt('feedactivity', 0);
     if ($this->feed == 1) {
         ob_clean();
         foreach ($this->results as $result) {
             require $this->getLayoutPath('default_item');
         }
         exit;
     }
     parent::display();
 }
Example #10
0
 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     if (!\App::isAdmin()) {
         return;
     }
     include_once Component::path('com_wishlist') . DS . 'models' . DS . 'wishlist.php';
     $wishlist = intval($this->params->get('wishlist', 0));
     if (!$wishlist) {
         $model = Wishlist::getInstance(1, 'general');
         if (!$model->exists()) {
             return false;
         }
         $wishlist = $model->get('id');
     }
     $this->wishlist = $wishlist;
     $queries = array('granted' => 1, 'pending' => "0 AND accepted=0", 'accepted' => "0 AND accepted=1", 'rejected' => 3, 'withdrawn' => 4, 'removed' => 2);
     $database = \App::get('db');
     foreach ($queries as $key => $state) {
         $database->setQuery("SELECT COUNT(*) FROM `#__wishlist_item` WHERE wishlist=" . $database->quote($wishlist) . " AND status=" . $state);
         $this->{$key} = $database->loadResult();
     }
     // Get the view
     parent::display();
 }
Example #11
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $this->total = 0;
     $this->registered = 0;
     $this->created = 0;
     $this->uploaded = 0;
     $this->installed = 0;
     $this->updated = 0;
     $this->approved = 0;
     $this->published = 0;
     $this->retired = 0;
     $this->abandoned = 0;
     $database = App::get('db');
     $database->setQuery("SELECT f.state FROM `#__tool` as f\n\t\t\t\tJOIN `#__tool_version` AS v ON f.id=v.toolid AND v.state=3\n\t\t\t\tWHERE f.id != 0 ORDER BY f.state_changed DESC");
     $this->data = $database->loadObjectList();
     if ($this->data) {
         $this->total = count($this->data);
         foreach ($this->data as $data) {
             switch ($data->state) {
                 case 1:
                     $this->registered++;
                     break;
                 case 2:
                     $this->created++;
                     break;
                 case 3:
                     $this->uploaded++;
                     break;
                 case 4:
                     $this->installed++;
                     break;
                 case 5:
                     $this->updated++;
                     break;
                 case 6:
                     $this->approved++;
                     break;
                 case 7:
                     $this->published++;
                     break;
                 case 8:
                     $this->retired++;
                     break;
                 case 9:
                     $this->abandoned++;
                     break;
             }
         }
     }
     // Get the view
     parent::display();
 }
Example #12
0
 /**
  * Display module contents
  *
  * @return     void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     include_once Component::path('com_support') . DS . 'tables' . DS . 'query.php';
     include_once Component::path('com_support') . DS . 'tables' . DS . 'ticket.php';
     $database = App::get('db');
     $st = new Ticket($database);
     $sq = new Query($database);
     $types = array('common' => $sq->getCommon());
     // Loop through each grouping
     foreach ($types as $key => $queries) {
         if (!is_array($queries) || count($queries) <= 0) {
             $one = new stdClass();
             $one->count = 0;
             $one->id = 0;
             $two = new stdClass();
             $two->count = 0;
             $two->id = 0;
             $three = new stdClass();
             $three->count = 0;
             $three->id = 0;
             $types[$key] = $queries = array($one, $two, $three);
         }
         // Loop through each query in a group
         foreach ($queries as $k => $query) {
             if ($query->id) {
                 // Build the query from the condition set
                 if (!$query->query) {
                     $query->query = $sq->getQuery($query->conditions);
                 }
                 // Get a record count
                 $types[$key][$k]->count = $st->getCount($query->query);
             }
         }
     }
     $this->topened = $types['common'];
     $this->offset = Config::get('offset');
     $year = Request::getInt('year', strftime("%Y", time() + $this->offset * 60 * 60));
     $month = strftime("%m", time() + $this->offset * 60 * 60);
     $this->year = $year;
     $this->opened = array();
     $this->closed = array();
     // First ticket
     $sql = "SELECT YEAR(created)\n\t\t\t\tFROM `#__support_tickets`\n\t\t\t\tWHERE report!=''\n\t\t\t\tAND type='0' ORDER BY created ASC LIMIT 1";
     $database->setQuery($sql);
     $first = intval($database->loadResult());
     // Opened tickets
     $sql = "SELECT id, created, YEAR(created) AS `year`, MONTH(created) AS `month`, status, owner\n\t\t\t\tFROM `#__support_tickets`\n\t\t\t\tWHERE report!=''\n\t\t\t\tAND type=0";
     $sql .= " AND (`group`='' OR `group` IS NULL)";
     $sql .= " ORDER BY created ASC";
     $database->setQuery($sql);
     $openTickets = $database->loadObjectList();
     $open = array();
     $this->opened['open'] = 0;
     $this->opened['new'] = 0;
     $this->opened['unassigned'] = 0;
     foreach ($openTickets as $o) {
         if (!isset($open[$o->year])) {
             $open[$o->year] = array();
         }
         if (!isset($open[$o->year][$o->month])) {
             $open[$o->year][$o->month] = 0;
         }
         $open[$o->year][$o->month]++;
         $this->opened['open']++;
         if (!$o->status) {
             $this->opened['new']++;
         }
         if (!$o->owner) {
             $this->opened['unassigned']++;
         }
     }
     // Closed tickets
     $sql = "SELECT c.ticket, c.created_by, c.created, YEAR(c.created) AS `year`, MONTH(c.created) AS `month`, UNIX_TIMESTAMP(t.created) AS opened, UNIX_TIMESTAMP(c.created) AS closed\n\t\t\t\tFROM `#__support_comments` AS c\n\t\t\t\tLEFT JOIN `#__support_tickets` AS t ON c.ticket=t.id\n\t\t\t\tWHERE t.report!=''\n\t\t\t\tAND type=0 AND open=0";
     $sql .= " AND (`group`='' OR `group` IS NULL)";
     $sql .= " ORDER BY c.created ASC";
     $database->setQuery($sql);
     $clsd = $database->loadObjectList();
     $this->opened['closed'] = 0;
     $closedTickets = array();
     foreach ($clsd as $closed) {
         if (!isset($closedTickets[$closed->ticket])) {
             $closedTickets[$closed->ticket] = $closed;
         } else {
             if ($closedTickets[$closed->ticket]->created < $closed->created) {
                 $closedTickets[$closed->ticket] = $closed;
             }
         }
     }
     $this->closedTickets = $closedTickets;
     $closed = array();
     foreach ($closedTickets as $o) {
         if (!isset($closed[$o->year])) {
             $closed[$o->year] = array();
         }
         if (!isset($closed[$o->year][$o->month])) {
             $closed[$o->year][$o->month] = 0;
         }
         $closed[$o->year][$o->month]++;
         $this->opened['closed']++;
     }
     // Group data by year and gather some info for each user
     $y = date("Y");
     $y++;
     $this->closedmonths = array();
     $this->openedmonths = array();
     for ($k = $first, $n = $y; $k < $n; $k++) {
         $this->closedmonths[$k] = array();
         $this->openedmonths[$k] = array();
         for ($i = 1; $i <= 12; $i++) {
             if ($k == $year && $i > $month) {
                 break;
             } else {
                 $this->closedmonths[$k][$i] = isset($closed[$k]) && isset($closed[$k][$i]) ? $closed[$k][$i] : 0;
                 $this->openedmonths[$k][$i] = isset($open[$k]) && isset($open[$k][$i]) ? $open[$k][$i] : 0;
             }
         }
     }
     // Get the view
     parent::display();
 }
Example #13
0
 /**
  * Constructor
  *
  * @param   object  $params  Registry
  * @param   object  $module  Database row
  * @return  void
  */
 public function __construct($params, $module)
 {
     parent::__construct($params, $module);
     self::$instances++;
 }