function triggerEvents($cio, $uid) { // instantiate all applications, divide in those who need meta informations and those who don't $applications = array(); $metaapplications = array(); foreach ($this->_GIS->people[$this->_id]->applications as $a) { $application = new Application($a, $this->_id, $this->_log); if ($application) { if ($application->needMeta()) { $metaapplications[] = $application; } else { $applications[] = $application; } } } $this->_log->log(\Psr\Log\LogLevel::DEBUG, "User " . $this->_id . " has " . count($metaapplications) . " applications which need meta informations and " . count($applications) . " which don't need them."); // retrieve metadata for all applications which needs it if (count($metaapplications) > 0) { // we need to be EP manager to retrieve the meta data if (!in_array($uid, $this->_managers)) { $m = $this->_managers; $m[] = $uid; if (!$this->updateEPmanagers($m)) { $this->_log->log(\Psr\Log\LogLevel::WARNING, "Could NOT become EP manager for user " . $this->_id . ". This means we have to skip all applications which need meta data"); $metaapplications = array(); } } // retrieve all the metadata foreach ($metaapplications as $application) { if ($application->setMeta($this->_GIS->applications[$application->getId()]->get()->meta)) { $applications[] = $application; } else { $this->_log->log(\Psr\Log\LogLevel::WARNING, "Could NOT get meta data for application " . $application->getId() . ". Skipping that application."); } } unset($metaapplications); // check if we need to drop EP manager rights if (!in_array($uid, $this->_managers)) { if (!$this->updateEPmanagers($this->_managers)) { $this->_log->log(\Psr\Log\LogLevel::INFO, "Could NOT remove GIS Bot as EP manager from person " . $this->_id, (array) $this->_managers); } } } // trigger the events for every application, but stop if we can not save the state of an application foreach ($applications as $application) { $err = false; while ($application->hasEvent() && !$err) { $application->nextEvent($cio); $err = !$application->saveStatus(); } } }