/** * @action getCsvUrl * @param int $id * @param int $reportPartnerId * @return string */ function getCsvUrlAction($id, $reportPartnerId) { $dbReport = ReportPeer::retrieveByPK($id); if (is_null($dbReport)) { throw new KalturaAPIException(KalturaErrors::REPORT_NOT_FOUND, $id); } $dbPartner = PartnerPeer::retrieveByPK($reportPartnerId); if (is_null($dbPartner)) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $reportPartnerId); } // allow creating urls for reports that are associated with partner 0 and the report owner if ($dbReport->getPartnerId() !== 0 && $dbReport->getPartnerId() !== $reportPartnerId) { throw new KalturaAPIException(KalturaErrors::REPORT_NOT_PUBLIC, $id); } $ks = new ks(); $ks->valid_until = time() + 2 * 365 * 24 * 60 * 60; // 2 years $ks->type = ks::TYPE_KS; $ks->partner_id = $reportPartnerId; $ks->master_partner_id = null; $ks->partner_pattern = $reportPartnerId; $ks->error = 0; $ks->rand = microtime(true); $ks->user = ''; $ks->privileges = 'setrole:REPORT_VIEWER_ROLE'; $ks->additional_data = null; $ks_str = $ks->toSecureString(); $paramsArray = $this->getParametersAction($id); $paramsStrArray = array(); foreach ($paramsArray as $param) { $paramsStrArray[] = $param->value . '={' . $param->value . '}'; } $url = "http://" . kConf::get("www_host") . "/api_v3/index.php/service/report/action/getCsvFromStringParams/id/{$id}/ks/" . $ks_str . "/params/" . implode(';', $paramsStrArray); return $url; }
public function executeMiniChart($request) { $interval = ReportPeer::getMeasurementInterval($this->report->getId()); $x_labels = array($interval['first'], $interval['last']); $decorator = new ThumbnailChartDecorator($x_labels); $this->chart = ReportPeer::getReportChartt($this->report, $decorator); }
public static function setDefaultCriteriaFilter() { if (is_null(self::$s_criteria_filter)) { self::$s_criteria_filter = new criteriaFilter(); } $c = new Criteria(); $c->add(self::DELETED_AT, null, Criteria::ISNULL); self::$s_criteria_filter->setFilter($c); }
public static function generate() { $urls = array(); $c = new Criteria(); $c->add(ReportPeer::PUBLIC_RECORD, true); $c->addDescendingOrderByColumn(ReportPeer::CREATED_AT); $reports = ReportPeer::doSelect($c); foreach ($reports as $report) { $urls[] = new sitemapURL("report/show?id=" . $report->getFriendlyUrl(), date('Y-m-d\\TH:i:s\\Z', strtotime($report->getCreatedAt())), 'weekly', 1.0); } return $urls; }
/** * Builds a Criteria object containing the primary key for this object. * * Unlike buildCriteria() this method includes the primary key values regardless * of whether or not they have been modified. * * @return Criteria The Criteria object containing value(s) for primary key(s). */ public function buildPkeyCriteria() { $criteria = new Criteria(ReportPeer::DATABASE_NAME); $criteria->add(ReportPeer::ID, $this->id); if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(ReportPeer::UPDATED_AT)) { $theModifiedColumn = null; foreach ($this->modifiedColumns as $modifiedColumn) { if ($modifiedColumn != ReportPeer::UPDATED_AT) { $theModifiedColumn = $modifiedColumn; } } $atomicColumns = ReportPeer::getAtomicColumns(); if (in_array($theModifiedColumn, $atomicColumns)) { $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL); } } return $criteria; }
private static function getQueryResults($report_id, $start_date, $end_date, $frequency = QueryResultPeer::FREQUENCY_DAY) { $report = ReportPeer::retrieveByPK($report_id); $temp = array(); foreach ($report->getReportQuerys() as $report_query) { $arr = QueryResultPeer::getChartData($report_query->getQueryId(), $frequency, $start_date, $end_date); $temp[] = $arr; } return $temp; }
/** * @action getCsv * @param int $id * @param KalturaKeyValueArray $params * @return file */ public function getCsvAction($id, KalturaKeyValueArray $params = null) { $dbReport = ReportPeer::retrieveByPK($id); if (is_null($dbReport)) { throw new KalturaAPIException(KalturaErrors::REPORT_NOT_FOUND, $id); } $query = $dbReport->getQuery(); $this->addPartnerIdToParams($params); $execParams = KalturaReportHelper::getValidateExecutionParameters($dbReport, $params); $kReportsManager = new kReportManager($dbReport); list($columns, $rows) = $kReportsManager->execute($execParams); $fileName = array('Report', $id, $this->getPartnerId()); foreach ($params as $param) { $fileName[] = $param->key; $fileName[] = $param->value; } $fileName = implode('_', $fileName) . '.csv'; header('Content-Type: text/csv'); header("Content-Disposition: attachment; filename=\"{$fileName}\""); echo ""; // a fix for excel, copied from myReportsMgr echo implode(',', $columns) . "\n"; foreach ($rows as $row) { echo implode(',', $row) . "\n"; } die; }
public function getFieldNameFromPeer($field_name) { $res = ReportPeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME); return $res; }
public function executeShow($request) { $this->pager = ReportPeer::findByQuery($request->getParameter('query'), $request->getParameter('page', 1), 10); }
<?php $c = new Criteria(); $c->add(ReportQueryPeer::QUERY_ID, $query->getId()); $c->addJoin(ReportPeer::ID, ReportQueryPeer::REPORT_ID); echo ReportPeer::doCount($c);
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ReportPeer::DATABASE_NAME); $criteria->add(ReportPeer::ID, $pks, Criteria::IN); $objs = ReportPeer::doSelect($criteria, $con); } return $objs; }
public function executeStatistics($request) { $this->statistics = array('reports' => ReportPeer::doCount(new Criteria()), 'queries' => QueryPeer::doCount(new Criteria()), 'query_results' => QueryResultBulkPeer::doCount(new Criteria())); }
public function executeFeed($request) { $feed_versions = array('Atom1', 'Rss091', 'Rss10', 'Rss201'); $type = $request->getParameter('type'); if (!$type || !in_array($type, $feed_versions)) { $type = 'Atom1'; } $class = 'sf' . $type . 'Feed'; $feed = new $class(); if (!$request->getParameter('username')) { $pager = ReportPeer::findNewReports(1, 10, 'desc'); $reports = $pager->getResults(); $feed->setTitle('Google Volume - New Reports'); $feed->setLink('http://www.googlevolume.com'); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('Info'); //$feedImage = new sfFeedImage(); //$feedImage->setFavicon('http://www.googlevolume.com/favicon.ico'); //$feed->setImage($feedImage); self::addToFeed($feed, $reports); } else { $username = $request->getParameter('username'); $sfGuardUser = myUser::retrieveByUsername($username); $profile = $sfGuardUser->getsfGuardUserProfiles(); $profile = $profile[0]; $feed->setTitle('Google Volume - ' . $profile->getFirstName() . ' ' . $profile->getLastname() . '\'s New Reports'); $feed->setLink('http://www.googlevolume.com'); $feed->setAuthorEmail('*****@*****.**'); $feed->setAuthorName('Info'); $c = new Criteria(); $c->add(ReportPeer::USER_ID, $sfGuardUser->getId()); $c->add(ReportPeer::PUBLIC_RECORD, true); $c->addDescendingOrderByColumn(ReportPeer::CREATED_AT); $c->setLimit(10); self::addToFeed($feed, ReportPeer::doSelect($c)); } $this->feed = $feed; }
protected function execute($arguments = array(), $options = array()) { $frequencies = array('D' => 'Daily', 'W' => 'Weekly', 'M' => 'Monthly'); $frequency = $arguments['frequency']; if (!array_key_exists($frequency, $frequencies)) { logline(sprintf('Invalid frequency %s use [D|W|M]', $frequency)); exit; } sfLoader::loadHelpers('Partial', 'My'); $context = sfContext::createInstance($this->configuration); $stop_watch = new StopWatch(); $stop_watch->start(); logline(sprintf('Started processing %s mails.', $frequencies[$frequency])); $databaseManager = new sfDatabaseManager($this->configuration); $c1 = new Criteria(); $c1->addJoin(sfGuardUserPeer::ID, ReportPeer::USER_ID); $c1->add(ReportPeer::MAIL_FREQUENCY, $frequency); $c1->setDistinct(); $users = sfGuardUserPeer::doSelect($c1); foreach ($users as $user) { $c = new Criteria(); $c->add(ReportPeer::USER_ID, $user->getId()); $c->add(ReportPeer::MAIL_FREQUENCY, $frequency); $reports = ReportPeer::doSelect($c); logline(sprintf("There are %s reports to process.", sizeof($reports))); $sfGuardUserProfile = $user->getsfGuardUserProfiles(); $sfGuardUserProfile = $sfGuardUserProfile[0]; $connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25); $connection->setUsername('*****@*****.**'); $connection->setPassword('gahve123'); $mailer = new Swift($connection); $message = new Swift_Message(sprintf("Goole Volume - %s notifications.", $frequencies[$frequency])); $images = array(); foreach ($reports as $report) { // $rtn = ReportPeer::_getReportChart( // $report, date('Y-m-d', strtotime(date('Ymd') . ' -1 months')), // date('Y-m-d', strtotime(date('Y-m-d') . ' +1 days')), // QueryResultPeer::FREQUENCY_DAY, new MailChartDecorator()); $rtn = ReportPeer::_getReportChartt($report, new MailChartDecorator()); $data = $rtn['values']; $line_chart = $rtn['chart']; $image_path = $local_url = sfConfig::get('app_web_images') . '/' . $line_chart->__toString(); $images[$report->getTitle()] = new Swift_Message_Image(new Swift_File($image_path)); $imageReferences = array(); foreach ($images as $name => $image) { $imageReferences[$name] = $message->attach($image); } $mailContext = array('data' => $data, 'full_name' => $sfGuardUserProfile->getFullName(), 'report' => $report, 'images' => $imageReferences); } try { $message->attach(new Swift_Message_Part(get_partial('mail/mailReportHtmlBody', $mailContext), 'text/html')); $message->attach(new Swift_Message_Part(get_partial('mail/mailReportTextBody', $mailContext), 'text/plain')); $mailer->send($message, $sfGuardUserProfile->getEmail(), '*****@*****.**'); $mailer->disconnect(); } catch (Exception $e) { logline(sprintf('Exception while sending email to %s about %s. %s', $sfGuardUserProfile->getEmail(), $report->getTitle(), $e)); $mailer->disconnect(); } logline(sprintf('Sent mail to %s.', $sfGuardUserProfile->getEmail())); } logline(sprintf("Finished processing.")); $stop_watch->end(); logline(sprintf('Execution time: %s seconds.', $stop_watch->getTime())); logline(sprintf('!!!!!CAN RUN %s TIMES A DAY!!!!!', 24 * 60 * 60 / ($stop_watch->getTime() == 0 ? 1 : $stop_watch->getTime()))); }