aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/contact_widgets.php10
-rw-r--r--include/menu.php70
-rw-r--r--mod/mitem.php45
-rw-r--r--view/js/mod_mitem.js22
-rw-r--r--view/tpl/mitemedit.tpl20
5 files changed, 128 insertions, 39 deletions
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index ddc89346a..2fa5dee0b 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -170,14 +170,16 @@ function suggest_widget() {
// This will throw some entropy intot he situation so you won't
// be looking at the same two mug shots every time the widget runs
- $index = mt_rand(0,count($r) - 2);
-
-
+
+ $index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
+
for($x = $index; $x <= ($index+1); $x ++) {
$rr = $r[$x];
-
+ if(! $rr['xchan_url'])
+ break;
+
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
$arr[] = array(
diff --git a/include/menu.php b/include/menu.php
index 900b48e65..c10a669b3 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -196,6 +196,31 @@ function menu_add_item($menu_id, $uid, $arr) {
$mitem_desc = escape_tags($arr['mitem_desc']);
$mitem_order = intval($arr['mitem_order']);
$mitem_flags = intval($arr['mitem_flags']);
+
+ if(local_user() == $uid) {
+ $channel = get_app()->get_channel();
+ }
+
+ if ((! $arr['contact_allow'])
+ && (! $arr['group_allow'])
+ && (! $arr['contact_deny'])
+ && (! $arr['group_deny'])) {
+ $str_group_allow = $channel['channel_allow_gid'];
+ $str_contact_allow = $channel['channel_allow_cid'];
+ $str_group_deny = $channel['channel_deny_gid'];
+ $str_contact_deny = $channel['channel_deny_cid'];
+ }
+ else {
+
+ // use the posted permissions
+
+ $str_group_allow = perms2str($arr['group_allow']);
+ $str_contact_allow = perms2str($arr['contact_allow']);
+ $str_group_deny = perms2str($arr['group_deny']);
+ $str_contact_deny = perms2str($arr['contact_deny']);
+ }
+
+
$allow_cid = perms2str($arr['allow_cid']);
$allow_gid = perms2str($arr['allow_gid']);
$deny_cid = perms2str($arr['deny_cid']);
@@ -205,10 +230,10 @@ function menu_add_item($menu_id, $uid, $arr) {
dbesc($mitem_link),
dbesc($mitem_desc),
intval($mitem_flags),
- dbesc($allow_cid),
- dbesc($allow_gid),
- dbesc($deny_cid),
- dbesc($deny_gid),
+ dbesc($str_contact_allow),
+ dbesc($str_group_allow),
+ dbesc($str_contact_deny),
+ dbesc($str_group_deny),
intval($uid),
intval($menu_id),
intval($mitem_order)
@@ -225,19 +250,40 @@ function menu_edit_item($menu_id, $uid, $arr) {
$mitem_desc = escape_tags($arr['mitem_desc']);
$mitem_order = intval($arr['mitem_order']);
$mitem_flags = intval($arr['mitem_flags']);
- $allow_cid = perms2str($arr['allow_cid']);
- $allow_gid = perms2str($arr['allow_gid']);
- $deny_cid = perms2str($arr['deny_cid']);
- $deny_gid = perms2str($arr['deny_gid']);
+
+
+ if(local_user() == $uid) {
+ $channel = get_app()->get_channel();
+ }
+
+ if ((! $arr['contact_allow'])
+ && (! $arr['group_allow'])
+ && (! $arr['contact_deny'])
+ && (! $arr['group_deny'])) {
+ $str_group_allow = $channel['channel_allow_gid'];
+ $str_contact_allow = $channel['channel_allow_cid'];
+ $str_group_deny = $channel['channel_deny_gid'];
+ $str_contact_deny = $channel['channel_deny_cid'];
+ }
+ else {
+
+ // use the posted permissions
+
+ $str_group_allow = perms2str($arr['group_allow']);
+ $str_contact_allow = perms2str($arr['contact_allow']);
+ $str_group_deny = perms2str($arr['group_deny']);
+ $str_contact_deny = perms2str($arr['contact_deny']);
+ }
+
$r = q("update menu_item set mitem_link = '%s', mitem_desc = '%s', mitem_flags = %d, allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', mitem_order = %d where mitem_channel_id = %d and mitem_menu_id = %d and mitem_id = %d limit 1",
dbesc($mitem_link),
dbesc($mitem_desc),
intval($mitem_flags),
- dbesc($allow_cid),
- dbesc($allow_gid),
- dbesc($deny_cid),
- dbesc($deny_gid),
+ dbesc($str_contact_allow),
+ dbesc($str_group_allow),
+ dbesc($str_contact_deny),
+ dbesc($str_group_deny),
intval($mitem_order),
intval($uid),
intval($menu_id),
diff --git a/mod/mitem.php b/mod/mitem.php
index 6a5785114..8e60e2d65 100644
--- a/mod/mitem.php
+++ b/mod/mitem.php
@@ -1,6 +1,7 @@
<?php
require_once('include/menu.php');
+require_once('include/acl_selectors.php');
function mitem_init(&$a) {
if(! local_user())
@@ -25,6 +26,9 @@ function mitem_post(&$a) {
if(! $a->data['menu'])
return;
+
+ $channel = $a->get_channel();
+
$_REQUEST['mitem_channel_id'] = local_user();
$_REQUEST['menu_id'] = $a->data['menu']['menu_id'];
@@ -34,29 +38,6 @@ function mitem_post(&$a) {
if($_REQUEST['newwin'])
$_REQUEST['mitem_flags'] |= MENU_ITEM_NEWWIN;
-// FIXME!!!!
-
- if ((! $_REQUEST['contact_allow'])
- && (! $_REQUEST['group_allow'])
- && (! $_REQUEST['contact_deny'])
- && (! $_REQUEST['group_deny'])) {
- $str_group_allow = $channel['channel_allow_gid'];
- $str_contact_allow = $channel['channel_allow_cid'];
- $str_group_deny = $channel['channel_deny_gid'];
- $str_contact_deny = $channel['channel_deny_cid'];
- }
- else {
-
- // use the posted permissions
-
- $str_group_allow = perms2str($_REQUEST['group_allow']);
- $str_contact_allow = perms2str($_REQUEST['contact_allow']);
- $str_group_deny = perms2str($_REQUEST['group_deny']);
- $str_contact_deny = perms2str($_REQUEST['contact_deny']);
- }
-
-
-
$mitem_id = ((argc() > 2) ? intval(argv(2)) : 0);
if($mitem_id) {
@@ -98,6 +79,8 @@ function mitem_content(&$a) {
return '';
}
+ $channel = $a->get_channel();
+
$a->set_widget('design',design_tools());
@@ -135,11 +118,24 @@ function mitem_content(&$a) {
if(argc() > 2) {
+
+
+
if(argv(2) === 'new') {
+ $perm_defaults = array(
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
+ 'deny_gid' => $channel['channel_deny_gid']
+ );
+
$o = replace_macros(get_markup_template('mitemedit.tpl'), array(
'$header' => t('New Menu Element'),
'$menu_id' => $a->data['menu']['menu_id'],
+ '$permissions' => t('Menu Item Permissions'),
+ '$permdesc' => t("\x28click to open/close\x29"),
+ '$aclselect' => populate_acl($perm_defaults),
'$mitem_desc' => array('mitem_desc', t('Link text'), '', '','*'),
'$mitem_link' => array('mitem_link', t('URL of link'), '', '', '*'),
'$usezid' => array('usezid', t('Use Red magic-auth if available'), true, ''),
@@ -180,6 +176,9 @@ function mitem_content(&$a) {
$o = replace_macros(get_markup_template('mitemedit.tpl'), array(
'$header' => t('Edit Menu Element'),
'$menu_id' => $a->data['menu']['menu_id'],
+ '$permissions' => t('Menu Item Permissions'),
+ '$permdesc' => t("\x28click to open/close\x29"),
+ '$aclselect' => populate_acl($mitem),
'$mitem_id' => intval(argv(2)),
'$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'),
'$mitem_link' => array('mitem_link', t('URL of link'), $mitem['mitem_link'], '', '*'),
diff --git a/view/js/mod_mitem.js b/view/js/mod_mitem.js
new file mode 100644
index 000000000..d33713ee3
--- /dev/null
+++ b/view/js/mod_mitem.js
@@ -0,0 +1,22 @@
+$(document).ready(function() {
+
+ $("a#settings-default-perms-menu").colorbox({
+ 'inline' : true,
+ 'transition' : 'elastic'
+ });
+
+
+ $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
+ var selstr;
+ $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
+ selstr = $(this).text();
+ $('#jot-perms-icon').removeClass('unlock').addClass('lock');
+ $('#jot-public').hide();
+ });
+ if(selstr == null) {
+ $('#jot-perms-icon').removeClass('lock').addClass('unlock');
+ $('#jot-public').show();
+ }
+
+ }).trigger('change');
+});
diff --git a/view/tpl/mitemedit.tpl b/view/tpl/mitemedit.tpl
index ef61be809..8f13f80c9 100644
--- a/view/tpl/mitemedit.tpl
+++ b/view/tpl/mitemedit.tpl
@@ -14,6 +14,26 @@
{{include file="field_input.tpl" field=$mitem_order}}
{{include file="field_checkbox.tpl" field=$usezid}}
{{include file="field_checkbox.tpl" field=$newwin}}
+
+<div id="settings-default-perms" class="settings-default-perms" >
+ <a href="#profile-jot-acl-wrapper" id="settings-default-perms-menu" >{{$permissions}} {{$permdesc}}</a>
+ <div id="settings-default-perms-menu-end"></div>
+
+ <div id="settings-default-perms-select" style="display: none; margin-bottom: 20px" >
+
+ <div style="display: none;">
+ <div id="profile-jot-acl-wrapper" style="width:auto;height:auto;overflow:auto;">
+ {{$aclselect}}
+ </div>
+ </div>
+
+ </div>
+</div>
+<br/>
+<div id="settings-default-perms-end"></div>
+
+
+
<div class="mitemedit-submit-wrapper" >
<input type="submit" name="submit" class="mitemedit-submit" value="{{$submit}}" />
</div>