CommunityID/modules/default/controllers/HistoryController.php

67 lines
1.9 KiB
PHP
Raw Normal View History

2019-07-17 20:08:50 +00:00
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
2019-07-17 20:16:19 +00:00
class HistoryController extends CommunityID_Controller_Action
2019-07-17 20:08:50 +00:00
{
public function indexAction()
{
$this->_helper->actionStack('index', 'login', 'users');
}
public function listAction()
{
$this->_helper->viewRenderer->setNeverRender(true);
2019-07-17 20:16:19 +00:00
$histories = new Model_Histories();
2019-07-17 20:08:50 +00:00
$historiesRows = $histories->get(
$this->user,
$this->_getParam('startIndex'),
2019-07-17 20:16:19 +00:00
$this->_getParam('results'),
$this->_getParam('sort', 'date'),
$this->_getParam('dir', Model_Histories::DIR_DESC)
2019-07-17 20:08:50 +00:00
);
$jsonObj = new StdClass();
$jsonObj->recordsReturned = count($historiesRows);
$jsonObj->totalRecords = $histories->getNumHistories($this->user);
$jsonObj->startIndex = $this->_getParam('startIndex');
$jsonObj->sort = null;
$jsonObj->dir = 'asc';
$jsonObj->records = array();
foreach ($historiesRows as $history) {
$jsonObjSite = new StdClass();
$jsonObjSite->id = $history->id;
$jsonObjSite->date = $history->date;
$jsonObjSite->site = $history->site;
$jsonObjSite->ip = $history->ip;
$jsonObjSite->result = $history->result;
$jsonObj->records[] = $jsonObjSite;
}
echo Zend_Json::encode($jsonObj);
}
public function clearAction()
{
$this->_helper->viewRenderer->setNeverRender(true);
2019-07-17 20:16:19 +00:00
$histories = new Model_Histories();
2019-07-17 20:08:50 +00:00
$histories->clear($this->user);
$json = new StdClass();
$json->code = 200;
echo Zend_Json::encode($json);
}
}