Merge branch 'dev' into pdo

This commit is contained in:
zotlabs 2016-10-23 17:49:15 -07:00
commit 8d52a278a9
19 changed files with 3702 additions and 3670 deletions

View File

@ -88,7 +88,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
if($r) {
$base_image = $r[0];
$base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['content']) : dbunescbin($base_image['content']));
$base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($base_image['content'])) : dbunescbin($base_image['content']));
$im = photo_factory($base_image['content'], $base_image['mimetype']);
if($im->is_valid()) {
@ -320,7 +320,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
}
if(intval($r[0]['os_storage']))
$data = @file_get_contents($r[0]['content']);
$data = @file_get_contents(dbunescbin($r[0]['content']));
else
$data = dbunescbin($r[0]['content']);

View File

@ -440,8 +440,6 @@ class Events extends \Zotlabs\Web\Controller {
$permissions = ((x($orig_event)) ? $orig_event : $perm_defaults);
//print_r(acl2json($permissions['allow_gid'])); killme();
$tpl = get_markup_template('event_form.tpl');
$form = replace_macros($tpl,array(
@ -469,9 +467,6 @@ class Events extends \Zotlabs\Web\Controller {
'$l_text' => (($event_id) ? t('Edit Location') : t('Location')),
'$l_orig' => $l_orig,
'$t_orig' => $t_orig,
'$sh_text' => t('Share this event'),
'$sh_checked' => $sh_checked,
'$share' => array('distr', t('Share this event'), $sh_checked, '', array(t('No'),t('Yes'))),
'$preview' => t('Preview'),
'$perms_label' => t('Permission settings'),
// populating the acl dialog was a permission description from view_stream because Cal.php, which
@ -483,6 +478,8 @@ class Events extends \Zotlabs\Web\Controller {
'$deny_cid' => acl2json($permissions['deny_cid']),
'$deny_gid' => acl2json($permissions['deny_gid']),
'$lockstate' => (($acl->is_private()) ? 'lock' : 'unlock'),
'$submit' => t('Submit'),
'$advanced' => t('Advanced Options')
@ -611,6 +608,12 @@ class Events extends \Zotlabs\Web\Controller {
$end = null;
} else {
$end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c'));
// give a fake end to birthdays so they get crammed into a
// single day on the calendar
if($rr['etype'] === 'birthday')
$end = null;
}

View File

@ -246,7 +246,7 @@ class Photos extends \Zotlabs\Web\Controller {
intval($page_owner_uid)
);
if(count($r)) {
$d = (($r[0]['os_storage']) ? @file_get_contents($r[0]['content']) : dbunescbin($r[0]['content']));
$d = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($r[0]['content'])) : dbunescbin($r[0]['content']));
$ph = photo_factory($d, $r[0]['mimetype']);
if($ph->is_valid()) {
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );

View File

@ -98,7 +98,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
if($r) {
$base_image = $r[0];
$base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['content']) : dbunescbin($base_image['content']));
$base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($base_image['content'])) : dbunescbin($base_image['content']));
$im = photo_factory($base_image['content'], $base_image['mimetype']);
if($im->is_valid()) {
@ -354,7 +354,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
if(intval($r[0]['os_storage']))
$data = @file_get_contents($r[0]['content']);
$data = @file_get_contents(dbunescbin($r[0]['content']));
else
$data = dbunescbin($r[0]['content']);

View File

@ -31,7 +31,7 @@ class Profiles extends \Zotlabs\Web\Controller {
// move every contact using this profile as their default to the user default
$r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ",
$r = q("UPDATE abook SET abook_profile = (SELECT profile_guid FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ",
intval(local_channel()),
dbesc($profile_guid),
intval(local_channel())

View File

@ -90,6 +90,35 @@ class Wiki extends \Zotlabs\Web\Controller {
// Not the channel owner
$channel_acl = $x = array();
}
// Download a wiki
if ((argc() > 3) && (argv(2) === 'download') && (argv(3) === 'wiki')) {
$resource_id = argv(4);
$w = wiki_get_wiki($resource_id);
if (!$w['path']) {
notice('Error retrieving wiki' . EOL);
}
$zip_folder_name = random_string(10);
$zip_folderpath = '/tmp/' . $zip_folder_name;
if (!mkdir($zip_folderpath, 0770, false)) {
logger('Error creating zip file export folder: ' . $zip_folderpath, LOGGER_NORMAL);
notice('Error creating zip file export folder' . EOL);
}
$zip_filename = $w['urlName'];
$zip_filepath = '/tmp/' . $zip_folder_name . '/' . $zip_filename;
// Generate the zip file
\Zotlabs\Lib\ExtendedZip::zipTree($w['path'], $zip_filepath, \ZipArchive::CREATE);
// Output the file for download
header('Content-disposition: attachment; filename="' . $zip_filename . '.zip"');
header("Content-Type: application/zip");
$success = readfile($zip_filepath);
if ($success) {
rrmdir($zip_folderpath); // delete temporary files
} else {
rrmdir($zip_folderpath); // delete temporary files
logger('Error downloading wiki: ' . $resource_id);
}
}
switch (argc()) {
case 2:
@ -297,6 +326,7 @@ class Wiki extends \Zotlabs\Web\Controller {
}
}
// Create a page
if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) {
$nick = argv(1);

View File

@ -244,8 +244,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$deny_gid = $c[0]['channel_deny_gid'];
}
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($c[0]['channel_account_id']),
intval($c[0]['channel_id']),
dbesc($hash),
@ -260,6 +260,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($f),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
'', //TODO: use os_path
'', //TODO: use display_path
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),

View File

@ -83,7 +83,7 @@
$ptr['content'] = '';
elseif(! intval($r[0]['os_storage'])) {
$ptr['start'] = $start;
$x = substr(dbunescbin($ptr['content'],$start,$length));
$x = substr(dbunescbin($ptr['content']),$start,$length);
$ptr['length'] = strlen($x);
$ptr['content'] = base64_encode($x);
}

View File

@ -704,6 +704,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
// not yet used
$os_path = '';
$display_path = '';
if($src)
@file_put_contents($os_basepath . $os_relpath,@file_get_contents($src));
@ -719,7 +720,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$edited = $created;
if($options === 'replace') {
$r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s', os_path = '%s' where id = %d and uid = %d",
$r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s', os_path = '%s', display_path = '%s' where id = %d and uid = %d",
dbesc($filename),
dbesc($mimetype),
dbesc($folder_hash),
@ -729,13 +730,14 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($os_basepath . $os_relpath),
dbesc($created),
dbesc($os_path),
dbesc($display_path),
intval($existing_id),
intval($channel_id)
);
}
elseif($options === 'revise') {
$r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
$r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($x[0]['aid']),
intval($channel_id),
dbesc($x[0]['hash']),
@ -751,6 +753,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($created),
dbesc($created),
dbesc($os_path),
dbesc($display_path),
dbesc($x[0]['allow_cid']),
dbesc($x[0]['allow_gid']),
dbesc($x[0]['deny_cid']),
@ -758,8 +761,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
elseif($options === 'update') {
$r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', edited = '%s', os_storage = %d, is_photo = %d, os_path = '%s',
allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d",
$r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', edited = '%s', os_storage = %d, is_photo = %d, os_path = '%s',
display_path = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d",
dbesc((array_key_exists('filename',$arr)) ? $arr['filename'] : $x[0]['filename']),
dbesc((array_key_exists('filetype',$arr)) ? $arr['filetype'] : $x[0]['filetype']),
dbesc(($folder_hash) ? $folder_hash : $x[0]['folder']),
@ -767,6 +770,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc((array_key_exists('os_storage',$arr)) ? $arr['os_storage'] : $x[0]['os_storage']),
dbesc((array_key_exists('is_photo',$arr)) ? $arr['is_photo'] : $x[0]['is_photo']),
dbesc((array_key_exists('os_path',$arr)) ? $arr['os_path'] : $x[0]['os_path']),
dbesc((array_key_exists('display_path',$arr)) ? $arr['display_path'] : $x[0]['display_path']),
dbesc((array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $x[0]['allow_cid']),
dbesc((array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $x[0]['allow_gid']),
dbesc((array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $x[0]['deny_cid']),
@ -776,8 +780,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
else {
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid,deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid,deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($channel['channel_account_id']),
intval($channel_id),
dbesc($hash),
@ -793,6 +798,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($created),
dbesc($created),
dbesc($os_path),
dbesc($display_path),
dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $str_contact_allow),
dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $str_group_allow),
dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $str_contact_deny),
@ -1037,8 +1043,12 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
$created = datetime_convert();
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
// not yet used
$os_path = '';
$display_path = '';
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($channel['channel_account_id']),
intval($channel_id),
dbesc($arr['hash']),
@ -1053,6 +1063,8 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
dbesc($path),
dbesc($created),
dbesc($created),
dbesc($os_path),
dbesc($display_path),
dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $channel['channel_allow_cid']),
dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $channel['channel_allow_gid']),
dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $channel['channel_deny_cid']),
@ -2233,4 +2245,4 @@ function attach_folder_rpaths($all_folders,$that_folder) {
}
return (($error) ? false : [ $current_hash , $path ]);
}
}

View File

@ -321,7 +321,7 @@ function bb2diaspora_itemwallwall(&$item,$uplink = false) {
}
function bb2diaspora_itembody($item, $force_update = false, $have_channel = false, $uplink) {
function bb2diaspora_itembody($item, $force_update = false, $have_channel = false, $uplink = false) {
if(! get_iconfig($item,'diaspora','fields')) {

View File

@ -860,7 +860,7 @@ function import_conv($channel,$convs) {
if($channel && $convs) {
foreach($convs as $conv) {
if($conv['deleted']) {
q("delete from conv where guid = '%s' and uid = %d limit 1",
q("delete from conv where guid = '%s' and uid = %d",
dbesc($conv['guid']),
intval($channel['channel_id'])
);

View File

@ -436,7 +436,7 @@ function private_messages_drop($channel_id, $messageitem_id, $drop_conversation
intval($channel_id)
);
if($z) {
q("delete from conv where guid = '%s' and uid = %d limit 1",
q("delete from conv where guid = '%s' and uid = %d",
dbesc($x[0]['conv_guid']),
intval($channel_id)
);

View File

@ -137,10 +137,6 @@ function oembed_fetch_url($embedurl){
if($action !== 'block') {
$txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $embedurl);
if(strstr($txt,'youtu') && strstr(z_root(),'https:')) {
$txt = str_replace('http:','https:',$txt);
}
}
if(is_null($txt)) {
@ -272,13 +268,7 @@ function oembed_format_object($j){
$th=120; $tw = $th*$tr;
$tpl=get_markup_template('oembed_video.tpl');
if(strstr($embedurl,'youtu') && strstr(z_root(),'https:')) {
$embedurl = str_replace('http:','https:',$embedurl);
$j['thumbnail_url'] = str_replace('http:','https:', $j['thumbnail_url']);
$jhtml = str_replace('http:','https:', $jhtml);
$j['html'] = str_replace('http:','https:', $j['html']);
}
$ret.=replace_macros($tpl, array(
'$baseurl' => z_root(),
'$embedurl'=>$embedurl,

File diff suppressed because it is too large Load Diff

View File

@ -202,7 +202,7 @@ function string2bb(element) {
$.fn.search_autocomplete = function(backend_url) {
// Autocomplete contacts
contacts = {
match: /(^@)([^\n]{2,})$/,
match: /(^@)([^\n]{3,})$/,
index: 2,
search: function(term, callback) { contact_search(term, callback, backend_url, 'x', [], spinelement='#nav-search-spinner'); },
replace: basic_replace,

View File

@ -111,7 +111,7 @@
<div class="btn-group pull-right">
<button id="event-edit-preview-btn" class="btn btn-default" type="button" title="{{$preview}}" onclick="doEventPreview();"><i class="fa fa-eye" ></i></button>
{{if ! $eid}}
<button id="dbtn-acl" class="btn btn-default" type="button" data-toggle="modal" data-target="#aclModal" title="{{$perms_label}}"><i id="jot-perms-icon" class="fa"></i></button>
<button id="dbtn-acl" class="btn btn-default" type="button" data-toggle="modal" data-target="#aclModal" title="{{$perms_label}}"><i id="jot-perms-icon" class="fa fa-{{$lockstate}}"></i></button>
{{/if}}
<button id="event-submit" class="btn btn-primary" type="submit" name="submit">{{$submit}}</button>
</div>

View File

@ -153,17 +153,6 @@
}
});
// ACL
$('#id_distr').change(function() {
if ($('#id_distr').is(':checked')) {
$('#dbtn-acl').show();
}
else {
$('#dbtn-acl').hide();
}
}).trigger('change');
});
</script>

View File

@ -239,6 +239,10 @@ function wiki_delete_wiki(wikiHtmlName, resource_id) {
}, 'json');
}
function wiki_download_wiki(resource_id) {
window.location = "wiki/{{$channel}}/download/wiki/" + resource_id;
}
$('#new-page-submit').click(function (ev) {
if (window.wiki_resource_id === '') {

View File

@ -8,6 +8,7 @@
</a>
<ul class="dropdown-menu pull-right">
<li><a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="View {{$wiki.title}}">View</a></li>
<li><a href="#" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;" title="Download {{$wiki.title}}">Download</a></li>
{{if $showControls}}
<li class="divider"></li>
<li><a href="#" onclick="wiki_delete_wiki('{{$wiki.title}}','{{$wiki.resource_id}}'); return false;" title="Delete {{$wiki.title}}">Delete wiki</a></li>