Beispiel #1
0
 public function addEvent(Project $project, EventRss $event)
 {
     $fileName = $this->rssDir . $this->pKey . ".rss";
     $now = \Carbon\Carbon::Now();
     $nowDateTimeStamp = str_replace(":", "", str_replace(" ", "", str_replace("-", "", $now->toDateTimeString())));
     if (!$this->checkFileExists($fileName)) {
         if (!$this->storeProjectRssFile($project)) {
             return false;
         }
     }
     $xml = $this->openRssFile($fileName);
     if ($xml === false) {
         return false;
     }
     $item = $xml->channel->addChild('item');
     $item->addChild('title', $event->title);
     $item->addChild('link', $event->link . $nowDateTimeStamp);
     $item->addChild('description', $event->description);
     $item->addChild('pubDate', $event->pubDate);
     try {
         $xml->asXML($fileName);
     } catch (Exception $er) {
         return false;
     }
     $rssLog = new Rss_log();
     $rssLog->setPid($event->PID);
     $rssLog->setCid($event->CID);
     $rssLog->setSid($event->SID);
     $rssLog->setEid($event->EID);
     $rssLog->setTitle($event->title);
     $rssLog->setDescription($event->description);
     $rssLog->setLink($event->link);
     $rssLog->setType("event add");
     $rssLog->setR_date(\Carbon\Carbon::Now()->toDateTimeString());
     $this->storeRssLog($rssLog);
     return true;
 }
 function find($criteria = null, $order = null, $limit = 1000, $from = 0)
 {
     $result = $this->database->query($this->buildFindQuery($criteria, $order, $limit, $from));
     if (!is_null($result->getError())) {
         return $result->getError();
     }
     $rss_logs = array();
     while ($row = $result->fetchRow()) {
         $rss_log = new Rss_log();
         $value = $row[0];
         $rss_log->setId($value);
         $value = $row[1];
         $rss_log->setPid($value);
         $value = $row[2];
         $rss_log->setCid($value);
         $value = $row[3];
         $rss_log->setSid($value);
         $value = $row[4];
         $rss_log->setEid($value);
         $value = $row[5];
         $rss_log->setTitle($value);
         $value = $row[6];
         $rss_log->setDescription($value);
         $value = $row[7];
         $rss_log->setLink($value);
         $value = $row[8];
         $rss_log->setType($value);
         $value = $row[9];
         $rss_log->setR_date($value);
         if ($order != null) {
             array_push($rss_logs, $rss_log);
         } else {
             $rss_logs[$rss_log->getId()] = $rss_log;
         }
     }
     return $rss_logs;
 }