add button for properly uninstalling apps
This commit is contained in:
parent
c8636ca4d9
commit
020255b4e5
5 changed files with 48 additions and 11 deletions
|
@ -248,11 +248,6 @@ class OC_App{
|
|||
return false;
|
||||
}
|
||||
|
||||
$disable = self::disable($app);
|
||||
if (!$disable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return OC_Installer::removeApp($app);
|
||||
}
|
||||
|
||||
|
@ -784,10 +779,12 @@ class OC_App{
|
|||
$info['internal']=true;
|
||||
$info['internallabel']='Internal App';
|
||||
$info['internalclass']='';
|
||||
$info['removable'] = false;
|
||||
} else {
|
||||
$info['internal']=false;
|
||||
$info['internallabel']='3rd Party';
|
||||
$info['internalclass']='externalapp';
|
||||
$info['removable'] = true;
|
||||
}
|
||||
|
||||
$info['update'] = OC_Installer::isUpdateAvailable($app);
|
||||
|
@ -797,7 +794,7 @@ class OC_App{
|
|||
$appList[] = $info;
|
||||
}
|
||||
}
|
||||
$remoteApps = OC_App::getAppstoreApps();
|
||||
$remoteApps = self::getAppstoreApps();
|
||||
if ( $remoteApps ) {
|
||||
// Remove duplicates
|
||||
foreach ( $appList as $app ) {
|
||||
|
@ -876,6 +873,7 @@ class OC_App{
|
|||
$app1[$i]['ocs_id'] = $app['id'];
|
||||
$app1[$i]['internal'] = $app1[$i]['active'] = 0;
|
||||
$app1[$i]['update'] = false;
|
||||
$app1[$i]['removable'] = false;
|
||||
if($app['label']=='recommended') {
|
||||
$app1[$i]['internallabel'] = 'Recommended';
|
||||
$app1[$i]['internalclass'] = 'recommendedapp';
|
||||
|
|
|
@ -366,19 +366,25 @@ class OC_Installer{
|
|||
* The function will check if the app is already downloaded in the apps repository
|
||||
*/
|
||||
public static function isDownloaded( $name ) {
|
||||
|
||||
$downloaded=false;
|
||||
foreach(OC::$APPSROOTS as $dir) {
|
||||
if(is_dir($dir['path'].'/'.$name)) $downloaded=true;
|
||||
$dirToTest = $dir['path'];
|
||||
$dirToTest .= '/';
|
||||
$dirToTest .= $name;
|
||||
$dirToTest .= '/';
|
||||
|
||||
if (is_dir($dirToTest)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return($downloaded);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an app
|
||||
* @param string $name name of the application to remove
|
||||
* @param array $options options
|
||||
* @return boolean|null
|
||||
* @return boolean
|
||||
*
|
||||
* This function removes an app. $options is an associative array. The
|
||||
* following keys are optional:ja
|
||||
|
@ -420,9 +426,11 @@ class OC_Installer{
|
|||
$appdir=OC_App::getInstallPath().'/'.$name;
|
||||
OC_Helper::rmdirr($appdir);
|
||||
|
||||
return true;
|
||||
}else{
|
||||
OC_Log::write('core', 'can\'t remove app '.$name.'. It is not installed.', OC_Log::ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,14 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
|||
page.find('input.update').hide();
|
||||
}
|
||||
|
||||
if (app.removable !== false) {
|
||||
page.find('input.uninstall').show();
|
||||
page.find('input.uninstall').data('appid', app.id);
|
||||
page.find('input.uninstall').attr('value', t('settings', 'Uninstall App'));
|
||||
} else {
|
||||
page.find('input.uninstall').hide();
|
||||
}
|
||||
|
||||
page.find('input.enable').show();
|
||||
page.find('input.enable').val((app.active) ? t('settings', 'Disable') : t('settings', 'Enable'));
|
||||
page.find('input.enable').data('appid', app.id);
|
||||
|
@ -158,6 +166,19 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
|||
}
|
||||
},'json');
|
||||
},
|
||||
uninstallApp:function(appid, element) {
|
||||
console.log('uninstall app:', appid, element);
|
||||
element.val(t('settings','Uninstalling ....'));
|
||||
$.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appid},function(result) {
|
||||
if(!result || result.status !== 'success') {
|
||||
OC.Settings.Apps.showErrorMessage(t('settings','Error while uninstalling app'),t('settings','Error'));
|
||||
element.val(t('settings','Uninstall'));
|
||||
} else {
|
||||
OC.Settings.Apps.removeNavigation(appid);
|
||||
appitem.removeClass('active');
|
||||
}
|
||||
},'json');
|
||||
},
|
||||
|
||||
insertApp:function(appdata) {
|
||||
var applist = $('#app-navigation ul li');
|
||||
|
@ -280,6 +301,13 @@ $(document).ready(function(){
|
|||
OC.Settings.Apps.updateApp(appid, element);
|
||||
}
|
||||
});
|
||||
$('#app-content input.uninstall').click(function(){
|
||||
var element = $(this);
|
||||
var appid=$(this).data('appid');
|
||||
if(appid) {
|
||||
OC.Settings.Apps.uninstallApp(appid, element);
|
||||
}
|
||||
});
|
||||
|
||||
if(appid) {
|
||||
var item = $('#app-navigation ul li[data-id="'+appid+'"]');
|
||||
|
|
|
@ -67,6 +67,8 @@ $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php')
|
|||
->actionInclude('settings/ajax/disableapp.php');
|
||||
$this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php')
|
||||
->actionInclude('settings/ajax/updateapp.php');
|
||||
$this->create('settings_ajax_uninstallapp', '/settings/ajax/uninstallapp.php')
|
||||
->actionInclude('settings/ajax/uninstallapp.php');
|
||||
$this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php')
|
||||
->actionInclude('settings/ajax/navigationdetect.php');
|
||||
$this->create('apps_custom', '/settings/js/apps-custom.js')
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
print_unescaped($l->t('<span class="licence"></span>-licensed by <span class="author"></span>'));?></p>
|
||||
<input class="enable hidden" type="submit" />
|
||||
<input class="update hidden" type="submit" value="<?php p($l->t('Update')); ?>" />
|
||||
<input class="uninstall hidden" type="submit" value="<?php p($l->t('Uninstall')); ?>"/>
|
||||
<div class="warning hidden"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue