mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 08:09:02 +01:00
allow apps to specify to be automatic deinstalled
this can either happen uncoditional or with an SQL statement checking they are empty first: $setup_info[wiki][autodeinstall] = "SELECT COUNT(*)<=3 FROM egw_wiki_pages"; which would deinstall wiki if it has only the 3 default pages in it
This commit is contained in:
parent
0f5ff805ec
commit
a6ee8eda1b
@ -127,36 +127,7 @@ if(@$_POST['submit'])
|
||||
|
||||
if(!empty($remove) && is_array($remove))
|
||||
{
|
||||
$historylog = new Api\Storage\History();
|
||||
$historylog->db = $GLOBALS['egw_setup']->db;
|
||||
|
||||
foreach($remove as $appname => $key)
|
||||
{
|
||||
$app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name'];
|
||||
$terror = array();
|
||||
$terror[$appname] = $setup_info[$appname];
|
||||
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$GLOBALS['egw_setup']->process->droptables($terror,$DEBUG);
|
||||
echo '<br />' . $app_title . ' ' . lang('tables dropped') . '.';
|
||||
}
|
||||
|
||||
$GLOBALS['egw_setup']->deregister_app($setup_info[$appname]['name']);
|
||||
echo '<br />' . $app_title . ' ' . lang('deregistered') . '.';
|
||||
|
||||
$register_hooks = true;
|
||||
|
||||
$historylog->appname = $appname;
|
||||
if ($historylog->delete(null))
|
||||
{
|
||||
echo '<br />' . $app_title . ' ' . lang('Historylog removed') . '.';
|
||||
}
|
||||
|
||||
// delete all application categories and ACL
|
||||
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->cats_table,array('cat_appname' => $appname),__LINE__,__FILE__);
|
||||
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->acl_table,array('acl_appname' => $appname),__LINE__,__FILE__);
|
||||
}
|
||||
$register_hooks = $GLOBALS['egw_setup']->process->remove(array_keys($remove), $setup_info, $DEBUG) > 0;
|
||||
}
|
||||
|
||||
if(!empty($install) && is_array($install))
|
||||
|
@ -329,6 +329,9 @@ abstract class setup_cmd extends admin_cmd
|
||||
self::$apps_to_install[] = $app;
|
||||
}
|
||||
}
|
||||
// add autodeinstall apps
|
||||
self::$apps_to_upgrade = array_unique(array_merge(self::$apps_to_upgrade, self::check_autodeinstall()));
|
||||
|
||||
if (self::$apps_to_install)
|
||||
{
|
||||
self::_echo_message($verbose);
|
||||
@ -370,6 +373,39 @@ abstract class setup_cmd extends admin_cmd
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if app should be automatically deinstalled
|
||||
*
|
||||
* @return array with app-names to automatic deinstall
|
||||
*/
|
||||
static function check_autodeinstall()
|
||||
{
|
||||
global $setup_info;
|
||||
|
||||
$ret = array_values(array_filter(array_keys($setup_info), function($app)
|
||||
{
|
||||
global $setup_info;
|
||||
if (empty($setup_info[$app]['autodeinstall']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$autodeinstall = $setup_info[$app]['autodeinstall'];
|
||||
if (!is_bool($autodeinstall))
|
||||
{
|
||||
try {
|
||||
$autodeinstall = (bool)$GLOBALS['egw_setup']->db->query($autodeinstall, __LINE__, __FILE__)->fetchColumn();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
_egw_log_exception($e);
|
||||
$autodeinstall = false;
|
||||
}
|
||||
}
|
||||
return $autodeinstall;
|
||||
}));
|
||||
//error_log(__METHOD__."() apps=".json_encode(array_keys($setup_info)).' returning '.json_encode($ret));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Echo the given message, if $verbose
|
||||
*
|
||||
|
@ -105,8 +105,8 @@ class setup_process
|
||||
$i = 1;
|
||||
$passed = array();
|
||||
$passing = array();
|
||||
$pass_string = implode (':', $pass);
|
||||
$passing_string = implode (':', $passing);
|
||||
$pass_string = implode (':', array_keys($pass));
|
||||
$passing_string = implode (':', array_keys($passing));
|
||||
while($pass_string != $passing_string)
|
||||
{
|
||||
$passing = array();
|
||||
@ -193,9 +193,16 @@ class setup_process
|
||||
_debug_array($passed);
|
||||
exit;
|
||||
}
|
||||
$pass_string = implode (':', $pass);
|
||||
$passing_string = implode (':', $passing);
|
||||
$pass_string = implode (':', array_keys($pass));
|
||||
$passing_string = implode (':', array_keys($passing));
|
||||
}
|
||||
|
||||
// remove all apps which should be automatic deinstalled
|
||||
if (($deinstall = setup_cmd::check_autodeinstall()))
|
||||
{
|
||||
$this->remove($deinstall, $setup_info, $DEBUG);
|
||||
}
|
||||
|
||||
try {
|
||||
// flush instance cache: also registers hooks and flushes image cache
|
||||
Api\Cache::flush(Api\Cache::INSTANCE);
|
||||
@ -771,7 +778,7 @@ class setup_process
|
||||
$sColumns = null;
|
||||
$GLOBALS['egw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['egw_setup']->oProc, $tablename, $sColumns);
|
||||
|
||||
foreach($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol as $key => $tbldata)
|
||||
foreach($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol as $tbldata)
|
||||
{
|
||||
$arr .= $tbldata;
|
||||
}
|
||||
@ -782,4 +789,45 @@ class setup_process
|
||||
|
||||
return array($arr,$pk,$fk,$ix,$uc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deinstall given apps
|
||||
*
|
||||
* @param array $apps name of apps to deinstall
|
||||
* @param array $setup_info
|
||||
* @param bool $DEBUG =false
|
||||
* @return int
|
||||
*/
|
||||
function remove(array $apps, array $setup_info, $DEBUG=false)
|
||||
{
|
||||
$historylog = new Api\Storage\History();
|
||||
$historylog->db = $GLOBALS['egw_setup']->db;
|
||||
|
||||
foreach($apps as $appname)
|
||||
{
|
||||
$app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name'];
|
||||
$terror = array();
|
||||
$terror[$appname] = $setup_info[$appname];
|
||||
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$this->droptables($terror,$DEBUG);
|
||||
echo '<br />' . $app_title . ' ' . lang('tables dropped') . '.';
|
||||
}
|
||||
|
||||
$GLOBALS['egw_setup']->deregister_app($setup_info[$appname]['name']);
|
||||
echo '<br />' . $app_title . ' ' . lang('deregistered') . '.';
|
||||
|
||||
$historylog->appname = $appname;
|
||||
if ($historylog->delete(null))
|
||||
{
|
||||
echo '<br />' . $app_title . ' ' . lang('Historylog removed') . '.';
|
||||
}
|
||||
|
||||
// delete all application categories and ACL
|
||||
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->cats_table,array('cat_appname' => $appname),__LINE__,__FILE__);
|
||||
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->acl_table,array('acl_appname' => $appname),__LINE__,__FILE__);
|
||||
}
|
||||
return count($apps);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user