public function deleteOldEvents() { $db = JFactory::getDBO(); // Load all events happening now or before now $query = 'SELECT `id`' . ' FROM #__acctexp_event' . ' WHERE `due_date` <= \'' . date('Y-m-d H:i:s', (int) gmdate('U')) . '\'' . ' AND `status` = \'waiting\''; $db->setQuery($query); $events = xJ::getDBArray($db); // Call each event individually foreach ($events as $evid) { $event = new aecEvent(); $event->load($evid); $event->trigger(); } }
/** * @param string $event * @param string $due_date */ public function redateUniqueEvent($request, $event, $due_date, $context = array(), $params = array(), $customparams = array()) { $db = JFactory::getDBO(); $query = 'SELECT `id`' . ' FROM #__acctexp_event' . ' WHERE `userid` = \'' . $request->metaUser->userid . '\'' . ' AND `appid` = \'' . $this->id . '\'' . ' AND `event` = \'' . $event . '\'' . ' AND `type` = \'mi\'' . ' AND `status` = \'waiting\''; $db->setQuery($query); $id = $db->loadResult(); if ($id) { $aecEvent = new aecEvent(); $aecEvent->load($id); if ($aecEvent->due_date != $due_date) { $aecEvent->due_date = $due_date; $aecEvent->storeload(); } } else { return $this->issueEvent($request, $event, $due_date, $context, $params, $customparams); } }