Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Haakon Meland Eriksen 2016-01-16 13:44:23 +01:00
commit 983e170f20
18 changed files with 819 additions and 597 deletions

View file

@ -48,7 +48,7 @@ require_once('include/AccessList.php');
define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')));
define ( 'STD_VERSION', '1.1.1' );
define ( 'STD_VERSION', '1.1.2' );
define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1161 );
@ -245,6 +245,21 @@ define ( 'PHOTO_COVER', 0x0010 );
define ( 'PHOTO_ADULT', 0x0008 );
define ( 'PHOTO_FLAG_OS', 0x4000 );
define ( 'PHOTO_RES_ORIG', 0 );
define ( 'PHOTO_RES_1024', 1 ); // rectangular 1024 max width or height, floating height if not (4:3)
define ( 'PHOTO_RES_640', 2 ); // to accomodate SMBC vertical comic strips without scrunching the width
define ( 'PHOTO_RES_320', 3 ); // accordingly
define ( 'PHOTO_RES_PROFILE_300', 4 ); // square 300 px
define ( 'PHOTO_RES_PROFILE_80', 5 ); // square 80 px
define ( 'PHOTO_RES_PROFILE_48', 6 ); // square 48 px
define ( 'PHOTO_RES_COVER_1200', 7 ); // 1200w x 435h (2.75:1)
define ( 'PHOTO_RES_COVER_850', 8 ); // 850w x 310h
define ( 'PHOTO_RES_COVER_425', 9 ); // 425w x 160h
/**
* Menu types
*/
@ -256,11 +271,11 @@ define ( 'MENU_BOOKMARK', 0x0002 );
* Network and protocol family types
*/
define ( 'NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations
define ( 'NETWORK_ZOT', 'zot!'); // Zot!
define ( 'NETWORK_DFRN', 'friendica-over-diaspora'); // Friendica, Mistpark, other DFRN implementations
define ( 'NETWORK_ZOT', 'zot'); // Zot!
define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations
define ( 'NETWORK_FEED', 'feed'); // RSS/Atom feeds with no known "post/notify" protocol
define ( 'NETWORK_DIASPORA', 'dspr'); // Diaspora
define ( 'NETWORK_FEED', 'rss'); // RSS/Atom feeds with no known "post/notify" protocol
define ( 'NETWORK_DIASPORA', 'diaspora'); // Diaspora
define ( 'NETWORK_MAIL', 'mail'); // IMAP/POP
define ( 'NETWORK_MAIL2', 'mai2'); // extended IMAP/POP
define ( 'NETWORK_FACEBOOK', 'face'); // Facebook API
@ -1989,12 +2004,14 @@ function load_pdl(&$a) {
$arr = array('module' => $a->module, 'layout' => '');
call_hooks('load_pdl',$arr);
$s = $arr['layout'];
$layout = $arr['layout'];
$n = 'mod_' . $a->module . '.pdl' ;
$u = comanche_get_channel_id();
if($u)
$s = get_pconfig($u, 'system', $n);
if(! $s)
$s = $layout;
if((! $s) && (($p = theme_include($n)) != ''))
$s = @file_get_contents($p);

View file

@ -85,6 +85,13 @@ Some/many of these widgets have restrictions which may restrict the type of page
* style - CSS style string
<br />&nbsp;<br />
* cover_photo - display the cover photo for the selected channel
* args:
* channel_id - channel to use, default is the profile_uid
* style - CSS style string (default is dynamically resized to width of region)
<br />&nbsp;<br />
* photo_rand - display a random photo from one of your photo albums. Photo permissions are honoured
* args:
* album - album name (very strongly recommended if you have lots of photos)

View file

@ -275,6 +275,7 @@ function comanche_widget($name, $text) {
$vars = array();
$matches = array();
$cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {

View file

@ -79,7 +79,7 @@ function network_to_name($s) {
NETWORK_MAIL => t('Email'),
NETWORK_DIASPORA => t('Diaspora'),
NETWORK_FACEBOOK => t('Facebook'),
NETWORK_ZOT => t('Zot!'),
NETWORK_ZOT => t('Zot'),
NETWORK_LINKEDIN => t('LinkedIn'),
NETWORK_XMPP => t('XMPP/IM'),
NETWORK_MYSPACE => t('MySpace'),

View file

@ -1737,3 +1737,38 @@ function auto_channel_create($account_id) {
}
function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) {
$r = q("select height, width, resource_id, type from photo where uid = %d and scale = %d and photo_usage = %d",
intval($channel_id),
intval($res),
intval(PHOTO_COVER)
);
if(! $r)
return false;
$output = false;
$url = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $res ;
switch($format) {
case 'bbcode':
$output = '[zrl=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . $url . '[/zrl]';
break;
case 'html':
$output = '<img class="zrl" width="' . $r[0]['width'] . '" height="' . $r[0]['height'] . '" src="' . $url . '" alt="' . t('cover photo') . '" />';
break;
case 'array':
default:
$output = array(
'width' => $r[0]['width'],
'height' => $r[0]['type'],
'type' => $r[0]['type'],
'url' => $url
);
break;
}
return $output;
}

View file

@ -936,6 +936,38 @@ function widget_photo($arr) {
}
function widget_cover_photo($arr) {
require_once('include/identity.php');
$o = '';
$channel_id = 0;
if(array_key_exists('channel_id', $arr) && intval($arr['channel_id']))
$channel_id = intval($arr['channel_id']);
if(! $channel_id)
$channel_id = get_app()->profile_uid;
if(! $channel_id)
return '';
if(array_key_exists('style', $arr) && isset($arr['style']))
$style = $arr['style'];
else
$style = 'width:100%; padding-right: 10px; height: auto;';
// ensure they can't sneak in an eval(js) function
if(strpos($style,'(') !== false)
return '';
$c = get_cover_photo($channel_id,'html');
if($c) {
$o = '<div class="widget">' . (($style) ? str_replace('alt=',' style="' . $style . '" alt=',$c) : $c) . '</div>';
}
return $o;
}
function widget_photo_rand($arr) {
require_once('include/photos.php');

View file

@ -228,23 +228,49 @@ function connections_content(&$a) {
foreach($r as $rr) {
if($rr['xchan_url']) {
$status_str = '';
$status = array(
((intval($rr['abook_pending'])) ? t('Pending approval') : ''),
((intval($rr['abook_archived'])) ? t('Archived') : ''),
((intval($rr['abook_hidden'])) ? t('Hidden') : ''),
((intval($rr['abook_ignored'])) ? t('Ignored') : ''),
((intval($rr['abook_blocked'])) ? t('Blocked') : '')
);
foreach($status as $str) {
if(!$str)
continue;
$status_str .= $str;
$status_str .= ', ';
}
$status_str = rtrim($status_str, ', ');
$contacts[] = array(
'img_hover' => sprintf( t('%1$s [%2$s]'),$rr['xchan_name'],$rr['xchan_url']),
'edit_hover' => t('Edit connection'),
'delete_hover' => t('Delete connection'),
'id' => $rr['abook_id'],
'alt_text' => $alt_text,
'dir_icon' => $dir_icon,
'thumb' => $rr['xchan_photo_m'],
'name' => $rr['xchan_name'],
'username' => $rr['xchan_name'],
'classes' => (intval($rr['abook_archived']) ? 'archived' : ''),
'link' => z_root() . '/connedit/' . $rr['abook_id'],
'deletelink' => z_root() . '/connedit/' . $rr['abook_id'] . '/drop',
'edit' => t('Edit'),
'deletelink' => z_root() . '/connedit/' . intval($rr['abook_id']) . '/drop',
'delete' => t('Delete'),
'url' => chanlink_url($rr['xchan_url']),
'network' => network_to_name($rr['network']),
'webbie_label' => t('Channel address'),
'webbie' => $rr['xchan_addr'],
'network_label' => t('Network'),
'network' => network_to_name($rr['xchan_network']),
'public_forum' => ((intval($rr['xchan_pubforum'])) ? true : false),
'status_label' => t('Status'),
'status' => $status_str,
'connected_label' => t('Connected'),
'connected' => datetime_convert('UTC',date_default_timezone_get(),$rr['abook_created'], 'c'),
'approve_hover' => t('Approve connection'),
'approve' => (($rr['abook_pending']) ? t('Approve') : false),
'recent_label' => t('Recent activity'),
'recentlink' => z_root() . '/network/?f=&cid=' . intval($rr['abook_id'])
);
}
}

View file

@ -305,6 +305,9 @@ function connedit_post(&$a) {
connedit_clone($a);
if(($_REQUEST['pending']) && (!$_REQUEST['done']))
goaway($a->get_baseurl(true) . '/connections/ifpending');
return;
}
@ -711,10 +714,6 @@ function connedit_content(&$a) {
'$slide' => $slide,
'$affinity' => $affinity,
'$pending_label' => t('Connection Pending Approval'),
'$pending_modal_title' => t('Connection Request'),
'$pending_modal_body' => sprintf(t('(%s) would like to connect with you. Please approve this connection to allow communication.'), $contact['xchan_addr']),
'$pending_modal_approve' => t('Approve'),
'$pending_modal_dismiss' => t('Approve Later'),
'$is_pending' => (intval($contact['abook_pending']) ? 1 : ''),
'$unapproved' => $unapproved,
'$inherited' => t('inherited'),

View file

@ -1,7 +1,8 @@
<?php
/* @file cover_photo.php
@brief Module-file with functions for handling of profile-photos
/*
@file cover_photo.php
@brief Module-file with functions for handling of cover-photos
*/
@ -40,6 +41,8 @@ function cover_photo_post(&$a) {
if(! local_channel()) {
return;
}
$channel = $a->get_channel();
check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
@ -65,6 +68,14 @@ function cover_photo_post(&$a) {
$srcW = $_POST['xfinal'] - $srcX;
$srcH = $_POST['yfinal'] - $srcY;
$r = q("select gender from profile where uid = %d and is_default = 1 limit 1",
intval(local_channel())
);
if($r) {
$profile = $r[0];
}
$r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND scale = 0 LIMIT 1",
dbesc($image_id),
intval(local_channel())
@ -78,12 +89,17 @@ function cover_photo_post(&$a) {
$im = photo_factory($base_image['data'], $base_image['type']);
if($im->is_valid()) {
// We are scaling and cropping the relative pixel locations to the original photo instead of the
// scaled photo we operated on.
// First load the scaled photo to check its size. (Should probably pass this in the post form and save
// a query.)
$g = q("select width, height from photo where resource_id = '%s' and uid = %d and scale = 3",
dbesc($image_id),
intval(local_channel())
);
// scale these numbers to the original photo instead of the scaled photo we operated on
$scaled_width = $g[0]['width'];
$scaled_height = $g[0]['height'];
@ -93,6 +109,14 @@ function cover_photo_post(&$a) {
return;
}
// unset all other cover photos
q("update photo set photo_usage = %d where photo_usage = %d and uid = %d",
intval(PHOTO_NORMAL),
intval(PHOTO_COVER),
intval(local_channel())
);
$orig_srcx = ( $r[0]['width'] / $scaled_width ) * $srcX;
$orig_srcy = ( $r[0]['height'] / $scaled_height ) * $srcY;
$orig_srcw = ( $srcW / $scaled_width ) * $r[0]['width'];
@ -103,7 +127,7 @@ function cover_photo_post(&$a) {
$aid = get_account_id();
$p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'],
'filename' => $base_image['filename'], 'album' => t('Profile Photos'));
'filename' => $base_image['filename'], 'album' => t('Cover Photos'));
$p['scale'] = 7;
$p['photo_usage'] = PHOTO_COVER;
@ -114,8 +138,14 @@ function cover_photo_post(&$a) {
$p['scale'] = 8;
$r2 = $im->save($p);
$im->doScaleImage(425,160);
$p['scale'] = 9;
$r3 = $im->save($p);
if($r1 === false || $r2 === false) {
if($r1 === false || $r2 === false || $r3 === false) {
// if one failed, delete them all so we can start over.
notice( t('Image resize failed.') . EOL );
$x = q("delete from photo where resource_id = '%s' and uid = %d and scale >= 7 ",
@ -126,6 +156,7 @@ function cover_photo_post(&$a) {
}
$channel = $a->get_channel();
send_cover_photo_activity($channel,$base_image,$profile);
}
@ -133,8 +164,8 @@ function cover_photo_post(&$a) {
notice( t('Unable to process image') . EOL);
}
goaway($a->get_baseurl() . '/profiles');
return; // NOTREACHED
goaway(z_root() . '/channel/' . $channel['channel_address']);
}
@ -143,7 +174,7 @@ function cover_photo_post(&$a) {
require_once('include/attach.php');
$res = attach_store($a->get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash));
$res = attach_store($a->get_channel(), get_observer_hash(), '', array('album' => t('Cover Photos'), 'hash' => $hash));
logger('attach_store: ' . print_r($res,true));
@ -182,11 +213,6 @@ function cover_photo_post(&$a) {
function send_cover_photo_activity($channel,$photo,$profile) {
// for now only create activities for the default profile
if(! intval($profile['is_default']))
return;
$arr = array();
$arr['item_thread_top'] = 1;
$arr['item_origin'] = 1;
@ -196,20 +222,20 @@ function send_cover_photo_activity($channel,$photo,$profile) {
$arr['object'] = json_encode(array(
'type' => $arr['obj_type'],
'id' => z_root() . '/photo/profile/l/' . $channel['channel_id'],
'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/profile/l/' . $channel['channel_id'])
'id' => z_root() . '/photo/' . $photo['resource_id'] . '-7',
'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/' . $photo['resource_id'] . '-7')
));
if(stripos($profile['gender'],t('female')) !== false)
if($profile && stripos($profile['gender'],t('female')) !== false)
$t = t('%1$s updated her %2$s');
elseif(stripos($profile['gender'],t('male')) !== false)
elseif($profile && stripos($profile['gender'],t('male')) !== false)
$t = t('%1$s updated his %2$s');
else
$t = t('%1$s updated their %2$s');
$ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('profile photo') . '[/zrl]';
$ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('cover photo') . '[/zrl]';
$ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg=150x150]' . z_root() . '/photo/' . $photo['resource_id'] . '-4[/zmg][/zrl]';
$ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-8[/zmg][/zrl]';
$arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ echo " USER=youruserame "
echo " PASS=yourpass"
echo " HUB=your.hub.domain.org"
echo
echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Hit ENTER to send."
echo "Type \"hz\" (with or without a conf file as an arg), then enter your message. Use ctrl-D to send.."
}
@ -29,8 +29,10 @@ CUR=`which curl`
[ "$PASS" ] || { echo "no PASS"; usage; exit 1; }
[ "$HUB" ] || { echo "no HUB"; usage; exit 1; }
echo "enter your message to be posted as $USER @ $HUB, then hit ENTER to send:"
echo "enter your message to be posted as $USER @ $HUB, then hit Ctrl-D to send."
(read MSG; curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update )
MSG=$(cat)
curl -ssl -u${USER}:${PASS} --data-urlencode "status=${MSG}" https://${HUB}/api/statuses/update

View file

@ -1 +1 @@
2016-01-13.1277H
2016-01-15.1279H

View file

@ -16,3 +16,20 @@
opacity: 0.3;
filter:alpha(opacity=30);
}
.contact-photo-wrapper {
display: table-cell;
table-layout: fixed;
vertical-align: top;
}
.contact-info {
display: table-cell;
table-layout: fixed;
vertical-align: top;
padding-left: 10px;
}
.contact-info-label {
font-weight: bold;
}

View file

@ -196,4 +196,4 @@ function submit_form(e) {
if(typeof onselect !== 'undefined')
a.on('textComplete:select', function(e, value, strategy) { onselect(value); });
};
})( jQuery );
})( jQuery );

View file

@ -1,15 +1,16 @@
$(document).ready(function() {
$(document).ready(function() {
$("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
$(".autotime").timeago();
});
$("#contacts-search").keyup(function(event){
if(event.keyCode == 13){
$("#contacts-search-submit").click();
$("#contacts-search").click();
}
});
$(".autocomplete-w1 .selected").keyup(function(event){
if(event.keyCode == 13){
$("#contacts-search-submit").click();
$("#contacts-search").click();
}
});

View file

@ -73,25 +73,6 @@
</div>
</div>
</div>
<div class="modal" id="abook-pending-modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">{{$pending_modal_title}}</h4>
</div>
<div class="modal-body">
<strong>{{$name}}</strong> {{$pending_modal_body}}
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-danger pull-left" title="{{$buttons.delete.title}}" onclick="window.location.href='{{$buttons.delete.url}}'; return false;">{{$buttons.delete.label}}</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{{$pending_modal_dismiss}}</button>
<button type="submit" class="btn btn-primary" name="pending" value="1">{{$pending_modal_approve}}</button>
</div>
</div>
</div>
</div>
<script>$('#abook-pending-modal').modal('show');</script>
{{/if}}
{{if $affinity }}
@ -177,6 +158,7 @@
{{/if}}
{{if ! $is_pending}}
<div class="panel">
{{if $notself}}
<div class="section-subtitle-wrapper" role="tab" id="perms-tool">
@ -222,6 +204,7 @@
</div>
</div>
</div>
{{/if}}
</div>
</form>
</div>

View file

@ -1,15 +1,45 @@
<div id="contact-entry-wrapper-{{$contact.id}}">
<div class="section-subtitle-wrapper">
<div class="pull-right">
{{if $contact.approve}}
<form action="connedit/{{$contact.id}}" method="post" >
<button type="submit" class="btn btn-success btn-xs" name="pending" value="1" title="{{$contact.approve_hover}}"><i class="icon-ok"></i> {{$contact.approve}}</button>
{{/if}}
<a href="#" class="btn btn-danger btn-xs" title="{{$contact.delete_hover}}" onclick="dropItem('{{$contact.deletelink}}', '#contact-entry-wrapper-{{$contact.id}}'); return false;"><i class="icon-trash"></i> {{$contact.delete}}</a>
<a href="{{$contact.link}}" class="btn btn-success btn-xs" title="{{$contact.edit_hover}}"><i class="icon-pencil"></i> {{$contact.edit}}</a>
<a href="{{$contact.link}}" class="btn btn-default btn-xs" title="{{$contact.edit_hover}}"><i class="icon-pencil"></i></a>
{{if $contact.approve}}
</form>
{{/if}}
</div>
<h3><a href="{{$contact.url}}" title="{{$contact.img_hover}}" >{{$contact.name}}</a></h3>
<h3>{{if $contact.public_forum}}<i class="icon-comments-alt"></i>&nbsp;{{/if}}<a href="{{$contact.url}}" title="{{$contact.img_hover}}" >{{$contact.name}}</a></h3>
</div>
<div class="section-content-tools-wrapper">
<div class="contact-entry-photo-wrapper" >
<div class="contact-photo-wrapper" >
<a href="{{$contact.url}}" title="{{$contact.img_hover}}" ><img class="directory-photo-img {{if $contact.classes}}{{$contact.classes}}{{/if}}" src="{{$contact.thumb}}" alt="{{$contact.name}}" /></a>
</div>
<div class="contact-info">
{{if $contact.status}}
<div class="contact-info-element">
<span class="contact-info-label">{{$contact.status_label}}:</span> {{$contact.status}}
</div>
{{/if}}
{{if $contact.connected}}
<div class="contact-info-element">
<span class="contact-info-label">{{$contact.connected_label}}:</span> <span class="autotime" title="{{$contact.connected}}"></span>
</div>
{{/if}}
{{if $contact.webbie}}
<div class="contact-info-element">
<span class="contact-info-label">{{$contact.webbie_label}}:</span> {{$contact.webbie}}
</div>
{{/if}}
{{if $contact.network}}
<div class="contact-info-element">
<span class="contact-info-label">{{$contact.network_label}}:</span> {{$contact.network}} - <a href="{{$contact.recentlink}}">{{$contact.recent_label}}</a>
</div>
{{/if}}
</div>
</div>
</div>

View file

@ -1,16 +1,17 @@
<div class="directory-item{{if $entry.safe}} safe{{/if}}" id="directory-item-{{$entry.hash}}" >
<div class="section-subtitle-wrapper">
<div class="pull-right">
{{if $entry.viewrate}}
{{if $entry.canrate}}<button class="btn btn-default btn-xs" onclick="doRatings('{{$entry.hash}}'); return false;" ><i class="icon-pencil"></i><span id="edited-{{$entry.hash}}" class="required" id="edited-{{$entry.hash}}" style="display: none;" >&nbsp;*</span></button>{{/if}}
{{if $entry.total_ratings}}<a href="ratings/{{$entry.hash}}" id="dir-rating-{{$entry.hash}}" class="btn btn-default btn-xs">{{$entry.total_ratings}}</a>{{/if}}
{{/if}}
{{if $entry.ignlink}}
<a class="directory-ignore btn btn-warning btn-xs" href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a>
{{/if}}
{{if $entry.connect}}
<a class="btn btn-success btn-xs" href="{{$entry.connect}}"><i class="icon-plus connect-icon"></i> {{$entry.conn_label}}</a>
{{/if}}
{{if $entry.viewrate}}
{{if $entry.total_ratings}}<a href="ratings/{{$entry.hash}}" id="dir-rating-{{$entry.hash}}" class="btn btn-default btn-xs">{{$entry.total_ratings}}</a>{{/if}}
{{if $entry.canrate}}<button class="btn btn-default btn-xs" onclick="doRatings('{{$entry.hash}}'); return false;" ><i class="icon-pencil"></i><span id="edited-{{$entry.hash}}" class="required" id="edited-{{$entry.hash}}" style="display: none;" >&nbsp;*</span></button>{{/if}}
{{/if}}
</div>
<h3>{{if $entry.public_forum}}<i class="icon-comments-alt" title="{{$entry.forum_label}} @{{$entry.nickname}}+"></i>&nbsp;{{/if}}<a href='{{$entry.profile_link}}' >{{$entry.name}}</a>{{if $entry.online}}&nbsp;<i class="icon-asterisk online-now" title="{{$entry.online}}"></i>{{/if}}</h3>
</div>