/** * 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 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 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; }
/** * @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 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; }
/** * 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(); } }
/** * 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'); }
/** * 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; }
/** * @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; }
/** * 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; }
/** * @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(); } }
/** * 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; }
/** * @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); } }
/** * Updates the data of a logged fleet. * * @param LoggableFleet */ public static function update(LoggableFleet $fleet) { EventHandler::fireAction($fleet, 'logData'); // TODO: integrate this in wcf eventlistener logData@Fleet self::addRelevantData($fleet); $data = $fleet->getData(); if (isset(self::$invalidFleetIDs[$data['fleetID']])) { return; } $array = self::readArray($data['fleetID']); if ($array === false) { self::$invalidFleetIDs[$data['fleetID']] = true; return; } $array[] = array('data' => $data, 'fleet' => $fleet->getFleetArray(), 'stack' => self::getStacktrace(), 'time' => time()); $string = LWUtil::serialize(serialize($array), 1); $sql = "UPDATE ugml_archive_fleet\r\n\t\t\t\tSET data = '" . escapeString($string) . "'\r\n\t\t\t\tWHERE fleetID = " . $data['fleetID']; WCF::getDB()->sendQuery($sql); }
/** * @see PackageInstallationPlugin::hasUninstall() */ public function hasUninstall() { EventHandler::fireAction($this, 'hasUninstall'); return false; }
/** * Assigns variables to the template engine. */ public function assignVariables() { // call assignVariables event EventHandler::fireAction($this, 'assignVariables'); if (!$this->getUser()->friends || !$this->getUser()->shareWhitelist) { // remove friends tab foreach (UserProfileMenu::getInstance()->menuItems as $parentMenuItem => $items) { foreach ($items as $key => $item) { if ($item['menuItem'] == 'wcf.user.profile.menu.link.friends') { unset(UserProfileMenu::getInstance()->menuItems[$parentMenuItem][$key]); } } } } // assign variables WCF::getTPL()->assign(array('user' => $this->user, 'userID' => $this->userID, 'connection' => $this->connection, 'network' => $this->network, 'userSymbols' => $this->userSymbols)); }
/** * Counts the displayed items. * * @return integer */ public function countPMItems() { // call countPMItems event EventHandler::fireAction($this, 'countPMItems'); return $this->pmList->countObjects(); }
/** * This function is called after the function has been executed */ protected function executed() { EventHandler::fireAction($this, 'executed'); }
/** * @see Form::submit() */ public function submit() { EventHandler::fireAction($this, 'submit'); $this->readFormParameters(); try { if ($this->preview) { //WCF::getTPL()->assign('preview', EventEditor::createPreview()); } if ($this->send) { $this->validate(); $this->save(); } } catch (UserInputException $e) { $this->errorField = $e->getField(); $this->errorType = $e->getType(); } }
/** * 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']; } }
/** * @see WOTAPIAction::answer() */ public function answer() { EventHandler::fireAction($this, 'answer'); }
/** * Generates the vcard. */ protected function generate() { $this->content .= "BEGIN:VCARD\r\n"; $this->content .= "VERSION:2.1\r\n"; // name if ($this->user->name || $this->user->surname) { $this->content .= "N:" . $this->user->surname . ";" . $this->user->name . "\r\n"; $this->content .= "FN:" . $this->user->name . " " . $this->user->surname . "\r\n"; } // telephone if ($this->user->telephone) { $this->content .= "TEL;VOICE:" . $this->user->telephone . "\r\n"; } // gender if ($this->user->gender) { $this->content .= "X-WAB-GENDER:" . (1 - $this->user->gender) . "\r\n"; } // username $this->content .= "NICKNAME:" . $this->user->username . "\r\n"; // occupation if ($this->user->occupation) { $this->content .= "TITLE;" . $this->user->occupation . "\r\n"; } // email if (!$this->user->hideEmailAddress) { $this->content .= "EMAIL;INTERNET:" . $this->user->email . "\r\n"; } // homepage if ($this->user->homepage) { $this->content .= "URL:" . $this->user->homepage . "\r\n"; } // birthday if ($this->user->birthday) { $this->content .= "BDAY;value=date:" . $this->user->birthday . "\r\n"; } // location if ($this->user->location) { $this->content .= "item2.ADR;type=HOME:;;" . $this->user->street . ";" . $this->user->location . ";" . $this->user->state . ";" . $this->user->zipcode . ";" . $this->user->country . "\r\n"; } // fire event EventHandler::fireAction($this, 'generate'); $this->content .= "END:VCARD"; // vCard format does not support utf-8? if (CHARSET != 'ISO-8859-1') { $this->content = StringUtil::convertEncoding(CHARSET, 'ISO-8859-1', $this->content); } }
/** * @see Form::submit() */ public function submit() { // call submit event EventHandler::fireAction($this, 'submit'); $this->readFormParameters(); try { // attachment handling if ($this->showAttachments) { $this->attachmentListEditor->handleRequest(); } $this->validate(); // no errors $this->save(); } catch (UserInputException $e) { $this->errorField = $e->getField(); $this->errorType = $e->getType(); } }
/** * Calls the 'saved' event after the successful call of the save method. * This functions won't called automatically. You must do this manually, if you inherit AbstractForm. */ protected function saved() { EventHandler::fireAction($this, 'saved'); }
/** * @see Module::checkPermissions() */ public function checkPermissions() { // call checkPermissions event EventHandler::fireAction($this, 'checkPermissions'); // check needed permissions return WCF::getUser()->getPermission($this->neededPermissions); }
/** * is closeable by current user * status close is a successfull finish, if you want to stop the contest use decline status * * @return boolean */ public function isClosable() { if (WCF::getUser()->userID == 0 || $this->isOwner() == false || !($this->state == 'scheduled' && $this->untilTime > TIME_NOW)) { return false; } try { // call assignVariables event EventHandler::fireAction($this, 'isClosable'); // check if all solutions have been judged $this->closableChecks[] = array('className' => 'ContestJuryTodoList', 'classPath' => WCF_DIR . 'lib/data/contest/jury/todo/ContestJuryTodoList.class.php'); foreach ($this->closableChecks as $check) { require_once $check['classPath']; $todoList = new $check['className'](); $todoList->sqlConditions .= 'contestID = ' . intval($this->contestID); if ($num = $todoList->countObjects()) { throw new Exception($row['className'] . ' returns ' . $num . ' todo objects.'); } } } catch (Exception $e) { return false; } return true; }