Merge remote-tracking branch 'upstream/develop' into 1610-performance

This commit is contained in:
Michael Vogel 2016-10-24 08:12:13 +00:00
commit 3463a442ba
7 changed files with 379 additions and 279 deletions

View file

@ -159,7 +159,7 @@ function mark_for_death($contact) {
} }
else { else {
/// @todo /// @todo
/// We really should send a notification to the owner after 2-3 weeks /// We really should send a notification to the owner after 2-3 weeks
/// so they won't be surprised when the contact vanishes and can take /// so they won't be surprised when the contact vanishes and can take
/// remedial action if this was a serious mistake or glitch /// remedial action if this was a serious mistake or glitch
@ -288,84 +288,88 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
return($profile); return($profile);
} }
if(! function_exists('contact_photo_menu')){ if (! function_exists('contact_photo_menu')) {
function contact_photo_menu($contact, $uid = 0) { function contact_photo_menu($contact, $uid = 0)
{
$a = get_app(); $a = get_app();
$contact_url=""; $contact_url = '';
$pm_url=""; $pm_url = '';
$status_link=""; $status_link = '';
$photos_link=""; $photos_link = '';
$posts_link=""; $posts_link = '';
$contact_drop_link = ""; $contact_drop_link = '';
$poke_link=""; $poke_link = '';
if ($uid == 0) if ($uid == 0) {
$uid = local_user(); $uid = local_user();
}
if ($contact["uid"] != $uid) { if ($contact['uid'] != $uid) {
if ($uid == 0) { if ($uid == 0) {
$profile_link = zrl($contact['url']); $profile_link = zrl($contact['url']);
$menu = Array('profile' => array(t("View Profile"), $profile_link, true)); $menu = Array('profile' => array(t('View Profile'), $profile_link, true));
return $menu; return $menu;
} }
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `network` = '%s' AND `uid` = %d", $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `network` = '%s' AND `uid` = %d",
dbesc($contact["nurl"]), dbesc($contact["network"]), intval($uid)); dbesc($contact['nurl']), dbesc($contact['network']), intval($uid));
if ($r) if ($r) {
return contact_photo_menu($r[0], $uid); return contact_photo_menu($r[0], $uid);
else { } else {
$profile_link = zrl($contact['url']); $profile_link = zrl($contact['url']);
$connlnk = 'follow/?url='.$contact['url']; $connlnk = 'follow/?url='.$contact['url'];
$menu = Array( $menu = array(
'profile' => array(t("View Profile"), $profile_link, true), 'profile' => array(t('View Profile'), $profile_link, true),
'follow' => array(t("Connect/Follow"), $connlnk, true) 'follow' => array(t('Connect/Follow'), $connlnk, true)
); );
return $menu; return $menu;
} }
} }
$sparkle = false; $sparkle = false;
if($contact['network'] === NETWORK_DFRN) { if ($contact['network'] === NETWORK_DFRN) {
$sparkle = true; $sparkle = true;
$profile_link = $a->get_baseurl() . '/redir/' . $contact['id']; $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
} } else {
else
$profile_link = $contact['url']; $profile_link = $contact['url'];
if($profile_link === 'mailbox')
$profile_link = '';
if($sparkle) {
$status_link = $profile_link . "?url=status";
$photos_link = $profile_link . "?url=photos";
$profile_link = $profile_link . "?url=profile";
} }
if (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA))) if ($profile_link === 'mailbox') {
$pm_url = $a->get_baseurl() . '/message/new/' . $contact['id']; $profile_link = '';
}
if ($contact["network"] == NETWORK_DFRN) if ($sparkle) {
$status_link = $profile_link . '?url=status';
$photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link . '?url=profile';
}
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
$pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
}
if ($contact['network'] == NETWORK_DFRN) {
$poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id']; $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
}
$contact_url = $a->get_baseurl() . '/contacts/' . $contact['id']; $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
$posts_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/posts';
$contact_drop_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/drop?confirm=1';
$posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
$contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
/** /**
* menu array: * menu array:
* "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ] * "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ]
*/ */
$menu = Array( $menu = array(
'status' => array(t("View Status"), $status_link, true), 'status' => array(t("View Status"), $status_link, true),
'profile' => array(t("View Profile"), $profile_link, true), 'profile' => array(t("View Profile"), $profile_link, true),
'photos' => array(t("View Photos"), $photos_link,true), 'photos' => array(t("View Photos"), $photos_link, true),
'network' => array(t("Network Posts"), $posts_link,false), 'network' => array(t("Network Posts"), $posts_link, false),
'edit' => array(t("Edit Contact"), $contact_url, false), 'edit' => array(t("View Contact"), $contact_url, false),
'drop' => array(t("Drop Contact"), $contact_drop_link, false), 'drop' => array(t("Drop Contact"), $contact_drop_link, false),
'pm' => array(t("Send PM"), $pm_url, false), 'pm' => array(t("Send PM"), $pm_url, false),
'poke' => array(t("Poke"), $poke_link, false), 'poke' => array(t("Poke"), $poke_link, false),
@ -378,9 +382,11 @@ function contact_photo_menu($contact, $uid = 0) {
$menucondensed = array(); $menucondensed = array();
foreach ($menu AS $menuname=>$menuitem) foreach ($menu AS $menuname => $menuitem) {
if ($menuitem[1] != "") if ($menuitem[1] != '') {
$menucondensed[$menuname] = $menuitem; $menucondensed[$menuname] = $menuitem;
}
}
return $menucondensed; return $menucondensed;
}} }}

View file

@ -903,79 +903,86 @@ function best_link_url($item,&$sparkle,$ssl_state = false) {
} }
if(! function_exists('item_photo_menu')){ if (! function_exists('item_photo_menu')) {
function item_photo_menu($item){ function item_photo_menu($item)
{
$ssl_state = false; $ssl_state = false;
if(local_user()) if(local_user()) {
$ssl_state = true; $ssl_state = true;
}
$sub_link=""; $sub_link = '';
$poke_link=""; $poke_link = '';
$contact_url=""; $contact_url = '';
$pm_url=""; $pm_url = '';
$status_link=""; $status_link = '';
$photos_link=""; $photos_link = '';
$posts_link=""; $posts_link = '';
$network = ""; $network = '';
if((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) { if ((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) {
$sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
} }
$sparkle = false; $sparkle = false;
$profile_link = best_link_url($item,$sparkle,$ssl_state); $profile_link = best_link_url($item, $sparkle, $ssl_state);
if($profile_link === 'mailbox') if ($profile_link === 'mailbox') {
$profile_link = ''; $profile_link = '';
}
$cid = 0; $cid = 0;
$network = ""; $network = '';
$rel = 0; $rel = 0;
$r = q("SELECT `id`, `network`, `rel` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1", $r = q("SELECT `id`, `network`, `rel` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
intval(local_user()), dbesc(normalise_link($item['author-link']))); intval(local_user()), dbesc(normalise_link($item['author-link'])));
if ($r) { if ($r) {
$cid = $r[0]["id"]; $cid = $r[0]['id'];
$network = $r[0]["network"]; $network = $r[0]['network'];
$rel = $r[0]["rel"]; $rel = $r[0]['rel'];
} }
if($sparkle) { if($sparkle) {
$status_link = $profile_link."?url=status"; $status_link = $profile_link . '?url=status';
$photos_link = $profile_link."?url=photos"; $photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link."?url=profile"; $profile_link = $profile_link . '?url=profile';
$zurl = ''; $zurl = '';
} else } else {
$profile_link = zrl($profile_link); $profile_link = zrl($profile_link);
}
if($cid && !$item['self']) { if ($cid && !$item['self']) {
$poke_link = 'poke/?f=&c='.$cid; $poke_link = 'poke/?f=&c=' . $cid;
$contact_url = 'contacts/'.$cid; $contact_url = 'contacts/' . $cid;
$posts_link = 'contacts/'.$cid.'/posts'; $posts_link = 'contacts/' . $cid . '/posts';
if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) {
$pm_url = 'message/new/'.$cid; $pm_url = 'message/new/' . $cid;
}
} }
if (local_user()) { if (local_user()) {
$menu = Array( $menu = Array(
t("Follow Thread") => $sub_link, t('Follow Thread') => $sub_link,
t("View Status") => $status_link, t('View Status') => $status_link,
t("View Profile") => $profile_link, t('View Profile') => $profile_link,
t("View Photos") => $photos_link, t('View Photos') => $photos_link,
t("Network Posts") => $posts_link, t('Network Posts') => $posts_link,
t("Edit Contact") => $contact_url, t('View Contact') => $contact_url,
t("Send PM") => $pm_url t('Send PM') => $pm_url
); );
if ($network == NETWORK_DFRN) if ($network == NETWORK_DFRN) {
$menu[t("Poke")] = $poke_link; $menu[t("Poke")] = $poke_link;
}
if ((($cid == 0) OR ($rel == CONTACT_IS_FOLLOWER)) AND if ((($cid == 0) OR ($rel == CONTACT_IS_FOLLOWER)) AND
in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
$menu[t("Connect/Follow")] = "follow?url=".urlencode($item['author-link']); $menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
} else }
$menu = array(t("View Profile") => $item['author-link']); } else {
$menu = array(t('View Profile') => $item['author-link']);
}
$args = array('item' => $item, 'menu' => $menu); $args = array('item' => $item, 'menu' => $menu);
@ -983,13 +990,14 @@ function item_photo_menu($item){
$menu = $args['menu']; $menu = $args['menu'];
$o = ""; $o = '';
foreach($menu as $k=>$v){ foreach ($menu as $k => $v) {
if(strpos($v,'javascript:') === 0) { if (strpos($v, 'javascript:') === 0) {
$v = substr($v,11); $v = substr($v, 11);
$o .= "<li role=\"menuitem\"><a onclick=\"$v\">$k</a></li>\n"; $o .= '<li role="menuitem"><a onclick="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
} elseif ($v!='') {
$o .= '<li role="menuitem"><a href="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
} }
elseif ($v!="") $o .= "<li role=\"menuitem\"><a href=\"$v\">$k</a></li>\n";
} }
return $o; return $o;
}} }}

View file

@ -43,181 +43,165 @@ function nav(&$a) {
call_hooks('page_header', $a->page['nav']); call_hooks('page_header', $a->page['nav']);
} }
/**
function nav_info(&$a) { * @brief Prepares a list of navigation links
*
* @param App $a
* @return array
*/
function nav_info(App $a)
{
$ssl_state = ((local_user()) ? true : false); $ssl_state = ((local_user()) ? true : false);
/* /*
*
* Our network is distributed, and as you visit friends some of the * Our network is distributed, and as you visit friends some of the
* sites look exactly the same - it isn't always easy to know where you are. * sites look exactly the same - it isn't always easy to know where you are.
* Display the current site location as a navigation aid. * Display the current site location as a navigation aid.
*
*/ */
$myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : ''); $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
$sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 ); $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2 );
// nav links: array of array('href', 'text', 'extra css classes', 'title') // nav links: array of array('href', 'text', 'extra css classes', 'title')
$nav = Array(); $nav = array();
/* // Display login or logout
* Display login or logout $nav['usermenu'] = array();
*/
$nav['usermenu']=array();
$userinfo = null; $userinfo = null;
if(local_user()) { if (local_user()) {
$nav['logout'] = Array('logout',t('Logout'), "", t('End this session')); $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
// user menu // user menu
$nav['usermenu'][] = Array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations')); $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
$nav['usermenu'][] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page')); $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
$nav['usermenu'][] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
$nav['usermenu'][] = Array('videos/' . $a->user['nickname'], t('Videos'), "", t('Your videos')); $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
$nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events')); $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
$nav['usermenu'][] = Array('notes/', t('Personal notes'), "", t('Your personal notes')); $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
// user info // user info
$r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
$userinfo = array( $userinfo = array(
'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg"), 'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'], 'name' => $a->user['username'],
); );
} else {
} $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
else {
$nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'selected':''), t('Sign in'));
} }
// "Home" should also take you home from an authenticated remote profile connection
/*
* "Home" should also take you home from an authenticated remote profile connection
*/
$homelink = get_my_url(); $homelink = get_my_url();
if(! $homelink) if (! $homelink) {
$homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : ''); $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
}
if(($a->module != 'home') && (! (local_user()))) if (($a->module != 'home') && (! (local_user()))) {
$nav['home'] = array($homelink, t('Home'), "", t('Home Page')); $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
}
if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) $nav['register'] = array('register', t('Register'), '', t('Create an account'));
$nav['register'] = array('register',t('Register'), "", t('Create an account')); }
$help_url = 'help'; $help_url = 'help';
if(! get_config('system','hide_help')) if (! get_config('system', 'hide_help')) {
$nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
}
if(count($a->apps)>0) if (count($a->apps) > 0) {
$nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games')); $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
}
if (local_user() OR !get_config('system','local_search')) { if (local_user() OR !get_config('system', 'local_search')) {
$nav['search'] = array('search', t('Search'), "", t('Search site content')); $nav['search'] = array('search', t('Search'), '', t('Search site content'));
$nav['searchoption'] = array( $nav['searchoption'] = array(
t("Full Text"), t('Full Text'),
t("Tags"), t('Tags'),
t("Contacts")); t('Contacts'));
if (get_config('system','poco_local_search')) if (get_config('system', 'poco_local_search')) {
$nav['searchoption'][] = t("Forums"); $nav['searchoption'][] = t('Forums');
}
} }
$gdirpath = 'directory'; $gdirpath = 'directory';
if(strlen(get_config('system','singleuser'))) { if (strlen(get_config('system', 'singleuser'))) {
$gdir = get_config('system','directory'); $gdir = get_config('system', 'directory');
if(strlen($gdir)) if(strlen($gdir)) {
$gdirpath = $gdir; $gdirpath = zrl($gdir, true);
}
} elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
$nav['community'] = array('community', t('Community'), '', t('Conversations on this site'));
} elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) {
$nav['community'] = array('community', t('Community'), '', t('Conversations on the network'));
} }
elseif(get_config('system','community_page_style') == CP_USERS_ON_SERVER)
$nav['community'] = array('community', t('Community'), "", t('Conversations on this site'));
elseif(get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
$nav['community'] = array('community', t('Community'), "", t('Conversations on the network'));
if(local_user()) if (local_user()) {
$nav['events'] = Array('events', t('Events'), "", t('Events and Calendar')); $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
}
$nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
$nav['about'] = Array('friendica', t('Information'), "", t('Information about this friendica instance')); $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
/* // The following nav links are only show to logged in users
* if (local_user()) {
* The following nav links are only show to logged in users $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
* $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
*/
if(local_user()) { $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
$nav['network'] = array('network', t('Network'), "", t('Conversations from your friends')); if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
$nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), "", t('Load Network page with no filters')); // only show friend requests for normal pages. Other page types have automatic friendship.
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
$nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations')); $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
}
if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) { if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
/* only show friend requests for normal pages. Other page types have automatic friendship. */ $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
$nav['introductions'] = array('notifications/intros', t('Introductions'), "", t('Friend Requests')); $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
$nav['notifications'] = array('notifications', t('Notifications'), "", t('Notifications'));
$nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");
$nav['notifications']['mark'] = array('', t('Mark as seen'), '',t('Mark all system notifications seen'));
} }
} }
$nav['messages'] = array('message', t('Messages'), "", t('Private mail')); $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
$nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
$nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox')); $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
$nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message')); $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
if(is_array($a->identities) && count($a->identities) > 1) { if (is_array($a->identities) && count($a->identities) > 1) {
$nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages')); $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
} }
$nav['delegations'] = Array('delegate', t('Delegations'), "", t('Delegate Page Management')); $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
$nav['settings'] = array('settings', t('Settings'),"", t('Account settings')); $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
if(feature_enabled(local_user(),'multi_profiles')) if (feature_enabled(local_user(), 'multi_profiles')) {
$nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/Edit Profiles')); $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
}
$nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts')); $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
} }
/* if (is_site_admin()) {
* Admin page $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
*/ }
if (is_site_admin()){
$nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
}
$nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
$nav['navigation'] = array('navigation/', t('Navigation'), "", t('Site map')); // Provide a banner/logo/whatever
$banner = get_config('system', 'banner');
if ($banner === false) {
/* $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
* }
* Provide a banner/logo/whatever
*
*/
$banner = get_config('system','banner');
if($banner === false)
$banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
call_hooks('nav_info', $nav); call_hooks('nav_info', $nav);
return array( return array(
'sitelocation' => $sitelocation, 'sitelocation' => $sitelocation,
'nav' => $nav, 'nav' => $nav,

View file

@ -130,7 +130,7 @@ function item_post(&$a) {
intval($parent_item['contact-id']), intval($parent_item['contact-id']),
intval($uid) intval($uid)
); );
if(count($r)) if (dbm::is_result($r))
$parent_contact = $r[0]; $parent_contact = $r[0];
// If the contact id doesn't fit with the contact, then set the contact to null // If the contact id doesn't fit with the contact, then set the contact to null
@ -175,6 +175,19 @@ function item_post(&$a) {
$app = ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : ''); $app = ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : '');
$extid = ((x($_REQUEST,'extid')) ? strip_tags($_REQUEST['extid']) : ''); $extid = ((x($_REQUEST,'extid')) ? strip_tags($_REQUEST['extid']) : '');
// Check for multiple posts with the same message id (when the post was created via API)
if (($message_id != '') AND ($profile_uid != 0)) {
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($message_id),
intval($profile_uid)
);
if (dbm::is_result($r)) {
logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
return;
}
}
$allow_moderated = false; $allow_moderated = false;
// here is where we are going to check for permission to post a moderated comment. // here is where we are going to check for permission to post a moderated comment.
@ -220,7 +233,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($profile_uid) intval($profile_uid)
); );
if(count($r)) if (dbm::is_result($r))
$user = $r[0]; $user = $r[0];
if($orig_post) { if($orig_post) {
@ -385,7 +398,7 @@ function item_post(&$a) {
} }
} }
if(count($r)) { if (dbm::is_result($r)) {
$author = $r[0]; $author = $r[0];
$contact_id = $author['id']; $contact_id = $author['id'];
} }
@ -399,7 +412,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($profile_uid) intval($profile_uid)
); );
if(count($r)) if (dbm::is_result($r))
$contact_record = $r[0]; $contact_record = $r[0];
} }
@ -482,7 +495,7 @@ function item_post(&$a) {
intval($profile_uid), intval($profile_uid),
intval($attach) intval($attach)
); );
if(count($r)) { if (dbm::is_result($r)) {
$r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' $r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `uid` = %d AND `id` = %d", WHERE `uid` = %d AND `id` = %d",
dbesc($str_contact_allow), dbesc($str_contact_allow),
@ -623,7 +636,7 @@ function item_post(&$a) {
intval($profile_uid), intval($profile_uid),
intval($mtch) intval($mtch)
); );
if(count($r)) { if (dbm::is_result($r)) {
if(strlen($attachments)) if(strlen($attachments))
$attachments .= ','; $attachments .= ',';
$attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
@ -1002,16 +1015,35 @@ function item_post(&$a) {
// Insert an item entry for UID=0 for global entries // Insert an item entry for UID=0 for global entries
// We have to remove or change some data before that, // We have to remove or change some data before that,
// so that the post appear like a regular received post. // so that the post appear like a regular received post.
unset($datarray['self']); // Additionally there is some data that isn't a database field.
unset($datarray['wall']); $arr = $datarray;
unset($datarray['origin']);
if (in_array($datarray['type'], array("net-comment", "wall-comment"))) $arr['app'] = $arr['source'];
$datarray['type'] = 'remote-comment'; unset($arr['source']);
elseif ($datarray['type'] == 'wall')
$datarray['type'] = 'remote';
add_shadow_entry($datarray); unset($arr['self']);
unset($arr['wall']);
unset($arr['origin']);
unset($arr['api_source']);
unset($arr['message_id']);
unset($arr['profile_uid']);
unset($arr['post_id']);
unset($arr['dropitems']);
unset($arr['commenter']);
unset($arr['return']);
unset($arr['preview']);
unset($arr['post_id_random']);
unset($arr['emailcc']);
unset($arr['pubmail_enable']);
unset($arr['category']);
unset($arr['jsreload']);
if (in_array($arr['type'], array("net-comment", "wall-comment"))) {
$arr['type'] = 'remote-comment';
} elseif ($arr['type'] == 'wall') {
$arr['type'] = 'remote';
}
add_shadow_entry($arr);
} }
// This is a real juggling act on shared hosting services which kill your processes // This is a real juggling act on shared hosting services which kill your processes

View file

@ -11,7 +11,7 @@
function(data){ function(data){
$.colorbox({html:data}); $.colorbox({html:data});
} }
); );
} }
function doEventPreview() { function doEventPreview() {
@ -30,28 +30,69 @@
$('#id_finish_text').prop("disabled", false); $('#id_finish_text').prop("disabled", false);
} }
$(document).ready(function() { $(document).ready(function() {
$('#events-calendar').fullCalendar({ $('#events-calendar').fullCalendar({
firstDay: {{$i18n.firstDay}}, firstDay: '{{$i18n.firstDay|escape:'quotes'}}',
monthNames: ['{{$i18n.January}}','{{$i18n.February}}','{{$i18n.March}}','{{$i18n.April}}','{{$i18n.May}}','{{$i18n.June}}','{{$i18n.July}}','{{$i18n.August}}','{{$i18n.September}}','{{$i18n.October}}','{{$i18n.November}}','{{$i18n.December}}'], monthNames: [
monthNamesShort: ['{{$i18n.Jan}}','{{$i18n.Feb}}','{{$i18n.Mar}}','{{$i18n.Apr}}','{{$i18n.May}}','{{$i18n.Jun}}','{{$i18n.Jul}}','{{$i18n.Aug}}','{{$i18n.Sep}}','{{$i18n.Oct}}','{{$i18n.Nov}}','{{$i18n.Dec}}'], '{{$i18n.January|escape:'quotes'}}',
dayNames: ['{{$i18n.Sunday}}','{{$i18n.Monday}}','{{$i18n.Tuesday}}','{{$i18n.Wednesday}}','{{$i18n.Thursday}}','{{$i18n.Friday}}','{{$i18n.Saturday}}'], '{{$i18n.February|escape:'quotes'}}',
dayNamesShort: ['{{$i18n.Sun}}','{{$i18n.Mon}}','{{$i18n.Tue}}','{{$i18n.Wed}}','{{$i18n.Thu}}','{{$i18n.Fri}}','{{$i18n.Sat}}'], '{{$i18n.March|escape:'quotes'}}',
allDayText: '{{$i18n.allday}}', '{{$i18n.April|escape:'quotes'}}',
noEventsMessage: '{{$i18n.noevent}}', '{{$i18n.May|escape:'quotes'}}',
'{{$i18n.June|escape:'quotes'}}',
'{{$i18n.July|escape:'quotes'}}',
'{{$i18n.August|escape:'quotes'}}',
'{{$i18n.September|escape:'quotes'}}',
'{{$i18n.October|escape:'quotes'}}',
'{{$i18n.November|escape:'quotes'}}',
'{{$i18n.December|escape:'quotes'}}'
],
monthNamesShort: [
'{{$i18n.Jan|escape:'quotes'}}',
'{{$i18n.Feb|escape:'quotes'}}',
'{{$i18n.Mar|escape:'quotes'}}',
'{{$i18n.Apr|escape:'quotes'}}',
'{{$i18n.May|escape:'quotes'}}',
'{{$i18n.Jun|escape:'quotes'}}',
'{{$i18n.Jul|escape:'quotes'}}',
'{{$i18n.Aug|escape:'quotes'}}',
'{{$i18n.Sep|escape:'quotes'}}',
'{{$i18n.Oct|escape:'quotes'}}',
'{{$i18n.Nov|escape:'quotes'}}',
'{{$i18n.Dec|escape:'quotes'}}'
],
dayNames: [
'{{$i18n.Sunday|escape:'quotes'}}',
'{{$i18n.Monday|escape:'quotes'}}',
'{{$i18n.Tuesday|escape:'quotes'}}',
'{{$i18n.Wednesday|escape:'quotes'}}',
'{{$i18n.Thursday|escape:'quotes'}}',
'{{$i18n.Friday|escape:'quotes'}}',
'{{$i18n.Saturday|escape:'quotes'}}'
],
dayNamesShort: [
'{{$i18n.Sun|escape:'quotes'}}',
'{{$i18n.Mon|escape:'quotes'}}',
'{{$i18n.Tue|escape:'quotes'}}',
'{{$i18n.Wed|escape:'quotes'}}',
'{{$i18n.Thu|escape:'quotes'}}',
'{{$i18n.Fri|escape:'quotes'}}',
'{{$i18n.Sat|escape:'quotes'}}'
],
allDayText: '{{$i18n.allday|escape:'quotes'}}',
noEventsMessage: '{{$i18n.noevent|escape:'quotes'}}',
buttonText: { buttonText: {
today: '{{$i18n.today}}', today: '{{$i18n.today|escape:'quotes'}}',
month: '{{$i18n.month}}', month: '{{$i18n.month|escape:'quotes'}}',
week: '{{$i18n.week}}', week: '{{$i18n.week|escape:'quotes'}}',
day: '{{$i18n.day}}' day: '{{$i18n.day|escape:'quotes'}}'
}, },
events: '{{$baseurl}}{{$module_url}}/json/', events: '{{$baseurl}}{{$module_url}}/json/',
header: { header: {
left: 'prev,next today', left: 'prev,next today',
center: 'title', center: 'title',
right: 'month,agendaWeek,agendaDay' right: 'month,agendaWeek,agendaDay'
}, },
timeFormat: 'H(:mm)', timeFormat: 'H(:mm)',
eventClick: function(calEvent, jsEvent, view) { eventClick: function(calEvent, jsEvent, view) {
showEvent(calEvent.id); showEvent(calEvent.id);
@ -61,9 +102,8 @@
$('td.fc-day').dblclick(function() { window.location.href='/events/new?start='+$(this).data('date'); }); $('td.fc-day').dblclick(function() { window.location.href='/events/new?start='+$(this).data('date'); });
} }
}, },
eventRender: function(event, element, view) { eventRender: function(event, element, view) {
//console.log(view.name);
if (event.item['author-name']==null) return; if (event.item['author-name']==null) return;
switch(view.name){ switch(view.name){
case "month": case "month":
@ -94,35 +134,33 @@
break; break;
} }
} }
}) })
// center on date // center on date
var args=location.href.replace(baseurl,"").split("/"); var args=location.href.replace(baseurl,"").split("/");
{{if $modparams == 2}} {{if $modparams == 2}}
if (args.length>=5) { if (args.length>=5) {
$("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1); $("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1);
} }
{{else}} {{else}}
if (args.length>=4) { if (args.length>=4) {
$("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1); $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
} }
{{/if}} {{/if}}
// show event popup // show event popup
var hash = location.hash.split("-") var hash = location.hash.split("-")
if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]); if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
}); });
</script> </script>
{{if $editselect != 'none'}} {{if $editselect != 'none'}}
<script language="javascript" type="text/javascript" <script language="javascript" type="text/javascript"
src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script> src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
tinyMCE.init({ tinyMCE.init({
theme : "advanced", theme : "advanced",
mode : "textareas", mode : "textareas",
@ -139,8 +177,6 @@
entity_encoding : "raw", entity_encoding : "raw",
add_unload_trigger : false, add_unload_trigger : false,
remove_linebreaks : false, remove_linebreaks : false,
//force_p_newlines : false,
//force_br_newlines : true,
forced_root_block : 'div', forced_root_block : 'div',
content_css: "{{$baseurl}}/view/custom_tinymce.css", content_css: "{{$baseurl}}/view/custom_tinymce.css",
theme_advanced_path : false, theme_advanced_path : false,
@ -152,22 +188,21 @@
}); });
$(document).ready(function() { $(document).ready(function() {
$('.comment-edit-bb').hide(); $('.comment-edit-bb').hide();
}); });
{{else}} {{else}}
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
{{/if}} {{/if}}
$(document).ready(function() {
$(document).ready(function() { {{if $editselect = 'none'}}
{{if $editselect = 'none'}}
$("#comment-edit-text-desc").bbco_autocomplete('bbcode'); $("#comment-edit-text-desc").bbco_autocomplete('bbcode');
{{/if}} {{/if}}
$('#id_share').change(function() { $('#id_share').change(function() {
if ($('#id_share').is(':checked')) { if ($('#id_share').is(':checked')) {
$('#acl-wrapper').show(); $('#acl-wrapper').show();
} }
else { else {
@ -175,7 +210,6 @@
} }
}).trigger('change'); }).trigger('change');
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
var selstr; var selstr;
$('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {

View file

@ -5,7 +5,7 @@
<div class="event-wrapper"> <div class="event-wrapper">
<div class="event"> <div class="event">
<div class="media"> <div class="media">
<div class="event-owner pull-left"> <div class="event-owner media-left">
{{if $event.item.author_name}} {{if $event.item.author_name}}
<a href="{{$event.item.author_link}}" ><img src="{{$event.item.author_avatar}}" /></a> <a href="{{$event.item.author_link}}" ><img src="{{$event.item.author_avatar}}" /></a>
<a href="{{$event.item.author_link}}" >{{$event.item.author_name}}</a> <a href="{{$event.item.author_link}}" >{{$event.item.author_name}}</a>

View file

@ -6,27 +6,67 @@
<script type="text/javascript" src="{{$baseurl}}/library/fullcalendar/fullcalendar.min.js"></script> <script type="text/javascript" src="{{$baseurl}}/library/fullcalendar/fullcalendar.min.js"></script>
<script type="text/javascript" src="view/theme/frio/js/mod_events.js"></script> <script type="text/javascript" src="view/theme/frio/js/mod_events.js"></script>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
// pass php translation strings to js variables/arrays so we can make use of it in js files // pass php translation strings to js variables/arrays so we can make use of it in js files
aStr.monthNames = ['{{$i18n.January}}','{{$i18n.February}}','{{$i18n.March}}','{{$i18n.April}}','{{$i18n.May}}','{{$i18n.June}}','{{$i18n.July}}','{{$i18n.August}}','{{$i18n.September}}','{{$i18n.October}}','{{$i18n.November}}','{{$i18n.December}}']; aStr.monthNames = [
aStr.monthNamesShort = ['{{$i18n.Jan}}','{{$i18n.Feb}}','{{$i18n.Mar}}','{{$i18n.Apr}}','{{$i18n.May}}','{{$i18n.Jun}}','{{$i18n.Jul}}','{{$i18n.Aug}}','{{$i18n.Sep}}','{{$i18n.Oct}}','{{$i18n.Nov}}','{{$i18n.Dec}}']; '{{$i18n.January|escape:'quotes'}}',
aStr.monthNamesShort = ['{{$i18n.Jan}}','{{$i18n.Feb}}','{{$i18n.Mar}}','{{$i18n.Apr}}','{{$i18n.May}}','{{$i18n.Jun}}','{{$i18n.Jul}}','{{$i18n.Aug}}','{{$i18n.Sep}}','{{$i18n.Oct}}','{{$i18n.Nov}}','{{$i18n.Dec}}']; '{{$i18n.February|escape:'quotes'}}',
aStr.dayNames = ['{{$i18n.Sunday}}','{{$i18n.Monday}}','{{$i18n.Tuesday}}','{{$i18n.Wednesday}}','{{$i18n.Thursday}}','{{$i18n.Friday}}','{{$i18n.Saturday}}']; '{{$i18n.March|escape:'quotes'}}',
aStr.dayNamesShort = ['{{$i18n.Sun}}','{{$i18n.Mon}}','{{$i18n.Tue}}','{{$i18n.Wed}}','{{$i18n.Thu}}','{{$i18n.Fri}}','{{$i18n.Sat}}']; '{{$i18n.April|escape:'quotes'}}',
'{{$i18n.May|escape:'quotes'}}',
'{{$i18n.June|escape:'quotes'}}',
'{{$i18n.July|escape:'quotes'}}',
'{{$i18n.August|escape:'quotes'}}',
'{{$i18n.September|escape:'quotes'}}',
'{{$i18n.October|escape:'quotes'}}',
'{{$i18n.November|escape:'quotes'}}',
'{{$i18n.December|escape:'quotes'}}'
];
aStr.monthNamesShort = [
'{{$i18n.Jan|escape:'quotes'}}',
'{{$i18n.Feb|escape:'quotes'}}',
'{{$i18n.Mar|escape:'quotes'}}',
'{{$i18n.Apr|escape:'quotes'}}',
'{{$i18n.May|escape:'quotes'}}',
'{{$i18n.Jun|escape:'quotes'}}',
'{{$i18n.Jul|escape:'quotes'}}',
'{{$i18n.Aug|escape:'quotes'}}',
'{{$i18n.Sep|escape:'quotes'}}',
'{{$i18n.Oct|escape:'quotes'}}',
'{{$i18n.Nov|escape:'quotes'}}',
'{{$i18n.Dec|escape:'quotes'}}'
];
aStr.dayNames = [
'{{$i18n.Sunday|escape:'quotes'}}',
'{{$i18n.Monday|escape:'quotes'}}',
'{{$i18n.Tuesday|escape:'quotes'}}',
'{{$i18n.Wednesday|escape:'quotes'}}',
'{{$i18n.Thursday|escape:'quotes'}}',
'{{$i18n.Friday|escape:'quotes'}}',
'{{$i18n.Saturday|escape:'quotes'}}'
];
aStr.dayNamesShort = [
'{{$i18n.Sun|escape:'quotes'}}',
'{{$i18n.Mon|escape:'quotes'}}',
'{{$i18n.Tue|escape:'quotes'}}',
'{{$i18n.Wed|escape:'quotes'}}',
'{{$i18n.Thu|escape:'quotes'}}',
'{{$i18n.Fri|escape:'quotes'}}',
'{{$i18n.Sat|escape:'quotes'}}'
];
aStr.firstDay = '{{$i18n.firstDay}}'; aStr.firstDay = '{{$i18n.firstDay|escape:'quotes'}}';
aStr.today = '{{$i18n.today}}'; aStr.today = '{{$i18n.today|escape:'quotes'}}';
aStr.month = '{{$i18n.month}}'; aStr.month = '{{$i18n.month|escape:'quotes'}}';
aStr.week = '{{$i18n.week}}'; aStr.week = '{{$i18n.week|escape:'quotes'}}';
aStr.day = '{{$i18n.day}}'; aStr.day = '{{$i18n.day|escape:'quotes'}}';
aStr.allday = '{{$i18n.allday}}'; aStr.allday = '{{$i18n.allday|escape:'quotes'}}';
aStr.noevent = '{{$i18n.noevent}}'; aStr.noevent = '{{$i18n.noevent|escape:'quotes'}}';
aStr.dtstartLabel = '{{$i18n.dtstart_label}}'; aStr.dtstartLabel = '{{$i18n.dtstart_label|escape:'quotes'}}';
aStr.dtendLabel = '{{$i18n.dtend_label}}'; aStr.dtendLabel = '{{$i18n.dtend_label|escape:'quotes'}}';
aStr.locationLabel = '{{$i18n.location_label}}'; aStr.locationLabel = '{{$i18n.location_label|escape:'quotes'}}';
var moduleUrl = '{{$module_url}}'; var moduleUrl = '{{$module_url}}';
var modparams = {{$modparams}} var modparams = {{$modparams}}
@ -38,7 +78,6 @@
src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script> src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
tinyMCE.init({ tinyMCE.init({
theme : "advanced", theme : "advanced",
mode : "textareas", mode : "textareas",
@ -55,8 +94,6 @@
entity_encoding : "raw", entity_encoding : "raw",
add_unload_trigger : false, add_unload_trigger : false,
remove_linebreaks : false, remove_linebreaks : false,
//force_p_newlines : false,
//force_br_newlines : true,
forced_root_block : 'div', forced_root_block : 'div',
content_css: "{{$baseurl}}/view/custom_tinymce.css", content_css: "{{$baseurl}}/view/custom_tinymce.css",
theme_advanced_path : false, theme_advanced_path : false,
@ -68,18 +105,17 @@
}); });
$(document).ready(function() { $(document).ready(function() {
$('.comment-edit-bb').hide(); $('.comment-edit-bb').hide();
}); });
{{else}} {{else}}
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
{{/if}} {{/if}}
$(document).ready(function() {
$(document).ready(function() { {{if $editselect = 'none'}}
{{if $editselect = 'none'}}
$("#comment-edit-text-desc").bbco_autocomplete('bbcode'); $("#comment-edit-text-desc").bbco_autocomplete('bbcode');
{{/if}} {{/if}}
}); });