Exemplo n.º 1
0
 /**
  * Register an event handler
  *
  * @param Mixed $event The event to register
  * @param EventHandler $handler The EventHandler in charge of the event.
  */
 static function register($event, EventHandler $handler)
 {
     if (!arr::hasKey(self::$_handlers, strtolower($event))) {
         self::$_handlers[$event] = array();
     }
     self::$_handlers[$event][$handler->getUniqueId()] = $handler;
 }
Exemplo n.º 2
0
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     $sql = "SELECT *\r\n\t\t\t\tFROM ugml_spec";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->data[$row['specID']] = $row;
     }
     // requirements
     $sql = "SELECT *\r\n\t\t\t\tFROM ugml_spec_requirement";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->data[$row['specID']]['requirement'][$row['requirement']] = $row;
     }
     foreach ($this->data as $specID => $spec) {
         if (!isset($spec['requirement'])) {
             $this->data[$specID]['requirement'] = array();
         }
     }
     flush();
     EventHandler::fireAction($this, 'getData');
     // sort
     $this->data = array('bySpecID' => $this->data, 'bySpecType' => array());
     // add arrays with spectypeid
     foreach ($this->data['bySpecID'] as $specID => $spec) {
         $this->data['bySpecType'][$spec['specType']][$specID] = $spec;
     }
     return $this->data;
 }
 /**
  * Returns the object of the active session.
  * Tries to find an existing session. 
  * Otherwise creates a new session.
  * 
  * @return 	 Session 		$session
  */
 public function get()
 {
     // get session id
     $this->sessionID = $this->readSessionID();
     $this->session = null;
     // get existing session
     if (!empty($this->sessionID)) {
         $this->session = $this->getExistingSession($this->sessionID);
     }
     // create new session
     if ($this->session == null) {
         $this->session = $this->create();
     }
     self::$activeSession = $this->session;
     // call shouldInit event
     if (!defined('NO_IMPORTS')) {
         EventHandler::fireAction($this, 'shouldInit');
     }
     // init session
     $this->session->init();
     // call didInit event
     if (!defined('NO_IMPORTS')) {
         EventHandler::fireAction($this, 'didInit');
     }
     return $this->session;
 }
 /**
  * @see TreeMenu::loadCache()
  */
 protected function loadCache()
 {
     parent::loadCache();
     WCF::getCache()->addResource('userProfileMenu-' . PACKAGE_ID, WCF_DIR . 'cache/cache.userProfileMenu-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderUserProfileMenu.class.php');
     $this->menuItems = WCF::getCache()->get('userProfileMenu-' . PACKAGE_ID);
     EventHandler::fireAction($this, 'loadedCache');
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $packageID) = explode('-', $cacheResource['cache']);
     $data = array('actions' => array('user' => array(), 'admin' => array()), 'inheritedActions' => array('user' => array(), 'admin' => array()));
     // get all listeners and filter options with low priority
     $sql = "SELECT\t\tlistener.*, package.packageDir\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_event_listener listener\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = listener.packageID)\n\t\t\tWHERE \t\tlistener.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $row['listenerClassName'] = StringUtil::getClassName($row['listenerClassFile']);
         // distinguish between inherited actions and non-inherited actions
         if (!$row['inherit']) {
             $data['actions'][$row['environment']][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;
         } else {
             if (!isset($data['inheritedActions'][$row['environment']][$row['eventClassName']])) {
                 $data['inheritedActions'][$row['eventClassName']] = array();
             }
             $data['inheritedActions'][$row['environment']][$row['eventClassName']][$row['eventName']][] = $row;
         }
     }
     // sort data by class name
     foreach ($data['actions'] as $environment => $listenerMap) {
         foreach ($listenerMap as $key => $listeners) {
             uasort($data['actions'][$environment][$key], array('CacheBuilderEventListener', 'sortListeners'));
         }
     }
     foreach ($data['inheritedActions'] as $environment => $listenerMap) {
         foreach ($listenerMap as $class => $listeners) {
             foreach ($listeners as $key => $val) {
                 uasort($data['inheritedActions'][$environment][$class][$key], array('CacheBuilderEventListener', 'sortListeners'));
             }
         }
     }
     return $data;
 }
 /**
  * @see Form::submit()
  */
 public function submit()
 {
     EventHandler::fireAction($this, 'submit');
     $this->readFormParameters();
     try {
         // attachment handling
         if ($this->showAttachments) {
             $this->attachmentsEditor->handleRequest();
         }
         // preview
         if ($this->preview || $this->upload) {
             require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php';
             AttachmentBBCode::setAttachments($this->attachmentsEditor->getSortedAttachments());
             $this->wantedPosterPreview = MessageParser::getInstance()->parse($this->text, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, false);
             if ($this->preview) {
                 $this->validate();
             }
         } else {
             $this->validate();
             $this->save();
         }
     } catch (UserInputException $e) {
         $this->errorField = $e->getField();
         $this->errorType = $e->getType();
     }
 }
 /** 
  * @see PackageInstallationPlugin::uninstall()
  */
 public function uninstall()
 {
     // call uninstall event
     EventHandler::fireAction($this, 'uninstall');
     // get all style of this package
     $isDefault = false;
     require_once WCF_DIR . 'lib/data/style/StyleEditor.class.php';
     $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_style\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID();
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         // delete style
         $style = new StyleEditor(null, $row);
         $style->delete();
         $isDefault = $isDefault || $style->isDefault;
     }
     // default style deleted
     if ($isDefault) {
         $sql = "SELECT\t\t*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_style\n\t\t\t\tORDER BY\tstyleID";
         $row = WCF::getDB()->getFirstRow($sql);
         if (!empty($row['styleID'])) {
             $style = new StyleEditor(null, $row);
             $style->setAsDefault();
         }
     }
 }
 /**
  * Creates a new OptionTypeMemberslistcolumns object.
  * Calls the construct event.
  */
 public function __construct()
 {
     if (MODULE_AVATAR != 1) {
         unset($this->staticColumns['avatar']);
     }
     // call construct event
     EventHandler::fireAction($this, 'construct');
 }
 public function getFormattedContent()
 {
     $this->formattedContent = WCF::getLanguage()->getDynamicVariable('wcf.sketchbook.sketchContents.' . SketchbookUtil::nameToLangVar($this->name));
     EventHandler::fireAction($this, 'shouldParseMessage');
     MessageParser::getInstance()->setOutputType('text/html');
     $this->formattedContent = MessageParser::getInstance()->parse($this->formattedContent, $this->enableSmilies, $this->enableHTML, $this->enableBBCodes);
     EventHandler::fireAction($this, 'didParseMessage');
     return $this->formattedContent;
 }
 /**
  * @see	PM::getOutstandingNotifications()
  */
 public function getOutstandingNotifications()
 {
     if ($this->outstandingNotifications === null) {
         // fire event
         EventHandler::fireAction($this, 'readOutstandingNotifications');
         /* require_once(WCF_DIR.'lib/data/message/pm/PM.class.php');
         			$this->outstandingNotifications = PM::getOutstandingNotifications(WCF::getUser()->userID); */
     }
     return $this->outstandingNotifications;
 }
Exemplo n.º 11
0
 public static function fire($eventName, $parameter)
 {
     if (self::$_eventManager === false) {
         global $adb;
         self::$_eventManager = new VTEventsManager($adb);
         // Initialize Event trigger cache
         self::$_eventManager->initTriggerCache();
     }
     self::$_eventManager->triggerEvent($eventName, $parameter);
 }
Exemplo n.º 12
0
 /**
  * Validates the given sort order parameter. 
  */
 public function validateSortOrder()
 {
     // call validateSortOrder event
     EventHandler::fireAction($this, 'validateSortOrder');
     switch ($this->sortOrder) {
         case 'ASC':
         case 'DESC':
             break;
         default:
             $this->sortOrder = $this->defaultSortOrder;
     }
 }
 /**
  * @see Form::submit()
  */
 public function submit()
 {
     EventHandler::fireAction($this, 'submit');
     $this->readFormParameters();
     try {
         $this->preview = MessageParser::getInstance()->parse($this->text, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, false);
         $this->validate();
     } catch (UserInputException $e) {
         $this->errorField = $e->getField();
         $this->errorType = $e->getType();
     }
 }
Exemplo n.º 14
0
 /**
  * @see CronInterface::run()
  */
 public static function run()
 {
     if (self::check() == true) {
         $last_run_daily_datetime = Registry::get_value("base_cron_last_run_daily_datetime");
         $last_run_weekly_datetime = Registry::get_value("base_cron_last_run_weekly_datetime");
         $last_run_daily_datetime_handler = new DatetimeHandler($last_run_daily_datetime);
         $last_run_weekly_datetime_handler = new DatetimeHandler($last_run_weekly_datetime);
         $current_datetime_handler = new DatetimeHandler(date("Y-m-d H:i:s"));
         if ($last_run_daily_datetime_handler->distance($current_datetime_handler) >= 86400) {
             $daily = true;
         } else {
             $daily = false;
         }
         if ($last_run_weekly_datetime_handler->distance($current_datetime_handler) >= 604800) {
             $weekly = true;
         } else {
             $weekly = false;
         }
         $cron_event = new CronEvent(self::$last_run_id, $daily, $weekly);
         $event_handler = new EventHandler($cron_event);
         if ($event_handler->get_success() == true) {
             if (self::$last_run_id + 1 > 256) {
                 Registry::set_value("base_cron_last_run_id", 1);
                 self::$last_run_id = 1;
             } else {
                 Registry::set_value("base_cron_last_run_id", self::$last_run_id + 1);
                 self::$last_run_id = self::$last_run_id + 1;
             }
             Registry::set_value("base_cron_last_run_datetime", date("Y-m-d H:i:s"));
             self::$last_run_datetime = date("Y-m-d H:i:s");
             if ($daily == true) {
                 Registry::set_value("base_cron_last_run_daily_datetime", date("Y-m-d H:i:s"));
             }
             if ($weekly == true) {
                 Registry::set_value("base_cron_last_run_weekly_datetime", date("Y-m-d H:i:s"));
             }
         }
     }
 }
Exemplo n.º 15
0
 /**
  * Builds the menu.
  */
 protected function buildMenu()
 {
     // get menu items from cache
     $this->loadCache();
     // check item permissions
     $this->checkPermissions();
     // check item options
     $this->checkOptions();
     // parse menu items
     $this->parseMenuItems();
     // call buildMenu event
     EventHandler::fireAction($this, 'buildMenu');
 }
Exemplo n.º 16
0
 /**
  * Returns an instance of the enabled user auth class.
  * 
  * @return	UserAuth
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         // call loadInstance event
         if (!defined('NO_IMPORTS')) {
             EventHandler::fireAction('UserAuth', 'loadInstance');
         }
         if (self::$instance === null) {
             self::$instance = new UserAuthDefault();
         }
     }
     return self::$instance;
 }
Exemplo n.º 17
0
 /**
  * @return void
  * @uses \Event
  * @uses \EventHandler
  * @uses \DI
  * @uses \DataFilter
  * @todo get teacher for mysql in GlobalEvents for Crontab
  */
 public static function startup()
 {
     $cronevent = new \Event('cron.run');
     $cronevent->call(function () {
         // do something
     });
     \EventHandler::attach($cronevent);
     $cronevent = new \Event('crontab.run.untis');
     $cronevent->call(function () {
         //do something
     });
     \EventHandler::attach($cronevent);
 }
	/**
	 * @see CacheBuilder::getData()
	 */
	public function getData($cacheResource) {
		list($cache, $this->packageID) = explode('-', $cacheResource['cache']);
		
		$this->loadRoutes();
		EventHandler::fireAction($this, 'loadRoutes');
		
		$this->buildCache();
		EventHandler::fireAction($this, 'buildCache');
		
		$this->sortCache();
		EventHandler::fireAction($this, 'sortCache');
		
		return $this->cache;
	}
Exemplo n.º 19
0
 function __construct($event_id, $registrant_id = null)
 {
     global $lr_session;
     if ($lr_session->is_admin() && !is_null($registrant_id)) {
         $this->registrant_id = $registrant_id;
         if ($this->registrant_id != 'choose') {
             $this->registrant = Person::load(array('user_id' => $registrant_id));
         }
     } else {
         $this->registrant_id = $lr_session->user->user_id;
         $this->registrant = $lr_session->user;
     }
     parent::__construct($event_id, $this->registrant);
 }
 /**
  * @see Form::submit()
  */
 public function submit()
 {
     // call submit event
     EventHandler::fireAction($this, 'submit');
     $this->readFormParameters();
     try {
         if ($this->doSave) {
             $this->validate();
             // no errors
             $this->save();
         }
     } catch (UserInputException $e) {
         $this->errorField = $e->getField();
         $this->errorType = $e->getType();
     }
 }
 /**
  * Creates a new entry event.
  *
  * @param	integer		$contestID
  * @param	integer		$userID
  * @param	integer		$groupID
  * @param	string		$eventName
  * @param	mixed		$placeholders
  * @param	integer		$time
  * @return	ContestEventEditor
  */
 public static function create($contestID, $userID, $groupID, $eventName, array $placeholders = array(), $time = TIME_NOW)
 {
     $eventName = preg_replace('/^Contest(.*)Editor(.*)$/', '$1$2', $eventName);
     $eventName = empty($eventName) ? 'contest' : StringUtil::toLowerCase($eventName);
     $sql = "INSERT INTO\twcf" . WCF_N . "_contest_event\n\t\t\t\t\t(contestID, userID, groupID, eventName, placeholders, time)\n\t\t\tVALUES\t\t(" . intval($contestID) . ", " . intval($userID) . ", " . intval($groupID) . ", '" . escapeString($eventName) . "', \n\t\t\t\t\t'" . escapeString(serialize($placeholders)) . "', " . intval($time) . ")";
     WCF::getDB()->sendQuery($sql);
     // get id
     $eventID = WCF::getDB()->getInsertID("wcf" . WCF_N . "_contest_event", 'eventID');
     // update entry
     $sql = "UPDATE\twcf" . WCF_N . "_contest\n\t\t\tSET\tevents = events + 1\n\t\t\tWHERE\tcontestID = " . intval($contestID);
     WCF::getDB()->sendQuery($sql);
     $event = new ContestEventEditor($eventID);
     // any event handlers?
     EventHandler::fireAction($event, 'create');
     return $event;
 }
Exemplo n.º 22
0
    /**
     * Adds the url and email bbcode tags in a text automatically.
     */
    public static function parse($text)
    {
        self::$text = $text;
        // cache codes
        self::$text = self::cacheCodes(self::$text);
        // call event
        EventHandler::fireAction('URLParser', 'shouldParse');
        // define pattern
        $urlPattern = '~(?<!\\B|"|\'|=|/|\\]|,|\\?)
			(?:						# hostname
				(?:ftp|https?)://' . self::$illegalChars . '(?:\\.' . self::$illegalChars . ')*
				|
				www\\.(?:' . self::$illegalChars . '\\.)+
				(?:[a-z]{2,4}(?=\\b))
			)

			(?::\\d+)?					# port

			(?:
				/
				[^!.,?;"\'<>()\\[\\]{}\\s]*
				(?:
					[!.,?;(){}]+ [^!.,?;"\'<>()\\[\\]{}\\s]+
				)*
			)?
			~ix';
        $emailPattern = '~(?<!\\B|"|\'|=|/|\\]|,|:)
			(?:)
			\\w+(?:[\\.\\-]\\w+)*
			@
			(?:' . self::$illegalChars . '\\.)+		# hostname
			(?:[a-z]{2,4}(?=\\b))
			(?!"|\'|\\[|\\-|\\.[a-z])
			~ix';
        // add url tags
        self::$text = preg_replace($urlPattern, '[url]\\0[/url]', self::$text);
        if (StringUtil::indexOf(self::$text, '@') !== false) {
            self::$text = preg_replace($emailPattern, '[email]\\0[/email]', self::$text);
        }
        // call event
        EventHandler::fireAction('URLParser', 'didParse');
        if (count(self::$cachedCodes) > 0) {
            // insert cached codes
            self::$text = self::insertCachedCodes(self::$text);
        }
        return self::$text;
    }
Exemplo n.º 23
0
 /**
  * Loads all registered actions of the active package.
  */
 protected static function loadActions()
 {
     $environment = class_exists('WCFACP') ? 'admin' : 'user';
     WCF::getCache()->addResource('eventListener-' . PACKAGE_ID, WCF_DIR . 'cache/cache.eventListener-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderEventListener.class.php');
     $cache = WCF::getCache()->get('eventListener-' . PACKAGE_ID);
     if (isset($cache['actions'][$environment])) {
         self::$actions = $cache['actions'][$environment];
     }
     if (isset($cache['inheritedActions'][$environment])) {
         self::$inheritedActions = $cache['inheritedActions'][$environment];
     }
     unset($cache);
     if (!is_array(self::$actions)) {
         self::$actions = array();
     }
     if (!is_array(self::$inheritedActions)) {
         self::$inheritedActions = array();
     }
 }
Exemplo n.º 24
0
 /**
  * get started with all this
  * @return void
  * @todo template-map
  */
 public static function startup()
 {
     $activeTemplate = new Template(app::get('template'));
     $gettext = new Gettext(HOME_DIR . '/locale/' . app::get('language') . '.mo');
     if ($activeTemplate->translated) {
         Gettext::addTranslation(HOME_DIR . '/templates/' . app::get('template') . '/locale/' . app::get('language') . '.mo');
     }
     require_once HOME_DIR . '/translate_functions.php';
     if (isset($activeTemplate->map)) {
         foreach ($activeTemplate->map as $map) {
             Route::get("/{$map}/[fn:filename]", "AssetsController.everything")->name($map);
         }
     }
     // add your routes here!
     Route::get('/^\\s*$/', 'IndexController.get', true);
     Route::get('/test/stack', 'TestController.stack');
     Route::get('/css/[fn:filename]', 'AssetsController.css');
     Route::get('/js/[fn:filename]', 'AssetsController.js');
     Modules::loadModuleList();
     Modules::loadModules();
     //$msqlo = new MySQLi(app::get('mysql')->host, app::get('mysql')->user, app::get('mysql')->password, app::get('mysql')->database);
     //\DI::addInstance($msqlo);
     $modelob = new \Observer\ModelObserver();
     \DI::addInstance($modelob);
     $etagevent = new \Event('etag.change');
     $etagevent->call(function ($newval) {
         \Kernel::$response->etag = md5(\Kernel::$response->etag . '|' . $newval);
     });
     \EventHandler::attach($etagevent);
     Route::registerNotFoundAction('/', function () {
         \Kernel::$response->errorCode(404);
         (new \Controller())->view('error', ['error' => ['code' => '404', 'text' => 'Not found!']]);
     });
     Route::registerNotFoundAction('/api/', function () {
         throw new \HTTPException\ObjectNotFoundException(404, "Requested resource not found!");
     });
 }
Exemplo n.º 25
0
 /**
  * @param $class
  */
 public function autoload($class)
 {
     $directories = [APP_PATH . '/controllers', APP_PATH . '/models'];
     if (isset($this->action->controllerDir) && strlen($this->action->controllerDir)) {
         $controllerDirPath = APP_PATH . "/controllers/{$this->action->controllerDir}";
         array_unshift($directories, $controllerDirPath);
     }
     $configDirectories = Config::get('autoload.directories');
     if (is_array($configDirectories)) {
         $directories = array_merge($directories, $configDirectories);
     }
     if (is_array($configDirectories)) {
         foreach ($configDirectories as $key => $val) {
             $configDirectories[$key] = APP_PATH . "/{$val}/";
         }
         $directories = array_merge($directories, $configDirectories);
     }
     $subdomain = Request::subdomain();
     if ($subdomain !== null) {
         $subdomainDirectories = [APP_PATH . "/subdomains/{$subdomain}/controllers", APP_PATH . "/subdomains/{$subdomain}/models"];
         if (isset($this->action->controllerDir) && strlen($this->action->controllerDir)) {
             array_unshift($subdomainDirectories, APP_PATH . "/subdomains/{$subdomain}/controllers/{$this->action->controllerDir}");
         }
         $configSubdomainDirectories = Config::get('autoload.subdomainDirectories');
         if (is_array($configSubdomainDirectories)) {
             foreach ($configSubdomainDirectories as $key => $val) {
                 $configSubdomainDirectories[$key] = "/subdomains/{$subdomain}/{$val}/";
             }
             $subdomainDirectories = array_merge($subdomainDirectories, $configSubdomainDirectories);
         }
         $directories = array_merge($subdomainDirectories, $directories);
     }
     $found = false;
     foreach ($directories as $dir) {
         $path = "{$dir}/{$class}.php";
         if (is_file($path)) {
             $found = true;
             require_once $path;
             break;
         }
     }
     if ($found === false) {
         EventHandler::triggerEvent('whirlpool-class-not-found', $class);
     }
 }
 /**
  * @see Module::checkPermissions()
  */
 public function checkPermissions()
 {
     // call checkPermissions event
     EventHandler::fireAction($this, 'checkPermissions');
     // check needed permissions
     return WCF::getUser()->getPermission($this->neededPermissions);
 }
Exemplo n.º 27
0
 /**
  * Search for users which fit to the search values.
  */
 protected function search()
 {
     $this->matches = array();
     $sql = "SELECT\t\tuser.userID\n\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value \n\t\t\tON\t\t(option_value.userID = user.userID)";
     // build search condition
     $this->conditions = new ConditionBuilder();
     // static fields
     $this->buildStaticConditions();
     // dynamic fields
     $this->buildDynamicConditions();
     // call buildConditions event
     EventHandler::fireAction($this, 'buildConditions');
     // do search
     $result = WCF::getDB()->sendQuery($sql . $this->conditions->get(), $this->maxResults);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->matches[] = $row['userID'];
     }
 }
Exemplo n.º 28
0
 public function mwCalendar($params)
 {
     global $wgOut, $wgTitle, $wgScript, $wgScriptPath, $IP;
     $this->setDefaults($params);
     ## RUN FIRST ##
     helpers::debug("******** Calendar Init()-{$this->key} ******** ");
     $list = '';
     $rteJS = '';
     // set the calendar's initial date
     $now = $this->now = getdate();
     $this->month = $now['mon'];
     $this->year = $now['year'];
     $this->day = $now['mday'];
     ## load normal calendar
     $cookie_name = helpers::cookie_name($this->key);
     helpers::debug('Checking for cookie: ' . $cookie_name);
     if (isset($_COOKIE[$cookie_name])) {
         $date = getdate($_COOKIE[$cookie_name]);
         //timestamp value
         $this->month = $date['mon'];
         $this->year = $date['year'];
         helpers::debug("Coookie found ({$cookie_name}), SETTING calendar date/time: {$this->month}/{$this->year}");
     }
     $this->title = $wgScript . '?title=' . $wgTitle->getPrefixedText();
     $this->db = new CalendarDatabase();
     $this->db->validateVersion();
     //make sure db and files match
     $this->options = $this->db->getOptions($this->calendarName);
     ## this basically calls a function that evaluates $_POST[] events (new, delete, cancel, etc)
     ## no need to do anything else in the calendar until any db updates have completed
     if (helpers::is_my_calendar($this->key)) {
         EventHandler::CheckForEvents();
     }
     ## add any custom groups
     $arrParamsGrps = isset($params['groups']) ? explode(',', $params['groups']) : array();
     foreach ($arrParamsGrps as $grp) {
         $grpCount = count($this->db->getGroupUsers($grp));
         $list .= "<option>#{$grp} ({$grpCount} " . helpers::translate("mwc_members") . ")</option>";
     }
     /* 		$arrGroups = $this->db->getDatabaseGroups();
     		foreach($arrGroups as $grp){
     			$list .= "<option>#$grp</option>";
     		} 
     */
     ## build the mw user-list which should only be users with active email
     $arrUsers = $this->db->getDatabaseUsers();
     while (list($user, $realname) = each($arrUsers)) {
         $realname = htmlentities($realname, ENT_QUOTES);
         $list .= "<option>{$user} ({$realname})</option>";
     }
     $list = "<SELECT class=notifyselect id=selectNotify name=selectNotify size=8 onClick=selectedListItem()>" . $list . "</SELECT>";
     ## pull in all the html template forms we have
     $addEventHtml = file_get_contents(mwcalendar_base_path . "/html/AddEvent.html");
     $batchHtml = file_get_contents(mwcalendar_base_path . "/html/batchadd.html");
     $this->htmlData = file_get_contents(mwcalendar_base_path . "/html/default.html");
     $this->htmlOption = file_get_contents(mwcalendar_base_path . "/html/Options.html");
     $addEventHtml = str_replace('[[SELECT_OPTIONS]]', $list, $addEventHtml);
     ## building my own sytlesheets and javascript links...
     $stdJSArray = array('DatePicker.js', 'tabber.js', 'InvitePicker.js', 'TimePicker.js', 'common.js', 'rte.js');
     $rteExists = file_exists($IP . "/extensions/tinymce/jscripts/tiny_mce/tiny_mce.js");
     if ($this->useRTE && $rteExists) {
         $rteJS .= $this->buildJavascript(array('/extensions/tinymce/jscripts/tiny_mce/tiny_mce.js'), true);
         $rteJS .= $this->buildJavascript(array('rte.js'));
     }
     $this->stylesheet = $this->buildStylesheet(array('DatePicker.css', 'tabber.css', 'default.css'));
     $this->javascript = $this->buildJavascript(array('DatePicker.js', 'tabber.js', 'InvitePicker.js', 'TimePicker.js', 'common.js'));
     $this->javascript .= $rteJS;
     ## build the addEvent and batch tabs
     $tab1 = $this->buildTab(helpers::translate('mwc_event'), $addEventHtml);
     $tab2 = $this->buildTab(helpers::translate('mwc_batch'), $batchHtml);
     $this->tabHtml = '<div class="tabber">' . $tab1 . $tab2 . '</div>';
 }
 /**
  * @see	 PackageInstallationPlugin::uninstall()
  */
 public function uninstall()
 {
     // call uninstall event
     EventHandler::fireAction($this, 'uninstall');
     // get container types
     $containerTypes = array();
     $sql = "SELECT\tcontainerType\n\t\t\tFROM\twcf" . WCF_N . "_" . $this->tableName . "\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID();
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $containerTypes[] = $row['containerType'];
     }
     if (count($containerTypes)) {
         require_once WCF_DIR . 'lib/data/attachment/AttachmentEditor.class.php';
         // delete attachments (files)
         $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_attachment\n\t\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID() . "\n\t\t\t\t\tAND containerType IN ('" . implode("','", array_map('escapeString', $containerTypes)) . "')";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $attachment = new AttachmentEditor(null, $row);
             $attachment->deleteFile();
         }
         // delete attachments (rows)
         $sql = "DELETE FROM\twcf" . WCF_N . "_attachment\n\t\t\t\tWHERE\t\tpackageID = " . $this->installation->getPackageID() . "\n\t\t\t\t\t\tAND containerType IN ('" . implode("','", array_map('escapeString', $containerTypes)) . "')";
         WCF::getDB()->sendQuery($sql);
         // delete container
         $sql = "DELETE FROM\twcf" . WCF_N . "_" . $this->tableName . "\n\t\t\t\tWHERE\t\tpackageID = " . $this->installation->getPackageID();
         WCF::getDB()->sendQuery($sql);
     }
 }
Exemplo n.º 30
0
 /**
  * @see SystemHandlerInterface::disable_module()
  * @param integer $module_id
  * @return bool
  */
 public static function disable_module($module_id)
 {
     global $transaction;
     if (is_numeric($module_id)) {
         $transaction_id = $transaction->begin();
         $module_access = new BaseModule_Access($module_id);
         if ($module_access->get_disabled() == true) {
             $module_enable_event = new ModuleEnableEvent($module_id);
             $event_handler = new EventHandler($module_enable_event);
             if ($event_handler->get_success() == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
             if ($module_access->set_disabled(false) == true) {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         } else {
             $module_disable_event = new ModuleDisableEvent($module_id);
             $event_handler = new EventHandler($module_disable_event);
             if ($event_handler->get_success() == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
             if ($module_access->set_disabled(true) == true) {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         }
     } else {
         return false;
     }
 }