diff options
author | redmatrix <git@macgirvin.com> | 2016-05-03 20:37:05 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-03 20:37:05 -0700 |
commit | 191298ec93968c8c5804c021d320c536dac32c12 (patch) | |
tree | d1d8dff651f96f2174972bd1cf3080d6b8f16db2 /include | |
parent | 45c7a03a0d3e534ee121a632fc279c353015b876 (diff) | |
download | volse-hubzilla-191298ec93968c8c5804c021d320c536dac32c12.tar.gz volse-hubzilla-191298ec93968c8c5804c021d320c536dac32c12.tar.bz2 volse-hubzilla-191298ec93968c8c5804c021d320c536dac32c12.zip |
more background work for app management - give every member a copy of all the system apps so that they can edit and delete them to taste/preference. This needs further work to pick up changes in system apps (additions, edits, deletions, etc.). Currently this is done once and never attempted again.
Diffstat (limited to 'include')
-rw-r--r-- | include/apps.php | 73 | ||||
-rw-r--r-- | include/widgets.php | 4 |
2 files changed, 62 insertions, 15 deletions
diff --git a/include/apps.php b/include/apps.php index dca49a3c6..cab851b66 100644 --- a/include/apps.php +++ b/include/apps.php @@ -8,7 +8,7 @@ require_once('include/plugin.php'); require_once('include/identity.php'); -function get_system_apps() { +function get_system_apps($translate = true) { $ret = array(); if(is_dir('apps')) @@ -17,7 +17,7 @@ function get_system_apps() { $files = glob('app/*.apd'); if($files) { foreach($files as $f) { - $x = parse_app_description($f); + $x = parse_app_description($f,$translate); if($x) { $ret[] = $x; } @@ -28,7 +28,7 @@ function get_system_apps() { foreach($files as $f) { $n = basename($f,'.apd'); if(plugin_is_installed($n)) { - $x = parse_app_description($f); + $x = parse_app_description($f,$translate); if($x) { $ret[] = $x; } @@ -40,11 +40,36 @@ function get_system_apps() { } + +function import_system_apps() { + if(! local_channel()) + return; + + // Eventually we want to look at modification dates and update system apps. + + $installed = get_pconfig(local_channel(),'system','apps_installed'); + if($installed) + return; + $apps = get_system_apps(false); + if($apps) { + foreach($apps as $app) { + $app['uid'] = local_channel(); + $app['guid'] = hash('whirlpool',$app['name']); + $app['system'] = 1; + app_install(local_channel(),$app); + } + } + set_pconfig(local_channel(),'system','apps_installed',1); +} + + + + function app_name_compare($a,$b) { return strcmp($a['name'],$b['name']); } -function parse_app_description($f) { +function parse_app_description($f,$translate = true) { $ret = array(); $baseurl = z_root(); @@ -116,7 +141,8 @@ function parse_app_description($f) { } } if($ret) { - translate_system_apps($ret); + if($translate) + translate_system_apps($ret); return $ret; } return false; @@ -293,11 +319,18 @@ function app_destroy($uid,$app) { ); $x[0]['app_deleted'] = 1; - - $r = q("delete from app where app_id = '%s' and app_channel = %d", - dbesc($app['guid']), - intval($uid) - ); + if($x[0]['app_system']) { + $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", + dbesc($app['guid']), + intval($uid) + ); + } + else { + $r = q("delete from app where app_id = '%s' and app_channel = %d", + dbesc($app['guid']), + intval($uid) + ); + } build_sync_packet($uid,array('app' => $x)); } @@ -370,10 +403,12 @@ function app_store($arr) { $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); + $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0); + $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0); $created = datetime_convert(); - $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires, app_created, app_edited ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )", + $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires, app_created, app_edited, app_system, app_deleted ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", dbesc($darray['app_id']), dbesc($darray['app_sig']), dbesc($darray['app_author']), @@ -388,7 +423,9 @@ function app_store($arr) { dbesc($darray['app_page']), dbesc($darray['app_requires']), dbesc($created), - dbesc($created) + dbesc($created), + intval($darray['app_system']), + intval($darray['app_deleted']) ); if($r) { $ret['success'] = true; @@ -425,10 +462,12 @@ function app_update($arr) { $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); + $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0); + $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0); $edited = datetime_convert(); - $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s', app_edited = '%s' where app_id = '%s' and app_channel = %d", + $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s', app_edited = '%s', app_system = %d, app_deleted = %d where app_id = '%s' and app_channel = %d", dbesc($darray['app_sig']), dbesc($darray['app_author']), dbesc($darray['app_name']), @@ -441,6 +480,8 @@ function app_update($arr) { dbesc($darray['app_page']), dbesc($darray['app_requires']), dbesc($edited), + intval($darray['app_system']), + intval($darray['app_deleted']), dbesc($darray['app_id']), intval($darray['app_channel']) ); @@ -499,6 +540,12 @@ function app_encode($app,$embed = false) { if($app['app_requires']) $ret['requires'] = $app['app_requires']; + if($app['app_system']) + $ret['system'] = $app['app_system']; + + if($app['app_deleted']) + $ret['deleted'] = $app['app_deleted']; + if(! $embed) return $ret; diff --git a/include/widgets.php b/include/widgets.php index fa92901ae..1b9d3c07a 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -103,8 +103,8 @@ function widget_appselect($arr) { '$system' => t('System'), '$authed' => ((local_channel()) ? true : false), '$personal' => t('Personal'), - '$new' => t('Create Personal App'), - '$edit' => t('Edit Personal App') + '$new' => t('New App'), + '$edit' => t('Edit App') )); } |