Merge remote-tracking branch 'mike/master' into dev
This commit is contained in:
		| @@ -7,18 +7,36 @@ require_once('include/channel.php'); | |||||||
|  |  | ||||||
| class Menu extends \Zotlabs\Web\Controller { | class Menu extends \Zotlabs\Web\Controller { | ||||||
|  |  | ||||||
|  |  | ||||||
| 	function init() { | 	function init() { | ||||||
| 		if (array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { |  | ||||||
|  | 		if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) { | ||||||
| 			$sys = get_sys_channel(); | 			$sys = get_sys_channel(); | ||||||
| 			if ($sys && intval($sys['channel_id'])) { | 			if($sys && intval($sys['channel_id'])) { | ||||||
| 				\App::$is_sys = true; | 				\App::$is_sys = true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		if(argc() > 1) | ||||||
|  | 			$which = argv(1); | ||||||
|  | 		else | ||||||
|  | 			return; | ||||||
|  |  | ||||||
|  | 		profile_load($which); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 		function post() { |  | ||||||
| 	 | 	 | ||||||
| 		$uid = local_channel(); | 	function post() { | ||||||
|  | 	 | ||||||
|  | 		if(! \App::$profile) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$which = argv(1); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 		$uid = \App::$profile['channel_id']; | ||||||
| 	 | 	 | ||||||
| 		if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { | 		if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { | ||||||
| 			$sys = get_sys_channel(); | 			$sys = get_sys_channel(); | ||||||
| @@ -43,7 +61,7 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 			if($r) { | 			if($r) { | ||||||
| 				menu_sync_packet($uid,get_observer_hash(),$menu_id); | 				menu_sync_packet($uid,get_observer_hash(),$menu_id); | ||||||
| 				//info( t('Menu updated.') . EOL); | 				//info( t('Menu updated.') . EOL); | ||||||
| 				goaway(z_root() . '/mitem/' . $menu_id . ((\App::$is_sys) ? '?f=&sys=1' : ''));  | 				goaway(z_root() . '/mitem/' . $which . '/' . $menu_id . ((\App::$is_sys) ? '?f=&sys=1' : ''));  | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 				notice( t('Unable to update menu.'). EOL); | 				notice( t('Unable to update menu.'). EOL); | ||||||
| @@ -54,7 +72,7 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 				menu_sync_packet($uid,get_observer_hash(),$r); | 				menu_sync_packet($uid,get_observer_hash(),$r); | ||||||
| 	 | 	 | ||||||
| 				//info( t('Menu created.') . EOL); | 				//info( t('Menu created.') . EOL); | ||||||
| 				goaway(z_root() . '/mitem/' . $r . ((\App::$is_sys) ? '?f=&sys=1' : ''));  | 				goaway(z_root() . '/mitem/' . $which . '/' . $r . ((\App::$is_sys) ? '?f=&sys=1' : ''));  | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 				notice( t('Unable to create menu.'). EOL); | 				notice( t('Unable to create menu.'). EOL); | ||||||
| @@ -67,27 +85,71 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 	 | 	 | ||||||
| 	function get() { | 	function get() { | ||||||
| 	 | 	 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 		if(! \App::$profile) { | ||||||
|  | 			notice( t('Requested profile is not available.') . EOL ); | ||||||
|  | 			\App::$error = 404; | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$which = argv(1); | ||||||
|  |  | ||||||
|  | 		$_SESSION['return_url'] = \App::$query_string; | ||||||
|  |  | ||||||
| 		$uid = local_channel(); | 		$uid = local_channel(); | ||||||
|  | 		$owner = 0; | ||||||
|  | 		$channel = null; | ||||||
|  | 		$observer = \App::get_observer(); | ||||||
|  |  | ||||||
| 		if (\App::$is_sys && is_site_admin()) { | 		$channel = \App::get_channel(); | ||||||
|  |  | ||||||
|  | 		if(\App::$is_sys && is_site_admin()) { | ||||||
| 			$sys = get_sys_channel(); | 			$sys = get_sys_channel(); | ||||||
| 			$uid = intval($sys['channel_id']); | 			if($sys && intval($sys['channel_id'])) { | ||||||
|  | 				$uid = $owner = intval($sys['channel_id']); | ||||||
|  | 				$channel = $sys; | ||||||
|  | 				$observer = $sys; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if(! $uid) { | 		if(! $owner) { | ||||||
|  | 			// Figure out who the page owner is. | ||||||
|  | 			$r = channelx_by_nick($which); | ||||||
|  | 			if($r) { | ||||||
|  | 				$owner = intval($r['channel_id']); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); | ||||||
|  |  | ||||||
|  | 		$perms = get_all_perms($owner,$ob_hash); | ||||||
|  |  | ||||||
|  | 		if(! $perms['write_pages']) { | ||||||
| 			notice( t('Permission denied.') . EOL); | 			notice( t('Permission denied.') . EOL); | ||||||
| 			return ''; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if(argc() == 1) { | 		// Get the observer, check their permissions | ||||||
|  |  | ||||||
| 			$channel = (($sys) ? $sys : \App::get_channel()); | 		$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); | ||||||
|  |  | ||||||
|  | 		$perms = get_all_perms($owner,$ob_hash); | ||||||
|  |  | ||||||
|  | 		if(! $perms['write_pages']) { | ||||||
|  | 			notice( t('Permission denied.') . EOL); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if(argc() == 2) { | ||||||
|  | 	 | ||||||
|  | 			$channel = (($sys) ? $sys : channelx_by_n($owner)); | ||||||
| 	 | 	 | ||||||
| 			// list menus | 			// list menus | ||||||
| 			$x = menu_list($uid); | 			$x = menu_list($owner); | ||||||
| 			if($x) { | 			if($x) { | ||||||
| 				for($y = 0; $y < count($x); $y ++) { | 				for($y = 0; $y < count($x); $y ++) { | ||||||
| 					$m = menu_fetch($x[$y]['menu_name'],$uid,get_observer_hash()); | 					$m = menu_fetch($x[$y]['menu_name'],$owner,get_observer_hash()); | ||||||
| 					if($m) | 					if($m) | ||||||
| 						$x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($channel,$m))) . '[/element]'; | 						$x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($channel,$m))) . '[/element]'; | ||||||
| 					$x[$y]['bookmark'] = (($x[$y]['menu_flags'] & MENU_BOOKMARK) ? true : false); | 					$x[$y]['bookmark'] = (($x[$y]['menu_flags'] & MENU_BOOKMARK) ? true : false); | ||||||
| @@ -100,6 +162,7 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 				'$menu_bookmark' => array('menu_bookmark', t('Allow Bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), | 				'$menu_bookmark' => array('menu_bookmark', t('Allow Bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), | ||||||
| 				'$submit' => t('Submit and proceed'), | 				'$submit' => t('Submit and proceed'), | ||||||
| 				'$sys' => \App::$is_sys, | 				'$sys' => \App::$is_sys, | ||||||
|  | 				'$nick' => $which, | ||||||
| 				'$display' => 'none' | 				'$display' => 'none' | ||||||
| 			)); | 			)); | ||||||
| 	 | 	 | ||||||
| @@ -119,6 +182,7 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 				'$hintdrop' => t('Delete this menu'), | 				'$hintdrop' => t('Delete this menu'), | ||||||
| 				'$hintcontent' => t('Edit menu contents'), | 				'$hintcontent' => t('Edit menu contents'), | ||||||
| 				'$hintedit' => t('Edit this menu'), | 				'$hintedit' => t('Edit this menu'), | ||||||
|  | 				'$nick' => $which, | ||||||
| 				'$sys' => \App::$is_sys | 				'$sys' => \App::$is_sys | ||||||
| 			)); | 			)); | ||||||
| 	 | 	 | ||||||
| @@ -126,19 +190,19 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 	 | 	 | ||||||
| 		} | 		} | ||||||
| 	 | 	 | ||||||
| 		if(argc() > 1) { | 		if(argc() > 2) { | ||||||
| 			if(intval(argv(1))) { | 			if(intval(argv(2))) { | ||||||
| 	 | 	 | ||||||
| 				if(argc() == 3 && argv(2) == 'drop') { | 				if(argc() == 4 && argv(3) == 'drop') { | ||||||
| 					menu_sync_packet($uid,get_observer_hash(),intval(argv(1)),true); | 					menu_sync_packet($owner,get_observer_hash(),intval(argv(1)),true); | ||||||
| 					$r = menu_delete_id(intval(argv(1)),$uid); | 					$r = menu_delete_id(intval(argv(2)),$owner); | ||||||
| 					if(!$r) | 					if(!$r) | ||||||
| 						notice( t('Menu could not be deleted.'). EOL); | 						notice( t('Menu could not be deleted.'). EOL); | ||||||
| 	 | 	 | ||||||
| 					goaway(z_root() . '/menu' . ((\App::$is_sys) ? '?f=&sys=1' : '')); | 					goaway(z_root() . '/menu/' . $which . ((\App::$is_sys) ? '?f=&sys=1' : '')); | ||||||
| 				} | 				} | ||||||
| 	 | 	 | ||||||
| 				$m = menu_fetch_id(intval(argv(1)),$uid); | 				$m = menu_fetch_id(intval(argv(2)),$owner); | ||||||
| 	 | 	 | ||||||
| 				if(! $m) { | 				if(! $m) { | ||||||
| 					notice( t('Menu not found.') . EOL); | 					notice( t('Menu not found.') . EOL); | ||||||
| @@ -148,14 +212,15 @@ class Menu extends \Zotlabs\Web\Controller { | |||||||
| 				$o = replace_macros(get_markup_template('menuedit.tpl'), array( | 				$o = replace_macros(get_markup_template('menuedit.tpl'), array( | ||||||
| 					'$header' => t('Edit Menu'), | 					'$header' => t('Edit Menu'), | ||||||
| 					'$sys' => \App::$is_sys, | 					'$sys' => \App::$is_sys, | ||||||
| 					'$menu_id' => intval(argv(1)), | 					'$menu_id' => intval(argv(2)), | ||||||
| 					'$menu_edit_link' => 'mitem/' . intval(argv(1)) . ((\App::$is_sys) ? '?f=&sys=1' : ''), | 					'$menu_edit_link' => 'mitem/' . $which . '/' . intval(argv(1)) . ((\App::$is_sys) ? '?f=&sys=1' : ''), | ||||||
| 					'$hintedit' => t('Add or remove entries to this menu'), | 					'$hintedit' => t('Add or remove entries to this menu'), | ||||||
| 					'$editcontents' => t('Edit menu contents'), | 					'$editcontents' => t('Edit menu contents'), | ||||||
| 					'$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), | 					'$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), | ||||||
| 					'$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), | 					'$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), | ||||||
| 					'$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), | 					'$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), | ||||||
| 					'$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), | 					'$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), | ||||||
|  | 					'$nick' => $which, | ||||||
| 					'$submit' => t('Submit and proceed') | 					'$submit' => t('Submit and proceed') | ||||||
| 				)); | 				)); | ||||||
| 	 | 	 | ||||||
|   | |||||||
| @@ -9,21 +9,24 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
|  |  | ||||||
| 	function init() { | 	function init() { | ||||||
|  |  | ||||||
| 		$uid = local_channel(); | 		if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) { | ||||||
| 	 |  | ||||||
| 		if(array_key_exists('sys',$_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { |  | ||||||
| 			$sys = get_sys_channel(); | 			$sys = get_sys_channel(); | ||||||
| 			$uid = intval($sys['channel_id']); | 			if($sys && intval($sys['channel_id'])) { | ||||||
| 			\App::$is_sys = true; | 				\App::$is_sys = true; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if(! $uid) | 		if(argc() > 1) | ||||||
|  | 			$which = argv(1); | ||||||
|  | 		else | ||||||
| 			return; | 			return; | ||||||
|  |  | ||||||
| 		if(argc() < 2) | 		profile_load($which); | ||||||
|  | 	 | ||||||
|  | 		if(argc() < 3) | ||||||
| 			return; | 			return; | ||||||
| 	 | 	 | ||||||
| 		$m = menu_fetch_id(intval(argv(1)),$uid); | 		$m = menu_fetch_id(intval(argv(2)),\App::$profile['channel_id']); | ||||||
| 		if(! $m) { | 		if(! $m) { | ||||||
| 			notice( t('Menu not found.') . EOL); | 			notice( t('Menu not found.') . EOL); | ||||||
| 			return ''; | 			return ''; | ||||||
| @@ -32,19 +35,27 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 	 | 	 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 		function post() { | 	function post() { | ||||||
| 	 | 	 | ||||||
| 		$uid = local_channel(); | 		if(! \App::$profile) { | ||||||
| 	 |  | ||||||
| 		if(\App::$is_sys && is_site_admin()) { |  | ||||||
| 			$sys = get_sys_channel(); |  | ||||||
| 			$uid = intval($sys['channel_id']); |  | ||||||
| 		} |  | ||||||
| 	 |  | ||||||
| 		if(! $uid) { |  | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		$which = argv(1); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 		$uid = \App::$profile['channel_id']; | ||||||
|  | 	 | ||||||
|  | 		if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { | ||||||
|  | 			$sys = get_sys_channel(); | ||||||
|  | 			$uid = intval($sys['channel_id']); | ||||||
|  | 			\App::$is_sys = true; | ||||||
|  | 		} | ||||||
|  | 	 | ||||||
|  | 		if(! $uid) | ||||||
|  | 			return; | ||||||
|  |  | ||||||
|  |  | ||||||
| 		if(! \App::$data['menu']) | 		if(! \App::$data['menu']) | ||||||
| 			return; | 			return; | ||||||
| 	 | 	 | ||||||
| @@ -63,14 +74,14 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 			$_REQUEST['mitem_flags'] |= MENU_ITEM_NEWWIN; | 			$_REQUEST['mitem_flags'] |= MENU_ITEM_NEWWIN; | ||||||
| 	 | 	 | ||||||
| 		 | 		 | ||||||
| 		$mitem_id = ((argc() > 2) ? intval(argv(2)) : 0); | 		$mitem_id = ((argc() > 3) ? intval(argv(3)) : 0); | ||||||
| 		if($mitem_id) { | 		if($mitem_id) { | ||||||
| 			$_REQUEST['mitem_id'] = $mitem_id; | 			$_REQUEST['mitem_id'] = $mitem_id; | ||||||
| 			$r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST);	 | 			$r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST);	 | ||||||
| 			if($r) { | 			if($r) { | ||||||
| 				menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); | 				menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); | ||||||
| 				//info( t('Menu element updated.') . EOL); | 				//info( t('Menu element updated.') . EOL); | ||||||
| 				goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); | 				goaway(z_root() . '/mitem/' . $which . '/' . $_REQUEST['menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 				notice( t('Unable to update menu element.') . EOL); | 				notice( t('Unable to update menu element.') . EOL); | ||||||
| @@ -82,10 +93,10 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 				menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); | 				menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); | ||||||
| 				//info( t('Menu element added.') . EOL); | 				//info( t('Menu element added.') . EOL); | ||||||
| 				if($_REQUEST['submit']) { | 				if($_REQUEST['submit']) { | ||||||
| 					goaway(z_root() . '/menu' . ((\App::$is_sys) ? '?f=&sys=1' : '')); | 					goaway(z_root() . '/menu/' . $which . ((\App::$is_sys) ? '?f=&sys=1' : '')); | ||||||
| 				} | 				} | ||||||
| 				if($_REQUEST['submit-more']) { | 				if($_REQUEST['submit-more']) { | ||||||
| 					goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . '?f=&display=block' . ((\App::$is_sys) ? '&sys=1' : '') ); | 					goaway(z_root() . '/mitem/' . $which . '/' . $_REQUEST['menu_id'] . '?f=&display=block' . ((\App::$is_sys) ? '&sys=1' : '') ); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| @@ -96,12 +107,15 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	 | 	 | ||||||
| 		function get() { | 	function get() { | ||||||
| 	 | 	 | ||||||
| 		$uid = local_channel(); | 		$uid = local_channel(); | ||||||
| 		$channel = \App::get_channel(); | 		$owner = \App::$profile['channel_id']; | ||||||
|  | 		$channel = channelx_by_n($owner); | ||||||
| 		$observer = \App::get_observer(); | 		$observer = \App::get_observer(); | ||||||
|  |  | ||||||
|  | 		$which = argv(1); | ||||||
|  |  | ||||||
| 		$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); | 		$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); | ||||||
| 	 | 	 | ||||||
| 		if(\App::$is_sys && is_site_admin()) { | 		if(\App::$is_sys && is_site_admin()) { | ||||||
| @@ -116,15 +130,15 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 			return ''; | 			return ''; | ||||||
| 		} | 		} | ||||||
| 	 | 	 | ||||||
| 		if(argc() < 2 || (! \App::$data['menu'])) { | 		if(argc() < 3 || (! \App::$data['menu'])) { | ||||||
| 			notice( t('Not found.') . EOL); | 			notice( t('Not found.') . EOL); | ||||||
| 			return ''; | 			return ''; | ||||||
| 		} | 		} | ||||||
| 	 | 	 | ||||||
| 		$m = menu_fetch(\App::$data['menu']['menu_name'],$uid,$ob_hash); | 		$m = menu_fetch(\App::$data['menu']['menu_name'],$owner,$ob_hash); | ||||||
| 		\App::$data['menu_item'] = $m; | 		\App::$data['menu_item'] = $m; | ||||||
| 	 | 	 | ||||||
| 		$menu_list = menu_list($uid); | 		$menu_list = menu_list($owner); | ||||||
| 	 | 	 | ||||||
| 		foreach($menu_list as $menus) { | 		foreach($menu_list as $menus) { | ||||||
| 			if($menus['menu_name'] != $m['menu']['menu_name']) | 			if($menus['menu_name'] != $m['menu']['menu_name']) | ||||||
| @@ -135,10 +149,10 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 	 | 	 | ||||||
| 		$lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'); | 		$lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'); | ||||||
| 	 | 	 | ||||||
| 		if(argc() == 2) { | 		if(argc() == 3) { | ||||||
| 			$r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc", | 			$r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc", | ||||||
| 				intval(\App::$data['menu']['menu_id']), | 				intval(\App::$data['menu']['menu_id']), | ||||||
| 				intval($uid) | 				intval($owner) | ||||||
| 			); | 			); | ||||||
| 	 | 	 | ||||||
| 			if($_GET['display']) { | 			if($_GET['display']) { | ||||||
| @@ -167,6 +181,7 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 				'$display'     => $display, | 				'$display'     => $display, | ||||||
| 				'$lockstate'   => $lockstate, | 				'$lockstate'   => $lockstate, | ||||||
| 				'$menu_names'  => $menu_names, | 				'$menu_names'  => $menu_names, | ||||||
|  | 				'$nick'        => $which, | ||||||
| 				'$sys'         => \App::$is_sys | 				'$sys'         => \App::$is_sys | ||||||
| 			)); | 			)); | ||||||
| 	 | 	 | ||||||
| @@ -187,40 +202,41 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 				'$hintnew'     => t('Add menu element'), | 				'$hintnew'     => t('Add menu element'), | ||||||
| 				'$hintdrop'    => t('Delete this menu item'), | 				'$hintdrop'    => t('Delete this menu item'), | ||||||
| 				'$hintedit'    => t('Edit this menu item'), | 				'$hintedit'    => t('Edit this menu item'), | ||||||
|  | 				'$nick'        => $which, | ||||||
| 			)); | 			)); | ||||||
| 	 | 	 | ||||||
| 			return $o; | 			return $o; | ||||||
| 		} | 		} | ||||||
| 	 | 	 | ||||||
| 	 | 	 | ||||||
| 		if(argc() > 2) { | 		if(argc() > 3) { | ||||||
|  |  | ||||||
| 			if(intval(argv(2))) { | 			if(intval(argv(3))) { | ||||||
| 	 | 	 | ||||||
| 				$m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1", | 				$m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1", | ||||||
| 					intval(argv(2)), | 					intval(argv(3)), | ||||||
| 					intval($uid) | 					intval($owner) | ||||||
| 				); | 				); | ||||||
| 	 | 	 | ||||||
| 				if(! $m) { | 				if(! $m) { | ||||||
| 					notice( t('Menu item not found.') . EOL); | 					notice( t('Menu item not found.') . EOL); | ||||||
| 					goaway(z_root() . '/menu'. ((\App::$is_sys) ? '?f=&sys=1' : '')); | 					goaway(z_root() . '/menu/'. $which . ((\App::$is_sys) ? '?f=&sys=1' : '')); | ||||||
| 				} | 				} | ||||||
| 	 | 	 | ||||||
| 				$mitem = $m[0]; | 				$mitem = $m[0]; | ||||||
| 	 | 	 | ||||||
| 				$lockstate = (($mitem['allow_cid'] || $mitem['allow_gid'] || $mitem['deny_cid'] || $mitem['deny_gid']) ? 'lock' : 'unlock'); | 				$lockstate = (($mitem['allow_cid'] || $mitem['allow_gid'] || $mitem['deny_cid'] || $mitem['deny_gid']) ? 'lock' : 'unlock'); | ||||||
| 	 | 	 | ||||||
| 				if(argc() == 4 && argv(3) == 'drop') { | 				if(argc() == 5 && argv(4) == 'drop') { | ||||||
| 					menu_sync_packet($uid,get_observer_hash(),$mitem['mitem_menu_id']); | 					menu_sync_packet($owner,get_observer_hash(),$mitem['mitem_menu_id']); | ||||||
| 					$r = menu_del_item($mitem['mitem_menu_id'], $uid, intval(argv(2))); | 					$r = menu_del_item($mitem['mitem_menu_id'], $owner, intval(argv(3))); | ||||||
| 					menu_sync_packet($uid,get_observer_hash(),$mitem['mitem_menu_id']); | 					menu_sync_packet($owner,get_observer_hash(),$mitem['mitem_menu_id']); | ||||||
| 					if($r) | 					if($r) | ||||||
| 						info( t('Menu item deleted.') . EOL); | 						info( t('Menu item deleted.') . EOL); | ||||||
| 					else | 					else | ||||||
| 						notice( t('Menu item could not be deleted.'). EOL); | 						notice( t('Menu item could not be deleted.'). EOL); | ||||||
| 	 | 	 | ||||||
| 					goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); | 					goaway(z_root() . '/mitem/' . $which . '/' . $mitem['mitem_menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); | ||||||
| 				} | 				} | ||||||
| 	 | 	 | ||||||
| 				// edit menu item | 				// edit menu item | ||||||
| @@ -234,7 +250,7 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 					'$allow_gid' => acl2json($mitem['allow_gid']), | 					'$allow_gid' => acl2json($mitem['allow_gid']), | ||||||
| 					'$deny_cid' => acl2json($mitem['deny_cid']), | 					'$deny_cid' => acl2json($mitem['deny_cid']), | ||||||
| 					'$deny_gid' => acl2json($mitem['deny_gid']), | 					'$deny_gid' => acl2json($mitem['deny_gid']), | ||||||
| 					'$mitem_id' => intval(argv(2)), | 					'$mitem_id' => intval(argv(3)), | ||||||
| 					'$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), | 					'$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), | ||||||
| 					'$mitem_link'  => array('mitem_link', t('Link or Submenu Target'), $mitem['mitem_link'], 'Enter URL of the link or select a menu name to create a submenu', '*', 'list="menu-names"'), | 					'$mitem_link'  => array('mitem_link', t('Link or Submenu Target'), $mitem['mitem_link'], 'Enter URL of the link or select a menu name to create a submenu', '*', 'list="menu-names"'), | ||||||
| 					'$usezid' => array('usezid', t('Use magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), '', array(t('No'), t('Yes'))), | 					'$usezid' => array('usezid', t('Use magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), '', array(t('No'), t('Yes'))), | ||||||
| @@ -242,7 +258,8 @@ class Mitem extends \Zotlabs\Web\Controller { | |||||||
| 					'$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), | 					'$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), | ||||||
| 					'$submit' => t('Submit'), | 					'$submit' => t('Submit'), | ||||||
| 					'$lockstate'     => $lockstate, | 					'$lockstate'     => $lockstate, | ||||||
| 					'$menu_names'  => $menu_names | 					'$menu_names'  => $menu_names, | ||||||
|  | 					'$nick'  => $which | ||||||
| 				)); | 				)); | ||||||
| 	 | 	 | ||||||
| 				return $o; | 				return $o; | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
| 	<h3>{{$title}}</h3> | 	<h3>{{$title}}</h3> | ||||||
| 	<div class="nav nav-pills flex-column"> | 	<div class="nav nav-pills flex-column"> | ||||||
| 		<a class="nav-link" href="blocks/{{$who}}">{{$blocks}}</a> | 		<a class="nav-link" href="blocks/{{$who}}">{{$blocks}}</a> | ||||||
| 		<a class="nav-link" href="menu{{if $sys}}?f=&sys=1{{/if}}">{{$menus}}</a> | 		<a class="nav-link" href="menu/{{$who}}">{{$menus}}</a> | ||||||
| 		<a class="nav-link" href="layouts/{{$who}}">{{$layout}}</a> | 		<a class="nav-link" href="layouts/{{$who}}">{{$layout}}</a> | ||||||
| 		<a class="nav-link" href="webpages/{{$who}}">{{$pages}}</a> | 		<a class="nav-link" href="webpages/{{$who}}">{{$pages}}</a> | ||||||
| 	</div> | 	</div> | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ | |||||||
| </div> | </div> | ||||||
| {{/if}} | {{/if}} | ||||||
| <div id="menu-creator" class="section-content-tools-wrapper" style="display: {{$display}};"> | <div id="menu-creator" class="section-content-tools-wrapper" style="display: {{$display}};"> | ||||||
| 	<form id="menuedit" action="menu{{if $menu_id}}/{{$menu_id}}{{/if}}{{if $sys}}?f=&sys=1{{/if}}" method="post" > | 	<form id="menuedit" action="menu/{{$nick}}{{if $menu_id}}/{{$menu_id}}{{/if}}{{if $sys}}?f=&sys=1{{/if}}" method="post" > | ||||||
| 		{{if $menu_id}} | 		{{if $menu_id}} | ||||||
| 		<input type="hidden" name="menu_id" value="{{$menu_id}}" /> | 		<input type="hidden" name="menu_id" value="{{$menu_id}}" /> | ||||||
| 		{{/if}} | 		{{/if}} | ||||||
|   | |||||||
| @@ -25,11 +25,11 @@ | |||||||
| 			{{foreach $menus as $m }} | 			{{foreach $menus as $m }} | ||||||
| 			<tr id="menu-list-item-{{$m.menu_id}}"> | 			<tr id="menu-list-item-{{$m.menu_id}}"> | ||||||
| 				<td>{{if $m.bookmark}}<i class="fa fa-bookmark menu-list-tool" title="{{$bmark}}" ></i>{{/if}}</td> | 				<td>{{if $m.bookmark}}<i class="fa fa-bookmark menu-list-tool" title="{{$bmark}}" ></i>{{/if}}</td> | ||||||
| 				<td><a href="mitem/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintcontent}}">{{$m.menu_name}}</a></td> | 				<td><a href="mitem/{{$nick}}/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintcontent}}">{{$m.menu_name}}</a></td> | ||||||
| 				<td>{{$m.menu_desc}}</td> | 				<td>{{$m.menu_desc}}</td> | ||||||
| 				<td class="menu-list-tool"><a href="menu/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintedit}}"><i class="fa fa-pencil"></i></a></td> | 				<td class="menu-list-tool"><a href="menu/{{$nick}}/{{$m.menu_id}}{{if $sys}}?f=&sys=1{{/if}}" title="{{$hintedit}}"><i class="fa fa-pencil"></i></a></td> | ||||||
| 				<td class="menu-list-tool"><a href="rpost?attachment={{$m.element}}" title="{{$share}}"><i class="fa fa-share-square-o"></i></a></td> | 				<td class="menu-list-tool"><a href="rpost?attachment={{$m.element}}" title="{{$share}}"><i class="fa fa-share-square-o"></i></a></td> | ||||||
| 				<td class="menu-list-tool"><a href="#" title="{{$hintdrop}}"  onclick="dropItem('menu/{{$m.menu_id}}/drop{{if $sys}}?f=&sys=1{{/if}}', '#menu-list-item-{{$m.menu_id}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a></td> | 				<td class="menu-list-tool"><a href="#" title="{{$hintdrop}}"  onclick="dropItem('menu/{{$nick}}/{{$m.menu_id}}/drop{{if $sys}}?f=&sys=1{{/if}}', '#menu-list-item-{{$m.menu_id}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a></td> | ||||||
| 				<td class="d-none d-md-table-cell">{{$m.menu_created}}</td> | 				<td class="d-none d-md-table-cell">{{$m.menu_created}}</td> | ||||||
| 				<td class="d-none d-md-table-cell">{{$m.menu_edited}}</td> | 				<td class="d-none d-md-table-cell">{{$m.menu_edited}}</td> | ||||||
| 			</tr> | 			</tr> | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| 	</div> | 	</div> | ||||||
| {{/if}} | {{/if}} | ||||||
| 	<div id="menu-element-creator" class="section-content-tools-wrapper" style="display: {{$display}};"> | 	<div id="menu-element-creator" class="section-content-tools-wrapper" style="display: {{$display}};"> | ||||||
| 		<form id="mitemedit" action="mitem/{{$menu_id}}{{if $mitem_id}}/{{$mitem_id}}{{/if}}{{if $sys}}?f=&sys=1{{/if}}" method="post" class="acl-form" data-form_id="mitemedit" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> | 		<form id="mitemedit" action="mitem/{{$nick}}/{{$menu_id}}{{if $mitem_id}}/{{$mitem_id}}{{/if}}{{if $sys}}?f=&sys=1{{/if}}" method="post" class="acl-form" data-form_id="mitemedit" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> | ||||||
| 			<input type="hidden" name="menu_id" value="{{$menu_id}}" /> | 			<input type="hidden" name="menu_id" value="{{$menu_id}}" /> | ||||||
| 			{{if $mitem_id}} | 			{{if $mitem_id}} | ||||||
| 			<input type="hidden" name="mitem_id" value="{{$mitem_id}}" /> | 			<input type="hidden" name="mitem_id" value="{{$mitem_id}}" /> | ||||||
|   | |||||||
| @@ -24,8 +24,8 @@ | |||||||
| 				<td width="1%">{{$m.mitem_desc}}</td> | 				<td width="1%">{{$m.mitem_desc}}</td> | ||||||
| 				<td width="96%"><a href="{{$m.mitem_link}}">{{$m.mitem_link}}</a></td> | 				<td width="96%"><a href="{{$m.mitem_link}}">{{$m.mitem_link}}</a></td> | ||||||
| 				<td width="1%" class="mitem-list-tool dropdown">{{if $m.allow_cid || $m.allow_gid || $m.deny_cid || $m.deny_gid}}<i class="fa fa-lock lockview" data-toggle="dropdown" onclick="lockview('menu_item',{{$m.mitem_id}});" ></i><ul id="panel-{{$m.mitem_id}}" class="lockview-panel dropdown-menu"></ul>{{/if}}</td> | 				<td width="1%" class="mitem-list-tool dropdown">{{if $m.allow_cid || $m.allow_gid || $m.deny_cid || $m.deny_gid}}<i class="fa fa-lock lockview" data-toggle="dropdown" onclick="lockview('menu_item',{{$m.mitem_id}});" ></i><ul id="panel-{{$m.mitem_id}}" class="lockview-panel dropdown-menu"></ul>{{/if}}</td> | ||||||
| 				<td width="1%" class="mitem-list-tool"><a href="mitem/{{$menu_id}}/{{$m.mitem_id}}" title="{{$hintedit}}"><i class="fa fa-pencil"></i></a></td> | 				<td width="1%" class="mitem-list-tool"><a href="mitem/{{$nick}}/{{$menu_id}}/{{$m.mitem_id}}" title="{{$hintedit}}"><i class="fa fa-pencil"></i></a></td> | ||||||
| 				<td width="1%" class="mitem-list-tool"><a href="#" title="{{$hintdrop}}"  onclick="dropItem('mitem/{{$menu_id}}/{{$m.mitem_id}}/drop', '#mitem-list-item-{{$m.mitem_id}}, #pmenu-item-{{$m.mitem_id}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a></td> | 				<td width="1%" class="mitem-list-tool"><a href="#" title="{{$hintdrop}}"  onclick="dropItem('mitem/{{$nick}}/{{$menu_id}}/{{$m.mitem_id}}/drop', '#mitem-list-item-{{$m.mitem_id}}, #pmenu-item-{{$m.mitem_id}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a></td> | ||||||
| 			</tr> | 			</tr> | ||||||
| 			{{/foreach}} | 			{{/foreach}} | ||||||
| 		</table> | 		</table> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user