Exemplo n.º 1
0
    public function checkAlarm()
    {
        $getStartdate = strtotime($this->getStartofTheWeek());
        $getEnddate = strtotime($this->getEndofTheWeek());
        $start = $this->getStartDayDB($getStartdate);
        $end = $this->getEndDayDB($getEnddate);
        $addWhereSql = '';
        $ids = array();
        //\OCP\Util::writeLog('calendarplus','COUNT ALARM:'.count($ids) ,\OCP\Util::DEBUG);
        $aExec = array('1', 'VJOURNAL');
        foreach ($this->aCalendars as $calInfo) {
            $ids[] = $calInfo['id'];
            array_push($aExec, $calInfo['id']);
        }
        $id_sql = '';
        if (count($ids) > 0) {
            $id_sql = join(',', array_fill(0, count($ids), '?'));
            array_push($aExec, $start, $end, $start, $end, $start, $start);
            $repeatDB = new RepeatDAO(\OC::$server->getDb(), \OCP\USER::getUser());
            $stmt = \OCP\DB::prepare('SELECT * FROM `' . App::CldObjectTable . '` WHERE `isalarm` = ? AND `objecttype`!= ?  AND `calendarid` IN (' . $id_sql . ') ' . ' AND ((`startdate` >= ? AND `enddate` <= ? AND `repeating` = 0)' . ' OR (`enddate` >= ? AND `startdate` <= ? AND `repeating` = 0)' . ' OR (`startdate` <= ? AND `repeating` = 1) ' . ' OR (`startdate` >= ? AND `repeating` = 1)
			)');
            $result = $stmt->execute($aExec);
            $calendarobjects = array();
            while ($row = $result->fetchRow()) {
                if ($row['repeating']) {
                    $cachedinperiod = $repeatDB->getEventInperiod($row['id'], $start, $end, true);
                    //\OCP\Util::writeLog('calendarplus','REPEAT ALARM:'.$row['id'] ,\OCP\Util::DEBUG);
                    $rowRepeat = array();
                    if (is_array($cachedinperiod)) {
                        foreach ($cachedinperiod as $cachedevent) {
                            $rowRepeat['startdate'] = $cachedevent['startdate'];
                            $rowRepeat['enddate'] = $cachedevent['enddate'];
                            $rowRepeat['calendardata'] = $row['calendardata'];
                            $rowRepeat['id'] = $row['id'];
                            $rowRepeat['summary'] = $row['summary'];
                            $calendarobjects[] = $rowRepeat;
                        }
                    }
                }
                $calendarobjects[] = $row;
            }
        }
        if (count($calendarobjects) > 0) {
            $this->parseAlarm($calendarobjects);
        } else {
            return false;
        }
    }
Exemplo n.º 2
0
 /**
  * @NoAdminRequired
  * 
  * @brief Gets the data of all events of a calendar per start and end date
  * @param integer $id
  * @param datetime $start
  * @param datetime $end
  * @param array $ids  - calendar ids
  * 
  * @return associative array || null
  */
 public function allInPeriodAlarm($id, $start, $end, $ids)
 {
     $id_sql = join(',', array_fill(0, count($ids), '?'));
     $aExec = array('1', 'VJOURNAL');
     foreach ($ids as $id) {
         array_push($aExec, $id);
     }
     array_push($aExec, $start, $end, $start, $end, $start);
     $repeatDB = new RepeatDAO($this->db, $this->userId);
     $stmt = $this->db->prepareQuery('SELECT * FROM `' . $this->objectTable . '` WHERE `isalarm` = ? AND `objecttype`!= ? AND `calendarid` IN (' . $id_sql . ')' . ' AND ((`startdate` >= ? AND `enddate` <= ? AND `repeating` = 0)' . ' OR (`enddate` >= ? AND `startdate` <= ? AND `repeating` = 0)' . ' OR (`startdate` <= ? AND `repeating` = 1) )');
     $result = $stmt->execute($aExec);
     if ($result !== false && $result !== null) {
         $calendarobjects = array();
         while ($row = $result->fetchRow()) {
             if ($row['repeating']) {
                 //Change later to controller
                 $cachedinperiod = $repeatDB->getEventInperiod($row['id'], $start, $end, true);
                 $rowRepeat = array();
                 foreach ($cachedinperiod as $cachedevent) {
                     $rowRepeat['startdate'] = $cachedevent['startdate'];
                     $rowRepeat['enddate'] = $cachedevent['enddate'];
                     $rowRepeat['calendardata'] = $row['calendardata'];
                     $rowRepeat['id'] = $row['id'];
                     $rowRepeat['summary'] = $row['summary'];
                     $calendarobjects[] = $rowRepeat;
                 }
             }
             $calendarobjects[] = $row;
         }
         return $calendarobjects;
     } else {
         return null;
     }
 }