the rest of the schema updates - WARNING: some third party plugins may fail; e.g. embedphotos and chess. $item['object'] is now $item['obj'] and $photo['type'] is $photo['mimetype'], $photo['scale'] is $photo['imgscale'] and $photo['data'] is now $photo['content']. There are a number of other changes, but these are the ones noted to cause issues with third-party plugins. The project plugins have been updated. Please note any new issues as this effort touched a lot of code in a lot of files.
This commit is contained in:
@@ -554,7 +554,7 @@ require_once('include/api_auth.php');
|
||||
dbesc($_REQUEST['file_id'])
|
||||
);
|
||||
if($r) {
|
||||
unset($r[0]['data']);
|
||||
unset($r[0]['content']);
|
||||
$ret = array('attach' => $r[0]);
|
||||
json_return_and_die($ret);
|
||||
}
|
||||
@@ -580,21 +580,21 @@ require_once('include/api_auth.php');
|
||||
$length = intval($ptr['filesize']);
|
||||
|
||||
if($ptr['is_dir'])
|
||||
$ptr['data'] = '';
|
||||
$ptr['content'] = '';
|
||||
elseif(! intval($r[0]['os_storage'])) {
|
||||
$ptr['start'] = $start;
|
||||
$x = substr(dbunescbin($ptr['data'],$start,$length));
|
||||
$x = substr(dbunescbin($ptr['content'],$start,$length));
|
||||
$ptr['length'] = strlen($x);
|
||||
$ptr['data'] = base64_encode($x);
|
||||
$ptr['content'] = base64_encode($x);
|
||||
}
|
||||
else {
|
||||
$fp = fopen(dbunescbin($ptr['data']),'r');
|
||||
$fp = fopen(dbunescbin($ptr['content']),'r');
|
||||
if($fp) {
|
||||
$seek = fseek($fp,$start,SEEK_SET);
|
||||
$x = fread($fp,$length);
|
||||
$ptr['start'] = $start;
|
||||
$ptr['length'] = strlen($x);
|
||||
$ptr['data'] = base64_encode($x);
|
||||
$ptr['content'] = base64_encode($x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,11 +617,11 @@ require_once('include/api_auth.php');
|
||||
);
|
||||
if($r) {
|
||||
if($r[0]['is_dir'])
|
||||
$r[0]['data'] = '';
|
||||
$r[0]['content'] = '';
|
||||
elseif(intval($r[0]['os_storage']))
|
||||
$r[0]['data'] = base64_encode(file_get_contents(dbunescbin($r[0]['data'])));
|
||||
$r[0]['content'] = base64_encode(file_get_contents(dbunescbin($r[0]['content'])));
|
||||
else
|
||||
$r[0]['data'] = base64_encode(dbunescbin($r[0]['data']));
|
||||
$r[0]['content'] = base64_encode(dbunescbin($r[0]['content']));
|
||||
|
||||
$ret = array('attach' => $r[0]);
|
||||
json_return_and_die($ret);
|
||||
@@ -647,16 +647,16 @@ require_once('include/api_auth.php');
|
||||
if (api_user()===false) return false;
|
||||
if(! $_REQUEST['photo_id']) return false;
|
||||
$scale = ((array_key_exists('scale',$_REQUEST)) ? intval($_REQUEST['scale']) : 0);
|
||||
$r = q("select * from photo where uid = %d and resource_id = '%s' and scale = %d limit 1",
|
||||
$r = q("select * from photo where uid = %d and resource_id = '%s' and imgscale = %d limit 1",
|
||||
intval(local_channel()),
|
||||
dbesc($_REQUEST['photo_id']),
|
||||
intval($scale)
|
||||
);
|
||||
if($r) {
|
||||
$data = dbunescbin($r[0]['data']);
|
||||
$data = dbunescbin($r[0]['content']);
|
||||
if(array_key_exists('os_storage',$r[0]) && intval($r[0]['os_storage']))
|
||||
$data = file_get_contents($data);
|
||||
$r[0]['data'] = base64_encode($data);
|
||||
$r[0]['content'] = base64_encode($data);
|
||||
$ret = array('photo' => $r[0]);
|
||||
$i = q("select id from item where uid = %d and resource_type = 'photo' and resource_id = '%s' limit 1",
|
||||
intval(local_channel()),
|
||||
|
||||
@@ -720,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, data = '%s', edited = '%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' where id = %d and uid = %d",
|
||||
dbesc($filename),
|
||||
dbesc($mimetype),
|
||||
dbesc($folder_hash),
|
||||
@@ -734,7 +734,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
||||
);
|
||||
}
|
||||
elseif($options === 'revise') {
|
||||
$r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
|
||||
$r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, 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' ) ",
|
||||
intval($x[0]['aid']),
|
||||
intval($channel_id),
|
||||
@@ -775,7 +775,7 @@ 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, data, created, edited, allow_cid, allow_gid,deny_cid, deny_gid )
|
||||
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, 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' ) ",
|
||||
intval($channel['channel_account_id']),
|
||||
intval($channel_id),
|
||||
@@ -1032,7 +1032,7 @@ 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, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
|
||||
$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' ) ",
|
||||
intval($channel['channel_account_id']),
|
||||
intval($channel_id),
|
||||
@@ -1275,16 +1275,16 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
|
||||
|
||||
// delete a file from filesystem
|
||||
if(intval($r[0]['os_storage'])) {
|
||||
$y = q("SELECT data FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
|
||||
$y = q("SELECT content FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
|
||||
dbesc($resource),
|
||||
intval($channel_id)
|
||||
);
|
||||
|
||||
if($y) {
|
||||
if(strpos($y[0]['data'],'store') === false)
|
||||
$f = 'store/' . $channel_address . '/' . $y[0]['data'];
|
||||
if(strpos($y[0]['content'],'store') === false)
|
||||
$f = 'store/' . $channel_address . '/' . $y[0]['content'];
|
||||
else
|
||||
$f = $y[0]['data'];
|
||||
$f = $y[0]['content'];
|
||||
|
||||
if(is_dir($f))
|
||||
@rmdir($f);
|
||||
@@ -1585,7 +1585,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
||||
$arr['deny_gid'] = perms2str($u_arr_deny_gid);
|
||||
$arr['item_private'] = $private;
|
||||
$arr['verb'] = ACTIVITY_UPDATE;
|
||||
$arr['object'] = $u_jsonobject;
|
||||
$arr['obj'] = $u_jsonobject;
|
||||
$arr['body'] = '';
|
||||
|
||||
$post = item_store($arr);
|
||||
@@ -1620,7 +1620,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
||||
$arr['deny_gid'] = perms2str($arr_deny_gid);
|
||||
$arr['item_private'] = $private;
|
||||
$arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST);
|
||||
$arr['object'] = (($update) ? $u_jsonobject : $jsonobject);
|
||||
$arr['obj'] = (($update) ? $u_jsonobject : $jsonobject);
|
||||
$arr['body'] = '';
|
||||
|
||||
$post = item_store($arr);
|
||||
@@ -1854,21 +1854,19 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
||||
} while($hash_ptr);
|
||||
|
||||
|
||||
|
||||
|
||||
$paths = array_reverse($paths);
|
||||
|
||||
$ret['attach'] = $paths;
|
||||
|
||||
|
||||
if($attach_ptr['is_photo']) {
|
||||
$r = q("select * from photo where resource_id = '%s' and uid = %d order by scale asc",
|
||||
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc",
|
||||
dbesc($resource_id),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if($r) {
|
||||
for($x = 0; $x < count($r); $x ++) {
|
||||
$r[$x]['data'] = base64_encode($r[$x]['data']);
|
||||
$r[$x]['content'] = base64_encode($r[$x]['content']);
|
||||
}
|
||||
$ret['photo'] = $r;
|
||||
}
|
||||
|
||||
@@ -550,13 +550,13 @@ function identity_basic_export($channel_id, $items = false) {
|
||||
if($r)
|
||||
$ret['config'] = $r;
|
||||
|
||||
$r = q("select type, data, os_storage from photo where scale = 4 and photo_usage = %d and uid = %d limit 1",
|
||||
$r = q("select mimetype, content, os_storage from photo where imgscale = 4 and photo_usage = %d and uid = %d limit 1",
|
||||
intval(PHOTO_PROFILE),
|
||||
intval($channel_id)
|
||||
);
|
||||
|
||||
if($r) {
|
||||
$ret['photo'] = array('type' => $r[0]['type'], 'data' => (($r[0]['os_storage']) ? base64url_encode(file_get_contents($r[0]['data'])) : base64url_encode($r[0]['data'])));
|
||||
$ret['photo'] = array('type' => $r[0]['mimetype'], 'data' => (($r[0]['os_storage']) ? base64url_encode(file_get_contents($r[0]['content'])) : base64url_encode($r[0]['content'])));
|
||||
}
|
||||
|
||||
// All other term types will be included in items, if requested.
|
||||
@@ -1108,150 +1108,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @FIXME or remove
|
||||
*/
|
||||
function get_birthdays() {
|
||||
|
||||
$o = '';
|
||||
|
||||
if(! local_channel())
|
||||
return $o;
|
||||
|
||||
$bd_format = t('g A l F d') ; // 8 AM Friday January 18
|
||||
$bd_short = t('F d');
|
||||
|
||||
$r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid`
|
||||
WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s'
|
||||
ORDER BY `start` ASC ",
|
||||
intval(local_channel()),
|
||||
dbesc(datetime_convert('UTC','UTC','now + 6 days')),
|
||||
dbesc(datetime_convert('UTC','UTC','now'))
|
||||
);
|
||||
|
||||
if($r && count($r)) {
|
||||
$total = 0;
|
||||
$now = strtotime('now');
|
||||
$cids = array();
|
||||
|
||||
$istoday = false;
|
||||
foreach($r as $rr) {
|
||||
if(strlen($rr['name']))
|
||||
$total ++;
|
||||
if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
|
||||
$istoday = true;
|
||||
}
|
||||
$classtoday = $istoday ? ' birthday-today ' : '';
|
||||
if($total) {
|
||||
foreach($r as &$rr) {
|
||||
if(! strlen($rr['name']))
|
||||
continue;
|
||||
|
||||
// avoid duplicates
|
||||
|
||||
if(in_array($rr['cid'],$cids))
|
||||
continue;
|
||||
$cids[] = $rr['cid'];
|
||||
|
||||
$today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
|
||||
$sparkle = '';
|
||||
$url = $rr['url'];
|
||||
if($rr['network'] === NETWORK_DFRN) {
|
||||
$sparkle = " sparkle";
|
||||
$url = z_root() . '/redir/' . $rr['cid'];
|
||||
}
|
||||
|
||||
$rr['link'] = $url;
|
||||
$rr['title'] = $rr['name'];
|
||||
$rr['date'] = day_translate(datetime_convert('UTC', App::$timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
|
||||
$rr['startime'] = Null;
|
||||
$rr['today'] = $today;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tpl = get_markup_template("birthdays_reminder.tpl");
|
||||
return replace_macros($tpl, array(
|
||||
'$baseurl' => z_root(),
|
||||
'$classtoday' => $classtoday,
|
||||
'$count' => $total,
|
||||
'$event_reminders' => t('Birthday Reminders'),
|
||||
'$event_title' => t('Birthdays this week:'),
|
||||
'$events' => $r,
|
||||
'$lbr' => '{', // raw brackets mess up if/endif macro processing
|
||||
'$rbr' => '}'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @FIXME
|
||||
*/
|
||||
function get_events() {
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
|
||||
if(! local_channel())
|
||||
return $o;
|
||||
|
||||
$bd_format = t('g A l F d') ; // 8 AM Friday January 18
|
||||
$bd_short = t('F d');
|
||||
|
||||
$r = q("SELECT `event`.* FROM `event`
|
||||
WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` > '%s'
|
||||
ORDER BY `start` ASC ",
|
||||
intval(local_channel()),
|
||||
dbesc(datetime_convert('UTC','UTC','now + 6 days')),
|
||||
dbesc(datetime_convert('UTC','UTC','now - 1 days'))
|
||||
);
|
||||
|
||||
if($r && count($r)) {
|
||||
$now = strtotime('now');
|
||||
$istoday = false;
|
||||
foreach($r as $rr) {
|
||||
if(strlen($rr['name']))
|
||||
$total ++;
|
||||
|
||||
$strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start'],'Y-m-d');
|
||||
if($strt === datetime_convert('UTC',App::$timezone,'now','Y-m-d'))
|
||||
$istoday = true;
|
||||
}
|
||||
$classtoday = (($istoday) ? 'event-today' : '');
|
||||
|
||||
foreach($r as &$rr) {
|
||||
if($rr['adjust'])
|
||||
$md = datetime_convert('UTC',App::$timezone,$rr['start'],'Y/m');
|
||||
else
|
||||
$md = datetime_convert('UTC','UTC',$rr['start'],'Y/m');
|
||||
$md .= "/#link-".$rr['id'];
|
||||
|
||||
$title = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... ';
|
||||
if(! $title)
|
||||
$title = t('[No description]');
|
||||
|
||||
$strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start']);
|
||||
$today = ((substr($strt,0,10) === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) ? true : false);
|
||||
|
||||
$rr['link'] = $md;
|
||||
$rr['title'] = $title;
|
||||
$rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? App::$timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
|
||||
$rr['startime'] = $strt;
|
||||
$rr['today'] = $today;
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = get_markup_template("events_reminder.tpl");
|
||||
return replace_macros($tpl, array(
|
||||
'$baseurl' => z_root(),
|
||||
'$classtoday' => $classtoday,
|
||||
'$count' => count($r),
|
||||
'$event_reminders' => t('Event Reminders'),
|
||||
'$event_title' => t('Events this week:'),
|
||||
'$events' => $r,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
function advanced_profile(&$a) {
|
||||
require_once('include/text.php');
|
||||
if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile'))
|
||||
@@ -1785,7 +1641,7 @@ 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",
|
||||
$r = q("select height, width, resource_id, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d",
|
||||
intval($channel_id),
|
||||
intval($res),
|
||||
intval(PHOTO_COVER)
|
||||
@@ -1808,8 +1664,8 @@ function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_
|
||||
default:
|
||||
$output = array(
|
||||
'width' => $r[0]['width'],
|
||||
'height' => $r[0]['type'],
|
||||
'type' => $r[0]['type'],
|
||||
'height' => $r[0]['height'],
|
||||
'type' => $r[0]['mimetype'],
|
||||
'url' => $url
|
||||
);
|
||||
break;
|
||||
@@ -1834,19 +1690,19 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
|
||||
$width = 425;
|
||||
$size = 'hz_small';
|
||||
$cover_size = PHOTO_RES_COVER_425;
|
||||
$pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
|
||||
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
|
||||
}
|
||||
elseif($maxwidth <= 900) {
|
||||
$width = 900;
|
||||
$size = 'hz_medium';
|
||||
$cover_size = PHOTO_RES_COVER_850;
|
||||
$pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
|
||||
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
|
||||
}
|
||||
elseif($maxwidth <= 1200) {
|
||||
$width = 1200;
|
||||
$size = 'hz_large';
|
||||
$cover_size = PHOTO_RES_COVER_1200;
|
||||
$pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
|
||||
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
|
||||
}
|
||||
|
||||
// $scale = (float) $maxwidth / $width;
|
||||
@@ -1856,7 +1712,7 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
|
||||
$channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname();
|
||||
$zcard = array('chan' => $channel);
|
||||
|
||||
$r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d",
|
||||
$r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d",
|
||||
intval($channel['channel_id']),
|
||||
intval($cover_size),
|
||||
intval(PHOTO_COVER)
|
||||
@@ -1864,7 +1720,7 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
|
||||
|
||||
if($r) {
|
||||
$cover = $r[0];
|
||||
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale'];
|
||||
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
|
||||
}
|
||||
else {
|
||||
$cover = $pphoto;
|
||||
@@ -1900,25 +1756,25 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
|
||||
$width = 425;
|
||||
$size = 'hz_small';
|
||||
$cover_size = PHOTO_RES_COVER_425;
|
||||
$pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
|
||||
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
|
||||
}
|
||||
elseif($maxwidth <= 900) {
|
||||
$width = 900;
|
||||
$size = 'hz_medium';
|
||||
$cover_size = PHOTO_RES_COVER_850;
|
||||
$pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
|
||||
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
|
||||
}
|
||||
elseif($maxwidth <= 1200) {
|
||||
$width = 1200;
|
||||
$size = 'hz_large';
|
||||
$cover_size = PHOTO_RES_COVER_1200;
|
||||
$pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
|
||||
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
|
||||
}
|
||||
|
||||
$channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname();
|
||||
$zcard = array('chan' => $channel);
|
||||
|
||||
$r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d",
|
||||
$r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d",
|
||||
intval($channel['channel_id']),
|
||||
intval($cover_size),
|
||||
intval(PHOTO_COVER)
|
||||
@@ -1926,7 +1782,7 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
|
||||
|
||||
if($r) {
|
||||
$cover = $r[0];
|
||||
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale'];
|
||||
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
|
||||
}
|
||||
else {
|
||||
$cover = $pphoto;
|
||||
|
||||
@@ -93,15 +93,15 @@ function localize_item(&$item){
|
||||
|
||||
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
|
||||
|
||||
if(! $item['object'])
|
||||
if(! $item['obj'])
|
||||
return;
|
||||
|
||||
if(intval($item['item_thread_top']))
|
||||
return;
|
||||
|
||||
$obj = json_decode_plus($item['object']);
|
||||
if((! $obj) && ($item['object'])) {
|
||||
logger('localize_item: failed to decode object: ' . print_r($item['object'],true));
|
||||
$obj = json_decode_plus($item['obj']);
|
||||
if((! $obj) && ($item['obj'])) {
|
||||
logger('localize_item: failed to decode object: ' . print_r($item['obj'],true));
|
||||
}
|
||||
|
||||
if($obj['author'] && $obj['author']['link'])
|
||||
@@ -186,7 +186,7 @@ function localize_item(&$item){
|
||||
$Alink = $item['author']['xchan_url'];
|
||||
|
||||
|
||||
$obj= json_decode_plus($item['object']);
|
||||
$obj= json_decode_plus($item['obj']);
|
||||
|
||||
$Blink = $Bphoto = '';
|
||||
|
||||
@@ -219,7 +219,7 @@ function localize_item(&$item){
|
||||
$Aname = $item['author']['xchan_name'];
|
||||
$Alink = $item['author']['xchan_url'];
|
||||
|
||||
$obj= json_decode_plus($item['object']);
|
||||
$obj= json_decode_plus($item['obj']);
|
||||
|
||||
$Blink = $Bphoto = '';
|
||||
|
||||
@@ -299,7 +299,7 @@ function localize_item(&$item){
|
||||
}
|
||||
$plink = '[zrl=' . $obj['plink'] . ']' . $post_type . '[/zrl]';
|
||||
|
||||
$parsedobj = parse_xml_string($xmlhead.$item['object']);
|
||||
$parsedobj = parse_xml_string($xmlhead.$item['obj']);
|
||||
|
||||
$tag = sprintf('#[zrl=%s]%s[/zrl]', $parsedobj->id, $parsedobj->content);
|
||||
$item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag );
|
||||
@@ -316,7 +316,7 @@ function localize_item(&$item){
|
||||
|
||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
||||
|
||||
$obj = parse_xml_string($xmlhead.$item['object']);
|
||||
$obj = parse_xml_string($xmlhead.$item['obj']);
|
||||
if(strlen($obj->id)) {
|
||||
$r = q("select * from item where mid = '%s' and uid = %d limit 1",
|
||||
dbesc($obj->id),
|
||||
|
||||
@@ -28,22 +28,22 @@ function format_event_html($ev) {
|
||||
$o .= '<div class="event-title"><h3><i class="fa fa-calendar"></i> ' . bbcode($ev['summary']) . '</h3></div>' . "\r\n";
|
||||
|
||||
$o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span> <span class="dtstart" title="'
|
||||
. datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
|
||||
. datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
|
||||
. '" >'
|
||||
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
|
||||
$ev['start'] , $bd_format ))
|
||||
$ev['dtstart'] , $bd_format ))
|
||||
: day_translate(datetime_convert('UTC', 'UTC',
|
||||
$ev['start'] , $bd_format)))
|
||||
$ev['dtstart'] , $bd_format)))
|
||||
. '</span></div>' . "\r\n";
|
||||
|
||||
if(! $ev['nofinish'])
|
||||
$o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span> <span class="dtend" title="'
|
||||
. datetime_convert('UTC','UTC',$ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
|
||||
. datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
|
||||
. '" >'
|
||||
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
|
||||
$ev['finish'] , $bd_format ))
|
||||
$ev['dtend'] , $bd_format ))
|
||||
: day_translate(datetime_convert('UTC', 'UTC',
|
||||
$ev['finish'] , $bd_format )))
|
||||
$ev['dtend'] , $bd_format )))
|
||||
. '</span></div>' . "\r\n";
|
||||
|
||||
$o .= '<div class="event-description">' . bbcode($ev['description']) . '</div>' . "\r\n";
|
||||
@@ -58,6 +58,37 @@ function format_event_html($ev) {
|
||||
return $o;
|
||||
}
|
||||
|
||||
function format_event_obj($jobject) {
|
||||
$event = array();
|
||||
|
||||
$object = json_decode($jobject,true);
|
||||
|
||||
//ensure compatibility with older items - this check can be removed at a later point
|
||||
if(array_key_exists('description', $object)) {
|
||||
|
||||
$bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM
|
||||
|
||||
$event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
|
||||
'$title' => bbcode($object['title']),
|
||||
'$dtstart_label' => t('Starts:'),
|
||||
'$dtstart_title' => datetime_convert('UTC', 'UTC', $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
|
||||
'$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))),
|
||||
'$finish' => (($object['nofinish']) ? false : true),
|
||||
'$dtend_label' => t('Finishes:'),
|
||||
'$dtend_title' => datetime_convert('UTC','UTC',$object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
|
||||
'$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format )))
|
||||
));
|
||||
|
||||
$event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(
|
||||
'$description' => bbcode($object['description']),
|
||||
'$location_label' => t('Location:'),
|
||||
'$location' => bbcode($object['location'])
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
function ical_wrapper($ev) {
|
||||
|
||||
@@ -68,7 +99,7 @@ function ical_wrapper($ev) {
|
||||
$o .= "\r\nVERSION:2.0";
|
||||
$o .= "\r\nMETHOD:PUBLISH";
|
||||
$o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Lib\System::get_platform_name() . "//" . strtoupper(App::$language). "\r\n";
|
||||
if(array_key_exists('start', $ev))
|
||||
if(array_key_exists('dtstart', $ev))
|
||||
$o .= format_event_ical($ev);
|
||||
else {
|
||||
foreach($ev as $e) {
|
||||
@@ -82,7 +113,7 @@ function ical_wrapper($ev) {
|
||||
|
||||
function format_event_ical($ev) {
|
||||
|
||||
if($ev['type'] === 'task')
|
||||
if($ev['etype'] === 'task')
|
||||
return format_todo_ical($ev);
|
||||
|
||||
$o = '';
|
||||
@@ -92,10 +123,10 @@ function format_event_ical($ev) {
|
||||
$o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z');
|
||||
$o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
|
||||
$o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
|
||||
if($ev['start'])
|
||||
$o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['finish'] && ! $ev['nofinish'])
|
||||
$o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['dtstart'])
|
||||
$o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['dtend'] && ! $ev['nofinish'])
|
||||
$o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['summary'])
|
||||
$o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']);
|
||||
if($ev['location'])
|
||||
@@ -119,10 +150,10 @@ function format_todo_ical($ev) {
|
||||
$o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z');
|
||||
$o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
|
||||
$o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
|
||||
if($ev['start'])
|
||||
$o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['finish'] && ! $ev['nofinish'])
|
||||
$o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['dtstart'])
|
||||
$o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['dtend'] && ! $ev['nofinish'])
|
||||
$o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
|
||||
if($ev['summary'])
|
||||
$o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']);
|
||||
if($ev['event_status']) {
|
||||
@@ -166,11 +197,11 @@ function format_event_bbcode($ev) {
|
||||
if($ev['description'])
|
||||
$o .= '[event-description]' . $ev['description'] . '[/event-description]';
|
||||
|
||||
if($ev['start'])
|
||||
$o .= '[event-start]' . $ev['start'] . '[/event-start]';
|
||||
if($ev['dtstart'])
|
||||
$o .= '[event-start]' . $ev['dtstart'] . '[/event-start]';
|
||||
|
||||
if(($ev['finish']) && (! $ev['nofinish']))
|
||||
$o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
|
||||
if(($ev['dtend']) && (! $ev['nofinish']))
|
||||
$o .= '[event-finish]' . $ev['dtend'] . '[/event-finish]';
|
||||
|
||||
if($ev['location'])
|
||||
$o .= '[event-location]' . $ev['location'] . '[/event-location]';
|
||||
@@ -207,10 +238,10 @@ function bbtoevent($s) {
|
||||
$ev['description'] = $match[1];
|
||||
$match = '';
|
||||
if(preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is",$s,$match))
|
||||
$ev['start'] = $match[1];
|
||||
$ev['dtstart'] = $match[1];
|
||||
$match = '';
|
||||
if(preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is",$s,$match))
|
||||
$ev['finish'] = $match[1];
|
||||
$ev['dtend'] = $match[1];
|
||||
$match = '';
|
||||
if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match))
|
||||
$ev['location'] = $match[1];
|
||||
@@ -220,11 +251,11 @@ function bbtoevent($s) {
|
||||
$match = '';
|
||||
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
|
||||
$ev['adjust'] = $match[1];
|
||||
if(array_key_exists('start',$ev)) {
|
||||
if(array_key_exists('finish',$ev)) {
|
||||
if($ev['finish'] === $ev['start'])
|
||||
if(array_key_exists('dtstart',$ev)) {
|
||||
if(array_key_exists('dtend',$ev)) {
|
||||
if($ev['dtend'] === $ev['dtstart'])
|
||||
$ev['nofinish'] = 1;
|
||||
elseif($ev['finish'])
|
||||
elseif($ev['dtend'])
|
||||
$ev['nofinish'] = 0;
|
||||
else
|
||||
$ev['nofinish'] = 1;
|
||||
@@ -260,8 +291,8 @@ function sort_by_date($arr) {
|
||||
*/
|
||||
function ev_compare($a, $b) {
|
||||
|
||||
$date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']);
|
||||
$date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['start']) : $b['start']);
|
||||
$date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['dtstart']) : $a['dtstart']);
|
||||
$date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['dtstart']) : $b['dtstart']);
|
||||
|
||||
if ($date_a === $date_b)
|
||||
return strcasecmp($a['description'], $b['description']);
|
||||
@@ -274,7 +305,7 @@ function event_store_event($arr) {
|
||||
|
||||
$arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
|
||||
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
|
||||
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
||||
$arr['etype'] = (($arr['etype']) ? $arr['etype'] : 'event' );
|
||||
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
|
||||
$arr['event_priority'] = (($arr['event_priority']) ? $arr['event_priority'] : 0);
|
||||
|
||||
@@ -324,12 +355,12 @@ function event_store_event($arr) {
|
||||
|
||||
$r = q("UPDATE `event` SET
|
||||
`edited` = '%s',
|
||||
`start` = '%s',
|
||||
`finish` = '%s',
|
||||
`dtstart` = '%s',
|
||||
`dtend` = '%s',
|
||||
`summary` = '%s',
|
||||
`description` = '%s',
|
||||
`location` = '%s',
|
||||
`type` = '%s',
|
||||
`etype` = '%s',
|
||||
`adjust` = %d,
|
||||
`nofinish` = %d,
|
||||
`event_status` = '%s',
|
||||
@@ -345,12 +376,12 @@ function event_store_event($arr) {
|
||||
WHERE `id` = %d AND `uid` = %d",
|
||||
|
||||
dbesc($arr['edited']),
|
||||
dbesc($arr['start']),
|
||||
dbesc($arr['finish']),
|
||||
dbesc($arr['dtstart']),
|
||||
dbesc($arr['dtend']),
|
||||
dbesc($arr['summary']),
|
||||
dbesc($arr['description']),
|
||||
dbesc($arr['location']),
|
||||
dbesc($arr['type']),
|
||||
dbesc($arr['etype']),
|
||||
intval($arr['adjust']),
|
||||
intval($arr['nofinish']),
|
||||
dbesc($arr['event_status']),
|
||||
@@ -378,7 +409,7 @@ function event_store_event($arr) {
|
||||
else
|
||||
$hash = random_string() . '@' . App::get_hostname();
|
||||
|
||||
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type,
|
||||
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,dtstart,dtend,summary,description,location,etype,
|
||||
adjust,nofinish, event_status, event_status_date, event_percent, event_repeat, event_sequence, event_priority, allow_cid,allow_gid,deny_cid,deny_gid)
|
||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
|
||||
intval($arr['uid']),
|
||||
@@ -387,12 +418,12 @@ function event_store_event($arr) {
|
||||
dbesc($hash),
|
||||
dbesc($arr['created']),
|
||||
dbesc($arr['edited']),
|
||||
dbesc($arr['start']),
|
||||
dbesc($arr['finish']),
|
||||
dbesc($arr['dtstart']),
|
||||
dbesc($arr['dtend']),
|
||||
dbesc($arr['summary']),
|
||||
dbesc($arr['description']),
|
||||
dbesc($arr['location']),
|
||||
dbesc($arr['type']),
|
||||
dbesc($arr['etype']),
|
||||
intval($arr['adjust']),
|
||||
intval($arr['nofinish']),
|
||||
dbesc($arr['event_status']),
|
||||
@@ -441,7 +472,7 @@ function event_addtocal($item_id, $uid) {
|
||||
|
||||
$ev = bbtoevent($r[0]['body']);
|
||||
|
||||
if(x($ev,'summary') && x($ev,'start')) {
|
||||
if(x($ev,'summary') && x($ev,'dtstart')) {
|
||||
$ev['event_xchan'] = $item['author_xchan'];
|
||||
$ev['uid'] = $channel['channel_id'];
|
||||
$ev['account'] = $channel['channel_account_id'];
|
||||
@@ -554,20 +585,20 @@ function event_import_ical($ical, $uid) {
|
||||
|
||||
// logger('dtstart: ' . var_export($dtstart,true));
|
||||
|
||||
$ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$dtstart->format(\DateTime::W3C));
|
||||
|
||||
|
||||
if(isset($ical->DTEND)) {
|
||||
$dtend = $ical->DTEND->getDateTime();
|
||||
$ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$dtend->format(\DateTime::W3C));
|
||||
}
|
||||
else
|
||||
$ev['nofinish'] = 1;
|
||||
|
||||
|
||||
if($ev['start'] === $ev['finish'])
|
||||
if($ev['dtstart'] === $ev['dtend'])
|
||||
$ev['nofinish'] = 1;
|
||||
|
||||
if(isset($ical->CREATED)) {
|
||||
@@ -601,7 +632,7 @@ function event_import_ical($ical, $uid) {
|
||||
$ev['external_id'] = $evuid;
|
||||
}
|
||||
|
||||
if($ev['summary'] && $ev['start']) {
|
||||
if($ev['summary'] && $ev['dtstart']) {
|
||||
$ev['event_xchan'] = $channel['channel_hash'];
|
||||
$ev['uid'] = $channel['channel_id'];
|
||||
$ev['account'] = $channel['channel_account_id'];
|
||||
@@ -640,29 +671,24 @@ function event_import_ical_task($ical, $uid) {
|
||||
|
||||
$dtstart = $ical->DTSTART->getDateTime();
|
||||
|
||||
$ev['adjust'] = (($ical->DTSTART->isFloating()) ? 1 : 0);
|
||||
|
||||
// logger('dtstart: ' . var_export($dtstart,true));
|
||||
|
||||
if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) {
|
||||
$ev['adjust'] = 1;
|
||||
}
|
||||
else {
|
||||
$ev['adjust'] = 0;
|
||||
}
|
||||
|
||||
$ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$dtstart->format(\DateTime::W3C));
|
||||
|
||||
|
||||
if(isset($ical->DUE)) {
|
||||
$dtend = $ical->DUE->getDateTime();
|
||||
$ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
|
||||
$dtend->format(\DateTime::W3C));
|
||||
}
|
||||
else
|
||||
$ev['nofinish'] = 1;
|
||||
|
||||
|
||||
if($ev['start'] === $ev['finish'])
|
||||
if($ev['dtstart'] === $ev['dtend'])
|
||||
$ev['nofinish'] = 1;
|
||||
|
||||
if(isset($ical->CREATED)) {
|
||||
@@ -727,9 +753,9 @@ function event_import_ical_task($ical, $uid) {
|
||||
$ev['event_percent'] = (string) $ical->{'PERCENT-COMPLETE'} ;
|
||||
}
|
||||
|
||||
$ev['type'] = 'task';
|
||||
$ev['etype'] = 'task';
|
||||
|
||||
if($ev['summary'] && $ev['start']) {
|
||||
if($ev['summary'] && $ev['dtstart']) {
|
||||
$ev['event_xchan'] = $channel['channel_hash'];
|
||||
$ev['uid'] = $channel['channel_id'];
|
||||
$ev['account'] = $channel['channel_account_id'];
|
||||
@@ -781,7 +807,7 @@ function event_store_item($arr, $event) {
|
||||
if(($event) && array_key_exists('event_hash',$event) && (! array_key_exists('event_hash',$arr)))
|
||||
$arr['event_hash'] = $event['event_hash'];
|
||||
|
||||
if($event['type'] === 'birthday') {
|
||||
if($event['etype'] === 'birthday') {
|
||||
if(! is_sys_channel($arr['uid']))
|
||||
$prefix = t('This event has been added to your calendar.');
|
||||
// $birthday = true;
|
||||
@@ -805,21 +831,22 @@ function event_store_item($arr, $event) {
|
||||
'type' => ACTIVITY_OBJ_EVENT,
|
||||
'id' => z_root() . '/event/' . $r[0]['resource_id'],
|
||||
'title' => $arr['summary'],
|
||||
'start' => $arr['start'],
|
||||
'finish' => $arr['finish'],
|
||||
'dtstart' => $arr['dtstart'],
|
||||
'dtend' => $arr['dtend'],
|
||||
'nofinish' => $arr['nofinish'],
|
||||
'description' => $arr['description'],
|
||||
'location' => $arr['location'],
|
||||
'adjust' => $arr['adjust'],
|
||||
'content' => format_event_bbcode($arr),
|
||||
'author' => array(
|
||||
'name' => $r[0]['xchan_name'],
|
||||
'address' => $r[0]['xchan_addr'],
|
||||
'guid' => $r[0]['xchan_guid'],
|
||||
'guid_sig' => $r[0]['xchan_guid_sig'],
|
||||
'link' => array(
|
||||
array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']),
|
||||
array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])),
|
||||
'name' => $r[0]['xchan_name'],
|
||||
'address' => $r[0]['xchan_addr'],
|
||||
'guid' => $r[0]['xchan_guid'],
|
||||
'guid_sig' => $r[0]['xchan_guid_sig'],
|
||||
'link' => array(
|
||||
array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']),
|
||||
array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
@@ -830,7 +857,7 @@ function event_store_item($arr, $event) {
|
||||
|
||||
$sig = '';
|
||||
|
||||
q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d",
|
||||
q("UPDATE item SET title = '%s', body = '%s', obj = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d",
|
||||
dbesc($arr['summary']),
|
||||
dbesc($prefix . format_event_bbcode($arr)),
|
||||
dbesc($object),
|
||||
@@ -946,12 +973,12 @@ function event_store_item($arr, $event) {
|
||||
dbesc($arr['event_xchan'])
|
||||
);
|
||||
if($x) {
|
||||
$item_arr['object'] = json_encode(array(
|
||||
$item_arr['obj'] = json_encode(array(
|
||||
'type' => ACTIVITY_OBJ_EVENT,
|
||||
'id' => z_root() . '/event/' . $event['event_hash'],
|
||||
'title' => $arr['summary'],
|
||||
'start' => $arr['start'],
|
||||
'finish' => $arr['finish'],
|
||||
'dtstart' => $arr['dtstart'],
|
||||
'dtend' => $arr['dtend'],
|
||||
'nofinish' => $arr['nofinish'],
|
||||
'description' => $arr['description'],
|
||||
'location' => $arr['location'],
|
||||
@@ -1001,7 +1028,7 @@ function tasks_fetch($arr) {
|
||||
if($arr && $arr['all'] == 1)
|
||||
$sql_extra = '';
|
||||
|
||||
$r = q("select * from event where type = 'task' and uid = %d $sql_extra order by created desc",
|
||||
$r = q("select * from event where etype = 'task' and uid = %d $sql_extra order by created desc",
|
||||
intval(local_channel())
|
||||
);
|
||||
|
||||
|
||||
@@ -144,9 +144,9 @@ function construct_verb($item) {
|
||||
|
||||
function construct_activity_object($item) {
|
||||
|
||||
if($item['object']) {
|
||||
if($item['obj']) {
|
||||
$o = '<as:object>' . "\r\n";
|
||||
$r = json_decode($item['object'],false);
|
||||
$r = json_decode($item['obj'],false);
|
||||
|
||||
if(! $r)
|
||||
return '';
|
||||
@@ -582,7 +582,7 @@ function get_atom_elements($feed, $item, &$author) {
|
||||
$obj['content'] = $body;
|
||||
}
|
||||
|
||||
$res['object'] = $obj;
|
||||
$res['obj'] = $obj;
|
||||
}
|
||||
|
||||
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target');
|
||||
@@ -1163,12 +1163,12 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
||||
}
|
||||
|
||||
if(activity_match($item['obj_type'],ACTIVITY_OBJ_EVENT) && activity_match($item['verb'],ACTIVITY_POST)) {
|
||||
$obj = ((is_array($item['obj'])) ? $item['object'] : json_decode($item['object'],true));
|
||||
$obj = ((is_array($item['obj'])) ? $item['obj'] : json_decode($item['obj'],true));
|
||||
|
||||
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
|
||||
$o .= '<summary xmlns="urn:ietf:params:xml:ns:xcal">' . xmlify(bbcode($obj['title'])) . '</summary>' . "\r\n";
|
||||
$o .= '<dtstart xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['start'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtstart>' . "\r\n";
|
||||
$o .= '<dtend xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['finish'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtend>' . "\r\n";
|
||||
$o .= '<dtstart xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['dtstart'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtstart>' . "\r\n";
|
||||
$o .= '<dtend xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['dtend'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtend>' . "\r\n";
|
||||
$o .= '<location xmlns="urn:ietf:params:xml:ns:xcal">' . xmlify(bbcode($obj['location'])) . '</location>' . "\r\n";
|
||||
$o .= '<content type="' . $type . '" >' . xmlify(bbcode($obj['description'])) . '</content>' . "\r\n";
|
||||
}
|
||||
|
||||
@@ -974,6 +974,11 @@ function sync_files($channel,$files) {
|
||||
$attachment_stored = false;
|
||||
foreach($f['attach'] as $att) {
|
||||
|
||||
if(array_key_exists('data',$att)) {
|
||||
$att['content'] = $att['data'];
|
||||
unset($att['data']);
|
||||
}
|
||||
|
||||
if($att['deleted']) {
|
||||
attach_delete($channel,$att['hash']);
|
||||
continue;
|
||||
@@ -1043,7 +1048,7 @@ function sync_files($channel,$files) {
|
||||
|
||||
// @fixme - update attachment structures if they are modified rather than created
|
||||
|
||||
$att['data'] = $newfname;
|
||||
$att['content'] = $newfname;
|
||||
|
||||
// Note: we use $att['hash'] below after it has been escaped to
|
||||
// fetch the file contents.
|
||||
@@ -1125,6 +1130,15 @@ function sync_files($channel,$files) {
|
||||
$p['aid'] = $channel['channel_account_id'];
|
||||
$p['uid'] = $channel['channel_id'];
|
||||
|
||||
if(array_key_exists('data',$p)) {
|
||||
$p['content'] = $p['data'];
|
||||
unset($p['data']);
|
||||
}
|
||||
if(array_key_exists('scale',$p)) {
|
||||
$p['imgscale'] = $p['scale'];
|
||||
unset($p['scale']);
|
||||
}
|
||||
|
||||
// if this is a profile photo, undo the profile photo bit
|
||||
// for any other photo which previously held it.
|
||||
|
||||
@@ -1150,15 +1164,15 @@ function sync_files($channel,$files) {
|
||||
);
|
||||
}
|
||||
|
||||
if($p['scale'] === 0 && $p['os_storage'])
|
||||
$p['data'] = $store_path;
|
||||
if($p['imgscale'] === 0 && $p['os_storage'])
|
||||
$p['content'] = $store_path;
|
||||
else
|
||||
$p['data'] = base64_decode($p['data']);
|
||||
$p['content'] = base64_decode($p['content']);
|
||||
|
||||
|
||||
$exists = q("select * from photo where resource_id = '%s' and scale = %d and uid = %d limit 1",
|
||||
$exists = q("select * from photo where resource_id = '%s' and imgscale = %d and uid = %d limit 1",
|
||||
dbesc($p['resource_id']),
|
||||
intval($p['scale']),
|
||||
intval($p['imgscale']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
|
||||
|
||||
@@ -666,7 +666,7 @@ function get_item_elements($x,$allow_code = false) {
|
||||
|
||||
$arr['diaspora_meta'] = (($x['diaspora_signature']) ? $x['diaspora_signature'] : '');
|
||||
|
||||
$arr['object'] = activity_sanitise($x['object']);
|
||||
$arr['obj'] = activity_sanitise($x['object']);
|
||||
$arr['target'] = activity_sanitise($x['target']);
|
||||
|
||||
$arr['attach'] = activity_sanitise($x['attach']);
|
||||
@@ -1055,8 +1055,8 @@ function encode_item($item,$mirror = false) {
|
||||
|
||||
$x['owner'] = encode_item_xchan($item['owner']);
|
||||
$x['author'] = encode_item_xchan($item['author']);
|
||||
if($item['object'])
|
||||
$x['object'] = json_decode_plus($item['object']);
|
||||
if($item['obj'])
|
||||
$x['object'] = json_decode_plus($item['obj']);
|
||||
if($item['target'])
|
||||
$x['target'] = json_decode_plus($item['target']);
|
||||
if($item['attach'])
|
||||
@@ -1595,9 +1595,9 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
}
|
||||
}
|
||||
|
||||
if((x($arr,'object')) && is_array($arr['object'])) {
|
||||
activity_sanitise($arr['object']);
|
||||
$arr['object'] = json_encode($arr['object']);
|
||||
if((x($arr,'obj')) && is_array($arr['obj'])) {
|
||||
activity_sanitise($arr['obj']);
|
||||
$arr['obj'] = json_encode($arr['obj']);
|
||||
}
|
||||
|
||||
if((x($arr,'target')) && is_array($arr['target'])) {
|
||||
@@ -1628,7 +1628,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
$arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']);
|
||||
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ACTIVITY_POST);
|
||||
$arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ACTIVITY_OBJ_NOTE);
|
||||
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : '');
|
||||
$arr['obj'] = ((x($arr,'obj')) ? trim($arr['obj']) : '');
|
||||
$arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : '');
|
||||
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : '');
|
||||
$arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : '');
|
||||
@@ -1697,7 +1697,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if(($arr['obj_type'] == ACTIVITY_OBJ_NOTE) && (! $arr['object']))
|
||||
if(($arr['obj_type'] == ACTIVITY_OBJ_NOTE) && (! $arr['obj']))
|
||||
$arr['obj_type'] = ACTIVITY_OBJ_COMMENT;
|
||||
|
||||
// is the new message multi-level threaded?
|
||||
@@ -1991,9 +1991,9 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) {
|
||||
}
|
||||
}
|
||||
|
||||
if((x($arr,'object')) && is_array($arr['object'])) {
|
||||
activity_sanitise($arr['object']);
|
||||
$arr['object'] = json_encode($arr['object']);
|
||||
if((x($arr,'obj')) && is_array($arr['obj'])) {
|
||||
activity_sanitise($arr['obj']);
|
||||
$arr['obj'] = json_encode($arr['obj']);
|
||||
}
|
||||
|
||||
if((x($arr,'target')) && is_array($arr['target'])) {
|
||||
@@ -2035,7 +2035,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) {
|
||||
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']);
|
||||
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']);
|
||||
$arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']);
|
||||
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : $orig[0]['object']);
|
||||
$arr['obj'] = ((x($arr,'obj')) ? trim($arr['obj']) : $orig[0]['obj']);
|
||||
$arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : $orig[0]['tgt_type']);
|
||||
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : $orig[0]['target']);
|
||||
$arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : $orig[0]['plink']);
|
||||
@@ -2369,10 +2369,10 @@ function tag_deliver($uid, $item_id) {
|
||||
if (stristr($item['verb'],ACTIVITY_POKE)) {
|
||||
$poke_notify = true;
|
||||
|
||||
if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['object']))
|
||||
if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['obj']))
|
||||
$poke_notify = false;
|
||||
|
||||
$obj = json_decode_plus($item['object']);
|
||||
$obj = json_decode_plus($item['obj']);
|
||||
if($obj) {
|
||||
if($obj['id'] !== $u[0]['channel_hash'])
|
||||
$poke_notify = false;
|
||||
@@ -2416,7 +2416,7 @@ function tag_deliver($uid, $item_id) {
|
||||
intval($u[0]['channel_id'])
|
||||
);
|
||||
if($p) {
|
||||
$j_obj = json_decode_plus($item['object']);
|
||||
$j_obj = json_decode_plus($item['obj']);
|
||||
logger('tag_deliver: tag object: ' . print_r($j_obj,true), LOGGER_DATA);
|
||||
if($j_obj && $j_obj['id'] && $j_obj['title']) {
|
||||
if(is_array($j_obj['link']))
|
||||
@@ -3093,7 +3093,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) {
|
||||
if($x) {
|
||||
$res = substr($i,$x+1);
|
||||
$i = substr($i,0,$x);
|
||||
$r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `scale` = %d AND `uid` = %d",
|
||||
$r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `imgscale` = %d AND `uid` = %d",
|
||||
dbesc($i),
|
||||
intval($res),
|
||||
intval($uid)
|
||||
@@ -4263,7 +4263,7 @@ function send_profile_photo_activity($channel,$photo,$profile) {
|
||||
$arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
|
||||
$arr['verb'] = ACTIVITY_UPDATE;
|
||||
|
||||
$arr['object'] = json_encode(array(
|
||||
$arr['obj'] = 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'])
|
||||
|
||||
@@ -316,7 +316,7 @@ abstract class photo_driver {
|
||||
$p['resource_id'] = (($arr['resource_id']) ? $arr['resource_id'] : '');
|
||||
$p['filename'] = (($arr['filename']) ? $arr['filename'] : '');
|
||||
$p['album'] = (($arr['album']) ? $arr['album'] : '');
|
||||
$p['scale'] = ((intval($arr['scale'])) ? intval($arr['scale']) : 0);
|
||||
$p['imgscale'] = ((intval($arr['imgscale'])) ? intval($arr['imgscale']) : 0);
|
||||
$p['allow_cid'] = (($arr['allow_cid']) ? $arr['allow_cid'] : '');
|
||||
$p['allow_gid'] = (($arr['allow_gid']) ? $arr['allow_gid'] : '');
|
||||
$p['deny_cid'] = (($arr['deny_cid']) ? $arr['deny_cid'] : '');
|
||||
@@ -329,14 +329,14 @@ abstract class photo_driver {
|
||||
$p['os_storage'] = intval($arr['os_storage']);
|
||||
$p['os_path'] = $arr['os_path'];
|
||||
|
||||
if(! intval($p['scale']))
|
||||
logger('save: ' . print_r($arr,true));
|
||||
if(! intval($p['imgscale']))
|
||||
logger('save: ' . print_r($arr,true), LOGGER_DATA);
|
||||
|
||||
$x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and `scale` = %d limit 1",
|
||||
$x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1",
|
||||
dbesc($p['resource_id']),
|
||||
intval($p['uid']),
|
||||
dbesc($p['xchan']),
|
||||
intval($p['scale'])
|
||||
intval($p['imgscale'])
|
||||
);
|
||||
if($x) {
|
||||
$r = q("UPDATE `photo` set
|
||||
@@ -347,14 +347,14 @@ abstract class photo_driver {
|
||||
`created` = '%s',
|
||||
`edited` = '%s',
|
||||
`filename` = '%s',
|
||||
`type` = '%s',
|
||||
`mimetype` = '%s',
|
||||
`album` = '%s',
|
||||
`height` = %d,
|
||||
`width` = %d,
|
||||
`data` = '%s',
|
||||
`content` = '%s',
|
||||
`os_storage` = %d,
|
||||
`size` = %d,
|
||||
`scale` = %d,
|
||||
`filesize` = %d,
|
||||
`imgscale` = %d,
|
||||
`photo_usage` = %d,
|
||||
`title` = '%s',
|
||||
`description` = '%s',
|
||||
@@ -378,7 +378,7 @@ abstract class photo_driver {
|
||||
(intval($p['os_storage']) ? dbesc($p['os_path']) : dbescbin($this->imageString())),
|
||||
intval($p['os_storage']),
|
||||
intval(strlen($this->imageString())),
|
||||
intval($p['scale']),
|
||||
intval($p['imgscale']),
|
||||
intval($p['photo_usage']),
|
||||
dbesc($p['title']),
|
||||
dbesc($p['description']),
|
||||
@@ -391,7 +391,7 @@ abstract class photo_driver {
|
||||
}
|
||||
else {
|
||||
$r = q("INSERT INTO `photo`
|
||||
( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `os_storage`, `size`, `scale`, `photo_usage`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
|
||||
( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, mimetype, `album`, `height`, `width`, `content`, `os_storage`, `filesize`, `imgscale`, `photo_usage`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
|
||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
|
||||
intval($p['aid']),
|
||||
intval($p['uid']),
|
||||
@@ -407,7 +407,7 @@ abstract class photo_driver {
|
||||
(intval($p['os_storage']) ? dbesc($p['os_path']) : dbescbin($this->imageString())),
|
||||
intval($p['os_storage']),
|
||||
intval(strlen($this->imageString())),
|
||||
intval($p['scale']),
|
||||
intval($p['imgscale']),
|
||||
intval($p['photo_usage']),
|
||||
dbesc($p['title']),
|
||||
dbesc($p['description']),
|
||||
@@ -422,7 +422,7 @@ abstract class photo_driver {
|
||||
|
||||
public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $usage = PHOTO_NORMAL, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
|
||||
|
||||
$x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `scale` = %d limit 1",
|
||||
$x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `imgscale` = %d limit 1",
|
||||
dbesc($rid),
|
||||
intval($uid),
|
||||
dbesc($xchan),
|
||||
@@ -437,13 +437,13 @@ abstract class photo_driver {
|
||||
`created` = '%s',
|
||||
`edited` = '%s',
|
||||
`filename` = '%s',
|
||||
`type` = '%s',
|
||||
`mimetype` = '%s',
|
||||
`album` = '%s',
|
||||
`height` = %d,
|
||||
`width` = %d,
|
||||
`data` = '%s',
|
||||
`size` = %d,
|
||||
`scale` = %d,
|
||||
`content` = '%s',
|
||||
`filesize` = %d,
|
||||
`imgscale` = %d,
|
||||
`photo_usage` = %d,
|
||||
`allow_cid` = '%s',
|
||||
`allow_gid` = '%s',
|
||||
@@ -475,7 +475,7 @@ abstract class photo_driver {
|
||||
}
|
||||
else {
|
||||
$r = q("INSERT INTO `photo`
|
||||
( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `photo_usage`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
|
||||
( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, mimetype, `album`, `height`, `width`, `content`, `filesize`, `imgscale`, `photo_usage`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
|
||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s' )",
|
||||
intval($aid),
|
||||
intval($uid),
|
||||
@@ -588,7 +588,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
|
||||
if($thing)
|
||||
$hash = photo_new_resource();
|
||||
else {
|
||||
$r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and scale = 4 limit 1",
|
||||
$r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and imgscale = 4 limit 1",
|
||||
dbesc($xchan),
|
||||
intval(PHOTO_XCHAN)
|
||||
);
|
||||
@@ -654,7 +654,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
|
||||
else
|
||||
$photo_failure = true;
|
||||
|
||||
$p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'scale' => 4);
|
||||
$p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'imgscale' => 4);
|
||||
|
||||
$r = $img->save($p);
|
||||
|
||||
@@ -662,7 +662,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
|
||||
$photo_failure = true;
|
||||
|
||||
$img->scaleImage(80);
|
||||
$p['scale'] = 5;
|
||||
$p['imgscale'] = 5;
|
||||
|
||||
$r = $img->save($p);
|
||||
|
||||
@@ -670,7 +670,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
|
||||
$photo_failure = true;
|
||||
|
||||
$img->scaleImage(48);
|
||||
$p['scale'] = 6;
|
||||
$p['imgscale'] = 6;
|
||||
|
||||
$r = $img->save($p);
|
||||
|
||||
@@ -715,7 +715,7 @@ function import_channel_photo($photo,$type,$aid,$uid) {
|
||||
|
||||
$img->scaleImageSquare(300);
|
||||
|
||||
$p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_usage' => PHOTO_PROFILE, 'scale' => 4);
|
||||
$p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_usage' => PHOTO_PROFILE, 'imgscale' => 4);
|
||||
|
||||
$r = $img->save($p);
|
||||
|
||||
@@ -723,7 +723,7 @@ function import_channel_photo($photo,$type,$aid,$uid) {
|
||||
$photo_failure = true;
|
||||
|
||||
$img->scaleImage(80);
|
||||
$p['scale'] = 5;
|
||||
$p['imgscale'] = 5;
|
||||
|
||||
$r = $img->save($p);
|
||||
|
||||
@@ -731,7 +731,7 @@ function import_channel_photo($photo,$type,$aid,$uid) {
|
||||
$photo_failure = true;
|
||||
|
||||
$img->scaleImage(48);
|
||||
$p['scale'] = 6;
|
||||
$p['imgscale'] = 6;
|
||||
|
||||
$r = $img->save($p);
|
||||
|
||||
|
||||
@@ -71,17 +71,17 @@ function photo_upload($channel, $observer, $args) {
|
||||
$type = $args['getimagesize']['mime'];
|
||||
$os_storage = 1;
|
||||
}
|
||||
elseif ($args['data']) {
|
||||
elseif ($args['data'] || $args['content']) {
|
||||
|
||||
// allow an import from a binary string representing the image.
|
||||
// This bypasses the upload step and max size limit checking
|
||||
|
||||
$imagedata = $args['data'];
|
||||
$imagedata = (($args['content']) ? $args['content'] : $args['data']);
|
||||
$filename = $args['filename'];
|
||||
$filesize = strlen($imagedata);
|
||||
// this is going to be deleted if it exists
|
||||
$src = '/tmp/deletemenow';
|
||||
$type = $args['type'];
|
||||
$type = (($args['mimetype']) ? $args['mimetype'] : $args['type']);
|
||||
} else {
|
||||
$f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
|
||||
|
||||
@@ -125,7 +125,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$imagedata = @file_get_contents($src);
|
||||
}
|
||||
|
||||
$r = q("select sum(size) as total from photo where aid = %d and scale = 0 ",
|
||||
$r = q("select sum(filesize) as total from photo where aid = %d and imgscale = 0 ",
|
||||
intval($account_id)
|
||||
);
|
||||
|
||||
@@ -172,7 +172,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$errors = false;
|
||||
|
||||
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
|
||||
'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_usage' => PHOTO_NORMAL,
|
||||
'filename' => $filename, 'album' => $album, 'imgscale' => 0, 'photo_usage' => PHOTO_NORMAL,
|
||||
'allow_cid' => $ac['allow_cid'], 'allow_gid' => $ac['allow_gid'],
|
||||
'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'],
|
||||
'os_storage' => $os_storage, 'os_path' => $args['os_path']
|
||||
@@ -205,7 +205,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
if(($width > 1024 || $height > 1024) && (! $errors))
|
||||
$ph->scaleImage(1024);
|
||||
|
||||
$p['scale'] = 1;
|
||||
$p['imgscale'] = 1;
|
||||
$r1 = $ph->save($p);
|
||||
$link[1] = array(
|
||||
'rel' => 'alternate',
|
||||
@@ -220,7 +220,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
if(($width > 640 || $height > 640) && (! $errors))
|
||||
$ph->scaleImage(640);
|
||||
|
||||
$p['scale'] = 2;
|
||||
$p['imgscale'] = 2;
|
||||
$r2 = $ph->save($p);
|
||||
$link[2] = array(
|
||||
'rel' => 'alternate',
|
||||
@@ -235,7 +235,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
if(($width > 320 || $height > 320) && (! $errors))
|
||||
$ph->scaleImage(320);
|
||||
|
||||
$p['scale'] = 3;
|
||||
$p['imgscale'] = 3;
|
||||
$r3 = $ph->save($p);
|
||||
$link[3] = array(
|
||||
'rel' => 'alternate',
|
||||
@@ -332,7 +332,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
|
||||
$item['body'] = $args['body'];
|
||||
$item['obj_type'] = ACTIVITY_OBJ_PHOTO;
|
||||
$item['object'] = json_encode($object);
|
||||
$item['obj'] = json_encode($object);
|
||||
|
||||
$item['tgt_type'] = ACTIVITY_OBJ_ALBUM;
|
||||
$item['target'] = json_encode($target);
|
||||
@@ -389,8 +389,8 @@ function photo_upload($channel, $observer, $args) {
|
||||
$arr['deny_cid'] = $ac['deny_cid'];
|
||||
$arr['deny_gid'] = $ac['deny_gid'];
|
||||
$arr['verb'] = ACTIVITY_POST;
|
||||
$arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
|
||||
$arr['object'] = json_encode($object);
|
||||
$arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
|
||||
$arr['obj'] = json_encode($object);
|
||||
$arr['tgt_type'] = ACTIVITY_OBJ_ALBUM;
|
||||
$arr['target'] = json_encode($target);
|
||||
$arr['item_wall'] = 1;
|
||||
@@ -535,7 +535,7 @@ function photos_list_photos($channel, $observer, $album = '') {
|
||||
|
||||
$ret = array('success' => false);
|
||||
|
||||
$r = q("select resource_id, created, edited, title, description, album, filename, type, height, width, size, scale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and photo_usage in ( %d, %d ) $sql_extra ",
|
||||
$r = q("select resource_id, created, edited, title, description, album, filename, mimetype, height, width, filesize, imgscale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and photo_usage in ( %d, %d ) $sql_extra ",
|
||||
intval($channel_id),
|
||||
intval(PHOTO_NORMAL),
|
||||
intval(PHOTO_PROFILE)
|
||||
@@ -543,7 +543,7 @@ function photos_list_photos($channel, $observer, $album = '') {
|
||||
|
||||
if($r) {
|
||||
for($x = 0; $x < count($r); $x ++) {
|
||||
$r[$x]['src'] = z_root() . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['scale'];
|
||||
$r[$x]['src'] = z_root() . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['imgscale'];
|
||||
}
|
||||
$ret['success'] = true;
|
||||
$ret['photos'] = $r;
|
||||
@@ -661,7 +661,7 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
|
||||
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
|
||||
|
||||
$arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']'
|
||||
. '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]'
|
||||
. '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['imgscale'] . '[/zmg]'
|
||||
. '[/zrl]';
|
||||
|
||||
$result = item_store($arr);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
function apply_updates() {
|
||||
|
||||
//check for updated items and remove them
|
||||
$x = q("SELECT mid, max(object) AS object FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid",
|
||||
$x = q("SELECT mid, max(obj) AS obj FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid",
|
||||
dbesc(ACTIVITY_UPDATE),
|
||||
dbesc(ACTIVITY_OBJ_FILE)
|
||||
);
|
||||
@@ -12,7 +12,7 @@ function apply_updates() {
|
||||
|
||||
foreach($x as $xx) {
|
||||
|
||||
$object = json_decode($xx['object'],true);
|
||||
$object = json_decode($xx['obj'],true);
|
||||
|
||||
$d_mid = $object['d_mid'];
|
||||
$u_mid = $xx['mid'];
|
||||
|
||||
@@ -1458,37 +1458,6 @@ function generate_named_map($location) {
|
||||
return (($arr['html']) ? $arr['html'] : $location);
|
||||
}
|
||||
|
||||
function format_event($jobject) {
|
||||
$event = array();
|
||||
|
||||
$object = json_decode($jobject,true);
|
||||
|
||||
//ensure compatibility with older items - this check can be removed at a later point
|
||||
if(array_key_exists('description', $object)) {
|
||||
|
||||
$bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM
|
||||
|
||||
$event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
|
||||
'$title' => bbcode($object['title']),
|
||||
'$dtstart_label' => t('Starts:'),
|
||||
'$dtstart_title' => datetime_convert('UTC', 'UTC', $object['start'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
|
||||
'$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['start'] , $bd_format))),
|
||||
'$finish' => (($object['nofinish']) ? false : true),
|
||||
'$dtend_label' => t('Finishes:'),
|
||||
'$dtend_title' => datetime_convert('UTC','UTC',$object['finish'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
|
||||
'$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['finish'] , $bd_format )))
|
||||
));
|
||||
|
||||
$event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(
|
||||
'$description' => bbcode($object['description']),
|
||||
'$location_label' => t('Location:'),
|
||||
'$location' => bbcode($object['location'])
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
function prepare_body(&$item,$attach = false) {
|
||||
|
||||
@@ -1516,7 +1485,7 @@ function prepare_body(&$item,$attach = false) {
|
||||
|
||||
$s .= prepare_text($item['body'],$item['mimetype'], false);
|
||||
|
||||
$event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event($item['object']) : false);
|
||||
$event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false);
|
||||
|
||||
$prep_arr = array(
|
||||
'item' => $item,
|
||||
|
||||
@@ -1126,7 +1126,7 @@ function widget_photo_rand($arr) {
|
||||
$filtered = array();
|
||||
if($ret['success'] && $ret['photos'])
|
||||
foreach($ret['photos'] as $p)
|
||||
if($p['scale'] == $scale)
|
||||
if($p['imgscale'] == $scale)
|
||||
$filtered[] = $p['src'];
|
||||
|
||||
if($filtered) {
|
||||
@@ -1459,9 +1459,9 @@ function widget_album($args) {
|
||||
|
||||
$order = 'DESC';
|
||||
|
||||
$r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.scale, p.description, p.created FROM photo p INNER JOIN
|
||||
(SELECT resource_id, max(scale) scale FROM photo WHERE uid = %d AND album = '%s' AND scale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
|
||||
ON (p.resource_id = ph.resource_id AND p.scale = ph.scale)
|
||||
$r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN
|
||||
(SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
|
||||
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
|
||||
ORDER BY created $order ",
|
||||
intval($owner_uid),
|
||||
dbesc($album),
|
||||
@@ -1482,7 +1482,7 @@ function widget_album($args) {
|
||||
else
|
||||
$twist = 'rotright';
|
||||
|
||||
$ext = $phototypes[$rr['type']];
|
||||
$ext = $phototypes[$rr['mimetype']];
|
||||
|
||||
$imgalt_e = $rr['filename'];
|
||||
$desc_e = $rr['description'];
|
||||
@@ -1495,7 +1495,7 @@ function widget_album($args) {
|
||||
'twist' => ' ' . $twist . rand(2,4),
|
||||
'link' => $imagelink,
|
||||
'title' => t('View Photo'),
|
||||
'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
|
||||
'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['imgscale'] . '.' .$ext,
|
||||
'alt' => $imgalt_e,
|
||||
'desc'=> $desc_e,
|
||||
'ext' => $ext,
|
||||
|
||||
Reference in New Issue
Block a user