// try to unzip all setup files into temp folder
$tar = new Tar(SETUP_FILE);
$contentList = $tar->getContentList();
- if (!count($contentList)) {
+ if (empty($contentList)) {
throw new SystemException("Can not unpack 'WCFSetup.tar.gz'. File is probably broken.");
}
$this->errorType = array_merge($this->optionHandler->validate(), $this->errorType);
- if (count($this->errorType) > 0) {
+ if (!empty($this->errorType)) {
throw new UserInputException('options', $this->errorType);
}
}
public function readData() {
parent::readData();
- if (!count($_POST)) {
+ if (empty($_POST)) {
$this->optionHandler->readData();
}
}
public function readData() {
parent::readData();
- if (!count($_POST)) {
+ if (empty($_POST)) {
$this->className = $this->cronjob->className;
$this->description = $this->cronjob->description;
$this->startMinute = $this->cronjob->startMinute;
parent::readData();
// get preferred username
- if (!count($_POST)) {
+ if (empty($_POST)) {
if (isset($_COOKIE[COOKIE_PREFIX.'userID'])) {
$user = new User(intval($_COOKIE[COOKIE_PREFIX.'userID']));
if ($user->userID) $this->username = $user->username;
public function readData() {
parent::readData();
- if (!count($_POST)) {
+ if (empty($_POST)) {
$this->url = WCF::getSession()->requestURI;
}
}
// load option tree
$this->optionTree = $this->optionHandler->getOptionTree($this->category->categoryName);
- if (!count($_POST)) {
+ if (empty($_POST)) {
// not a valid top (level 1 or 2) category
if (!isset($this->optionTree[0])) {
throw new IllegalLinkException();
// validate php requirements
$errors = PackageInstallationDispatcher::validatePHPRequirements($this->archive->getPhpRequirements());
- if (count($errors)) {
+ if (!empty($errors)) {
WCF::getTPL()->assign('phpRequirements', $errors);
throw new UserInputException($type, 'phpRequirements');
}
public function validate() {
parent::validate();
- if (!count($this->updates)) {
+ if (empty($this->updates)) {
throw new UserInputException('updates');
}
try {
$this->packageUpdate->buildPackageInstallationStack();
$this->excludedPackages = $this->packageUpdate->getExcludedPackages();
- if (count($this->excludedPackages)) {
+ if (!empty($this->excludedPackages)) {
throw new UserInputException('excludedPackages');
}
}
*/
public function validate() {
parent::validate();
-
+
// refresh package database
PackageUpdateDispatcher::refreshPackageDatabase($this->packageUpdateServerIDs);
// build conditions
$conditions = new PreparedStatementConditionBuilder();
+
// update servers
- if (count($this->packageUpdateServerIDs)) $conditions->add("packageUpdateServerID IN (?)", array($this->packageUpdateServerIDs));
+ if (!empty($this->packageUpdateServerIDs)) {
+ $conditions->add("packageUpdateServerID IN (?)", array($this->packageUpdateServerIDs));
+ }
+
// name
if (!empty($this->packageName)) {
$condition = "packageName LIKE ?";
$packages[$row['package']][$row['packageUpdateID']][] = $row['packageVersion'];
}
- foreach ($packages as $identifier => $packageUpdates) {
+ foreach ($packages as $packageUpdates) {
if (count($packageUpdates) > 1) {
foreach ($packageUpdates as $packageUpdateID => $versions) {
usort($versions, array('wcf\data\package\Package', 'compareVersion'));
public function readData() {
parent::readData();
- if (!count($_POST)) {
+ if (empty($_POST)) {
$this->serverURL = $this->updateServer->serverURL;
$this->loginUsername = $this->updateServer->loginUsername;
$this->loginPassword = $this->updateServer->loginPassword;
}
// validate user groups
- if (count($this->groupIDs) > 0) {
+ if (!empty($this->groupIDs)) {
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("groupID IN (?)", array($this->groupIDs));
$conditions->add("groupType NOT IN (?)", array(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS)));
unset($this->visibleLanguages[$key]);
}
}
- if (!count($this->visibleLanguages) && ($language = LanguageFactory::getInstance()->getLanguage($this->languageID)) && $language->hasContent) {
+ if (empty($this->visibleLanguages) && ($language = LanguageFactory::getInstance()->getLanguage($this->languageID)) && $language->hasContent) {
$this->visibleLanguages[] = $this->languageID;
}
* @see wcf\page\IPage::readData()
*/
public function readData() {
- if (!count($_POST)) {
+ if (empty($_POST)) {
// get visible languages
$this->readVisibleLanguages();
$this->errorType[$e->getField()] = $e->getType();
}
- if (count($this->errorType) > 0) {
+ if (!empty($this->errorType)) {
throw new UserInputException('groupName', $this->errorType);
- }
+ }
}
/**
parent::readData();
$this->optionTree = $this->optionHandler->getOptionTree();
- if (!count($_POST)) {
+ if (empty($_POST)) {
$this->activeTabMenuItem = $this->optionTree[0]['object']->categoryName;
}
}
* @see wcf\page\IPage::readData()
*/
public function readData() {
- if (!count($_POST)) {
+ if (empty($_POST)) {
I18nHandler::getInstance()->setOptions('groupName', 1, $this->group->groupName, 'wcf.acp.group.group\d+');
$this->groupName = $this->group->groupName;
$options = $this->optionHandler->getCategoryOptions();
public function assignVariables() {
parent::assignVariables();
- $useRequestData = (count($_POST)) ? true : false;
- I18nHandler::getInstance()->assignVariables($useRequestData);
+ I18nHandler::getInstance()->assignVariables(!empty($_POST));
WCF::getTPL()->assign(array(
'groupID' => $this->group->groupID,
// do search
$this->search();
- if (count($this->matches) == 0) {
+ if (empty($this->matches)) {
throw new UserInputException('search', 'noMatches');
}
}
if (!empty($this->email)) {
$this->conditions->add("user_table.email LIKE ?", array('%'.addcslashes($this->email, '_%').'%'));
}
- if (count($this->groupIDs)) {
+ if (!empty($this->groupIDs)) {
$this->conditions->add("user_table.userID ".($this->invertGroupIDs == 1 ? 'NOT ' : '')."IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", array($this->groupIDs));
}
- if (count($this->languageIDs)) {
+ if (!empty($this->languageIDs)) {
$this->conditions->add("user_table.languageID IN (?)", array($this->languageIDs));
}
}
// assign to group
if ($this->action == 'assignToGroup') {
- if (!count($this->assignToGroupIDArray)) {
+ if (empty($this->assignToGroupIDArray)) {
throw new UserInputException('assignToGroupIDArray');
}
}
// build conditions
$this->conditions = new PreparedStatementConditionBuilder();
+
// static fields
if (!empty($this->username)) {
$this->conditions->add("user.username LIKE ?", array('%'.addcslashes($this->username, '_%').'%'));
if (!empty($this->email)) {
$this->conditions->add("user.email LIKE ?", array('%'.addcslashes($this->email, '_%').'%'));
}
- if (count($this->groupIDArray) > 0) {
+ if (!empty($this->groupIDArray)) {
$this->conditions->add("user.userID ".($this->invertGroupIDs == 1 ? 'NOT ' : '')."IN (SELECT userID FROM wcf".WCF_N."_user_to_group WHERE groupID IN (?))", array($this->groupIDArray));
}
- if (count($this->languageIDArray) > 0) {
+ if (!empty($this->languageIDArray)) {
$this->conditions->add("user.languageID IN (?)", array($this->languageIDArray));
}
public function readData() {
parent::readData();
- if (!count($_POST)) {
- if (MAIL_USE_FORMATTED_ADDRESS) $this->from = MAIL_FROM_NAME . ' <' . MAIL_FROM_ADDRESS . '>';
- else $this->from = MAIL_FROM_ADDRESS;
+ if (empty($_POST)) {
+ if (MAIL_USE_FORMATTED_ADDRESS) {
+ $this->from = MAIL_FROM_NAME.' <'.MAIL_FROM_ADDRESS.'>';
+ }
+ else {
+ $this->from = MAIL_FROM_ADDRESS;
+ }
}
$this->availableGroups = $this->getAvailableGroups();
public function readParameters() {
parent::readParameters();
- if (!count($_POST)) {
+ if (empty($_POST)) {
// refresh package database
PackageUpdateDispatcher::refreshPackageDatabase();
}
$row['packageVersions'][] = $row2['packageVersion'];
}
- if (count($row['packageVersions'])) {
+ if (!empty($row['packageVersions'])) {
// remove duplicates
$row['packageVersions'] = array_unique($row['packageVersions']);
// sort versions
// take lastest version
$row['packageVersion'] = end($row['packageVersions']);
}
-
+
// get installed instances
$sql = "SELECT package.*, CASE WHEN instanceName <> '' THEN instanceName ELSE packageName END AS packageName
FROM wcf".WCF_N."_package package
if (!empty($_REQUEST['id'])) {
$this->searchID = intval($_REQUEST['id']);
if ($this->searchID) $this->readSearchResult();
- if (!count($this->userIDs)) {
+ if (empty($this->userIDs)) {
throw new IllegalLinkException();
}
$this->conditions->add("user_table.userID IN (?)", array($this->userIDs));
}
// get user data
- if (count($userIDs)) {
+ if (!empty($userIDs)) {
$userToGroups = array();
// get group ids
}
// check modules
- if (count($this->neededModules)) {
+ if (!empty($this->neededModules)) {
foreach ($this->neededModules as $module) {
if (!defined($module) || !constant($module)) throw new IllegalLinkException();
}
}
// check permission
- if (count($this->neededPermissions)) {
+ if (!empty($this->neededPermissions)) {
WCF::getSession()->checkPermissions($this->neededPermissions);
}
}
$objects = ClipboardHandler::getInstance()->getMarkedItems($typeID);
- if (!count($objects) || !isset($objects[$this->typeName]) || !count($objects[$this->typeName])) {
+ if (empty($objects) || !isset($objects[$this->typeName]) || empty($objects[$this->typeName])) {
return null;
}
*/
public function validateCreate() {
// validate permissions
- if (is_array($this->permissionsCreate) && count($this->permissionsCreate)) {
+ if (is_array($this->permissionsCreate) && !empty($this->permissionsCreate)) {
try {
WCF::getSession()->checkPermissions($this->permissionsCreate);
}
*/
public function validateDelete() {
// validate permissions
- if (is_array($this->permissionsDelete) && count($this->permissionsDelete)) {
+ if (is_array($this->permissionsDelete) && !empty($this->permissionsDelete)) {
try {
WCF::getSession()->checkPermissions($this->permissionsDelete);
}
}
// read objects
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
- }
-
- if (!count($this->objects)) {
- throw new ValidateActionException('Invalid object id');
+
+ if (empty($this->objects)) {
+ throw new ValidateActionException('Invalid object id');
+ }
}
}
*/
public function validateUpdate() {
// validate permissions
- if (is_array($this->permissionsUpdate) && count($this->permissionsUpdate)) {
+ if (is_array($this->permissionsUpdate) && !empty($this->permissionsUpdate)) {
try {
WCF::getSession()->checkPermissions($this->permissionsUpdate);
}
}
// read objects
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
- }
-
- if (!count($this->objects)) {
- throw new ValidateActionException('Invalid object id');
+
+ if (empty($this->objects)) {
+ throw new ValidateActionException('Invalid object id');
+ }
}
}
* @see wcf\data\IDeleteAction::delete()
*/
public function delete() {
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
}
* Updates data.
*/
public function update() {
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
}
* Reads data by data id.
*/
protected function readObjects() {
- if (!count($this->objectIDs)) {
+ if (empty($this->objectIDs)) {
return;
}
* @see wcf\data\IEditableObject::update()
*/
public function update(array $parameters = array()) {
- if (!count($parameters)) return;
+ if (empty($parameters)) return;
// check whether any value changed or not
$update = false;
* @see wcf\data\IEditableObject::updateCounters()
*/
public function updateCounters(array $counters = array()) {
- if (!count($counters)) return;
+ if (empty($counters)) return;
$updateSQL = '';
$statementParameters = array();
*/
public function readObjects() {
if ($this->objectIDs !== null) {
- if (!count($this->objectIDs)) {
+ if (empty($this->objectIDs)) {
return;
}
$sql = "SELECT ".(!empty($this->sqlSelects) ? $this->sqlSelects.($this->useQualifiedShorthand ? ',' : '') : '')."
*/
public static function deleteUserSessions(array $userIDs = array()) {
$conditionBuilder = new PreparedStatementConditionBuilder();
- if (count($userIDs)) $conditionBuilder->add('userID IN (?)', array($userIDs));
+ if (!empty($userIDs)) {
+ $conditionBuilder->add('userID IN (?)', array($userIDs));
+ }
$sql = "DELETE FROM ".call_user_func(array(static::$baseClass, 'getDatabaseTableName'))."
".$conditionBuilder;
*/
public function validateCreate() {
// validate permissions
- if (count($this->permissionsCreate)) {
+ if (!empty($this->permissionsCreate)) {
try {
WCF::getSession()->checkPermissions($this->permissionsCreate);
}
*/
public function validateDelete() {
// validate permissions
- if (count($this->permissionsDelete)) {
+ if (!empty($this->permissionsDelete)) {
try {
WCF::getSession()->checkPermissions($this->permissionsDelete);
}
}
// read objects
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
- }
-
- if (!count($this->objects)) {
- throw new ValidateActionException('Invalid object id');
+
+ if (empty($this->objects)) {
+ throw new ValidateActionException('Invalid object id');
+ }
}
foreach ($this->objects as $categoryEditor) {
*/
public function validateUpdate() {
// validate permissions
- if (count($this->permissionsUpdate)) {
+ if (!empty($this->permissionsUpdate)) {
try {
WCF::getSession()->checkPermissions($this->permissionsUpdate);
}
}
// read objects
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
}
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
throw new ValidateActionException('Invalid object id');
}
*/
public function validateUpdatePosition() {
// validate permissions
- if (count($this->permissionsUpdate)) {
+ if (!empty($this->permissionsUpdate)) {
try {
WCF::getSession()->checkPermissions($this->permissionsUpdate);
}
throw new ValidateActionException('Insufficient permissions');
}
- // read data
- $this->readObjects();
-
- if (!count($this->objects)) {
- throw new ValidateActionException('Invalid object id');
+ // read objects
+ if (empty($this->objects)) {
+ $this->readObjects();
+
+ if (empty($this->objects)) {
+ throw new ValidateActionException('Invalid object id');
+ }
}
}
* @param array $packageIDs
*/
public function updateCategory(array $categoryIDs = array(), array $packageIDs = array()) {
- if (!count($categoryIDs)) {
+ if (empty($categoryIDs)) {
// get all categories
$sql = "SELECT languageCategoryID
FROM wcf".WCF_N."_language_category";
// get items
$items = array();
- if (count($packageIDArray)) {
+ if (!empty($packageIDArray)) {
// sql conditions
$conditions->add("language_item.packageID IN (?)", array($packageIDArray));
$conditions->add("language_item.languageID = ?", array($this->languageID));
$usedCategories[$category->getAttribute('name')] = 0;
}
- if (!count($usedCategories)) return;
+ if (empty($usedCategories)) return;
// select existing categories
$conditions = new PreparedStatementConditionBuilder();
}
}
- if (count($items)) {
+ if (!empty($items)) {
$existingItems = $statementParameters = array();
// find existing items
}
}
- if (count($statementParameters)) {
+ if (!empty($statementParameters)) {
if ($packageID) {
$sql = "INSERT INTO wcf".WCF_N."_language_item
(languageID, languageItem, languageItemValue, languageCategoryID, packageID)
* @param array $useCustom
*/
public function updateItems(array $items, LanguageCategory $category, $packageID = PACKAGE_ID, array $useCustom = array()) {
- if (!count($items)) return;
+ if (empty($items)) return;
// find existing language items
$languageItemList = new LanguageItemList();
}
// create remaining items
- if (count($items)) {
+ if (!empty($items)) {
// bypass LanguageItemEditor::create() for performance reasons
$sql = "INSERT INTO wcf".WCF_N."_language_item
(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)
}
// save updates
- if (count($updatedItems) > 0) {
+ if (!empty($updatedItems)) {
foreach ($updatedItems as $languageID => $categories) {
$language = new LanguageEditor($languageID);
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(0));
- if (count($languageIDs)) {
+ if (!empty($languageIDs)) {
$sql = '';
$statementParameters = array();
foreach ($languageIDs as $languageID) {
}
// update language files here
- if (count($categoriesToCache) > 0) {
+ if (!empty($categoriesToCache)) {
$file = new File($filename);
$file->write("<?php\n/**\n* WoltLab Community Framework\n* language: ".$this->languageCode."\n* encoding: UTF-8\n* category: WCF Setup\n* generated at ".gmdate("r")."\n* \n* DO NOT EDIT THIS FILE\n*/\n");
foreach ($categoriesToCache as $name) {
}
$options = array();
- if (count($optionIDs)) {
+ if (!empty($optionIDs)) {
// get needed options
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("optionID IN (?)", array($optionIDs));
}
// insert requirements of requirements
- if (count($requirements) > 0) {
+ if (!empty($requirements)) {
$sql = "INSERT INTO wcf".WCF_N."_package_requirement_map
(packageID, requirement, level)
VALUES (?, ?, ?)";
$directRequirements = array();
$conditions = new PreparedStatementConditionBuilder($sql);
$conditions->add("packageID = ?", array($packageID));
- if (count($requirements)) $conditions->add("requirement NOT IN (?)", array(array_keys($requirements)));
+ if (!empty($requirements)) {
+ $conditions->add("requirement NOT IN (?)", array(array_keys($requirements)));
+ }
$sql = "SELECT requirement,
(
}
// insert requirements
- if (count($directRequirements) > 0) {
+ if (!empty($directRequirements)) {
$sql = "INSERT INTO wcf".WCF_N."_package_requirement_map
(packageID, requirement, level)
VALUES (?, ?, ?)";
$list = new PackageUpdateServerList();
$list->sqlLimit = 0;
$list->getConditionBuilder()->add("disabled = ?", array(0));
- if (count($packageUpdateServerIDs)) {
+ if (!empty($packageUpdateServerIDs)) {
$list->getConditionBuilder()->add("packageUpdateServerID IN (?)", array($packageUpdateServerIDs));
}
$list->readObjects();
}
// get templates
- if (!count($availableTemplateIDs)) return $results;
+ if (empty($availableTemplateIDs)) return $results;
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("template.templateID IN (?)", array($availableTemplateIDs));
*/
public function validateUpdate() {
// read objects
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
- }
-
- if (!count($this->objects)) {
- throw new ValidateActionException('Invalid object id');
+
+ if (empty($this->objects)) {
+ throw new ValidateActionException('Invalid object id');
+ }
}
try {
}
}
else {
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
}
}
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add("username LIKE ?", array($searchString.'%'));
- if (count($excludedSearchValues)) {
+ if (!empty($excludedSearchValues)) {
$conditionBuilder->add("username NOT IN (?)", array($excludedSearchValues));
}
}
// insert new groups
- if (count($groupIDs) > 0) {
+ if (!empty($groupIDs)) {
$sql = "INSERT INTO wcf".WCF_N."_user_to_group
(userID, groupID)
VALUES (?, ?)";
self::getCache();
// get all groups
- if (!count($types)) return self::$cache['groups'];
+ if (empty($types)) return self::$cache['groups'];
// get groups by type
$groupIDs = self::getGroupIDsByType($types);
self::$accessibleGroups = explode(',', WCF::getSession()->getPermission('admin.user.accessibleGroups'));
}
- if (count($groupIDs) == 0) return false;
+ if (empty($groupIDs)) return false;
foreach ($groupIDs as $groupID) {
if (!in_array($groupID, self::$accessibleGroups)) {
public static function getAccessibleGroups(array $groupTypes = array(), array $invalidGroupTypes = array()) {
$groups = self::getGroupsByType($groupTypes);
- if (count($invalidGroupTypes) > 0) {
+ if (!empty($invalidGroupTypes)) {
$invalidGroups = self::getGroupsByType($invalidGroupTypes);
foreach ($invalidGroups as $groupID => $group) {
unset($groups[$groupID]);
$groupOptionIDs[$row['optionName']] = $row['optionID'];
}
- if (count($groupOptionIDs)) {
+ if (!empty($groupOptionIDs)) {
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("option_value.groupID = ?", array($this->groupID));
$conditions->add("option_value.optionID IN (?)", array($groupOptionIDs));
* @see wcf\data\AbstractDatabaseObjectAction::update()
*/
public function update() {
- if (!count($this->objects)) {
+ if (empty($this->objects)) {
$this->readObjects();
}
* @param array $groupIDs
*/
protected static function removeGroupAssignments(array $groupIDs) {
- if (!count($groupIDs)) return;
+ if (empty($groupIDs)) return;
$sql = "DELETE FROM wcf".WCF_N."_user_to_group
WHERE groupID = ?";
* @param array $groupIDs
*/
protected static function removeOptionValues(array $groupIDs) {
- if (!count($groupIDs)) return;
+ if (empty($groupIDs)) return;
$sql = "DELETE FROM wcf".WCF_N."_user_group_option_value
WHERE groupID = ?";
$optionID = $row['optionID'];
// update optionValue from groups which got all existing groups as value
- if (count($updateGroupIDs)) {
+ if (!empty($updateGroupIDs)) {
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('groupID IN (?)', array($updateGroupIDs));
$conditionBuilder->add('optionID = ?', array($optionID));
* @see wcf\page\IPage::readData()
*/
public function readData() {
- if (count($_POST) || count($_FILES)) {
+ if (!empty($_POST) || !empty($_FILES)) {
$this->submit();
}
EventHandler::getInstance()->fireAction($this, 'checkModules');
// check modules
- if (count($this->neededModules)) {
- foreach ($this->neededModules as $module) {
- if (!defined($module) || !constant($module)) {
- throw new IllegalLinkException();
- }
+ foreach ($this->neededModules as $module) {
+ if (!defined($module) || !constant($module)) {
+ throw new IllegalLinkException();
}
}
}
protected function initMagicQuotes() {
if (function_exists('get_magic_quotes_gpc')) {
if (@get_magic_quotes_gpc()) {
- if (count($_REQUEST)) {
+ if (!empty($_REQUEST)) {
$_REQUEST = util\ArrayUtil::stripslashes($_REQUEST);
}
- if (count($_POST)) {
+ if (!empty($_POST)) {
$_POST = util\ArrayUtil::stripslashes($_POST);
}
- if (count($_GET)) {
+ if (!empty($_GET)) {
$_GET = util\ArrayUtil::stripslashes($_GET);
}
- if (count($_COOKIE)) {
+ if (!empty($_COOKIE)) {
$_COOKIE = util\ArrayUtil::stripslashes($_COOKIE);
}
- if (count($_FILES)) {
+ if (!empty($_FILES)) {
foreach ($_FILES as $name => $attributes) {
foreach ($attributes as $key => $value) {
if ($key != 'tmp_name') {
// sql
$system['sql']['value'] = array_keys(self::getAvailableDBClasses());
- $system['sql']['result'] = count($system['sql']['value']) > 0;
+ $system['sql']['result'] = !empty($system['sql']['value']);
// upload_max_filesize
$system['uploadMaxFilesize']['value'] = ini_get('upload_max_filesize');
if (isset($_POST['send'])) {
try {
// no languages selected
- if (count(self::$selectedLanguages) == 0) {
+ if (empty(self::$selectedLanguages)) {
throw new UserInputException('selectedLanguages');
}
// log sql queries
preg_match_all("~CREATE\s+TABLE\s+(\w+)~i", $sql, $matches);
- if (count($matches[1])) {
+ if (!empty($matches[1])) {
$sql = "INSERT INTO wcf".WCF_N."_package_installation_sql_log
(sqlTable)
VALUES (?)";
$languages[] = $row['languageID'];
}
- if (count($languages) > 0) {
+ if (!empty($languages)) {
$sql = "INSERT INTO wcf".WCF_N."_language_to_package
(languageID)
VALUES (?)";
$itemIDs[$row['menuItem']] = $row['menuItemID'];
}
- if (count($itemIDs) > 0) {
+ if (!empty($itemIDs)) {
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("menuItemID IN (?)", array($itemIDs));
// get top option categories
$optionCategories = $this->getTopOptionCategories($packageID);
- if (count($optionCategories) > 0) {
+ if (!empty($optionCategories)) {
if (!isset($data['wcf.acp.menu.link.option.category'])) {
$data['wcf.acp.menu.link.option.category'] = array();
}
$optionCategories[$row['categoryName']] = $row['categoryID'];
}
- if (count($optionCategories) > 0) {
+ if (!empty($optionCategories) > 0) {
// get needed option categories
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("categoryID IN (?)", array($optionCategories));
$optionIDs[$row['optionName']] = $row['optionID'];
}
- if (count($optionIDs) > 0) {
+ if (!empty($optionIDs)) {
// get option class from type
$className = 'wcf\data\option\Option';
if (!empty($type)) {
$itemIDs[$row['menuItem']] = $row['menuItemID'];
}
- if (count($itemIDs) > 0) {
+ if (!empty($itemIDs)) {
// get needed menu items and build item tree
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("menu_item.menuItemID IN (?)", array($itemIDs));
$options[$row['optionName']] = $row['optionID'];
}
- if (count($options) > 0) {
+ if (!empty($options)) {
// get needed options
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs)));
* Saves modifications of the cache log.
*/
protected function updateLog() {
- if (count($this->newLogEntries)) {
+ if (!empty($this->newLogEntries)) {
$sql = "DELETE FROM wcf".WCF_N."_cache_resource
WHERE cacheResource = ?";
$statement = WCF::getDB()->prepareStatement($sql);
}
}
- if (count($this->obsoleteLogEntries)) {
+
+ if (!empty($this->obsoleteLogEntries)) {
$sql = "DELETE FROM wcf".WCF_N."_cache_resource
WHERE cacheResource = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$objectIDs[] = $row['objectID'];
}
- if (count($objectIDs)) {
+ if (!empty($objectIDs)) {
$this->executeAdapters($adapters, $objectIDs);
}
}
// get objects
$this->loadMarkedItems();
- if (!count($this->markedItems)) return null;
+ if (empty($this->markedItems)) return null;
// fetch action ids
$this->loadActionCache();
case 'delete':
$userIDs = $this->validateDelete($objects);
- if (!count($userIDs)) {
+ if (empty($userIDs)) {
return null;
}
}
// no valid users found
- if (!count($userIDs)) return array();
+ if (empty($userIDs)) return array();
// fetch user to group associations
$conditions = new PreparedStatementConditionBuilder();
$xpath = $xml->xpath();
// fetch spiders
- $spiders = $xpath->query('/spiderlist/spider');
+ $spiders = $xpath->query('/spiderlist/spider');
- if (count($spiders)) {
+ if (!empty($spiders)) {
// delete old entries
$sql = "DELETE FROM wcf".WCF_N."_spider";
$statement = WCF::getDB()->prepareStatement($sql);
try {
if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
- if (!count($parameters)) $this->pdoStatement->execute();
+ if (empty($parameters)) $this->pdoStatement->execute();
else $this->pdoStatement->execute($parameters);
if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop();
try {
if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
- if (!count($parameters)) $this->pdoStatement->execute();
+ if (empty($parameters)) $this->pdoStatement->execute();
else $this->pdoStatement->execute($parameters);
if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop();
if (!array_key_exists($count, $parameters)) {
throw new SystemException("missing parameter for token number " . ($count + 1) . " in condition '".$condition."'");
}
-
+
$result = '?';
- if (is_array($parameters[$count]) && count($parameters[$count])) {
+ if (is_array($parameters[$count]) && !empty($parameters[$count])) {
$result .= str_repeat(',?', count($parameters[$count]) - 1);
}
foreach ($familyTree as $member) {
if (isset($this->inheritedActions[$member])) {
$actions = $this->inheritedActions[$member];
- if (isset($actions[$eventName]) && count($actions[$eventName]) > 0) {
+ if (isset($actions[$eventName]) && !empty($actions[$eventName])) {
foreach ($actions[$eventName] as $action) {
if (isset($this->inheritedActionsObjects[$name][$action['listenerClassName']])) continue;
$name = self::generateKey($className, $eventName);
// execute inherited actions first
- if (count($this->inheritedActions) > 0) {
+ if (!empty($this->inheritedActions)) {
$this->executeInheritedActions($eventObj, $eventName, $className, $name);
}
*/
public function __construct($filename, $mode = 'wb', $options = array()) {
$this->filename = $filename;
- if (count($options)) {
+ if (!empty($options)) {
$context = stream_context_create($options);
$this->resource = fopen($filename, $mode, false, $context);
}
*/
public function add($files, $addDir = '', $removeDir = '') {
if (!is_array($files)) $files = array($files);
- if (!count($files)) return false;
+ if (empty($files)) return false;
$result = true;
* @throws SystemException if $i18nValues doesn't have any elements
*/
public function setValues($elementID, array $i18nValues) {
- if (!count($i18nValues)) {
+ if (empty($i18nValues)) {
throw new SystemException('Invalid argument for parameter $i18nValues', 0, 'Expected filled array as second argument. Empty array given.');
}
if (!$this->isPlainValue($elementID)) {
}
// insert language items
- if (count($insertLanguageIDs)) {
+ if (!empty($insertLanguageIDs)) {
$sql = "INSERT INTO wcf".WCF_N."_language_item
(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)
VALUES (?, ?, ?, ?, ?, ?)";
}
// update language items
- if (count($updateLanguageIDs)) {
+ if (!empty($updateLanguageIDs)) {
$sql = "UPDATE wcf".WCF_N."_language_item
SET languageItemValue = ?
WHERE languageItemID = ?";
*/
public function getLanguageByCode($languageCode) {
// called within WCFSetup
- if ($this->cache === false || !count($this->cache['codes'])) {
+ if ($this->cache === false || empty($this->cache['codes'])) {
$sql = "SELECT languageID
FROM wcf".WCF_N."_language
WHERE languageCode = ?";
* @param array<wcf\data\language\server\LanguageServer> $languageServers
*/
public function import(Language $language, array $languageServers) {
- if (!count($languageServers)) return;
+ if (empty($languageServers)) return;
$this->language = $language;
// get package list
}
// ignore variables if no package is known
- if (!count($packages)) return;
+ if (empty($packages)) return;
$this->importVariables($variables, $packages);
}
}
// create items
- if (count($createItems)) {
+ if (!empty($createItems)) {
$sql = "INSERT INTO wcf".WCF_N."_language_item
(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)
VALUES (?, ?, ?, ?, ?, ?)";
}
// update items
- if (count($updateItems)) {
+ if (!empty($updateItems)) {
$sql = "UPDATE wcf".WCF_N."_language_item
SET languageItemValue = ?
WHERE languageItemID = ?";
// create non-existing categories
$createCategories = array_diff($categoryNames, array_keys($existingCategories));
- if (count($createCategories)) {
+ if (!empty($createCategories)) {
// use raw queries for better performance
$sql = "INSERT INTO wcf".WCF_N."_language_category
(languageCategory)
if (!empty($cc)) $this->addCC($cc);
if (!empty($bcc)) $this->addBCC($bcc);
- if (count($attachments) > 0) $this->setAttachments($attachments);
+ if (!empty($attachments)) $this->setAttachments($attachments);
}
/**
*/
public function sendMail(Mail $mail) {
$this->recipients = array();
- if (count($mail->getTo()) > 0) $this->recipients = $mail->getTo();
- if (count($mail->getCC()) > 0) $this->recipients = array_merge($this->recipients, $mail->getCC());
- if (count($mail->getBCC())> 0) $this->recipients = array_merge($this->recipients, $mail->getBCC());
+ if (count($mail->getTo()) > 0) $this->recipients = $mail->getTo();
+ if (count($mail->getCC()) > 0) $this->recipients = array_merge($this->recipients, $mail->getCC());
+ if (count($mail->getBCC())> 0) $this->recipients = array_merge($this->recipients, $mail->getBCC());
// apply connection
if ($this->connection === null) {
foreach ($this->menuItems[$parentMenuItem] as $key => $item) {
$this->removeEmptyItems($item->menuItem);
- if (empty($item->menuItemLink) && (!isset($this->menuItems[$item->menuItem]) || !count($this->menuItems[$item->menuItem]))) {
+ if (empty($item->menuItemLink) && (!isset($this->menuItems[$item->menuItem]) || empty($this->menuItems[$item->menuItem]))) {
// remove this item
unset($this->menuItems[$parentMenuItem][$key]);
}
* @see wcf\system\option\ISearchableUserOption::getCondition()
*/
public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
- if (!is_array($value) || !count($value)) return false;
+ if (!is_array($value) || empty($value)) return false;
$value = ArrayUtil::trim($value);
- if (!count($value)) return false;
+ if (empty($value)) return false;
$conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value)));
return true;
* @see wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- $useRequestData = (count($_POST)) ? true : false;
- I18nHandler::getInstance()->assignVariables($useRequestData);
+ I18nHandler::getInstance()->assignVariables(!empty($_POST));
WCF::getTPL()->assign(array(
'option' => $option,
* @see wcf\system\option\IOptionType::getFormElement()
*/
public function getFormElement(Option $option, $value) {
- $useRequestData = (count($_POST)) ? true : false;
- I18nHandler::getInstance()->assignVariables($useRequestData);
+ I18nHandler::getInstance()->assignVariables(!empty($_POST));
WCF::getTPL()->assign(array(
'option' => $option,
}
// check if files from installing package are in conflict with already installed files
- if (!$this->packageInstallation->getPackage()->isApplication && count($lockedFiles) > 0) {
+ if (!$this->packageInstallation->getPackage()->isApplication && !empty($lockedFiles)) {
foreach ($fileNames as $key => $file) {
if (isset($lockedFiles[$file]) && $packageID != $lockedFiles[$file]) {
$owningPackage = new Package($lockedFiles[$file]);
}
}
- if (count($files)) {
+ if (!empty($files)) {
$sql = "INSERT INTO wcf".WCF_N."_".$this->tableName."
(packageID, templateName)
VALUES (?, ?)";
}
// check delivered files
- if (count($lockedFiles) > 0) {
+ if (!empty($lockedFiles)) {
$dir = $this->packageInstallation->getPackage()->packageDir;
foreach ($files as $key => $file) {
if (isset($lockedFiles[$dir.$file])) {
*/
public function getConflictedExcludedPackages() {
$conflictedPackages = array();
- if (count($this->excludedPackages) > 0) {
+ if (!empty($this->excludedPackages)) {
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("package IN (?)", array(array_keys($this->excludedPackages)));
// if package is plugin to com.woltlab.wcf it must not have any other requirement
$requirements = $this->getArchive()->getRequirements();
- if ($package->parentPackageID == 1 && count($requirements)) {
- foreach ($requirements as $package => $data) {
- if ($package == 'com.woltlab.wcf') continue;
- throw new SystemException('Package '.$package->package.' is plugin of com.woltlab.wcf (WCF) but has more than one requirement.');
- }
+ if ($package->parentPackageID == 1 && !empty($requirements)) {
+ foreach ($requirements as $package => $data) {
+ if ($package == 'com.woltlab.wcf') continue;
+ throw new SystemException('Package '.$package->package.' is plugin of com.woltlab.wcf (WCF) but has more than one requirement.');
+ }
}
// insert requirements and dependencies
$requirements = $this->getArchive()->getAllExistingRequirements();
- if (count($requirements) > 0) {
+ if (!empty($requirements)) {
$sql = "INSERT INTO wcf".WCF_N."_package_requirement
(packageID, requirement)
VALUES (?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($requirements as $identifier => $possibleRequirements) {
- if (count($possibleRequirements) == 1) $requirement = array_shift($possibleRequirements);
+ if (count($possibleRequirements) == 1) {
+ $requirement = array_shift($possibleRequirements);
+ }
else {
$requirement = $possibleRequirements[$this->selectedRequirements[$identifier]];
}
}
// insert nodes
- if (count($pluginNodes) > 0) {
+ if (!empty($pluginNodes)) {
$sql = "INSERT INTO wcf".WCF_N."_package_installation_node
(queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
+
foreach ($pluginNodes as $index => $nodeData) {
$statement->execute(array(
$this->installation->queue->queueID,
}
// columns
- if (count($this->columnLog)) {
+ if (!empty($this->columnLog)) {
$sql = "DELETE FROM wcf".WCF_N."_package_installation_sql_log
WHERE sqlTable = ?
AND sqlColumn = ?";
}
// indices
- if (count($this->indexLog)) {
+ if (!empty($this->indexLog)) {
$sql = "DELETE FROM wcf".WCF_N."_package_installation_sql_log
WHERE sqlTable = ?
AND sqlIndex = ?";
}
}
- if (count($authorizationRequiredException)) {
+ if (!empty($authorizationRequiredException)) {
throw array_shift($authorizationRequiredException);
}
- if (count($systemExceptions)) {
+ if (!empty($systemExceptions)) {
throw array_shift($systemExceptions);
}
public function getExcludedPackages() {
$excludedPackages = array();
- if (count($this->packageInstallationStack)) {
+ if (!empty($this->packageInstallationStack)) {
$packageInstallations = array();
$packageIdentifier = array();
foreach ($this->packageInstallationStack as $packageInstallation) {
$packageInstallations[] = $packageInstallation;
$packageIdentifier[] = $packageInstallation['package'];
}
-
+
// check exclusions of the new packages
// get package update ids
$conditions = new PreparedStatementConditionBuilder();
unset($response);
// save packages
- if (count($allNewPackages)) {
+ if (!empty($allNewPackages)) {
self::savePackageUpdates($allNewPackages, $updateServer->packageUpdateServerID);
}
unset($allNewPackages);
// get existing versions
$existingPackageVersions = array();
- if (count($existingPackages) > 0) {
+ if (!empty($existingPackages)) {
// get package update ids
$packageUpdateIDs = array();
foreach ($existingPackages as $packageUpdate) {
$versions[] = $row;
}
- if (!count($versions)) {
+ if (empty($versions)) {
throw new SystemException("Can not find package '".$package."' in version '".$version."'");
}
$templates[] = 'acp/templates/'.$row['templateName'].'.tpl';
}
- if (count($templates) > 0) {
+ if (!empty($templates)) {
// delete template files
$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
$deleteEmptyDirectories = $this->installation->getPackage()->isApplication;
$options[] = $element->getAttribute('name');
}
- if (count($options)) {
+ if (!empty($options)) {
$sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
WHERE optionName = ?
AND packageID = ?";
$categories[] = $element->getAttribute('name');
}
- if (count($categories)) {
+ if (!empty($categories)) {
// delete options for given categories
$sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
WHERE categoryName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($this->installation->getPackageID()));
- if (count($this->pages)) {
+ if (!empty($this->pages)) {
// insert pages
$sql = "INSERT INTO wcf".WCF_N."_clipboard_page
(pageClassName, packageID, actionID)
$files[] = $row['filename'];
}
- if (count($files) > 0) {
+ if (!empty($files)) {
// delete files
$this->installation->deleteFiles($packageDir, $files);
}
// save package to language
- if (count($addedLanguageIDArray)) {
+ if (!empty($addedLanguageIDArray)) {
$condition = '';
$statementParameters = array($this->installation->getPackageID());
foreach ($addedLanguageIDArray as $languageID) {
$categoryIDs[$row['languageCategoryID']] = true;
}
- if (count($itemIDs) > 0) {
+ if (!empty($itemIDs)) {
$sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
WHERE languageItemID = ?
AND packageID = ?";
}
// Delete categories from DB.
- if (count($categoriesToDelete) > 0) {
+ if (!empty($categoriesToDelete)) {
$sql = "DELETE FROM wcf".WCF_N."_language_category
WHERE languageCategory = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$styleList->readObjects();
$styles = $styleList->getObjects();
- if (count($styles)) {
+ if (!empty($styles)) {
$styleEditor = new StyleEditor($styles[0]);
$styleEditor->setAsDefault();
}
$templates[] = 'templates/'.$row['templateName'].'.tpl';
}
- if (count($templates) > 0) {
+ if (!empty($templates)) {
// delete template files
$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
$deleteEmptyDirectories = $this->installation->getPackage()->isApplication;
* @param array<integer> $userIDs
*/
public static function resetSessions(array $userIDs = array()) {
- if (count($userIDs)) {
+ if (!empty($userIDs)) {
UserStorageHandler::getInstance()->reset($userIDs, 'groupIDs', 1);
UserStorageHandler::getInstance()->reset($userIDs, 'languageIDs', 1);
}
$errors[] = array('file' => $file, 'code' => $e->getCode(), 'message' => $e->getMessage());
}
}
- if (count($errors) > 0) {
+ if (!empty($errors)) {
throw new SystemException('error(s) during the installation of the files.', $errors);
}
public function getTree() {
$tree = array();
- if (count($this->cache) > 0) {
+ if (!empty($this->cache)) {
foreach ($this->cache as $sitemap) {
$tree[] = $sitemap->sitemapName;
}
}
// add new template variables
- if (count($variables)) {
+ if (!empty($variables)) {
$this->v = array_merge($this->v, $variables);
}
}
// add new template variables
- if (count($variables)) {
+ if (!empty($variables)) {
$this->v = array_merge($this->v, $variables);
}
}
// add new template variables
- if (count($variables)) {
+ if (!empty($variables)) {
$this->v = array_merge($this->v, $variables);
}
*/
protected function loadTemplateListenerCode($templateName) {
// cache was already loaded
- if (!isset($this->templateListeners[$templateName]) || count($this->templateListeners[$templateName])) return;
+ if (!isset($this->templateListeners[$templateName]) || !empty($this->templateListeners[$templateName])) return;
$cacheName = PACKAGE_ID.'-'.$this->environment.'-'.$templateName;
CacheHandler::getInstance()->addResource(
public function shutdown() {
WCF::getDB()->beginTransaction();
// remove outdated entries
- if (count($this->resetFields)) {
+ if (!empty($this->resetFields)) {
$sql = "DELETE FROM wcf".WCF_N."_user_storage
WHERE userID = ?
AND field = ?
}
// insert data
- if (count($this->updateFields)) {
+ if (!empty($this->updateFields)) {
$sql = "INSERT INTO wcf".WCF_N."_user_storage
(userID, field, fieldValue, packageID)
VALUES (?, ?, ?, ?)";
// check for errors occured in libxml
$errors = $this->pollErrors();
- if (count($errors)) {
+ if (!empty($errors)) {
$this->throwException("XML document '".$this->path."' is not valid XML.", $errors);
}
}
// check for errors occured in libxml
$errors = $this->pollErrors();
- if (count($errors)) {
+ if (!empty($errors)) {
$this->throwException("XML document '".$this->path."' is not valid XML.", $errors);
}
}
// check for errors occured in libxml
$errors = $this->pollErrors();
- if (count($errors)) {
+ if (!empty($errors)) {
$this->throwException("XML document '".$this->path."' violates XML schema definition.", $errors);
}
}
* @param array $errors
*/
protected function throwException($message, array $errors = array()) {
- if (count($errors)) {
+ if (!empty($errors)) {
$description = '<b>LibXML output:</b><pre>';
foreach ($errors as $error) {
$description .= "#".$error['line']."\t".$error['message'];