Skip to content

Commit

Permalink
Fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
Eywek committed Oct 10, 2017
1 parent 3715b7b commit a47a21e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/Controller/Component/EyPluginComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public function download($apiID, $slug, $install = false)
// Temporary file
$filename = ROOT . DS . 'app' . DS . 'tmp' . DS . 'plugin-' . $slug . '-' . $apiID . '.zip';
$file = fopen($filename, 'w+');
if (!fwrite($file, $zip)) {
if (!fwrite($file, $apiQuery['content'])) {
$this->log('Error when downloading plugin, save files failed.');
return 'ERROR__PLUGIN_PERMISSIONS';
}
Expand Down Expand Up @@ -929,7 +929,7 @@ private function refreshPermissions()
$defaultPermissions = $this->controller->Permissions->permissions;
$pluginsPermissions = array();

foreach ($this->$pluginsLoaded as $id => $data) {
foreach ($this->pluginsLoaded as $id => $data) {
if (!isset($data->permissions->available)) continue; // no permissions on this plugin
foreach ($data->permissions->available as $key => $permission) {
$pluginsPermissions[] = $permission; // add permission to plugins permissions
Expand Down
21 changes: 15 additions & 6 deletions app/Controller/Component/ThemeComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ public function initialize($controller)
App::import('Vendor', 'load', array('file' => 'phar-io/version-master/load.php'));
}

private function getThemeFromAPI($id)
{
if (isset($this->themesAvailable['all']))
foreach ($this->themesAvailable['all'] as $theme)
if (strtolower($theme['author'] . '.' . $theme['slug'] . '.' . $theme['id']) === $id)
return $theme;
return false;
}

// get themes in folder
public function getThemesInstalled($api = true)
{
Expand Down Expand Up @@ -68,7 +77,7 @@ public function getThemesInstalled($api = true)
$config = $this->getConfig($slug);
if (empty($config) || !isset($config->apiID)) continue; // config not found
// add config
$id = strtolower($config->author . '.' . $slug . '.' . $config->apiID);;
$id = strtolower($config->author . '.' . $slug . '.' . $config->apiID);
$themesList->$id = $config;
$checkSupported = $this->checkSupported($slug);
$themesList->$id->supported = (empty($checkSupported)) ? true : false;
Expand All @@ -78,8 +87,8 @@ public function getThemesInstalled($api = true)
else
$themesList->$id->valid = false;
// set last version
if (isset($this->themesAvailable['all']) && isset($this->themesAvailable['all'][$id]))
$themesList->$id->lastVersion = $this->themesAvailable['all'][$id]['version'];
if (($theme = $this->getThemeFromAPI($id)))
$themesList->$id->lastVersion = $theme['version'];
}
// cache for this request
return $this->themesInstalled[$api] = $themesList;
Expand Down Expand Up @@ -198,7 +207,7 @@ private function checkSecure($slug)
return false;

// Check files
foreach ($content['files'] as $file => $size) {
/*foreach ($content['files'] as $file => $size) {
if (!file_exists($path . DS . $file))
return false;
if (($fileSize = filesize($path . DS . $file)) === $size)
Expand All @@ -207,7 +216,7 @@ private function checkSecure($slug)
return false;
else if ($size > $fileSize && (($fileSize / $size) * 100) < 75)
return false;
}
}*/

// Check if purchased
if (in_array($configuration['apiID'], $cache['themes'])) // in not purchased used themes list
Expand Down Expand Up @@ -396,7 +405,7 @@ public function install($apiID, $update = false, $slug = null)
$folder->delete();
if ($update) {
// Config
$config = $this->getConfig($slug);
$config = $this->getConfig($slug, true);
foreach ($config['configurations'] as $key => $value) {
if (isset($oldConfig[$key]))
$config['configurations'][$key] = $oldConfig[$key];
Expand Down
4 changes: 3 additions & 1 deletion app/Controller/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public function admin_update($componentUpdated = '0') {
$componentUpdated = ($componentUpdated) ? true : false;
if($this->Update->updateCMS($componentUpdated)) {
if($componentUpdated == '1') {
$this->Configuration->setKey('version', $this->Update->update['version']);
$lastVersion = @file_get_contents('http://api.mineweb.org/api/v2/cms/version');
$lastVersion = json_decode($lastVersion, true);
$this->Configuration->setKey('version', $lastVersion['version']);
$this->response->body(json_encode(array('statut' => 'success', 'msg' => $this->Lang->get('UPDATE__SUCCESS'))));
} else {
$this->response->body(json_encode(array('statut' => 'continue', 'msg' => '')));
Expand Down

0 comments on commit a47a21e

Please sign in to comment.