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; }
/** * @action list * @param KalturaReportFilter $filter * @param KalturaReport $report * @return KalturaReportListResponse */ function listAction(KalturaReportFilter $filter = null, KalturaFilterPager $pager = null) { if (!$filter) { $filter = new KalturaReportFilter(); } if (!$pager) { $pager = new KalturaFilterPager(); } $reportFilter = new ReportFilter(); $filter->toObject($reportFilter); $c = new Criteria(); $reportFilter->attachToCriteria($c); $pager->attachToCriteria($c); $dbList = ReportPeer::doSelect($c); $c->setLimit(null); $totalCount = ReportPeer::doCount($c); $list = KalturaReportArray::fromDbArray($dbList, $this->getResponseProfile()); $response = new KalturaReportListResponse(); $response->objects = $list; $response->totalCount = $totalCount; return $response; }
/** * 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 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()))); }