diff --git a/bin/dev/minifyjs.sh b/bin/dev/minifyjs.sh index 50a56a45c..caa2b3846 100755 --- a/bin/dev/minifyjs.sh +++ b/bin/dev/minifyjs.sh @@ -5,16 +5,13 @@ command -v uglifyjs >/dev/null 2>&1 || { echo >&2 "I require UglifyJS but it's n MINIFY_CMD=uglifyjs JSFILES=( - "view/js/acl.js" "view/js/ajaxupload.js" "view/js/country.js" "view/js/main.js" "vendor/asset/base64/base64.min.js" - "view/theme/frost/js/acl.js" "view/theme/frost/js/jquery.divgrow-1.3.1.f1.js" "view/theme/frost/js/main.js" "view/theme/frost/js/theme.js" - "view/theme/frost-mobile/js/acl.js" "view/theme/frost-mobile/js/jquery.divgrow-1.3.1.f1.js" "view/theme/frost-mobile/js/main.js" "view/theme/frost-mobile/js/theme.js" diff --git a/mod/community.php b/mod/community.php index 81857c6d3..4d98f0c4f 100644 --- a/mod/community.php +++ b/mod/community.php @@ -125,7 +125,7 @@ function community_content(App $a, $update = 0) 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'), - 'acl' => ACL::getFullSelectorHTML($a->user, true), + 'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), diff --git a/mod/display.php b/mod/display.php index 12fa8d7ec..175616f98 100644 --- a/mod/display.php +++ b/mod/display.php @@ -304,7 +304,7 @@ function display_content(App $a, $update = false, $update_uid = 0) 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'), - 'acl' => ACL::getFullSelectorHTML($a->user, true), + 'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), diff --git a/mod/events.php b/mod/events.php index 11bb25f51..a642f1665 100644 --- a/mod/events.php +++ b/mod/events.php @@ -13,6 +13,7 @@ use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; +use Friendica\Core\Theme; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Model\Event; @@ -384,6 +385,12 @@ function events_content(App $a) $events[$key]['item'] = $event_item; } + // ACL blocks are loaded in modals in frio + $a->page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $a->page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $a->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $a->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); + $o = Renderer::replaceMacros($tpl, [ '$tabs' => $tabs, '$title' => L10n::t('Events'), @@ -486,7 +493,7 @@ function events_content(App $a) $perms = ACL::getDefaultUserPermissions($orig_event); if (!$cid && in_array($mode, ['new', 'copy'])) { - $acl = ACL::getFullSelectorHTML($a->user, false, $orig_event); + $acl = ACL::getFullSelectorHTML($a->page, $a->user, false, $perms); } else { $acl = ''; } @@ -506,11 +513,6 @@ function events_content(App $a) '$cid' => $cid, '$uri' => $uri, - '$allow_cid' => json_encode($perms['allow_cid']), - '$allow_gid' => json_encode($perms['allow_gid']), - '$deny_cid' => json_encode($perms['deny_cid']), - '$deny_gid' => json_encode($perms['deny_gid']), - '$title' => L10n::t('Event details'), '$desc' => L10n::t('Starting date and Title are required.'), '$s_text' => L10n::t('Event Starts:') . ' *', diff --git a/mod/network.php b/mod/network.php index 5fbfa9a5d..44c7c8b44 100644 --- a/mod/network.php +++ b/mod/network.php @@ -377,7 +377,7 @@ function networkFlatView(App $a, $update = 0) (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'), 'default_perms' => ACL::getDefaultUserPermissions($a->user), - 'acl' => ACL::getFullSelectorHTML($a->user, true), + 'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), @@ -554,7 +554,7 @@ function networkThreadedView(App $a, $update, $parent) (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'), 'default_perms' => ACL::getDefaultUserPermissions($a->user), - 'acl' => ACL::getFullSelectorHTML($a->user, true, $default_permissions), + 'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true, $default_permissions), 'bang' => (($gid || $cid || $nets) ? '!' : ''), 'visitor' => 'block', 'profile_uid' => local_user(), diff --git a/mod/photos.php b/mod/photos.php index e0630e7dc..684e525d4 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -960,7 +960,7 @@ function photos_content(App $a) $tpl = Renderer::getMarkupTemplate('photos_upload.tpl'); - $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML($a->user)); + $aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML($a->page, $a->user)); $o .= Renderer::replaceMacros($tpl,[ '$pagename' => L10n::t('Upload Photos'), @@ -1332,7 +1332,7 @@ function photos_content(App $a) $album_e = $ph[0]['album']; $caption_e = $ph[0]['desc']; - $aclselect_e = ACL::getFullSelectorHTML($a->user, false, $ph[0]); + $aclselect_e = ACL::getFullSelectorHTML($a->page, $a->user, false, $ph[0]); $edit = Renderer::replaceMacros($edit_tpl, [ '$id' => $ph[0]['id'], diff --git a/mod/settings.php b/mod/settings.php index 45867c7ef..c7fcbc0e5 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -1206,7 +1206,7 @@ function settings_content(App $a) '$permissions' => L10n::t('Default Post Permissions'), '$permdesc' => L10n::t("\x28click to open/close\x29"), '$visibility' => $profile['net-publish'], - '$aclselect' => ACL::getFullSelectorHTML($a->user), + '$aclselect' => ACL::getFullSelectorHTML($a->page, $a->user), '$suggestme' => $suggestme, '$blockwall'=> $blockwall, // array('blockwall', L10n::t('Allow friends to post to your profile page:'), !$blockwall, ''), '$blocktags'=> $blocktags, // array('blocktags', L10n::t('Allow friends to tag your posts:'), !$blocktags, ''), diff --git a/src/App/Page.php b/src/App/Page.php index 7af0bc899..7b3bc286f 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -15,6 +15,7 @@ use Friendica\Core\Renderer; use Friendica\Core\Theme; use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Network\HTTPException; +use Friendica\Util\Strings; /** * Contains the page specific environment variables for the current Page @@ -224,15 +225,15 @@ class Page implements ArrayAccess * being first */ $this->page['htmlhead'] = Renderer::replaceMacros($tpl, [ - '$local_user' => local_user(), - '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION, - '$delitem' => $l10n->t('Delete this item?'), - '$update_interval' => $interval, - '$shortcut_icon' => $shortcut_icon, - '$touch_icon' => $touch_icon, - '$block_public' => intval($config->get('system', 'block_public')), - '$stylesheets' => $this->stylesheets, - ]) . $this->page['htmlhead']; + '$local_user' => local_user(), + '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION, + '$delitem' => $l10n->t('Delete this item?'), + '$update_interval' => $interval, + '$shortcut_icon' => $shortcut_icon, + '$touch_icon' => $touch_icon, + '$block_public' => intval($config->get('system', 'block_public')), + '$stylesheets' => array_unique($this->stylesheets), + ]) . $this->page['htmlhead']; } /** @@ -282,8 +283,8 @@ class Page implements ArrayAccess $tpl = Renderer::getMarkupTemplate('footer.tpl'); $this->page['footer'] = Renderer::replaceMacros($tpl, [ - '$footerScripts' => $this->footerScripts, - ]) . $this->page['footer']; + '$footerScripts' => array_unique($this->footerScripts), + ]) . $this->page['footer']; } /** @@ -455,13 +456,13 @@ class Page implements ArrayAccess * to load another page template than the default one. * The page templates are located in /view/php/ or in the theme directory. */ - if (isset($_GET["mode"])) { - $template = Theme::getPathForFile($_GET["mode"] . '.php'); + if (isset($_GET['mode'])) { + $template = Theme::getPathForFile('php/' . Strings::sanitizeFilePathItem($_GET['mode']) . '.php'); } // If there is no page template use the default page template if (empty($template)) { - $template = Theme::getPathForFile("default.php"); + $template = Theme::getPathForFile('php/default.php'); } // Theme templates expect $a as an App instance @@ -470,7 +471,6 @@ class Page implements ArrayAccess // Used as is in view/php/default.php $lang = $l10n->getCurrentLang(); - /// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything require_once $template; } } diff --git a/src/Core/ACL.php b/src/Core/ACL.php index df2f86e2b..880a1e47f 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -6,13 +6,11 @@ namespace Friendica\Core; +use Friendica\App\Page; use Friendica\BaseObject; -use Friendica\Content\Feature; use Friendica\Database\DBA; use Friendica\Model\Contact; -use Friendica\Model\GContact; -use Friendica\Core\Session; -use Friendica\Util\Network; +use Friendica\Model\Group; /** * Handle ACL management and display @@ -251,29 +249,110 @@ class ACL extends BaseObject ]; } + /** + * Returns the ACL list of contacts for a given user id + * + * @param int $user_id + * @return array + * @throws \Exception + */ + public static function getContactListByUserId(int $user_id) + { + $acl_contacts = Contact::selectToArray( + ['id', 'name', 'addr', 'micro'], + ['uid' => $user_id, 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]] + ); + array_walk($acl_contacts, function (&$value) { + $value['type'] = 'contact'; + }); + + return $acl_contacts; + } + + /** + * Returns the ACL list of groups (including meta-groups) for a given user id + * + * @param int $user_id + * @return array + */ + public static function getGroupListByUserId(int $user_id) + { + $acl_groups = [ + [ + 'id' => Group::FOLLOWERS, + 'name' => L10n::t('Followers'), + 'addr' => '', + 'micro' => 'images/twopeople.png', + 'type' => 'group', + ], + [ + 'id' => Group::MUTUALS, + 'name' => L10n::t('Mutuals'), + 'addr' => '', + 'micro' => 'images/twopeople.png', + 'type' => 'group', + ] + ]; + foreach (Group::getByUserId($user_id) as $group) { + $acl_groups[] = [ + 'id' => $group['id'], + 'name' => $group['name'], + 'addr' => '', + 'micro' => 'images/twopeople.png', + 'type' => 'group', + ]; + } + + return $acl_groups; + } + /** * Return the full jot ACL selector HTML * + * @param Page $page * @param array $user User array - * @param bool $show_jotnets - * @param array $default_permissions Static defaults permission array: ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''] + * @param bool $for_federation + * @param array $default_permissions Static defaults permission array: + * [ + * 'allow_cid' => [], + * 'allow_gid' => [], + * 'deny_cid' => [], + * 'deny_gid' => [], + * 'hidewall' => true/false + * ] * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function getFullSelectorHTML(array $user = null, $show_jotnets = false, array $default_permissions = []) + public static function getFullSelectorHTML(Page $page, array $user = null, bool $for_federation = false, array $default_permissions = []) { + $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); + // Defaults user permissions if (empty($default_permissions)) { $default_permissions = self::getDefaultUserPermissions($user); } + if (count($default_permissions['allow_cid']) + + count($default_permissions['allow_gid']) + + count($default_permissions['deny_cid']) + + count($default_permissions['deny_gid'])) { + $visibility = 'custom'; + } else { + $visibility = 'public'; + // Default permission display for custom panel + $default_permissions['allow_gid'] = [Group::FOLLOWERS]; + } + $jotnets_fields = []; - if ($show_jotnets) { + if ($for_federation) { $mail_enabled = false; $pubmail_enabled = false; if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) { - $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]); + $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', $user['úid']]); if (DBA::isResult($mailacct)) { $mail_enabled = true; $pubmail_enabled = !empty($mailacct['pubmail']); @@ -296,27 +375,35 @@ class ACL extends BaseObject } } + $acl_contacts = self::getContactListByUserId($user['uid']); + + $acl_groups = self::getGroupListByUserId($user['uid']); + + $acl_list = array_merge($acl_groups, $acl_contacts); + $tpl = Renderer::getMarkupTemplate('acl_selector.tpl'); $o = Renderer::replaceMacros($tpl, [ - '$showall' => L10n::t('Visible to everybody'), - '$show' => L10n::t('show'), - '$hide' => L10n::t('don\'t show'), - '$allowcid' => json_encode(($default_permissions['allow_cid'] ?? '') ?: []), // We need arrays for - '$allowgid' => json_encode(($default_permissions['allow_gid'] ?? '') ?: []), // Javascript since we - '$denycid' => json_encode(($default_permissions['deny_cid'] ?? '') ?: []), // call .remove() and - '$denygid' => json_encode(($default_permissions['deny_gid'] ?? '') ?: []), // .push() on these values - '$networks' => $show_jotnets, - '$emailcc' => L10n::t('CC: email addresses'), - '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'), - '$jotnets_enabled' => empty($default_permissions['hidewall']), + '$public_title' => L10n::t('Public'), + '$public_desc' => L10n::t('This content will be shown to all your followers and can be seen in the community pages and by anyone with its link.'), + '$custom_title' => L10n::t('Limited/Private'), + '$custom_desc' => L10n::t('This content will be shown only to the people in the first box, to the exception of the people mentioned in the second box. It won\'t appear anywhere public.'), + '$allow_label' => L10n::t('Show to:'), + '$deny_label' => L10n::t('Except to:'), + '$emailcc' => L10n::t('CC: email addresses'), + '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'), '$jotnets_summary' => L10n::t('Connectors'), - '$jotnets_fields' => $jotnets_fields, '$jotnets_disabled_label' => L10n::t('Connectors disabled, since "%s" is enabled.', L10n::t('Hide your profile details from unknown viewers?')), - '$aclModalTitle' => L10n::t('Permissions'), - '$aclModalDismiss' => L10n::t('Close'), - '$features' => [ - 'aclautomention' => !empty($user['uid']) && Feature::isEnabled($user['uid'], 'aclautomention') ? 'true' : 'false' - ], + '$visibility' => $visibility, + '$acl_contacts' => $acl_contacts, + '$acl_groups' => $acl_groups, + '$acl_list' => $acl_list, + '$contact_allow' => implode(',', $default_permissions['allow_cid']), + '$group_allow' => implode(',', $default_permissions['allow_gid']), + '$contact_deny' => implode(',', $default_permissions['deny_cid']), + '$group_deny' => implode(',', $default_permissions['deny_gid']), + '$for_federation' => $for_federation, + '$jotnets_fields' => $jotnets_fields, + '$user_hidewall' => $default_permissions['hidewall'], ]); return $o; diff --git a/src/Core/Theme.php b/src/Core/Theme.php index 61798a396..7a59f1132 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -185,45 +185,33 @@ class Theme /** * @brief Get the full path to relevant theme files by filename * - * This function search in the theme directory (and if not present in global theme directory) - * if there is a directory with the file extension and for a file with the given - * filename. + * This function searches in order in the current theme directory, in the current theme parent directory, and lastly + * in the base view/ folder. * * @param string $file Filename - * @param string $root Full root path * @return string Path to the file or empty string if the file isn't found - * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \Exception */ - public static function getPathForFile($file, $root = '') + public static function getPathForFile($file) { - $file = basename($file); + $a = BaseObject::getApp(); + + $theme = $a->getCurrentTheme(); + + $parent = Strings::sanitizeFilePathItem($a->theme_info['extends'] ?? $theme); - // Make sure $root ends with a slash / if it's not blank - if ($root !== '' && $root[strlen($root) - 1] !== '/') { - $root = $root . '/'; - } - $theme_info = \get_app()->theme_info; - if (is_array($theme_info) && array_key_exists('extends', $theme_info)) { - $parent = $theme_info['extends']; - } else { - $parent = 'NOPATH'; - } - $theme = \get_app()->getCurrentTheme(); - $parent = Strings::sanitizeFilePathItem($parent); - $ext = substr($file, strrpos($file, '.') + 1); $paths = [ - "{$root}view/theme/$theme/$ext/$file", - "{$root}view/theme/$parent/$ext/$file", - "{$root}view/$ext/$file", + "view/theme/$theme/$file", + "view/theme/$parent/$file", + "view/$file", ]; - foreach ($paths as $p) { - // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) - if (strpos($p, 'NOPATH') !== false) { - continue; - } elseif (file_exists($p)) { - return $p; + + foreach ($paths as $path) { + if (file_exists($path)) { + return $path; } } + return ''; } diff --git a/src/Module/Bookmarklet.php b/src/Module/Bookmarklet.php index a50f23c25..08bac2c1d 100644 --- a/src/Module/Bookmarklet.php +++ b/src/Module/Bookmarklet.php @@ -44,7 +44,7 @@ class Bookmarklet extends BaseModule 'nickname' => $app->user['nickname'], 'lockstate' => ((is_array($app->user) && ((strlen($app->user['allow_cid'])) || (strlen($app->user['allow_gid'])) || (strlen($app->user['deny_cid'])) || (strlen($app->user['deny_gid'])))) ? 'lock' : 'unlock'), 'default_perms' => ACL::getDefaultUserPermissions($app->user), - 'acl' => ACL::getFullSelectorHTML($app->user, true), + 'acl' => ACL::getFullSelectorHTML($app->page, $app->user, true), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), diff --git a/src/Module/Contact.php b/src/Module/Contact.php index ded5ffbe2..5ef06b72a 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -926,7 +926,7 @@ class Contact extends BaseModule 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'), - 'acl' => ACL::getFullSelectorHTML($a->user, true), + 'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index ad0a2d805..db44ee3d1 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -4,10 +4,13 @@ namespace Friendica\Module\Item; use Friendica\BaseModule; use Friendica\Content\Feature; +use Friendica\Core\ACL; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\Core\System; +use Friendica\Core\Theme; use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\FileTag; @@ -45,7 +48,7 @@ class Compose extends BaseModule } /// @TODO Retrieve parameter from router - $posttype = $a->argv[1] ?? Item::PT_ARTICLE; + $posttype = $parameters['type'] ?? Item::PT_ARTICLE; if (!in_array($posttype, [Item::PT_ARTICLE, Item::PT_PERSONAL_NOTE])) { switch ($posttype) { case 'note': @@ -62,20 +65,37 @@ class Compose extends BaseModule /** @var ACLFormatter $aclFormatter */ $aclFormatter = self::getClass(ACLFormatter::class); + $contact_allow_list = $aclFormatter->expand($user['allow_cid']); + $group_allow_list = $aclFormatter->expand($user['allow_gid']); + $contact_deny_list = $aclFormatter->expand($user['deny_cid']); + $group_deny_list = $aclFormatter->expand($user['deny_gid']); + switch ($posttype) { case Item::PT_PERSONAL_NOTE: $compose_title = L10n::t('Compose new personal note'); $type = 'note'; $doesFederate = false; - $contact_allow = $a->contact['id']; - $group_allow = ''; + $contact_allow_list = [$a->contact['id']]; + $group_allow_list = []; + $contact_deny_list = []; + $group_deny_list = []; break; default: $compose_title = L10n::t('Compose new post'); $type = 'post'; $doesFederate = true; - $contact_allow = implode(',', $aclFormatter->expand($user['allow_cid'])); - $group_allow = implode(',', $aclFormatter->expand($user['allow_gid'])) ?: Group::FOLLOWERS; + + if ($_REQUEST['contact_allow'] + . $_REQUEST['group_allow'] + . $_REQUEST['contact_deny'] + . $_REQUEST['group_deny']) + { + $contact_allow_list = $_REQUEST['contact_allow'] ? explode(',', $_REQUEST['contact_allow']) : []; + $group_allow_list = $_REQUEST['group_allow'] ? explode(',', $_REQUEST['group_allow']) : []; + $contact_deny_list = $_REQUEST['contact_deny'] ? explode(',', $_REQUEST['contact_deny']) : []; + $group_deny_list = $_REQUEST['group_deny'] ? explode(',', $_REQUEST['group_deny']) : []; + } + break; } @@ -84,93 +104,19 @@ class Compose extends BaseModule $body = $_REQUEST['body'] ?? ''; $location = $_REQUEST['location'] ?? $user['default-location']; $wall = $_REQUEST['wall'] ?? $type == 'post'; - $contact_allow = $_REQUEST['contact_allow'] ?? $contact_allow; - $group_allow = $_REQUEST['group_allow'] ?? $group_allow; - $contact_deny = $_REQUEST['contact_deny'] ?? implode(',', $aclFormatter->expand($user['deny_cid'])); - $group_deny = $_REQUEST['group_deny'] ?? implode(',', $aclFormatter->expand($user['deny_gid'])); - $visibility = ($contact_allow . $user['allow_gid'] . $user['deny_cid'] . $user['deny_gid']) ? 'custom' : 'public'; - - $acl_contacts = Contact::selectToArray(['id', 'name', 'addr', 'micro'], ['uid' => local_user(), 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]]); - array_walk($acl_contacts, function (&$value) { - $value['type'] = 'contact'; - }); - - $acl_groups = [ - [ - 'id' => Group::FOLLOWERS, - 'name' => L10n::t('Followers'), - 'addr' => '', - 'micro' => 'images/twopeople.png', - 'type' => 'group', - ], - [ - 'id' => Group::MUTUALS, - 'name' => L10n::t('Mutuals'), - 'addr' => '', - 'micro' => 'images/twopeople.png', - 'type' => 'group', - ] - ]; - foreach (Group::getByUserId(local_user()) as $group) { - $acl_groups[] = [ - 'id' => $group['id'], - 'name' => $group['name'], - 'addr' => '', - 'micro' => 'images/twopeople.png', - 'type' => 'group', - ]; - } - - $acl = array_merge($acl_groups, $acl_contacts); - - $jotnets_fields = []; - $mail_enabled = false; - $pubmail_enabled = false; - if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) { - $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]); - if (DBA::isResult($mailacct)) { - $mail_enabled = true; - $pubmail_enabled = !empty($mailacct['pubmail']); - } - } - - if (empty($user['hidewall'])) { - if ($mail_enabled) { - $jotnets_fields[] = [ - 'type' => 'checkbox', - 'field' => [ - 'pubmail_enable', - L10n::t('Post to Email'), - $pubmail_enabled - ] - ]; - } - - Hook::callAll('jot_networks', $jotnets_fields); - } $jotplugins = ''; Hook::callAll('jot_tool', $jotplugins); // Output - - $a->registerFooterScript('view/js/ajaxupload.js'); - $a->registerFooterScript('view/js/linkPreview.js'); - $a->registerFooterScript('view/asset/typeahead.js/dist/typeahead.bundle.js'); - $a->registerFooterScript('view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.js'); - $a->registerStylesheet('view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.css'); - $a->registerStylesheet('view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput-typeahead.css'); - - $tpl = Renderer::getMarkupTemplate('item/compose-footer.tpl'); - $a->page['footer'] .= Renderer::replaceMacros($tpl, [ - '$acl_contacts' => $acl_contacts, - '$acl_groups' => $acl_groups, - '$acl' => $acl, - ]); + $a->page->registerFooterScript(Theme::getPathForFile('js/ajaxupload.js')); + $a->page->registerFooterScript(Theme::getPathForFile('js/linkPreview.js')); + $a->page->registerFooterScript(Theme::getPathForFile('js/compose.js')); $tpl = Renderer::getMarkupTemplate('item/compose.tpl'); return Renderer::replaceMacros($tpl, [ '$compose_title'=> $compose_title, + '$visibility_title'=> L10n::t('Visibility'), '$id' => 0, '$posttype' => $posttype, '$type' => $type, @@ -197,25 +143,26 @@ class Compose extends BaseModule '$wait' => L10n::t('Please wait'), '$placeholdertitle' => L10n::t('Set title'), '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t('Categories (comma-separated list)') : ''), - '$public_title' => L10n::t('Public'), - '$public_desc' => L10n::t('This post will be sent to all your followers and can be seen in the community pages and by anyone with its link.'), - '$custom_title' => L10n::t('Limited/Private'), - '$custom_desc' => L10n::t('This post will be sent only to the people in the first box, to the exception of the people mentioned in the second box. It won\'t appear anywhere public.'), - '$emailcc' => L10n::t('CC: email addresses'), + '$title' => $title, '$category' => $category, '$body' => $body, '$location' => $location, - '$visibility' => $visibility, - '$contact_allow'=> $contact_allow, - '$group_allow' => $group_allow, - '$contact_deny' => $contact_deny, - '$group_deny' => $group_deny, + + '$contact_allow'=> implode(',', $contact_allow_list), + '$group_allow' => implode(',', $group_allow_list), + '$contact_deny' => implode(',', $contact_deny_list), + '$group_deny' => implode(',', $group_deny_list), + '$jotplugins' => $jotplugins, - '$doesFederate' => $doesFederate, - '$jotnets_fields'=> $jotnets_fields, '$sourceapp' => L10n::t($a->sourcename), - '$rand_num' => Crypto::randomDigits(12) + '$rand_num' => Crypto::randomDigits(12), + '$acl_selector' => ACL::getFullSelectorHTML($a->page, $a->user, $doesFederate, [ + 'allow_cid' => $contact_allow_list, + 'allow_gid' => $group_allow_list, + 'deny_cid' => $contact_deny_list, + 'deny_gid' => $group_deny_list, + ]), ]); } } diff --git a/src/Module/Profile.php b/src/Module/Profile.php index aab591856..db1a6f86b 100644 --- a/src/Module/Profile.php +++ b/src/Module/Profile.php @@ -208,7 +208,7 @@ class Profile extends BaseModule || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid']) ) ? 'lock' : 'unlock', - 'acl' => $is_owner ? ACL::getFullSelectorHTML($a->user, true) : '', + 'acl' => $is_owner ? ACL::getFullSelectorHTML($a->page, $a->user, true) : '', 'bang' => '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $a->profile['profile_uid'], diff --git a/view/js/acl.js b/view/js/acl.js deleted file mode 100644 index b50dbaec8..000000000 --- a/view/js/acl.js +++ /dev/null @@ -1,376 +0,0 @@ -// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later -function ACL(backend_url, preset, automention, is_mobile){ - - this.url = backend_url; - this.automention = automention; - this.is_mobile = is_mobile; - - - this.kp_timer = null; - - if (preset == undefined) { - preset = []; - } - this.allow_cid = (preset[0] || []); - this.allow_gid = (preset[1] || []); - this.deny_cid = (preset[2] || []); - this.deny_gid = (preset[3] || []); - this.group_uids = []; - this.forumCache = null; - - if (this.is_mobile) { - this.nw = 1; - } else { - this.nw = 4; - } - - - this.list_content = $("#acl-list-content"); - this.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html()); - this.showall = $("#acl-showall"); - - if (preset.length==0) { - this.showall.addClass("selected"); - } - - /*events*/ - this.showall.click(this.on_showall.bind(this)); - $(document).on("click", ".acl-button-show", this.on_button_show.bind(this)); - $(document).on("click", ".acl-button-hide", this.on_button_hide.bind(this)); - $("#acl-search").keypress(this.on_search.bind(this)); - $("#acl-wrapper").parents("form").submit(this.on_submit.bind(this)); - - /* add/remove mentions */ - this.element = $("#profile-jot-text"); - this.htmlelm = this.element.get()[0]; -} - -ACL.prototype.remove_mention = function(id) { - if (!this.automention) { - return; - } - var nick = this.data[id].nick; - var addr = this.data[id].addr; - - if (addr != "") { - var searchText = "!" + addr + " "; - } else { - var searchText = "!" + nick + "+" + id + " "; - } - - var start = this.element.val().indexOf(searchText); - if (start < 0) { - return; - } - var end = start + searchText.length; - this.element.setSelection(start, end).replaceSelectedText('').collapseSelection(false); -}; - -ACL.prototype.add_mention = function(id) { - if (!this.automention) { - return; - } - var nick = this.data[id].nick; - var addr = this.data[id].addr; - - if (addr != "") { - var searchText = "!" + addr + " "; - } else { - var searchText = "!" + nick + "+" + id + " "; - } - - if (this.element.val().indexOf( searchText) >= 0 ) { - return; - } - this.element.val(searchText + this.element.val()).trigger('change'); -} - -ACL.prototype.on_submit = function(){ - var aclfields = $("#acl-fields").html(""); - $(this.allow_gid).each(function(i,v){ - aclfields.append(""); - }); - $(this.allow_cid).each(function(i,v){ - aclfields.append(""); - }); - $(this.deny_gid).each(function(i,v){ - aclfields.append(""); - }); - $(this.deny_cid).each(function(i,v){ - aclfields.append(""); - }); -}; - -ACL.prototype.search = function(){ - var srcstr = $("#acl-search").val(); - this.list_content.html(""); - this.get(0,100, srcstr); -}; - -ACL.prototype.on_search = function(event){ - if (this.kp_timer) clearTimeout(this.kp_timer); - - // Triggers an immediate search while preventing form submission - if (event.key === 'Enter') { - this.search(); - event.preventDefault(); - } else { - this.kp_timer = setTimeout( this.search.bind(this), 500); - } -}; - -ACL.prototype.on_showall = function(event){ - event.preventDefault() - event.stopPropagation(); - - if (this.showall.hasClass("selected")){ - return false; - } - this.showall.addClass("selected"); - - this.allow_cid = []; - this.allow_gid = []; - this.deny_cid = []; - this.deny_gid = []; - - this.update_view(); - - return false; -}; - -ACL.prototype.on_button_show = function(event){ - event.preventDefault() - event.stopImmediatePropagation() - event.stopPropagation(); - - this.set_allow($(event.target).parent().attr('id')); - - return false; -}; - -ACL.prototype.on_button_hide = function(event){ - event.preventDefault() - event.stopImmediatePropagation() - event.stopPropagation(); - - this.set_deny($(event.target).parent().attr('id')); - - return false; -}; - -ACL.prototype.set_allow = function(itemid) { - type = itemid[0]; - id = parseInt(itemid.substr(1)); - - switch (type){ - case "g": - if (this.allow_gid.indexOf(id) < 0) { - this.allow_gid.push(id); - }else { - this.allow_gid.remove(id); - } - if (this.deny_gid.indexOf(id) >= 0) { - this.deny_gid.remove(id); - } - break; - case "c": - if (this.allow_cid.indexOf(id) < 0){ - this.allow_cid.push(id); - if (this.data[id].forum == "1") { - // If we have select already a forum, - // we need to remove the old one (because friendica does - // allow only one forum as receiver). - if (this.forumCache !== null && this.forumCache !== id) { - this.deselectCid(this.forumCache); - } - // Update the forum cache. - this.forumCache = id; - this.add_mention(id); - } - } else { - this.allow_cid.remove(id); - if (this.data[id].forum == "1") { - this.remove_mention(id); - } - } - if (this.deny_cid.indexOf(id) >=0 ) { - this.deny_cid.remove(id); - } - break; - } - this.update_view(); -}; - -ACL.prototype.set_deny = function(itemid){ - type = itemid[0]; - id = parseInt(itemid.substr(1)); - - switch(type){ - case "g": - if (this.deny_gid.indexOf(id)<0){ - this.deny_gid.push(id) - } else { - this.deny_gid.remove(id); - } - if (this.allow_gid.indexOf(id)>=0) this.allow_gid.remove(id); - break; - case "c": - if (this.data[id].forum=="1") this.remove_mention(id); - if (this.deny_cid.indexOf(id)<0){ - this.deny_cid.push(id) - } else { - this.deny_cid.remove(id); - } - if (this.allow_cid.indexOf(id)>=0) this.allow_cid.remove(id); - break; - } - this.update_view(); -}; - -ACL.prototype.is_show_all = function() { - return (this.allow_gid.length==0 && this.allow_cid.length==0 && - this.deny_gid.length==0 && this.deny_cid.length==0); -}; - -ACL.prototype.update_view = function () { - if (this.is_show_all()) { - this.showall.addClass("selected"); - /* jot acl */ - $('#jot-perms-icon').removeClass('lock').addClass('unlock'); - $('#jot-public').show(); - $('.profile-jot-net input[type=checkbox]').each(function() { - // Restores checkbox state if it had been saved - if ($(this).attr('data-checked') !== undefined) { - $(this).prop('checked', $(this).attr('data-checked') === 'true'); - } - }); - - $('.profile-jot-net input').attr('disabled', false); - if (typeof editor != 'undefined' && editor != false) { - $('#profile-jot-desc').html(ispublic); - } - } else { - this.showall.removeClass("selected"); - /* jot acl */ - $('#jot-perms-icon').removeClass('unlock').addClass('lock'); - $('#jot-public').hide(); - $('.profile-jot-net input[type=checkbox]').each(function() { - // Saves current checkbox state - $(this) - .attr('data-checked', $(this).prop('checked')) - .prop('checked', false); - }); - $('.profile-jot-net input').attr('disabled', 'disabled'); - $('#profile-jot-desc').html(' '); - } - - $("#acl-list-content .acl-list-item").each(function (index, element) { - $(this).removeClass("groupshow grouphide"); - - itemid = $(element).attr('id'); - type = itemid[0]; - id = parseInt(itemid.substr(1)); - - btshow = $(element).children(".acl-button-show").removeClass("selected"); - bthide = $(element).children(".acl-button-hide").removeClass("selected"); - - switch (type) { - case "g": - var uclass = ""; - if (this.allow_gid.indexOf(id) >= 0) { - btshow.addClass("selected"); - bthide.removeClass("selected"); - uclass = "groupshow"; - } - if (this.deny_gid.indexOf(id) >= 0) { - btshow.removeClass("selected"); - bthide.addClass("selected"); - uclass = "grouphide"; - } - - $(this.group_uids[id]).each(function (i, v) { - if (uclass == "grouphide") - $("#c" + v).removeClass("groupshow"); - if (uclass != "") { - var cls = $("#c" + v).attr('class'); - if (cls == undefined) - return true; - var hiding = cls.indexOf('grouphide'); - if (hiding == -1) - $("#c" + v).addClass(uclass); - } - }); - - break; - case "c": - if (this.allow_cid.indexOf(id) >= 0) { - btshow.addClass("selected"); - bthide.removeClass("selected"); - } - if (this.deny_cid.indexOf(id) >= 0) { - btshow.removeClass("selected"); - bthide.addClass("selected"); - } - } - - }.bind(this)); - -}; - -ACL.prototype.get = function(start,count, search){ - var postdata = { - start:start, - count:count, - search:search, - } - - $.ajax({ - type:'POST', - url: this.url, - data: postdata, - dataType: 'json', - success:this.populate.bind(this) - }); -}; - -ACL.prototype.populate = function(data){ - var height = Math.ceil(data.tot / this.nw) * 42; - this.list_content.height(height); - this.data = {}; - $(data.items).each(function(index, item) { - if (item.separator != undefined) { - html = "
"; - } else { - html = "
"+this.item_tpl+"
"; - html = html.format(item.photo, item.name, item.type, item.id, (item.forum=='1'?'forum':''), item.network, item.link); - if (item.uids != undefined) { - this.group_uids[item.id] = item.uids; - } - } - this.list_content.append(html); - this.data[item.id] = item; - }.bind(this)); - $(".acl-list-item img[data-src]", this.list_content).each(function(i, el){ - // Add src attribute for images with a data-src attribute - $(el).attr('src', $(el).data("src")); - }); - - this.update_view(); -}; - -/** - * @brief Deselect previous selected contact. - * - * @param {int} id The contact ID. - * @returns {void} - */ -ACL.prototype.deselectCid = function(id) { - if (this.allow_cid.indexOf(id) >= 0) { - this.allow_cid.remove(id); - } - if (this.deny_cid.indexOf(id) >=0 ) { - this.deny_cid.remove(id); - } - this.remove_mention(id); -}; -// @license-end diff --git a/view/theme/frio/frameworks/friendica-tagsinput/LICENSE b/view/js/friendica-tagsinput/LICENSE similarity index 100% rename from view/theme/frio/frameworks/friendica-tagsinput/LICENSE rename to view/js/friendica-tagsinput/LICENSE diff --git a/view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput-typeahead.css b/view/js/friendica-tagsinput/friendica-tagsinput-typeahead.css similarity index 100% rename from view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput-typeahead.css rename to view/js/friendica-tagsinput/friendica-tagsinput-typeahead.css diff --git a/view/js/friendica-tagsinput/friendica-tagsinput.css b/view/js/friendica-tagsinput/friendica-tagsinput.css new file mode 100644 index 000000000..6ad1d0015 --- /dev/null +++ b/view/js/friendica-tagsinput/friendica-tagsinput.css @@ -0,0 +1,155 @@ +/* + * friendica-tagsinput v0.8.0 + * + * Non-Bootstrap edition + */ + +.label { + display: inline; + padding: .2em .6em .3em; + font-size: 75%; + font-weight: 700; + line-height: 1; + color: #fff; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: .25em; +} + +.label-default { + background-color: #777777; +} +.label-default[href]:hover, +.label-default[href]:focus { + background-color: #5e5e5e; +} +.label-primary { + background-color: #337ab7; +} +.label-primary[href]:hover, +.label-primary[href]:focus { + background-color: #286090; +} +.label-success { + background-color: #5cb85c; +} +.label-success[href]:hover, +.label-success[href]:focus { + background-color: #449d44; +} +.label-info { + background-color: #5bc0de; +} +.label-info[href]:hover, +.label-info[href]:focus { + background-color: #31b0d5; +} +.label-warning { + background-color: #f0ad4e; +} +.label-warning[href]:hover, +.label-warning[href]:focus { + background-color: #ec971f; +} +.label-danger { + background-color: #d9534f; +} +.label-danger[href]:hover, +.label-danger[href]:focus { + background-color: #c9302c; +} + +.form-control[disabled], +.form-control[readonly], +fieldset[disabled] .form-control { + background-color: #eeeeee; + opacity: 1; +} +.form-control[disabled], +fieldset[disabled] .form-control { + cursor: not-allowed; +} + + + + +.friendica-tagsinput { + background-color: #fff; + border: 1px solid #ccc; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + display: inline-block; + padding: 4px 6px; + color: #555; + vertical-align: middle; + border-radius: 4px; + max-width: 100%; + line-height: 22px; + cursor: text; + height: auto; +} + +.friendica-tagsinput.input-lg { + line-height: 27px; +} + +.friendica-tagsinput input { + border: none; + box-shadow: none; + outline: none; + background-color: transparent; + padding: 0 6px; + margin: 0; + width: auto; + max-width: inherit; +} + +.friendica-tagsinput.form-control input::-moz-placeholder { + color: #777; + opacity: 1; +} + +.friendica-tagsinput.form-control input:-ms-input-placeholder { + color: #777; +} + +.friendica-tagsinput.form-control input::-webkit-input-placeholder { + color: #777; +} + +.friendica-tagsinput input:focus { + border: none; + box-shadow: none; +} + +.friendica-tagsinput .tag { + margin: 0 2px 2px 0; + color: white; + font-weight: normal; +} + +.friendica-tagsinput .tag img { + width: auto; + height: 1.5em; + vertical-align: text-top; + margin-right: 8px; +} + +.friendica-tagsinput .tag [data-role="remove"] { + margin-left: 8px; + cursor: pointer; +} + +.friendica-tagsinput .tag [data-role="remove"]:after { + content: "x"; + padding: 0px 2px; + font-weight: bold; +} + +.friendica-tagsinput .tag [data-role="remove"]:hover { + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.friendica-tagsinput .tag [data-role="remove"]:hover:active { + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); +} diff --git a/view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.js b/view/js/friendica-tagsinput/friendica-tagsinput.js similarity index 100% rename from view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.js rename to view/js/friendica-tagsinput/friendica-tagsinput.js diff --git a/view/js/linkPreview.js b/view/js/linkPreview.js index 09493eeba..f7278ce5b 100644 --- a/view/js/linkPreview.js +++ b/view/js/linkPreview.js @@ -14,40 +14,39 @@ $.fn.linkPreview = function (options) { var opts = jQuery.extend({}, $.fn.linkPreview.defaults, options); - var selector = $(this).selector; - selector = selector.substr(1); + var id = $(this).attr('id'); var previewTpl = '\ -
\ +
\ {1}\ - \ - \ - \ + \ + \ + \
'; var attachmentTpl = '\
\ -
\ +
\ \
\ -
\ -
\ - \
\ -
\ +
\
\ - \ - \ - \ - \ + \ + \ + \ + \
\ -
\ -

\ -
\ -
\ - \ +
\ +

\ +
\ +
\ + \
\
\
'; @@ -72,7 +71,7 @@ * @returns {void} */ var init = function() { - $('#' + selector).bind({ + $('#' + id).bind({ paste: function () { setTimeout(function () { crawlText(); @@ -88,7 +87,7 @@ // Check if we have already attachment bbcode in the textarea // and add it to the attachment preview. - var content = $('#' + selector).val(); + var content = $('#' + id).val(); addBBCodeToPreview(content); }; @@ -98,7 +97,7 @@ * @returns {void} */ var resetPreview = function() { - $('#hasAttachment_' + selector).val(0); + $('#hasAttachment_' + id).val(0); photoNumber = 0; images = ""; }; @@ -121,7 +120,7 @@ // If no text is passed to crawlText() we // take the previous word before the cursor. if (typeof text === 'undefined') { - text = getPrevWord(selector); + text = getPrevWord(id); } else { isExtern = true; } @@ -254,7 +253,7 @@ return; } - $('#photoNumber_' + selector).val(0); + $('#photoNumber_' + id).val(0); resetPreview(); processAttachmentTpl(data, 'type-' + data.type); @@ -275,7 +274,7 @@ */ var processAttachmentTpl = function(data) { // Load and add the template if it isn't allready loaded. - if ($('#preview_' + selector).length === 0) { + if ($('#preview_' + id).length === 0) { var tpl = previewTpl.format( 'type-' + data.type, attachmentTpl, @@ -283,7 +282,7 @@ bin2hex(data.url), data.type ); - $('#' + selector).after(tpl); + $('#' + id).after(tpl); } isActive = true; @@ -303,14 +302,14 @@ description = defaultDescription; } - $('#previewTitle_' + selector).html("\ - " + escapeHTML(data.title) + "\ - " + $('#previewTitle_' + id).html("\ + " + escapeHTML(data.title) + "\ + " ); - $('#previewDescription_' + selector).html("\ - " + escapeHTML(description) + "\n\ - " + $('#previewDescription_' + id).html("\ + " + escapeHTML(description) + "\n\ + " ); }; @@ -325,7 +324,7 @@ var regexpr = "(https?://)([^:^/]*)(:\\d*)?(.*)?"; var regResult = url.match(regexpr); var urlHost = regResult[1] + regResult[2]; - $('#previewUrl_' + selector).html("" + urlHost + ""); + $('#previewUrl_' + id).html("" + urlHost + ""); } }; @@ -340,12 +339,12 @@ var imageClass = 'attachment-preview'; if (Array.isArray(images)) { - $('#previewImages_' + selector).show(); - $('#attachmentImageSrc_' + selector).val(bin2hex(images[photoNumber].src)); - $('#attachmentImageWidth_' + selector).val(images[photoNumber].width); - $('#attachmentImageHeight_' + selector).val(images[photoNumber].height); + $('#previewImages_' + id).show(); + $('#attachmentImageSrc_' + id).val(bin2hex(images[photoNumber].src)); + $('#attachmentImageWidth_' + id).val(images[photoNumber].width); + $('#attachmentImageHeight_' + id).val(images[photoNumber].height); } else { - $('#previewImages_' + selector).hide(); + $('#previewImages_' + id).hide(); } images.length = parseInt(images.length); @@ -359,26 +358,26 @@ } if (i === 0) { - appendImage += ""; + appendImage += ""; } else { - appendImage += ""; + appendImage += ""; } } - $('#previewImage_' + selector).html(appendImage + ""); + $('#previewImage_' + id).html(appendImage + ""); // More than just one image. if (images.length > 1) { // Enable the the button to change the preview pictures. - $('#previewChangeImg_' + selector).show(); + $('#previewChangeImg_' + id).show(); if (firstPosted === false) { firstPosted = true; - $('#previewChangeImg_' + selector).unbind('click').click(function (e) { + $('#previewChangeImg_' + id).unbind('click').click(function (e) { e.stopPropagation(); if (images.length > 1) { - $('#imagePreview_' + selector + '_' + photoNumber).css({ + $('#imagePreview_' + id + '_' + photoNumber).css({ 'display': 'none' }); photoNumber += 1; @@ -388,13 +387,13 @@ photoNumber = 0; } - $('#imagePreview_' + selector + '_' + photoNumber).css({ + $('#imagePreview_' + id + '_' + photoNumber).css({ 'display': 'block' }); - $('#photoNumber_' + selector).val(photoNumber); - $('#attachmentImageSrc_' + selector).val(bin2hex(images[photoNumber].src)); - $('#attachmentImageWidth_' + selector).val(images[photoNumber].width); - $('#attachmentImageHeight_' + selector).val(images[photoNumber].height); + $('#photoNumber_' + id).val(photoNumber); + $('#attachmentImageSrc_' + id).val(bin2hex(images[photoNumber].src)); + $('#attachmentImageWidth_' + id).val(images[photoNumber].width); + $('#attachmentImageHeight_' + id).val(images[photoNumber].height); } }); } @@ -407,94 +406,94 @@ * @returns {void} */ var processEventListener = function() { - $('#previewSpanTitle_' + selector).unbind('click').click(function (e) { + $('#previewSpanTitle_' + id).unbind('click').click(function (e) { e.stopPropagation(); if (blockTitle === false) { blockTitle = true; - $('#previewSpanTitle_' + selector).hide(); - $('#previewInputTitle_' + selector).show(); - $('#previewInputTitle_' + selector).val($('#previewInputTitle_' + selector).val()); - $('#previewInputTitle_' + selector).focus().select(); + $('#previewSpanTitle_' + id).hide(); + $('#previewInputTitle_' + id).show(); + $('#previewInputTitle_' + id).val($('#previewInputTitle_' + id).val()); + $('#previewInputTitle_' + id).focus().select(); } }); - $('#previewInputTitle_' + selector).blur(function () { + $('#previewInputTitle_' + id).blur(function () { blockTitle = false; - $('#previewSpanTitle_' + selector).html($('#previewInputTitle_' + selector).val()); - $('#previewSpanTitle_' + selector).show(); - $('#previewInputTitle_' + selector).hide(); + $('#previewSpanTitle_' + id).html($('#previewInputTitle_' + id).val()); + $('#previewSpanTitle_' + id).show(); + $('#previewInputTitle_' + id).hide(); }); - $('#previewInputTitle_' + selector).keypress(function (e) { + $('#previewInputTitle_' + id).keypress(function (e) { if (e.which === 13) { blockTitle = false; - $('#previewSpanTitle_' + selector).html($('#previewInputTitle_' + selector).val()); - $('#previewSpanTitle_' + selector).show(); - $('#previewInputTitle_' + selector).hide(); + $('#previewSpanTitle_' + id).html($('#previewInputTitle_' + id).val()); + $('#previewSpanTitle_' + id).show(); + $('#previewInputTitle_' + id).hide(); } }); - $('#previewSpanDescription_' + selector).unbind('click').click(function (e) { + $('#previewSpanDescription_' + id).unbind('click').click(function (e) { e.stopPropagation(); if (blockDescription === false) { blockDescription = true; - $('#previewSpanDescription_' + selector).hide(); - $('#previewInputDescription_' + selector).show(); - $('#previewInputDescription_' + selector).val($('#previewInputDescription_' + selector).val()); - $('#previewInputDescription_' + selector).focus().select(); + $('#previewSpanDescription_' + id).hide(); + $('#previewInputDescription_' + id).show(); + $('#previewInputDescription_' + id).val($('#previewInputDescription_' + id).val()); + $('#previewInputDescription_' + id).focus().select(); } }); - $('#previewInputDescription_' + selector).blur(function () { + $('#previewInputDescription_' + id).blur(function () { blockDescription = false; - $('#previewSpanDescription_' + selector).html($('#previewInputDescription_' + selector).val()); - $('#previewSpanDescription_' + selector).show(); - $('#previewInputDescription_' + selector).hide(); + $('#previewSpanDescription_' + id).html($('#previewInputDescription_' + id).val()); + $('#previewSpanDescription_' + id).show(); + $('#previewInputDescription_' + id).hide(); }); - $('#previewInputDescription_' + selector).keypress(function (e) { + $('#previewInputDescription_' + id).keypress(function (e) { if (e.which === 13) { blockDescription = false; - $('#previewSpanDescription_' + selector).html($('#previewInputDescription_' + selector).val()); - $('#previewSpanDescription_' + selector).show(); - $('#previewInputDescription_' + selector).hide(); + $('#previewSpanDescription_' + id).html($('#previewInputDescription_' + id).val()); + $('#previewSpanDescription_' + id).show(); + $('#previewInputDescription_' + id).hide(); } }); - $('#previewSpanTitle_' + selector).mouseover(function () { - $('#previewSpanTitle_' + selector).css({ + $('#previewSpanTitle_' + id).mouseover(function () { + $('#previewSpanTitle_' + id).css({ "background-color": "#ff9" }); }); - $('#previewSpanTitle_' + selector).mouseout(function () { - $('#previewSpanTitle_' + selector).css({ + $('#previewSpanTitle_' + id).mouseout(function () { + $('#previewSpanTitle_' + id).css({ "background-color": "transparent" }); }); - $('#previewSpanDescription_' + selector).mouseover(function () { - $('#previewSpanDescription_' + selector).css({ + $('#previewSpanDescription_' + id).mouseover(function () { + $('#previewSpanDescription_' + id).css({ "background-color": "#ff9" }); }); - $('#previewSpanDescription_' + selector).mouseout(function () { - $('#previewSpanDescription_' + selector).css({ + $('#previewSpanDescription_' + id).mouseout(function () { + $('#previewSpanDescription_' + id).css({ "background-color": "transparent" }); }); - $('#closePreview_' + selector).unbind('click').click(function (e) { + $('#closePreview_' + id).unbind('click').click(function (e) { e.stopPropagation(); block = false; images = ''; isActive = false; firstPosted = false; - $('#preview_' + selector).fadeOut("fast", function () { - $('#preview_' + selector).remove(); + $('#preview_' + id).fadeOut("fast", function () { + $('#preview_' + id).remove(); $('#profile-rotator').hide(); - $('#' + selector).focus(); + $('#' + id).focus(); }); }); @@ -628,8 +627,8 @@ reAddAttachment(attachmentData); // Remove the attachment bbcode from the textarea. var content = content.replace(/\[attachment[\s\S]*\[\/attachment]/im, ''); - $('#' + selector).val(content); - $('#' + selector).focus(); + $('#' + id).val(content); + $('#' + id).focus(); } }; @@ -676,16 +675,16 @@ } if (image !== '') { - var appendImage = "" - $('#previewImage_' + selector).html(appendImage); - $('#attachmentImageSrc_' + selector).val(bin2hex(image)); + var appendImage = "" + $('#previewImage_' + id).html(appendImage); + $('#attachmentImageSrc_' + id).val(bin2hex(image)); // We need to add the image widht and height when it is // loaded. $('' ,{ load : function(){ - $('#attachmentImageWidth_' + selector).val(this.width); - $('#attachmentImageHeight_' + selector).val(this.height); + $('#attachmentImageWidth_' + id).val(this.width); + $('#attachmentImageHeight_' + id).val(this.height); }, src : image }); @@ -751,8 +750,8 @@ * @returns {void} */ var destroy = function() { - $('#' + selector).unbind(); - $('#preview_' + selector).remove(); + $('#' + id).unbind(); + $('#preview_' + id).remove(); binurl; block = false; blockTitle = false; @@ -764,7 +763,7 @@ firstPosted = false; isActive = false; isCrawling = false; - selector = ""; + id = ""; }; var trim = function(str) { diff --git a/view/js/main.js b/view/js/main.js index 94644c5df..e15ee77e1 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -764,11 +764,10 @@ function showHideComments(id) { } function preview_post() { - $("#jot-preview").val("1"); $("#jot-preview-content").show(); $.post( "item", - $("#profile-jot-form").serialize(), + $("#profile-jot-form").serialize() + '&preview=1', function(data) { if (data.preview) { $("#jot-preview-content").html(data.preview); @@ -778,7 +777,6 @@ function preview_post() { }, "json" ); - $("#jot-preview").val("0"); return true; } diff --git a/view/templates/acl_selector.tpl b/view/templates/acl_selector.tpl index 58a0f483b..21b28d5d7 100644 --- a/view/templates/acl_selector.tpl +++ b/view/templates/acl_selector.tpl @@ -1,58 +1,263 @@ -
- - {{$showall}} -
-
+
+
+
+ +
+
+
+

{{$public_desc}}

+ {{if $for_federation}} + {{if $user_hidewall}} +

{{$jotnets_summary}}

+ {{$jotnets_disabled_label}} + {{elseif $jotnets_fields}} + {{if $jotnets_fields|count < 3}} +
+ {{else}} +
+ {{$jotnets_summary}} + {{/if}} + + {{foreach $jotnets_fields as $jotnets_field}} + {{if $jotnets_field.type == 'checkbox'}} + {{include file="field_checkbox.tpl" field=$jotnets_field.field}} + {{elseif $jotnets_field.type == 'select'}} + {{include file="field_select.tpl" field=$jotnets_field.field}} + {{/if}} + {{/foreach}} + + {{if $jotnets_fields|count >= 3}} +
+ {{else}} +
+ {{/if}} + {{/if}} + {{/if}} +
+
+
+
+
+ +
+
+ + + + +
+

{{$custom_desc}}

+ +
+ + +
+ +
+ + +
+
+
- -
- -{{if $networks}} -
-
{{$emailcc}}
-
- - {{if $jotnets_fields}} - {{if $jotnets_fields|count < 3}} -
- {{else}} -
- {{$jotnets_summary}} - {{/if}} - - {{foreach $jotnets_fields as $jotnets_field}} - {{if $jotnets_field.type == 'checkbox'}} - {{include file="field_checkbox.tpl" field=$jotnets_field.field}} - {{elseif $jotnets_field.type == 'select'}} - {{include file="field_select.tpl" field=$jotnets_field.field}} - {{/if}} - {{/foreach}} - - {{if $jotnets_fields|count >= 3}} -
- {{else}} -
- {{/if}} - {{/if}} +{{if $for_federation}} +
+ + +
+
{{/if}} +
+ diff --git a/view/templates/head.tpl b/view/templates/head.tpl index 3d11f1ab8..6e3f741ad 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -42,7 +42,6 @@ - diff --git a/view/templates/item/compose-footer.tpl b/view/templates/item/compose-footer.tpl deleted file mode 100644 index 7e18d18ff..000000000 --- a/view/templates/item/compose-footer.tpl +++ /dev/null @@ -1,250 +0,0 @@ - diff --git a/view/templates/item/compose.tpl b/view/templates/item/compose.tpl index d18b1a2d3..8b7414fd6 100644 --- a/view/templates/item/compose.tpl +++ b/view/templates/item/compose.tpl @@ -74,82 +74,18 @@ - - - - {{if $type == 'post'}} -

Visibility

-
-
-
- -
-
-
-

{{$public_desc}}

- {{if $doesFederate && $jotnets_fields}} - {{if $jotnets_fields|count < 3}} -
- {{else}} -
- {{$jotnets_summary}} - {{/if}} +

{{$visibility_title}}

+ {{$acl_selector nofilter}} - {{foreach $jotnets_fields as $jotnets_field}} - {{if $jotnets_field.type == 'checkbox'}} - {{include file="field_checkbox.tpl" field=$jotnets_field.field}} - {{elseif $jotnets_field.type == 'select'}} - {{include file="field_select.tpl" field=$jotnets_field.field}} - {{/if}} - {{/foreach}} - - {{if $jotnets_fields|count >= 3}} -
- {{else}} -
- {{/if}} - {{/if}} -
-
-
-
- -
-
-

{{$custom_desc}}

- -
- - -
- -
- - -
-
-
-
-
- {{if $doesFederate}} -
- - -
-
- {{/if}}
{{$jotplugins nofilter}}
+{{else}} + + + + {{/if}}
diff --git a/view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.css b/view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.css deleted file mode 100644 index f2e1197a5..000000000 --- a/view/theme/frio/frameworks/friendica-tagsinput/friendica-tagsinput.css +++ /dev/null @@ -1,72 +0,0 @@ -/* - * friendica-tagsinput v0.8.0 - * - */ - -.friendica-tagsinput { - background-color: #fff; - border: 1px solid #ccc; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - display: inline-block; - padding: 4px 6px; - color: #555; - vertical-align: middle; - border-radius: 4px; - max-width: 100%; - line-height: 22px; - cursor: text; - height: auto; -} -.friendica-tagsinput.input-lg { - line-height: 27px; -} -.friendica-tagsinput input { - border: none; - box-shadow: none; - outline: none; - background-color: transparent; - padding: 0 6px; - margin: 0; - width: auto; - max-width: inherit; -} -.friendica-tagsinput.form-control input::-moz-placeholder { - color: #777; - opacity: 1; -} -.friendica-tagsinput.form-control input:-ms-input-placeholder { - color: #777; -} -.friendica-tagsinput.form-control input::-webkit-input-placeholder { - color: #777; -} -.friendica-tagsinput input:focus { - border: none; - box-shadow: none; -} -.friendica-tagsinput .tag { - margin: 0 2px 2px 0; - color: white; - font-weight: normal; -} -.friendica-tagsinput .tag img { - width: auto; - height: 1.5em; - vertical-align: text-top; - margin-right: 8px; -} -.friendica-tagsinput .tag [data-role="remove"] { - margin-left: 8px; - cursor: pointer; -} -.friendica-tagsinput .tag [data-role="remove"]:after { - content: "x"; - padding: 0px 2px; - font-weight: bold; -} -.friendica-tagsinput .tag [data-role="remove"]:hover { - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -} -.friendica-tagsinput .tag [data-role="remove"]:hover:active { - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} diff --git a/view/theme/frio/js/compose.js b/view/theme/frio/js/compose.js new file mode 100644 index 000000000..88cd386f8 --- /dev/null +++ b/view/theme/frio/js/compose.js @@ -0,0 +1,57 @@ +$(function() { + // Jot attachment live preview. + let $textarea = $('textarea[name=body]'); + $textarea.linkPreview(); + $textarea.keyup(function(){ + var textlen = $(this).val().length; + $('#character-counter').text(textlen); + }); + $textarea.editor_autocomplete(baseurl + '/search/acl'); + $textarea.bbco_autocomplete('bbcode'); + + let location_button = document.getElementById('profile-location'); + let location_input = document.getElementById('jot-location'); + + if (location_button && location_input) { + updateLocationButtonDisplay(location_button, location_input); + + location_input.addEventListener('change', function () { + updateLocationButtonDisplay(location_button, location_input); + }); + location_input.addEventListener('keyup', function () { + updateLocationButtonDisplay(location_button, location_input); + }); + + location_button.addEventListener('click', function() { + if (location_input.value) { + location_input.value = ''; + updateLocationButtonDisplay(location_button, location_input); + } else if ("geolocation" in navigator) { + navigator.geolocation.getCurrentPosition(function(position) { + location_input.value = position.coords.latitude + ', ' + position.coords.longitude; + updateLocationButtonDisplay(location_button, location_input); + }, function (error) { + location_button.disabled = true; + updateLocationButtonDisplay(location_button, location_input); + }); + } + }); + } +}); + +function updateLocationButtonDisplay(location_button, location_input) +{ + location_button.classList.remove('btn-primary'); + if (location_input.value) { + location_button.disabled = false; + location_button.classList.add('btn-primary'); + location_button.title = location_button.dataset.titleClear; + } else if (!"geolocation" in navigator) { + location_button.disabled = true; + location_button.title = location_button.dataset.titleUnavailable; + } else if (location_button.disabled) { + location_button.title = location_button.dataset.titleDisabled; + } else { + location_button.title = location_button.dataset.titleSet; + } +} diff --git a/view/theme/frio/js/event_edit.js b/view/theme/frio/js/event_edit.js index 597563fe1..a068b4fe0 100644 --- a/view/theme/frio/js/event_edit.js +++ b/view/theme/frio/js/event_edit.js @@ -49,24 +49,6 @@ $(document).ready(function() { $("#event-preview").empty(); e.preventDefault(); }); - - // Construct a new ACL. We need this everytime the 'event-edit-form' is loaded - // without page reloading (e.g. closing an old modal and open a new modal). - // Otherwise we wouldn't get the ACL data. - /// @todo: Try to implement some kind of ACL reloading in acl.js. - - var eventPerms = document.getElementById('event-edit-form'); - - acl = new ACL( - baseurl + '/search/acl', - [ - JSON.parse(eventPerms.dataset.allow_cid), - JSON.parse(eventPerms.dataset.allow_gid), - JSON.parse(eventPerms.dataset.deny_cid), - JSON.parse(eventPerms.dataset.deny_gid) - ] - ); - acl.get(0, 100); }); // Load the html of the actual event and incect the output to the diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index f33988e13..04184a651 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -344,11 +344,11 @@ function toggleJotNav (elm) { // Minimize all tab content wrapper and activate only the selected // tab panel. - $('#jot-modal [role=tabpanel]').addClass("minimize").attr("aria-hidden" ,"true"); - $('#jot-modal #' + tabpanel).removeClass("minimize").attr("aria-hidden" ,"false"); + $('#profile-jot-form > [role=tabpanel]').addClass("minimize").attr("aria-hidden" ,"true"); + $('#' + tabpanel).removeClass("minimize").attr("aria-hidden" ,"false"); // Set the aria-selected states - $("#jot-modal .nav-tabs .jot-nav-lnk").attr("aria-selected", "false"); + $("#jot-modal .modal-header .nav-tabs .jot-nav-lnk").attr("aria-selected", "false"); elm.setAttribute("aria-selected", "true"); // For some some tab panels we need to execute other js functions. diff --git a/view/theme/frio/php/standard.php b/view/theme/frio/php/standard.php index 1dc4e94a4..00555192c 100644 --- a/view/theme/frio/php/standard.php +++ b/view/theme/frio/php/standard.php @@ -98,7 +98,6 @@ $("nav").bind('nav-update', function(e,data) }); - diff --git a/view/theme/frio/templates/acl_selector.tpl b/view/theme/frio/templates/acl_selector.tpl deleted file mode 100644 index e335a4f3c..000000000 --- a/view/theme/frio/templates/acl_selector.tpl +++ /dev/null @@ -1,64 +0,0 @@ - -
- - -
-
-
- -
- - - -{{if $networks}} -
-
- - -
-
- - {{if $jotnets_fields}} - {{if $jotnets_fields|count < 3}} -
- {{else}} -
- {{$jotnets_summary}} - {{/if}} - - {{foreach $jotnets_fields as $jotnets_field}} - {{if $jotnets_field.type == 'checkbox'}} - {{include file="field_checkbox.tpl" field=$jotnets_field.field}} - {{elseif $jotnets_field.type == 'select'}} - {{include file="field_select.tpl" field=$jotnets_field.field}} - {{/if}} - {{/foreach}} - - {{if $jotnets_fields|count >= 3}} -
- {{else}} -
- {{/if}} - {{/if}} -{{/if}} - - diff --git a/view/theme/frio/templates/event_form.tpl b/view/theme/frio/templates/event_form.tpl index 661bdecb2..c48d5c7fc 100644 --- a/view/theme/frio/templates/event_form.tpl +++ b/view/theme/frio/templates/event_form.tpl @@ -30,7 +30,7 @@
-
+ diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index f944c80ae..eea3e738a 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -63,7 +63,6 @@ - diff --git a/view/theme/smoothly/templates/jot.tpl b/view/theme/smoothly/templates/jot.tpl index c690cdf18..07c452c7e 100644 --- a/view/theme/smoothly/templates/jot.tpl +++ b/view/theme/smoothly/templates/jot.tpl @@ -70,9 +70,6 @@
{{$acl nofilter}} -
-
{{$emailcc}}
-
{{$jotnets nofilter}}