Skip to content

Commit

Permalink
Fixed issue #9888: disable comfortUpdate in config.php
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Dec 8, 2015
1 parent 9820071 commit dd3b12e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 53 deletions.
117 changes: 64 additions & 53 deletions application/models/UpdateForm.php
Expand Up @@ -60,17 +60,26 @@ public function init()
*/
public function getUpdateInfo($crosscheck="1")
{
if( $this->build != '' )
if(Yii::app()->getConfig('updatable'))
{
$crosscheck = (int) $crosscheck;
$getters = '/index.php?r=updates/updateinfo&currentbuild='.$this->build.'&id='.md5(getGlobalSetting('SessionName')).'&crosscheck='.$crosscheck;
$content = $this->_performRequest($getters);
if( $this->build != '' )
{
$crosscheck = (int) $crosscheck;
$getters = '/index.php?r=updates/updateinfo&currentbuild='.$this->build.'&id='.md5(getGlobalSetting('SessionName')).'&crosscheck='.$crosscheck;
$content = $this->_performRequest($getters);
}
else
{
$content = new stdClass();
$content->result = FALSE;
$content->error = "no_build";
}
}
else
{
$content = new stdClass();
$content->result = FALSE;
$content->error = "no_build";
$content->error = "not_updatable";
}
return $content;
}
Expand Down Expand Up @@ -535,64 +544,66 @@ public function backupDb($destionationBuild)
*/
public function getUpdateNotification()
{

$today = new DateTime("now");
$next_update_check = Yii::app()->session['next_update_check'];

if (is_null($next_update_check) || ($next_update_check < $today) || is_null(Yii::app()->session['update_result']) )
if(Yii::app()->getConfig('updatable'))
{
// Turn on the alert notification
Yii::app()->session['notificationstate']=1;
$today = new DateTime("now");
$next_update_check = Yii::app()->session['next_update_check'];

$updates = $this->getUpdateInfo('1');
$update_available = FALSE;
if($updates->result)
if (is_null($next_update_check) || ($next_update_check < $today) || is_null(Yii::app()->session['update_result']) )
{
unset($updates->result);
// Turn on the alert notification
Yii::app()->session['notificationstate']=1;

if( count($updates) > 0)
$updates = $this->getUpdateInfo('1');
$update_available = FALSE;
if($updates->result)
{
$update_available = TRUE;
$security_update_available = FALSE;
$unstable_update_available = FALSE;
foreach( $updates as $update )
{
if($update->security_update)
$security_update_available = TRUE;
unset($updates->result);

if($update->branch != 'master')
$unstable_update_available = TRUE;
if( count($updates) > 0)
{
$update_available = TRUE;
$security_update_available = FALSE;
$unstable_update_available = FALSE;
foreach( $updates as $update )
{
if($update->security_update)
$security_update_available = TRUE;

if($update->branch != 'master')
$unstable_update_available = TRUE;
}
}
Yii::app()->session['update_result'] = $update_available;
Yii::app()->session['security_update'] = $security_update_available;

// If only one update is available and it's an unstable one, then it will be displayed in a different color, and will be removed, not minified when clicked
if( count((array)$updates) == 1 && $unstable_update_available )
Yii::app()->session['unstable_update'] = $unstable_update_available;
else
Yii::app()->session['unstable_update'] = false;

$next_update_check = $today->add(new DateInterval('P1D'));
Yii::app()->session['next_update_check'] = $next_update_check;
$updates = array('result'=>$update_available , 'security_update'=>$security_update_available, 'unstable_update'=>$unstable_update_available);
}
else
{
$next_update_check = $today->add(new DateInterval('P1D'));
Yii::app()->session['next_update_check'] = $next_update_check;
Yii::app()->session['update_result'] = false;
Yii::app()->session['unstable_update'] = false;
}
}
Yii::app()->session['update_result'] = $update_available;
Yii::app()->session['security_update'] = $security_update_available;

// If only one update is available and it's an unstable one, then it will be displayed in a different color, and will be removed, not minified when clicked
if( count((array)$updates) == 1 && $unstable_update_available )
Yii::app()->session['unstable_update'] = $unstable_update_available;
else
Yii::app()->session['unstable_update'] = false;

$next_update_check = $today->add(new DateInterval('P1D'));
Yii::app()->session['next_update_check'] = $next_update_check;
$updates = array('result'=>$update_available , 'security_update'=>$security_update_available, 'unstable_update'=>$unstable_update_available);
}
else
{
$next_update_check = $today->add(new DateInterval('P1D'));
Yii::app()->session['next_update_check'] = $next_update_check;
Yii::app()->session['update_result'] = false;
Yii::app()->session['unstable_update'] = false;
}
}
else
{
$update_available = Yii::app()->session['update_result'];
$unstable_update_available = Yii::app()->session['unstable_update'];
$security_update_available = Yii::app()->session['security_update'];
$updates = array('result'=>$update_available , 'security_update'=>$security_update_available, 'unstable_update'=>$unstable_update_available);
{
$update_available = Yii::app()->session['update_result'];
$unstable_update_available = Yii::app()->session['unstable_update'];
$security_update_available = Yii::app()->session['security_update'];
$updates = array('result'=>$update_available , 'security_update'=>$security_update_available, 'unstable_update'=>$unstable_update_available);
}
return (object) $updates;
}
return (object) $updates;
}


Expand Down
Expand Up @@ -46,6 +46,12 @@
$sMessage = gT("It seems you're using a version coming from the LimeSurvey GitHub repository. You can't use ComfortUpdate.");
break;

case 'not_updatable':
$sTile = gT('Error!');
$sHeader = gT('No build version found!');
$sMessage = gT("You disabled comfortUpdate in your configuration file.");
break;

default :
$sTile = gT('Error!');
$sHeader = gT('Unknown error!');
Expand Down

0 comments on commit dd3b12e

Please sign in to comment.