예제 #1
0
 /**
  * @see \wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     $application = ApplicationHandler::getInstance()->getPrimaryApplication();
     $cacheName = 'sitemap-' . $application->packageID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\SitemapCacheBuilder');
     $this->cache = CacheHandler::getInstance()->get($cacheName);
 }
예제 #2
0
 /**
  * Updates the values of the given options.
  * 
  * @param	array		$options	id to value
  */
 public static function updateAll(array $options)
 {
     $sql = "SELECT\toptionID, optionValue\n\t\t\tFROM\twcf" . WCF_N . "_option\n\t\t\tWHERE\toptionName = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array('cache_source_type'));
     $row = $statement->fetchArray();
     $sql = "UPDATE\twcf" . WCF_N . "_option\n\t\t\tSET\toptionValue = ?\n\t\t\tWHERE\toptionID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $flushCache = false;
     WCF::getDB()->beginTransaction();
     foreach ($options as $id => $value) {
         if ($id == $row['optionID'] && ($value != $row['optionValue'] || $value != CACHE_SOURCE_TYPE)) {
             $flushCache = true;
         }
         $statement->execute(array($value, $id));
     }
     WCF::getDB()->commitTransaction();
     // force a cache reset if options were changed
     self::resetCache();
     // flush entire cache, as the CacheSource was changed
     if ($flushCache) {
         // flush caches (in case register_shutdown_function gets not properly called)
         CacheHandler::getInstance()->flushAll();
         // flush cache before finishing request to flush caches created after this was executed
         register_shutdown_function(function () {
             CacheHandler::getInstance()->flushAll();
         });
     }
 }
 /**
  * @see wcf\system\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     $filename = FileUtil::downloadFileFromHttp('http://www.woltlab.com/spiderlist/spiderlist.xml', 'spiders');
     $xml = new XML();
     $xml->load($filename);
     $xpath = $xml->xpath();
     // fetch spiders
     $spiders = $xpath->query('/spiderlist/spider');
     if (count($spiders)) {
         // delete old entries
         $sql = "DELETE FROM wcf" . WCF_N . "_spider";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute();
         $statementParameters = array();
         foreach ($spiders as $spider) {
             $identifier = StringUtil::toLowerCase($spider->getAttribute('ident'));
             $name = $xpath->query('name', $spider)->item(0);
             $info = $xpath->query('info', $spider)->item(0);
             $statementParameters[$identifier] = array('spiderIdentifier' => $identifier, 'spiderName' => $name->nodeValue, 'spiderURL' => $info ? $info->nodeValue : '');
         }
         if (!empty($statementParameters)) {
             $sql = "INSERT INTO\twcf" . WCF_N . "_spider\n\t\t\t\t\t\t\t(spiderIdentifier, spiderName, spiderURL)\n\t\t\t\t\tVALUES\t\t(?, ?, ?)";
             $statement = WCF::getDB()->prepareStatement($sql);
             foreach ($statementParameters as $parameters) {
                 $statement->execute(array($parameters['spiderIdentifier'], $parameters['spiderName'], $parameters['spiderURL']));
             }
         }
         // clear spider cache
         CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.spiders.php');
     }
     // delete tmp file
     @unlink($filename);
 }
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::install()
	 */
	public function install() {
		parent::install();
		
		// get installation path of package
		$sql = "SELECT	packageDir
			FROM	wcf".WCF_N."_package
			WHERE	packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->installation->getPackageID()));
		$packageDir = $statement->fetchArray();
		$packageDir = $packageDir['packageDir'];
		
		// get relative path of script
		$path = FileUtil::getRealPath(WCF_DIR.$packageDir);
		
		// reset WCF cache
		CacheHandler::getInstance()->flushAll();
		
		// run script
		$this->run($path.$this->instruction['value']);
		
		// delete script
		if (@unlink($path.$this->instruction['value'])) {
			// delete file log entry
			$sql = "DELETE FROM	wcf".WCF_N."_package_installation_file_log
				WHERE		packageID = ?
						AND filename = ?";
			$statement = WCF::getDB()->prepareStatement($sql);
			$statement->execute(array(
				$this->installation->getPackageID(),
				$this->instruction['value']
			));
		}
	}
 /**
  * @see	\wcf\system\package\plugin\IPackageInstallationPlugin::install()
  */
 public function install()
 {
     parent::install();
     $abbreviation = 'wcf';
     $path = '';
     if (isset($this->instruction['attributes']['application'])) {
         $abbreviation = $this->instruction['attributes']['application'];
     } else {
         if ($this->installation->getPackage()->isApplication) {
             $path = FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->packageDir);
         }
     }
     if (empty($path)) {
         $dirConstant = strtoupper($abbreviation) . '_DIR';
         if (!defined($dirConstant)) {
             throw new SystemException("Cannot execute script-PIP, abbreviation '" . $abbreviation . "' is unknown");
         }
         $path = constant($dirConstant);
     }
     // reset WCF cache
     CacheHandler::getInstance()->flushAll();
     // run script
     $this->run($path . $this->instruction['value']);
     // delete script
     if (@unlink($path . $this->instruction['value'])) {
         // delete file log entry
         $sql = "DELETE FROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t\tWHERE\t\tpackageID = ?\n\t\t\t\t\t\tAND filename = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->installation->getPackageID(), $this->instruction['value']));
     }
 }
예제 #6
0
 /**
  * Loads action cache.
  */
 protected function loadActionCache()
 {
     if ($this->actionCache !== null) {
         return;
     }
     CacheHandler::getInstance()->addResource('clipboard-action-' . PACKAGE_ID, WCF_DIR . 'cache/cache.clipboard-action-' . PACKAGE_ID . '.php', 'wcf\\system\\cache\\builder\\ClipboardActionCacheBuilder');
     $this->actionCache = CacheHandler::getInstance()->get('clipboard-action-' . PACKAGE_ID);
 }
예제 #7
0
 /**
  * @see	wcf\system\menu\TreeMenu::loadCache()
  */
 protected function loadCache()
 {
     parent::loadCache();
     // get cache
     $cacheName = 'pageMenu-' . PACKAGE_ID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\PageMenuCacheBuilder');
     $this->menuItems = CacheHandler::getInstance()->get($cacheName);
 }
예제 #8
0
 /**
  * @see	wcf\system\menu\TreeMenu::loadCache()
  */
 protected function loadCache()
 {
     parent::loadCache();
     if (PACKAGE_ID == 0) {
         return;
     }
     $cacheName = 'acpMenu-' . PACKAGE_ID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\ACPMenuCacheBuilder');
     $this->menuItems = CacheHandler::getInstance()->get($cacheName);
 }
예제 #9
0
 /**
  * Creates a new ActiveStyle object.
  * 
  * @param	Style	$object
  */
 public function __construct(Style $object)
 {
     parent::__construct($object);
     // calculate page logo path
     if (!empty($this->object->data['variables']['page.logo.image']) && !FileUtil::isURL($this->object->data['variables']['page.logo.image']) && StringUtil::substring($this->object->data['variables']['page.logo.image'], 0, 1) !== '/') {
         $this->object->data['variables']['page.logo.image'] = RELATIVE_WCF_DIR . $this->object->data['variables']['page.logo.image'];
     }
     // load icon cache
     $cacheName = 'icon-' . PACKAGE_ID . '-' . $this->styleID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\IconCacheBuilder');
     $this->iconCache = CacheHandler::getInstance()->get($cacheName);
 }
예제 #10
0
 /**
  * @see	\wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // reset stylesheets
     StyleHandler::resetStylesheets();
     // delete language cache and compiled templates as well
     LanguageFactory::getInstance()->deleteLanguageCache();
     // get package dirs
     CacheHandler::getInstance()->flushAll();
     $this->executed();
     if (!isset($_POST['noRedirect'])) {
         HeaderUtil::redirect(LinkHandler::getInstance()->getLink('CacheList'));
     }
     exit;
 }
	/**
	 * Uninstalls node components and returns next node.
	 * 
	 * @param	string		$node
	 * @return	string
	 */
	public function uninstall($node) {
		$nodes = $this->nodeBuilder->getNodeData($node);
		
		// invoke node-specific actions
		foreach ($nodes as $data) {
			$nodeData = unserialize($data['nodeData']);
			
			switch ($data['nodeType']) {
				case 'package':
					$this->uninstallPackage($nodeData);
				break;
				
				case 'pip':
					$this->executePIP($nodeData);
				break;
			}
		}
		
		// mark node as completed
		$this->nodeBuilder->completeNode($node);
		$node = $this->nodeBuilder->getNextNode($node);
		
		// perform post-uninstall actions
		if ($node == '') {
			// update options.inc.php if uninstallation is completed
			OptionEditor::resetCache();
			
			// clear cache
			CacheHandler::getInstance()->flushAll();
			
			// reset language cache
			LanguageFactory::getInstance()->clearCache();
			LanguageFactory::getInstance()->deleteLanguageCache();
			
			// reset stylesheets
			StyleHandler::resetStylesheets();
			
			// rebuild application paths
			ApplicationHandler::rebuild();
		}
		
		if ($this->requireRestructureVersionTables) {
			$this->restructureVersionTables();
		}		
		
		// return next node
		return $node;
	}
예제 #12
0
 /**
  * @see wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     // get definition cache
     CacheHandler::getInstance()->addResource('objectType-' . PACKAGE_ID, WCF_DIR . 'cache/cache.objectType-' . PACKAGE_ID . '.php', 'wcf\\system\\cache\\builder\\ObjectTypeCacheBuilder');
     $this->definitions = CacheHandler::getInstance()->get('objectType-' . PACKAGE_ID, 'definitions');
     foreach ($this->definitions as $definition) {
         $this->definitionsByName[$definition->definitionName] = $definition;
     }
     // get object type cache
     $this->objectTypes = CacheHandler::getInstance()->get('objectType-' . PACKAGE_ID, 'objectTypes');
     foreach ($this->objectTypes as $objectType) {
         $definition = $this->getDefinition($objectType->definitionID);
         if (!isset($this->groupedObjectTypes[$definition->definitionName])) {
             $this->groupedObjectTypes[$definition->definitionName] = array();
         }
         $this->groupedObjectTypes[$definition->definitionName][$objectType->objectType] = $objectType;
     }
 }
예제 #13
0
 /**
  * Loads all registered actions of the active package.
  */
 protected function loadActions()
 {
     $environment = class_exists('wcf\\system\\WCFACP', false) ? 'admin' : 'user';
     $cacheName = 'eventListener-' . PACKAGE_ID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\EventListenerCacheBuilder');
     $cache = CacheHandler::getInstance()->get($cacheName);
     if (isset($cache['actions'][$environment])) {
         $this->actions = $cache['actions'][$environment];
     }
     if (isset($cache['inheritedActions'][$environment])) {
         $this->inheritedActions = $cache['inheritedActions'][$environment];
     }
     unset($cache);
     if (!is_array($this->actions)) {
         $this->actions = array();
     }
     if (!is_array($this->inheritedActions)) {
         $this->inheritedActions = array();
     }
 }
예제 #14
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // init cache data
     $this->cacheData = array('source' => get_class(CacheHandler::getInstance()->getCacheSource()), 'version' => '', 'size' => 0, 'files' => 0);
     switch ($this->cacheData['source']) {
         case 'wcf\\system\\cache\\source\\DiskCacheSource':
             // set version
             $this->cacheData['version'] = WCF_VERSION;
             $this->readCacheFiles('data', WCF_DIR . 'cache');
             break;
         case 'wcf\\system\\cache\\source\\MemcachedCacheSource':
             // set version
             $this->cacheData['version'] = WCF_VERSION;
             break;
     }
     $this->readCacheFiles('language', FileUtil::unifyDirSeparator(WCF_DIR . 'language'));
     $this->readCacheFiles('template', FileUtil::unifyDirSeparator(WCF_DIR . 'templates/compiled'), new Regex('\\.meta\\.php$'));
     $this->readCacheFiles('template', FileUtil::unifyDirSeparator(WCF_DIR . 'acp/templates/compiled'), new Regex('\\.meta\\.php$'));
     $this->readCacheFiles('style', FileUtil::unifyDirSeparator(WCF_DIR . 'style'), null, 'css');
     $this->readCacheFiles('style', FileUtil::unifyDirSeparator(WCF_DIR . 'acp/style'), new Regex('WCFSetup.css$'), 'css');
 }
예제 #15
0
 /**
  * @see wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // delete language cache and compiled templates as well
     LanguageFactory::getInstance()->deleteLanguageCache();
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("packageID IN (?)", array(PackageDependencyHandler::getInstance()->getDependencies()));
     $conditions->add("isApplication = ?", array(1));
     // get package dirs
     $sql = "SELECT\tpackageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t" . $conditions;
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     while ($row = $statement->fetchArray()) {
         $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
         try {
             CacheHandler::getInstance()->clear($packageDir . 'cache', '*.php');
         } catch (SystemException $e) {
         }
     }
     $this->executed();
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('CacheList'));
     exit;
 }
예제 #16
0
 /**
  * @see wcf\data\IEditableCachedObject::resetCache()
  */
 public static function resetCache()
 {
     // reset cache
     CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.option-*.php');
     // reset options.inc.php files
     $sql = "SELECT\tpackage, packageID, packageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tisApplication = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(1));
     while ($row = $statement->fetchArray()) {
         if ($row['package'] == 'com.woltlab.wcf') {
             $packageDir = WCF_DIR;
         } else {
             $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
         }
         $filename = FileUtil::addTrailingSlash($packageDir) . self::FILENAME;
         if (file_exists($filename)) {
             if (!@touch($filename, 1)) {
                 if (!@unlink($filename)) {
                     self::rebuildFile($filename, $row['packageID']);
                 }
             }
         }
     }
 }
예제 #17
0
 /**
  * Initializes core object cache.
  */
 protected function initCoreObjects()
 {
     // ignore core objects if installing WCF
     if (PACKAGE_ID == 0) {
         return;
     }
     self::$coreObjectCache = CacheHandler::getInstance()->get('coreObjects-' . PACKAGE_ID);
     self::$packageDependencies = \wcf\system\package\PackageDependencyHandler::getInstance()->getDependencies();
 }
	/**
	 * Executes post-setup actions.
	 */
	public function completeSetup() {
		// mark queue as done
		$queueEditor = new PackageInstallationQueueEditor($this->queue);
		$queueEditor->update(array(
			'done' => 1
		));
		
		// remove node data
		$this->nodeBuilder->purgeNodes();
		
		// update package version
		if ($this->action == 'update') {
			$packageEditor = new PackageEditor($this->getPackage());
			$packageEditor->update(array(
				'updateDate' => TIME_NOW,
				'packageVersion' => $this->getArchive()->getPackageInfo('version')
			));
		}
		
		// clear language files once whole installation is completed
		LanguageEditor::deleteLanguageFiles();
		
		// reset all caches
		CacheHandler::getInstance()->flushAll();
	}
예제 #19
0
 /**
  * Clears the cronjob data cache.
  */
 public static function clearCache()
 {
     CacheHandler::getInstance()->clear(WCF_DIR . 'cache/', 'cache.cronjobs-' . PACKAGE_ID . '.php');
 }
예제 #20
0
 /**
  * Gets the user options from cache.
  */
 protected function readUserOptions()
 {
     $cacheName = 'user-option-' . PACKAGE_ID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\OptionCacheBuilder');
     $this->options = CacheHandler::getInstance()->get($cacheName, 'options');
     foreach ($this->options as &$option) {
         $option = new ViewableUserOption($option);
     }
     unset($option);
 }
예제 #21
0
 /**
  * Clears resources after successful installation.
  */
 protected function finalize()
 {
     // clear cache
     $sql = "SELECT\tpackageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tisApplication = 1";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute();
     while ($row = $statement->fetchArray()) {
         $cacheDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir'] . 'cache/');
         CacheHandler::getInstance()->clear($cacheDir, '*.php');
     }
 }
예제 #22
0
 /**
  * Gets all user options from cache.
  */
 protected static function getUserOptionCache()
 {
     $cacheName = 'user-option-' . PACKAGE_ID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\OptionCacheBuilder');
     self::$userOptions = CacheHandler::getInstance()->get($cacheName, 'options');
 }
예제 #23
0
 /**
  * @see wcf\data\IEditableCachedObject::resetCache()
  */
 public static function resetCache()
 {
     CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.cronjobs-*');
 }
 /**
  * @see	wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
  */
 public function uninstall()
 {
     parent::uninstall();
     // clear cache immediately
     CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.sitemap-*.php');
 }
예제 #25
0
 /**
  * Uninstalls the specified package.
  * $package may either be the packageID or the package identifier.
  * 
  * @param	mixed	$package
  */
 private function uninstall($package)
 {
     if (Package::isValidPackageName($package)) {
         $packageID = PackageCache::getInstance()->getPackageID($package);
     } else {
         $packageID = $package;
     }
     // UninstallPackageAction::prepare()
     $package = new Package($packageID);
     if (!$package->packageID || !$package->canUninstall()) {
         $this->error('invalidUninstallation');
     }
     // get new process no
     $processNo = PackageInstallationQueue::getNewProcessNo();
     // create queue
     $queue = PackageInstallationQueueEditor::create(array('processNo' => $processNo, 'userID' => CLIWCF::getUser()->userID, 'packageName' => $package->getName(), 'packageID' => $package->packageID, 'action' => 'uninstall'));
     // initialize uninstallation
     $installation = new PackageUninstallationDispatcher($queue);
     $installation->nodeBuilder->purgeNodes();
     $installation->nodeBuilder->buildNodes();
     CLIWCF::getTPL()->assign(array('queue' => $queue));
     $queueID = $installation->nodeBuilder->getQueueByNode($queue->processNo, $installation->nodeBuilder->getNextNode());
     $step = 'uninstall';
     $node = $installation->nodeBuilder->getNextNode();
     $currentAction = CLIWCF::getLanguage()->get('wcf.package.installation.step.uninstalling');
     $progress = 0;
     // initialize progressbar
     $progressbar = new ProgressBar(new ConsoleProgressBar(array('width' => CLIWCF::getTerminal()->getWidth(), 'elements' => array(ConsoleProgressBar::ELEMENT_PERCENT, ConsoleProgressBar::ELEMENT_BAR, ConsoleProgressBar::ELEMENT_TEXT), 'textWidth' => min(floor(CLIWCF::getTerminal()->getWidth() / 2), 50))));
     // InstallPackageAction::readParameters()
     $finished = false;
     while (!$finished) {
         $queue = new PackageInstallationQueue($queueID);
         $installation = new PackageUninstallationDispatcher($queue);
         switch ($step) {
             case 'uninstall':
                 $_node = $installation->uninstall($node);
                 if ($_node == '') {
                     // remove node data
                     $installation->nodeBuilder->purgeNodes();
                     // UninstallPackageAction::finalize()
                     CacheHandler::getInstance()->flushAll();
                     // /UninstallPackageAction::finalize()
                     // show success
                     $currentAction = CLIWCF::getLanguage()->get('wcf.acp.package.uninstallation.step.success');
                     $progress = 100;
                     $step = 'success';
                     $finished = true;
                     continue;
                 }
                 // continue with next node
                 $queueID = $installation->nodeBuilder->getQueueByNode($installation->queue->processNo, $installation->nodeBuilder->getNextNode($node));
                 $step = 'uninstall';
                 $progress = $installation->nodeBuilder->calculateProgress($node);
                 $node = $_node;
         }
         $progressbar->update($progress, $currentAction);
     }
     $progressbar->getAdapter()->finish();
 }
 /**
  * @see wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     $cacheName = 'packageDependencies-' . PACKAGE_ID;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.' . $cacheName . '.php', 'wcf\\system\\cache\\builder\\PackageDependencyCacheBuilder');
     $this->packageDependencyCache = CacheHandler::getInstance()->get($cacheName);
 }
예제 #27
0
파일: install.php 프로젝트: 0xLeon/WCF
$sql = "UPDATE	wcf".WCF_N."_package_installation_file_log
	SET	packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));

$sql = "UPDATE	wcf".WCF_N."_package_installation_sql_log
	SET	packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));

// update pips
$sql = "UPDATE	wcf".WCF_N."_package_installation_plugin
	SET	packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));

// group options
$sql = "UPDATE	wcf".WCF_N."_user_group_option
	SET	packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));

// reset all caches
CacheHandler::getInstance()->flushAll();

// delete language files
LanguageEditor::deleteLanguageFiles();

// delete all compiled templates
ACPTemplateEngine::deleteCompiledTemplates(WCF_DIR.'acp/templates/compiled/');
예제 #28
0
	/**
	 * Clears resources after successful installation.
	 */
	protected function finalize() {
		CacheHandler::getInstance()->flushAll();
	}
예제 #29
0
 /**
  * @see wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     CacheHandler::getInstance()->addResource('package', WCF_DIR . 'cache/cache.package.php', 'wcf\\system\\cache\\builder\\PackageCacheBuilder');
     $this->packages = CacheHandler::getInstance()->get('package');
 }
예제 #30
0
 /**
  * Copies a user group.
  */
 public function copy()
 {
     // fetch user group option values
     if ($this->parameters['copyUserGroupOptions']) {
         $sql = "SELECT\toptionID, optionValue\n\t\t\t\tFROM\twcf" . WCF_N . "_user_group_option_value\n\t\t\t\tWHERE\tgroupID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->groupEditor->groupID));
     } else {
         $sql = "SELECT\toptionID, defaultValue AS optionValue\n\t\t\t\tFROM\twcf" . WCF_N . "_user_group_option";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute();
     }
     $optionValues = array();
     while ($row = $statement->fetchArray()) {
         $optionValues[$row['optionID']] = $row['optionValue'];
     }
     $groupAction = new UserGroupAction(array(), 'create', array('data' => array('groupName' => $this->groupEditor->groupName, 'groupDescription' => $this->groupEditor->groupDescription, 'priority' => $this->groupEditor->priority, 'userOnlineMarking' => $this->groupEditor->userOnlineMarking, 'showOnTeamPage' => $this->groupEditor->showOnTeamPage), 'options' => $optionValues));
     $returnValues = $groupAction->executeAction();
     $group = $returnValues['returnValues'];
     $groupEditor = new UserGroupEditor($group);
     // update group name
     $groupName = $this->groupEditor->groupName;
     if (preg_match('~^wcf\\.acp\\.group\\.group\\d+$~', $this->groupEditor->groupName)) {
         $groupName = 'wcf.acp.group.group' . $group->groupID;
         // create group name language item
         $sql = "INSERT INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)\n\t\t\t\tSELECT\t\tlanguageID, '" . $groupName . "', CONCAT(languageItemValue, ' (2)'), 0, languageCategoryID, packageID\n\t\t\t\tFROM\t\twcf" . WCF_N . "_language_item\n\t\t\t\tWHERE\t\tlanguageItem = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->groupEditor->groupName));
     } else {
         $groupName .= ' (2)';
     }
     // update group name
     $groupDescription = $this->groupEditor->groupName;
     if (preg_match('~^wcf\\.acp\\.group\\.groupDescription\\d+$~', $this->groupEditor->groupDescription)) {
         $groupDescription = 'wcf.acp.group.groupDescription' . $group->groupID;
         // create group name language item
         $sql = "INSERT INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)\n\t\t\t\tSELECT\t\tlanguageID, '" . $groupDescription . "', languageItemValue, 0, languageCategoryID, packageID\n\t\t\t\tFROM\t\twcf" . WCF_N . "_language_item\n\t\t\t\tWHERE\t\tlanguageItem = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->groupEditor->groupDescription));
     }
     $groupEditor->update(array('groupDescription' => $groupDescription, 'groupName' => $groupName));
     // copy members
     if ($this->parameters['copyMembers']) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_user_to_group\n\t\t\t\t\t\t(userID, groupID)\n\t\t\t\tSELECT\t\tuserID, " . $group->groupID . "\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_to_group\n\t\t\t\tWHERE\t\tgroupID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->groupEditor->groupID));
     }
     // copy acl options
     if ($this->parameters['copyACLOptions']) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_acl_option_to_group\n\t\t\t\t\t\t(optionID, objectID, groupID, optionValue)\n\t\t\t\tSELECT\t\toptionID, objectID, " . $group->groupID . ", optionValue\n\t\t\t\tFROM\t\twcf" . WCF_N . "_acl_option_to_group\n\t\t\t\tWHERE\t\tgroupID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->groupEditor->groupID));
         // it is likely that applications or plugins use caches
         // for acl option values like for the labels which have
         // to be renewed after copying the acl options; because
         // there is no other way to delete these caches, we simply
         // delete all caches
         CacheHandler::getInstance()->flushAll();
     }
     // reset language cache
     LanguageFactory::getInstance()->deleteLanguageCache();
     UserGroupEditor::resetCache();
     return array('redirectURL' => LinkHandler::getInstance()->getLink('UserGroupEdit', array('id' => $group->groupID)));
 }