Merge remote-tracking branch 'friendica/develop' into Issue-#2816-2

This commit is contained in:
Hypolite Petovan 2016-10-03 19:04:57 -04:00
commit b3ac6189b3
28 changed files with 141 additions and 82 deletions

View file

@ -208,22 +208,22 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
$uid = local_user();
// Fetch contact data from the contact table for the given user
$r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
`xmpp`, `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, `self`
$r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
dbesc(normalise_link($url)), intval($uid));
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
if (!$r)
$r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
`xmpp`, `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, 0 AS `self`
$r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
dbesc(normalise_link($url)));
// Fetch the data from the gcontact table
if (!$r)
$r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
'' AS `xmpp`, `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `birthday`, 0 AS `self`
$r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, 0 AS `contact-type`, `birthday`, 0 AS `self`
FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($url)));
@ -683,4 +683,50 @@ function formatted_location($profile) {
return $location;
}
/**
* @brief Returns the account type name
*
* The function can be called with either the user or the contact array
*
* @param array $contact contact or user array
*/
function account_type($contact) {
// There are several fields that indicate that the contact or user is a forum
// "page-flags" is a field in the user table,
// "forum" and "prv" are used in the contact table. They stand for PAGE_COMMUNITY and PAGE_PRVGROUP.
// "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP.
if((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY))
|| (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP))
|| (isset($contact['forum']) && intval($contact['forum']))
|| (isset($contact['prv']) && intval($contact['prv']))
|| (isset($contact['community']) && intval($contact['community'])))
$type = ACCOUNT_TYPE_COMMUNITY;
else
$type = ACCOUNT_TYPE_PERSON;
// The "contact-type" (contact table) and "account-type" (user table) are more general then the chaos from above.
if (isset($contact["contact-type"]))
$type = $contact["contact-type"];
if (isset($contact["account-type"]))
$type = $contact["account-type"];
switch($type) {
case ACCOUNT_TYPE_ORGANISATION:
$account_type = t("Organisation");
break;
case ACCOUNT_TYPE_NEWS:
$account_type = t('News');
break;
case ACCOUNT_TYPE_COMMUNITY:
$account_type = t("Forum");
break;
default:
$account_type = "";
break;
}
return $account_type;
}
?>

View file

@ -130,6 +130,9 @@ function print_structure($database, $charset) {
function update_structure($verbose, $action, $tables=null, $definition=null) {
global $a, $db;
if ($action)
set_config('system', 'maintenance', 1);
if (isset($a->config["system"]["db_charset"]))
$charset = $a->config["system"]["db_charset"];
else
@ -251,6 +254,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
}
}
if ($action)
set_config('system', 'maintenance', 0);
return $errors;
}

View file

@ -2492,7 +2492,19 @@ class dfrn {
logger("Import DFRN message for user ".$importer["uid"]." from contact ".$importer["id"], LOGGER_DEBUG);
// is it a public forum? Private forums aren't supported by now with this method
// The account type is new since 3.5.1
if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
$accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue);
if ($accounttype != $importer["contact-type"])
q("UPDATE `contact` SET `contact-type` = %d WHERE `id` = %d",
intval($accounttype),
intval($importer["id"])
);
}
// is it a public forum? Private forums aren't supported with this method
// This is deprecated since 3.5.1
$forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue);
if ($forum != $importer["forum"])

View file

@ -49,7 +49,7 @@ function notification($params) {
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
// the database, and an email is sent if applicable.
// default, if not specified: true
$show_in_notification_page = ((x($params, 'show_in_notification_page')) ? $params['show_in_notification_page']:True);
$show_in_notification_page = ((x($params, 'show_in_notification_page')) ? $params['show_in_notification_page']:true);
$additional_mail_header = "";
$additional_mail_header .= "Precedence: list\n";

View file

@ -310,15 +310,8 @@ function profile_sidebar($profile, $block = 0) {
);
}
// check if profile is a forum
if((intval($profile['page-flags']) == PAGE_COMMUNITY)
|| (intval($profile['page-flags']) == PAGE_PRVGROUP)
|| (isset($profile['forum']) && intval($profile['forum']))
|| (isset($profile['prv']) && intval($profile['prv']))
|| (isset($profile['community']) && intval($profile['community'])))
$account_type = t('Forum');
else
$account_type = "";
// Fetch the account type
$account_type = account_type($profile);
if((x($profile,'address') == 1)
|| (x($profile,'location') == 1)

View file

@ -210,8 +210,10 @@ function oembed_format_object($j){
}
/**
* Generates the iframe HTML for an oembed attachment. Width and height are given
* by the remote, and are regularly too small for the generated iframe.
* @brief Generates the iframe HTML for an oembed attachment.
*
* Width and height are given by the remote, and are regularly too small for
* the generated iframe.
*
* The width is entirely discarded for the actual width of the post, while fixed
* height is used as a starting point before the inevitable resizing.
@ -222,7 +224,7 @@ function oembed_format_object($j){
* @param string $src Original remote URL to embed
* @param string $width
* @param string $height
* @return string
* @return string formatted HTML
*
* @see oembed_format_object()
*/

View file

@ -179,7 +179,7 @@ function get_avaiable_languages() {
asort($langs);
foreach($langs as $l) {
$t = explode("/",$l);
$lang_choices[$t[1]] = $t[1];
$lang_choices[$t[2]] = $t[2];
}
}
return $lang_choices;

View file

@ -29,6 +29,10 @@ function poller_run(&$argv, &$argc){
unset($db_host, $db_user, $db_pass, $db_data);
};
// Quit when in maintenance
if (get_config('system', 'maintenance', true))
return;
$a->start_process();
$mypid = getmypid();
@ -71,6 +75,10 @@ function poller_run(&$argv, &$argc){
while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority`, `created` LIMIT 1")) {
// Quit when in maintenance
if (get_config('system', 'maintenance', true))
return;
// Constantly check the number of parallel database processes
if ($a->max_processes_reached())
return;

View file

@ -263,13 +263,13 @@
var html = notifications_tpl.format(
e.attr('href'), // {0} // link to the source
e.attr('photo'), // {1} // photo of the contact
text, // {2} // preformatet text (autor + text)
text, // {2} // preformatted text (autor + text)
e.attr('date'), // {3} // date of notification (time ago)
seenclass, // {4} // vistiting status of the notification
seenclass, // {4} // visited status of the notification
new Date(e.attr('timestamp')*1000), // {5} // date of notification
e.attr('url'), // {6} // profile url of the contact
e.text().format(""), // {7} // clean status text
contact // {8} //preformatat author (name + profile url)
e.text().format(contact), // {7} // preformatted html (text including author profile url)
'' // {8} // Deprecated
);
nnm.append(html);
});

View file

@ -76,7 +76,7 @@ function allfriends_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'network' => network_to_name($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'conntxt' => t('Connect'),

View file

@ -40,10 +40,7 @@ function cal_init(&$a) {
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
$account_type = t('Forum');
else
$account_type = "";
$account_type = account_type($profile);
$tpl = get_markup_template("vcard-widget.tpl");

View file

@ -120,7 +120,7 @@ function common_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'network' => network_to_name($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'id' => ++$id,

View file

@ -48,7 +48,7 @@ function contacts_init(&$a) {
'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
'$network_name' => $networkname,
'$network' => t('Network:'),
'account_type' => (($a->data['contact']['forum'] || $a->data['contact']['prv']) ? t('Forum') : '')
'$account_type' => account_type($a->data['contact'])
));
$finpeople_widget = '';
$follow_widget = '';
@ -623,7 +623,7 @@ function contacts_content(&$a) {
'$url' => $url,
'$profileurllabel' => t('Profile URL'),
'$profileurl' => $contact['url'],
'account_type' => (($contact['forum'] || $contact['prv']) ? t('Forum') : ''),
'$account_type' => account_type($contact),
'$location' => bbcode($contact["location"]),
'$location_label' => t("Location:"),
'$xmpp' => bbcode($contact["xmpp"]),
@ -910,8 +910,6 @@ function contact_posts($a, $contact_id) {
function _contact_detail_for_template($rr){
$community = '';
switch($rr['rel']) {
case CONTACT_IS_FRIEND:
$dir_icon = 'images/lrarrow.gif';
@ -937,11 +935,6 @@ function _contact_detail_for_template($rr){
$sparkle = '';
}
//test if contact is a forum page
if (isset($rr['forum']) OR isset($rr['prv']))
$community = ($rr['forum'] OR $rr['prv']);
return array(
'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
'edit_hover' => t('Edit contact'),
@ -952,7 +945,7 @@ function _contact_detail_for_template($rr){
'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
'name' => htmlentities($rr['name']),
'username' => htmlentities($rr['name']),
'account_type' => ($community ? t('Forum') : ''),
'account_type' => account_type($rr),
'sparkle' => $sparkle,
'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
'url' => $url,

View file

@ -99,7 +99,6 @@ function directory_content(&$a) {
foreach($r as $rr) {
$community = '';
$itemurl= '';
$itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
@ -128,13 +127,6 @@ function directory_content(&$a) {
// if(strlen($rr['gender']))
// $details .= '<br />' . t('Gender: ') . $rr['gender'];
// show if account is a community account
/// @TODO The other page types should be also respected, but first we need a good
/// translatiion and systemwide consistency for displaying the page type
if((intval($rr['page-flags']) == PAGE_COMMUNITY) OR (intval($rr['page-flags']) == PAGE_PRVGROUP))
$community = true;
$profile = $rr;
if((x($profile,'address') == 1)
@ -171,7 +163,7 @@ function directory_content(&$a) {
'img_hover' => $rr['name'],
'name' => $rr['name'],
'details' => $details,
'account_type' => ($community ? t('Forum') : ''),
'account_type' => account_type($rr),
'profile' => $profile,
'location' => $location_e,
'tags' => $rr['pub_keywords'],

View file

@ -220,7 +220,7 @@ function dirfind_content(&$a, $prefix = "") {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'network' => network_to_name($jj->network, $jj->url),
'id' => ++$id,
);

View file

@ -77,10 +77,9 @@ function hovercard_content() {
// 'server_url' => $contact["server_url"],
'bd' => (($contact["birthday"] == "0000-00-00") ? "" : $contact["birthday"]),
// 'generation' => $contact["generation"],
'account_type' => ($contact['community'] ? t("Forum") : ""),
'account_type' => account_type($contact),
'actions' => $actions,
);
if($datatype == "html") {
$t = get_markup_template("hovercard.tpl");

View file

@ -1,6 +1,10 @@
<?php
function maintenance_content(&$a) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 600');
return replace_macros(get_markup_template('maintenance.tpl'), array(
'$sysdown' => t('System down for maintenance')
));

View file

@ -81,7 +81,7 @@ function match_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
'inttxt' => ' ' . t('is interested in:'),
'conntxt' => t('Connect'),

View file

@ -502,7 +502,7 @@ function network_content(&$a, $update = 0) {
}
elseif($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($cid)
);
@ -514,10 +514,11 @@ function network_content(&$a, $update = 0) {
'name' => htmlentities($r[0]['name']),
'itemurl' => (($r[0]['addr']) ? ($r[0]['addr']) : ($r[0]['nurl'])),
'thumb' => proxy_url($r[0]['thumb'], false, PROXY_SIZE_THUMB),
'account_type' => (($r[0]['forum']) || ($r[0]['prv']) ? t('Forum') : ''),
'details' => $r[0]['location'],
);
$entries[0]["account_type"] = account_type($r[0]);
$o = replace_macros(get_markup_template("viewcontact_template.tpl"),array(
'contacts' => $entries,
'id' => 'network',

View file

@ -38,10 +38,7 @@ function photos_init(&$a) {
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
$account_type = t('Forum');
else
$account_type = "";
$account_type = account_type($profile);
$tpl = get_markup_template("vcard-widget.tpl");

View file

@ -132,7 +132,6 @@ function register_post(&$a) {
$admin_mail_list
);
foreach ($adminlist as $admin) {
notification(array(
'type' => NOTIFY_SYSTEM,
@ -145,11 +144,11 @@ function register_post(&$a) {
'source_photo' => $a->get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
'to_email' => $admin['email'],
'uid' => $admin['uid'],
'language' => ($admin['language']?$admin['language']:'en'))
);
'language' => ($admin['language']?$admin['language']:'en'),
'show_in_notification_page' => false
));
}
info( t('Your registration is pending approval by the site owner.') . EOL ) ;
goaway(z_root());

View file

@ -95,7 +95,7 @@ function suggest_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'ignlnk' => $ignlnk,
'ignid' => $rr['id'],
'conntxt' => t('Connect'),
@ -113,7 +113,6 @@ function suggest_content(&$a) {
$o .= replace_macros($tpl,array(
'$title' => t('Friend Suggestions'),
'$contacts' => $entries,
));
return $o;

View file

@ -33,10 +33,7 @@ function videos_init(&$a) {
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
$account_type = t('Forum');
else
$account_type = "";
$account_type = account_type($profile);
$tpl = get_markup_template("vcard-widget.tpl");

View file

@ -102,7 +102,7 @@ function viewcontacts_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'url' => $url,
'sparkle' => '',
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),

View file

@ -19,7 +19,10 @@
<link rel="apple-touch-icon" href="{{$touch_icon}}"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<script>
// Prevents links to switch to Safari in a home screen app - see https://gist.github.com/irae/1042167
(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone");
</script>
<link rel="search"
href="{{$baseurl}}/opensearch"

View file

@ -1422,6 +1422,7 @@ section #jotOpen {
width: 20px;
}
/* wall-item content elements */
.shared-wrapper,
.vevent {
padding: 10px;
@ -1451,6 +1452,12 @@ blockquote.shared_content {
margin-left: 0px;
color: inherit;
}
code > .hl-main {
padding: 10px 10px 1px 0;
}
.hl-main ol {
line-height: 1.7;
}
.wall-item-tags,
.itemedited {
margin-top: 10px;

View file

@ -40,6 +40,10 @@
<link rel="apple-touch-icon" href="{{$touch_icon}}"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<script>
// Prevents links to switch to Safari in a home screen app - see https://gist.github.com/irae/1042167
(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone");
</script>
<link rel="search"
href="{{$baseurl}}/opensearch"

View file

@ -275,7 +275,7 @@
{{*The second part of the notifications dropdown menu. It handles the notifications *}}
{{if $nav.notifications}}
<ul id="nav-notifications-template" class="media-list" style="display:none;" rel="template"> <!-- needs further investigation. I thought the notifications have their own templates -->
<ul id="nav-notifications-template" class="media-list" style="display:none;" rel="template">
<li class="{4} notif-entry">
<div class="notif-entry-wrapper media">
<div class="notif-photo-wrapper media-object pull-left"><a href="{6}"><img data-src="{1}"></a></div>