Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dev: The file list the updater of the ComfortUpdate must check its pe…
…rmission is now provided by the ComfortUpdate Server

Dev: subscribe page text is now in LimeSurvey installation for translation
  • Loading branch information
louis committed Aug 27, 2015
1 parent 0f99273 commit 9009a75
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 67 deletions.
2 changes: 1 addition & 1 deletion application/config/updater_version.php
Expand Up @@ -15,7 +15,7 @@

// THIS FILE SHOULD NOT BE CHANGED MANUALLY !

$config['updaterversion'] = 2;
$config['updaterversion'] = 5;
$config['comfort_update_server_url'] = 'comfortupdate.limesurvey.org/';
$config['comfort_update_server_ssl'] = 0;
return $config;
Expand Down
2 changes: 2 additions & 0 deletions application/controllers/admin/update.php
Expand Up @@ -331,6 +331,8 @@ public function updateUpdater()
$unzip = $updateModel->unzipUpdateUpdaterFile();
if( $unzip->result )
{
$updateModel->removeTmpFile('update_updater.zip');
$updateModel->removeTmpFile('comfort_updater_cookie.txt');
return $this->controller->renderPartial('update/updater/steps/_updater_updated', array('destinationBuild'=>$destinationBuild), false, false);
}
else
Expand Down
74 changes: 11 additions & 63 deletions application/models/UpdateForm.php
Expand Up @@ -172,38 +172,19 @@ public function getLocalChecks($destinationBuild)
*/
public function getLocalChecksForUpdater()
{
$toCheck = array(
'config'.DIRECTORY_SEPARATOR.'updater_version.php',
'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'update.php',
'models'.DIRECTORY_SEPARATOR.'UpdateForm.php',
'..'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'ajax-loader.gif',);

$toCheckRecurive = array(
'views'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'',
'..'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'comfortupdate'.DIRECTORY_SEPARATOR );


$getters = '/index.php?r=updates/filesystemchecklistforupdater';
$content = $this->_performRequest($getters);
$toCheck = $content->list;
$readOnly = array();

// We check the write permission of files
$lsRootPath = dirname(Yii::app()->request->scriptFile).'/';
foreach( $toCheck as $check )
{
if( !is_writable( APPPATH . $check ) )
if( !is_writable( $lsRootPath . $check ) )
{
$readOnly[] = APPPATH . $check ;
}
}

// We check the write permission of directories and their content
// TODO : a beautifull recursive function
foreach( $toCheckRecurive as $check )
{
$start_directory = APPPATH . $check;
$readOnly = $this->_checkDirectoryAndItsFiles( $start_directory , $readOnly);

$check_all_subdirectories = $this->_getAllSubDirectories( $start_directory, DIRECTORY_SEPARATOR );
foreach ($check_all_subdirectories as $directory)
{
$readOnly = $this->_checkDirectoryAndItsFiles( $directory , $readOnly);
$readOnly[] = $lsRootPath . $check ;
}
}

Expand Down Expand Up @@ -540,13 +521,15 @@ public function backupDb($destionationBuild)
*/
public function getUpdateNotification()
{

$crosscheck = (getGlobalSetting('updatenotification')=="both")?1:0;
$today = new DateTime("now");

$next_update_check = Yii::app()->session['next_update_check'];

if (is_null($next_update_check) || ($next_update_check < $today) )
if (is_null($next_update_check) || ($next_update_check < $today) || is_null(Yii::app()->session['update_result']) )
{
echo "processing";
$updates = $this->getUpdateInfo($crosscheck="1");
$update_available = FALSE;
if($updates->result)
Expand Down Expand Up @@ -676,7 +659,7 @@ private function _getReadOnlyCheckedFile($file)
$searchpath = $this->rootdir . $file['file'];
$is_writable = is_writable(dirname($searchpath));

// LOUIS : snippet from the original code. It supposed to go up in the file sytem : if one directory need to be deleted... TODO : check if it works, if it's needed...
// LOUIS : snippet from the original code.
while ( !$is_writable && strlen($searchpath) > strlen($this->rootdir) )
{
$searchpath = dirname($searchpath);
Expand All @@ -701,41 +684,6 @@ private function _getReadOnlyCheckedFile($file)
return $checkedfile;
}

/**
* Check if a given directory and its files are writable
* Used by the Updater of the Updater
*/
private function _checkDirectoryAndItsFiles($start_directory , $readOnly)
{
if(! is_writable( realpath ( $start_directory )) )
$readOnly[] = realpath ( $start_directory ) ;

$pattern = '*.*';
$files = glob ( $start_directory.$pattern );

foreach( $files as $file )
{
if(! is_writable( $file ))
$readOnly[] = $file ;
}
return $readOnly;
}

/**
* Return a list of all the subdirectories (and their own subdirectories) of a given directory
* Used by the Updater of the Updater
*/
private function _getAllSubDirectories( $directory, $directory_seperator )
{
$dirs = array_map( function($item)use($directory_seperator){ return $item . $directory_seperator;}, array_filter( glob( $directory . '*' ), 'is_dir') );

foreach( $dirs AS $dir )
{
$dirs = array_merge( $dirs, $this->_getAllSubDirectories( $dir, $directory_seperator ) );
}

return $dirs;
}


/**
Expand Down
18 changes: 15 additions & 3 deletions application/views/admin/update/updater/welcome/_subscribe.php
Expand Up @@ -4,7 +4,7 @@
* The javascript inject it inside the div#updaterContainer, in the _updater view. (like any steps)
*/
?>
<h2 class="maintitle"><?php eT($serverAnswer->title);?></h2>
<h2 class="maintitle"><?php eT("Subscribe to the ComfortUpdate!");?></h2>

<?php
if( isset($serverAnswer->html) )
Expand All @@ -13,8 +13,20 @@

<div class="updater-background">
<br/>
<?php echo html_entity_decode($serverAnswer->message); ?>

<?php eT('The LimeSurvey ComfortUpdate is an easy procedure to quickly update to the latest version of LimeSurvey.');?><br/>
<?php
$aopen = '<a href="https://www.limesurvey.org/en/your-account/your-details" target="_blank">';
$aclose = '</a>';

?>
<?php echo sprintf(gT("To use it, you need an update key. You can get an update key from %s your account in limesurvey.org website. %s"),$aopen, $aclose); ?>
<?php
$aopen = '<a href="https://www.limesurvey.org/en/cb-registration/registers">';
$aclose = '</a>';

?>
<?php echo sprintf(gT("If you don't have an account in limesurvey.org website, please, %s register first %s"),$aopen, $aclose);?><br/>

<?php
$url = Yii::app()->createUrl('/admin/update/sa/submitkey');
echo CHtml::beginForm($url, 'post', array("id"=>"submitKeyForm"));
Expand Down

0 comments on commit 9009a75

Please sign in to comment.