/**
  * @name: activate
  * @description: Activates an event
  */
 public function activate($type, $filename)
 {
     $type = strtolower($type);
     $this->logger->log('DEBUG', "Activating event Type:({$type}) File:({$filename})");
     list($name, $method) = explode(".", $filename);
     if (!Registry::instanceExists($name)) {
         $this->logger->log('ERROR', "Error activating method {$filename} for event type {$type}.  Could not find instance '{$name}'.");
         return;
     }
     if ($type == "setup") {
         $eventObj = new stdClass();
         $eventObj->type = 'setup';
         $this->callEventHandler($eventObj, $filename);
     } else {
         if (in_array($type, $this->eventTypes)) {
             if (!isset($this->events[$type]) || !in_array($filename, $this->events[$type])) {
                 $this->events[$type][] = $filename;
             } else {
                 $this->logger->log('ERROR', "Error activating event Type:({$type}) File:({$filename}). Event already activated!");
             }
         } else {
             $time = $this->util->parseTime($type);
             if ($time > 0) {
                 $key = $this->getKeyForCronEvent($time, $filename);
                 if ($key === null) {
                     $this->cronevents[] = array('nextevent' => 0, 'filename' => $filename, 'time' => $time);
                 } else {
                     $this->logger->log('ERROR', "Error activating event Type:({$type}) File:({$filename}). Event already activated!");
                 }
             } else {
                 $this->logger->log('ERROR', "Error activating event Type:({$type}) File:({$filename}). The type is not a recognized event type!");
             }
         }
     }
 }
 public function registerModule($baseDir, $MODULE_NAME)
 {
     // read module.ini file (if it exists) from module's directory
     if (file_exists("{$baseDir}/{$MODULE_NAME}/module.ini")) {
         $entries = parse_ini_file("{$baseDir}/{$MODULE_NAME}/module.ini");
         // check that current PHP version is greater or equal than module's
         // minimum required PHP version
         if (isset($entries["minimum_php_version"])) {
             $minimum = $entries["minimum_php_version"];
             $current = phpversion();
             if (strnatcmp($minimum, $current) > 0) {
                 $this->logger->log('WARN', "Could not load module" . " {$MODULE_NAME} as it requires at least PHP version '{$minimum}'," . " but current PHP version is '{$current}'");
                 return;
             }
         }
     }
     $newInstances = $this->getNewInstancesInDir("{$baseDir}/{$MODULE_NAME}");
     foreach ($newInstances as $name => $className) {
         $obj = new $className();
         $obj->moduleName = $MODULE_NAME;
         if (Registry::instanceExists($name)) {
             $this->logger->log('WARN', "Instance with name '{$name}' already registered--replaced with new instance");
         }
         Registry::setInstance($name, $obj);
     }
     if (count($newInstances) == 0) {
         $this->logger->log('ERROR', "Could not load module {$MODULE_NAME}. No classes found with @Instance annotation!");
         return;
     }
 }
 /**
  * @name: activate
  * @description: Activates a command
  */
 public function activate($channel, $filename, $command, $accessLevel = 'all')
 {
     $command = strtolower($command);
     $accessLevel = $this->accessManager->getAccessLevel($accessLevel);
     $channel = strtolower($channel);
     $this->logger->log('DEBUG', "Activate Command:({$command}) Admin Type:({$accessLevel}) File:({$filename}) Channel:({$channel})");
     foreach (explode(',', $filename) as $handler) {
         list($name, $method) = explode(".", $handler);
         if (!Registry::instanceExists($name)) {
             $this->logger->log('ERROR', "Error activating method {$handler} for command {$command}.  Could not find instance '{$name}'.");
             return;
         }
     }
     $obj = new stdClass();
     $obj->file = $filename;
     $obj->admin = $accessLevel;
     $this->commands[$channel][$command] = $obj;
 }