/** * function to get keyword report using user id * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * $info['from_time'] The from time of report in (yyyy-mm-dd) Eg: 2014-12-24 - Optional - (default => Yesterday) * $info['to_time'] The to time of report in (yyyy-mm-dd) Eg: 2014-12-28 - Optional - (default => Today) * @return Array $returnInfo Contains informations about keyword reports */ function getReportByUserId($info) { $userId = intval($info['id']); if (empty($userId)) { return array('response' => 'Error', 'result' => 'Invalid user id'); } $fromTime = getFromTime($info); $toTime = getToTime($info); // get all active websites $websiteController = new WebsiteController(); $websiteList = $websiteController->__getAllWebsitesWithActiveKeywords($userId, true); // loop through websites $keywordList = array(); foreach ($websiteList as $websiteInfo) { $websiteId = $websiteInfo['id']; $list = $this->ctrler->__getAllKeywords('', $websiteId); // loop through keywords foreach ($list as $keywordInfo) { $keywordList[$keywordInfo['id']] = $this->getFormattedReport($keywordInfo, $fromTime, $toTime); } } // if position information is not empty if (empty($keywordList)) { $returnInfo['response'] = 'Error'; $returnInfo['result'] = "No reports found!"; } else { $returnInfo['response'] = 'success'; $returnInfo['result'] = $keywordList; } return $returnInfo; }
function showGraphicalReports($searchInfo = '') { $userId = isLoggedIn(); if (!empty($searchInfo['from_time'])) { $fromTime = strtotime($searchInfo['from_time'] . ' 00:00:00'); } else { $fromTime = mktime(0, 0, 0, date('m'), date('d') - 30, date('Y')); } if (!empty($searchInfo['to_time'])) { $toTime = strtotime($searchInfo['to_time'] . ' 23:59:59'); } else { $toTime = mktime(); } $this->set('fromTime', date('Y-m-d', $fromTime)); $this->set('toTime', date('Y-m-d', $toTime)); $websiteController = new WebsiteController(); $websiteList = $websiteController->__getAllWebsitesWithActiveKeywords($userId, true); $this->set('websiteList', $websiteList); $websiteId = empty($searchInfo['website_id']) ? $websiteList[0]['id'] : intval($searchInfo['website_id']); $this->set('websiteId', $websiteId); $keywordController = new KeywordController(); $keywordList = $keywordController->__getAllKeywords($userId, $websiteId, true); $this->set('keywordList', $keywordList); $keywordId = empty($searchInfo['keyword_id']) ? $keywordList[0]['id'] : intval($searchInfo['keyword_id']); $this->set('keywordId', $keywordId); $seController = new SearchEngineController(); $seList = $seController->__getAllSearchEngines(); $this->set('seList', $seList); $seId = empty($searchInfo['se_id']) ? '' : intval($searchInfo['se_id']); $this->set('seId', $seId); $this->set('seNull', true); $this->set('graphUrl', "graphical-reports.php?sec=graph&fromTime={$fromTime}&toTime={$toTime}&keywordId={$keywordId}&seId={$seId}"); $this->render('report/graphicalreport'); }