diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/acl_selectors.php | 27 | ||||
-rw-r--r-- | include/apps.php | 84 | ||||
-rw-r--r-- | include/widgets.php | 4 |
3 files changed, 92 insertions, 23 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 92f9436a2..584a70142 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -210,12 +210,24 @@ function fixacl(&$item) { $item = str_replace(array('<','>'),array('',''),$item); } -function populate_acl($defaults = null,$show_jotnets = true, $showall = '') { +/** +* Builds a modal dialog for editing permissions, using acl_selector.tpl as the template. +* +* @param array $default Optional access control list for the initial state of the dialog. +* @param boolean $show_jotnets Whether plugins for federated networks should be included in the permissions dialog +* @param string $showall_caption An optional caption to describe the scope of an unrestricted post. e.g. "Public" +* @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent". +* @param string $context_help Allows the dialog to present a help icon. E.g. "acl_dialog_post" +* @param boolean $readonly Not implemented yet. When implemented, the dialog will use acl_readonly.tpl instead, so that permissions may be viewed for posts that can no longer have their permissions changed. +* +* @return string html modal dialog build from acl_selector.tpl +*/ +function populate_acl($defaults = null,$show_jotnets = true, $showall_caption = '', $dialog_description = '', $context_help = '', $readonly = false) { $allow_cid = $allow_gid = $deny_cid = $deny_gid = false; - if(! $showall) - $showall = t('Visible to your default audience'); + if(! $showall_caption) + $showall_caption = t('Visible to your default audience'); if(is_array($defaults)) { $allow_cid = ((strlen($defaults['allow_cid'])) @@ -239,9 +251,12 @@ function populate_acl($defaults = null,$show_jotnets = true, $showall = '') { $tpl = get_markup_template("acl_selector.tpl"); $o = replace_macros($tpl, array( - '$showall' => $showall, + '$showall' => $showall_caption, + '$showlimited' => t("Limit access:"), + '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), '$show' => t("Show"), '$hide' => t("Don't show"), + '$search' => t("Search"), '$allowcid' => json_encode($allow_cid), '$allowgid' => json_encode($allow_gid), '$denycid' => json_encode($deny_cid), @@ -249,7 +264,9 @@ function populate_acl($defaults = null,$show_jotnets = true, $showall = '') { '$jnetModalTitle' => t('Other networks and post services'), '$jotnets' => $jotnets, '$aclModalTitle' => t('Permissions'), - '$aclModalDismiss' => t('Close') + '$aclModalDesc' => $dialog_description, + '$aclModalDismiss' => t('Close'), + '$helpUrl' => (($context_help == '') ? '' : (z_root() . '/help/' . $context_help)) )); return $o; diff --git a/include/apps.php b/include/apps.php index dca49a3c6..30fed361d 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; @@ -126,8 +152,13 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { $apps = array( 'Site Admin' => t('Site Admin'), - 'Bookmarks' => t('Bookmarks'), - 'Address Book' => t('Address Book'), + 'Bug Report' => t('Bug Report'), + 'View Bookmarks' => t('View Bookmarks'), + 'My Chatrooms' => t('My Chatrooms'), + 'Connections' => t('Connections'), + 'Firefox Share' => t('Firefox Share'), + 'Remote Diagnostics' => t('Remote Diagnostics'), + 'Suggest Channels' => t('Suggest Channels'), 'Login' => t('Login'), 'Channel Manager' => t('Channel Manager'), 'Grid' => t('Grid'), @@ -135,7 +166,7 @@ function translate_system_apps(&$arr) { 'Files' => t('Files'), 'Webpages' => t('Webpages'), 'Channel Home' => t('Channel Home'), - 'Profile' => t('Profile'), + 'View Profile' => t('View Profile'), 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory'), @@ -293,11 +324,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 +408,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 +428,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 +467,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 +485,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 +545,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') )); } |