/** * Returns the list of actions done in one item. * * REQUIRES request parameters: * <pre> * - integer <b>moduleId</b> id of the module (if moduleName is sent, this is not necessary). * - integer <b>itemId</b> id of the item. * </pre> * * OPTIONAL request parameters: * <pre> * - integer <b>userId</b> To filter by user id. * - string <b>moduleName</b> Name of the module (if moduleId is sent, this is not necessary). * - date <b>startDate</b> To filter by start date. * - date <b>endDate</b> To filter by end date. * </pre> * * The return is in JSON format. * * @throws Zend_Controller_Action_Exception On missing or wrong moduleId or itemId. * * @return void */ public function jsonListAction() { $moduleId = (int) $this->getRequest()->getParam('moduleId', null); $itemId = (int) $this->getRequest()->getParam('itemId', null); $userId = (int) $this->getRequest()->getParam('userId', null); $moduleName = Cleaner::sanitize('alnum', $this->getRequest()->getParam('moduleName', 'Default')); $startDate = Cleaner::sanitize('date', $this->getRequest()->getParam('startDate', null)); $endDate = Cleaner::sanitize('date', $this->getRequest()->getParam('endDate', null)); $this->setCurrentProjectId(); if (empty($moduleId)) { $moduleId = Phprojekt_Module::getId($moduleName); } if (empty($itemId) || empty($moduleId)) { throw new Zend_Controller_Action_Exception("Invalid module or item", 400); } else { $history = new Phprojekt_History(); $data = $history->getHistoryData(null, $itemId, $moduleId, $startDate, $endDate, $userId); $data = array('data' => $data); Phprojekt_Converter_Json::echoConvert($data); } }
/** * Test delete history */ public function testDeleteCall() { $project = new Project_Models_Project(array('db' => $this->sharedFixture)); $history = new Phprojekt_History(array('db' => $this->sharedFixture)); $project->find(Zend_Registry::get('insertedId')); $project->delete(); $data = $history->getHistoryData($project, Zend_Registry::get('insertedId')); $array = array('userId' => '1', 'moduleId' => '1', 'itemId' => Zend_Registry::get('insertedId'), 'field' => 'title', 'label' => 'Title', 'oldValue' => 'EDITED TEST', 'newValue' => '', 'action' => 'delete', 'datetime' => date("Y-m-d")); $found = 0; foreach ($data as $values) { /* Remove the hour */ $values['datetime'] = substr($values['datetime'], 0, 10); $result = array_diff_assoc($values, $array); if (empty($result)) { $found = 1; } } if (!$found) { $this->fail('Save delete history error'); } }