Skip to content

Commit

Permalink
Fixed issue #9822: Unable to upload image on server via KCFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Aug 21, 2015
1 parent 5b90968 commit 89eb467
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
39 changes: 31 additions & 8 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1304,10 +1304,15 @@ function db_upgrade_all($iOldDBVersion) {
upgradeSurveyTables181();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>181),"stg_name='DBVersion'");
}
if ($iOldDBVersion < 182)
if ($iOldDBVersion < 183)
{
fixKCFinder182();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>182),"stg_name='DBVersion'");
upgradeSurveyTables183();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>183),"stg_name='DBVersion'");
}
if ($iOldDBVersion < 184)
{
fixKCFinder184();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>184),"stg_name='DBVersion'");
}
$oTransaction->commit();
// Activate schema caching
Expand Down Expand Up @@ -1353,15 +1358,15 @@ function upgradeSurveyTables183()
}


function fixKCFinder182()
function fixKCFinder184()
{
$sThirdPartyDir=Yii::app()->getConfig('standardtemplaterootdir').DIRECTORY_SEPARATOR.'third_party'.DIRECTORY_SEPARATOR;
$sThirdPartyDir=Yii::app()->getConfig('homedir').DIRECTORY_SEPARATOR.'third_party'.DIRECTORY_SEPARATOR;
rmdirr($sThirdPartyDir.'ckeditor/plugins/toolbar');
rmdirr($sThirdPartyDir.'ckeditor/plugins/toolbar/ls-office2003');
array_map('unlink', glob($sThirdPartyDir.'kcfinder/cache/*.js'));
array_map('unlink', glob($sThirdPartyDir.'kcfinder/cache/*.css'));
rmdirr($sThirdPartyDir.'kcfinder/upload/files');
rmdirr($sThirdPartyDir.'kcfinder/upload/.htumbs');
rmdirr($sThirdPartyDir.'kcfinder/upload/.thumbs');
}


Expand Down Expand Up @@ -1430,8 +1435,15 @@ function upgradeTokenTables179()
{
$oDB = Yii::app()->db;
$oSchema = Yii::app()->db->schema;
if(Yii::app()->db->driverName=='mssql' || Yii::app()->db->driverName=='mysql') $sSubstringCommand='substring'; else $sSubstringCommand='substr';

switch (Yii::app()->db->driverName){
case 'sqlsrv':
case 'dblib':
case 'mssql':
$sSubstringCommand='substring';
break;
default:
$sSubstringCommand='substr';
}
$surveyidresult = dbGetTablesLike("tokens%");
if ($surveyidresult)
{
Expand Down Expand Up @@ -2194,6 +2206,9 @@ function alterLanguageCode($sOldLanguageCode,$sNewLanguageCode)
}
}

/**
* @param string $sTablename
*/
function addPrimaryKey($sTablename, $aColumns)
{
return Yii::app()->db->createCommand()->addPrimaryKey('PRIMARY', '{{'.$sTablename.'}}', $aColumns);
Expand All @@ -2218,6 +2233,7 @@ function dropPrimaryKey($sTablename)
Yii::app()->db->createCommand($sQuery)->execute();
break;
case 'pgsql':
case 'sqlsrv':
case 'mssql':
$pkquery = "SELECT CONSTRAINT_NAME "
."FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS "
Expand Down Expand Up @@ -2290,6 +2306,10 @@ function alterColumn($sTable, $sColumn, $sFieldType, $bAllowNull=true, $sDefault
}


/**
* @param string $sTableName
* @param string $sColumnName
*/
function dropColumn($sTableName, $sColumnName)
{
if (Yii::app()->db->getDriverName()=='mssql' || Yii::app()->db->getDriverName()=='sqlsrv' || Yii::app()->db->getDriverName()=='dblib')
Expand All @@ -2303,6 +2323,9 @@ function dropColumn($sTableName, $sColumnName)



/**
* @param string $sType
*/
function addColumn($sTableName, $sColumn, $sType)
{
Yii::app()->db->createCommand()->addColumn($sTableName,$sColumn,$sType);
Expand Down
2 changes: 1 addition & 1 deletion installer/sql/create-mssql.sql
Expand Up @@ -566,4 +566,4 @@ create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '182');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '184');
2 changes: 1 addition & 1 deletion installer/sql/create-mysql.sql
Expand Up @@ -575,4 +575,4 @@ CREATE INDEX `parent_qid_idx` ON `prefix_questions` (`parent_qid`);
--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '182');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '184');
2 changes: 1 addition & 1 deletion installer/sql/create-pgsql.sql
Expand Up @@ -576,4 +576,4 @@ create unique index permissions_idx2 ON prefix_permissions (entity_id, entity, u
--
-- Version Info
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '182');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '184');

0 comments on commit 89eb467

Please sign in to comment.