diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Photo.php | 12 | ||||
-rw-r--r-- | include/acl_selectors.php | 6 | ||||
-rw-r--r-- | include/auth.php | 12 | ||||
-rw-r--r-- | include/bbcode.php | 2 | ||||
-rw-r--r-- | include/conversation.php | 8 | ||||
-rw-r--r-- | include/group.php | 2 | ||||
-rw-r--r-- | include/items.php | 46 | ||||
-rw-r--r-- | include/main.js | 15 | ||||
-rw-r--r-- | include/notifier.php | 2 | ||||
-rw-r--r-- | include/poller.php | 6 |
10 files changed, 86 insertions, 25 deletions
diff --git a/include/Photo.php b/include/Photo.php index 9934b9a39..707b0de5d 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -162,12 +162,20 @@ class Photo { } public function saveImage($path) { - imagejpeg($this->image,$path,100); + $quality = get_config('system','jpeg_quality'); + if((! $quality) || ($quality > 100)) + $quality = JPEG_QUALITY; + imagejpeg($this->image,$path,$quality); } public function imageString() { ob_start(); - imagejpeg($this->image,NULL,100); + + $quality = get_config('system','jpeg_quality'); + if((! $quality) || ($quality > 100)) + $quality = JPEG_QUALITY; + + imagejpeg($this->image,NULL,$quality); $s = ob_get_contents(); ob_end_clean(); return $s; diff --git a/include/acl_selectors.php b/include/acl_selectors.php index d1303d933..f2763a569 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -48,7 +48,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o = ''; - // When used for private messages, we limit correspondence to mutual friends and the selector + // When used for private messages, we limit correspondence to mutual DFRN/Friendika friends and the selector // to one recipient. By default our selector allows multiple selects amongst all contacts. $sql_extra = ''; @@ -61,7 +61,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $sql_extra .= " AND `network` IN ( 'dfrn' ) "; } elseif($privatenet) { - $sql_extra .= " AND `network` IN ( 'dfrn', 'mail' ) "; + $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face' ) "; } if($privmail) @@ -83,8 +83,6 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p call_hooks($a->module . '_pre_' . $selname, $arr); - - if(count($r)) { foreach($r as $rr) { if((is_array($preselected)) && in_array($rr['id'], $preselected)) diff --git a/include/auth.php b/include/auth.php index e8cee3918..4c7e85d86 100644 --- a/include/auth.php +++ b/include/auth.php @@ -191,9 +191,17 @@ else { $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; - notice( t("Welcome back ") . $record['username'] . EOL); $a->user = $record; + if($a->user['login_date'] === '0000-00-00 00:00:00') { + $_SESSION['return_url'] = 'profile_photo/new'; + $a->module = 'profile_photo'; + notice( t("Welcome ") . $a->user['username'] . EOL); + notice( t('Please upload a profile photo.') . EOL); + } + else + notice( t("Welcome back ") . $a->user['username'] . EOL); + if(strlen($a->user['timezone'])) { date_default_timezone_set($a->user['timezone']); $a->timezone = $a->user['timezone']; @@ -214,6 +222,8 @@ else { $a->cid = $r[0]['id']; $_SESSION['cid'] = $a->cid; } + + q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d LIMIT 1", dbesc(datetime_convert()), intval($_SESSION['uid']) diff --git a/include/bbcode.php b/include/bbcode.php index 6fadbaf7e..89a14988a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -80,7 +80,7 @@ function bbcode($Text,$preserve_nl = false) { // Images // [img]pathtoimage[/img] - $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $Text); + $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text); // html5 video and audio diff --git a/include/conversation.php b/include/conversation.php index 1c56fa1bf..7c30c01c2 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -225,7 +225,7 @@ function conversation(&$a, $items, $mode, $update) { $comments = array(); foreach($items as $item) { - if(intval($item['gravity']) == 6) { + if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { if(! x($comments,$item['parent'])) $comments[$item['parent']] = 1; else @@ -294,6 +294,7 @@ function conversation(&$a, $items, $mode, $update) { $comments_seen ++; + $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false); if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { @@ -368,7 +369,7 @@ function conversation(&$a, $items, $mode, $update) { )); } - if(($show_comment_box) || (($show_comment_box == false) && ($item['last-child']))) { + if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { $comment = replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), @@ -686,6 +687,7 @@ function status_editor($a,$x) { '$baseurl' => $a->get_baseurl(), '$geotag' => $geotag, '$nickname' => $x['nickname'], + '$ispublic' => t('Visible to <strong>everybody</strong>'), '$linkurl' => t('Please enter a link URL:'), '$utubeurl' => t('Please enter a YouTube link:'), '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"), @@ -744,7 +746,7 @@ function status_editor($a,$x) { '$content' => '', '$post_id' => '', '$baseurl' => $a->get_baseurl(), - '$defloc' => $x['default-location'], + '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$emailcc' => t('CC: email addresses'), '$jotnets' => $jotnets, diff --git a/include/group.php b/include/group.php index 5dca08c76..8866104fc 100644 --- a/include/group.php +++ b/include/group.php @@ -124,7 +124,7 @@ function group_public_members($gid) { $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` WHERE `gid` = %d AND `group_member`.`uid` = %d - AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' ", + AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' AND `contact`.`network` != 'face' ", intval($gid), intval(local_user()) ); diff --git a/include/items.php b/include/items.php index 733cd8048..3a3085f1b 100644 --- a/include/items.php +++ b/include/items.php @@ -701,6 +701,7 @@ function item_store($arr,$force_parent = false) { $parent_id = 0; $arr['thr-parent'] = $arr['parent-uri']; $arr['parent-uri'] = $arr['uri']; + $arr['gravity'] = 0; } else { logger('item_store: item parent was not found - ignoring item'); @@ -1496,10 +1497,17 @@ function atom_author($tag,$name,$uri,$h,$w,$photo) { function atom_entry($item,$type,$author,$owner,$comment = false) { + $a = get_app(); + if($item['deleted']) return '<at:deleted-entry ref="' . xmlify($item['uri']) . '" when="' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '" />' . "\r\n"; - $a = get_app(); + + if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) + $body = fix_private_photos($item['body'],$owner['uid']); + else + $body = $item['body']; + $o = "\r\n\r\n<entry>\r\n"; @@ -1517,8 +1525,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { $o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n"; $o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n"; $o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n"; - $o .= '<dfrn:env>' . base64url_encode($item['body'], true) . '</dfrn:env>' . "\r\n"; - $o .= '<content type="' . $type . '" >' . xmlify(($type === 'html') ? bbcode($item['body']) : $item['body']) . '</content>' . "\r\n"; + $o .= '<dfrn:env>' . base64url_encode($body, true) . '</dfrn:env>' . "\r\n"; + $o .= '<content type="' . $type . '" >' . xmlify(($type === 'html') ? bbcode($body) : $body) . '</content>' . "\r\n"; $o .= '<link rel="alternate" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']) . '" />' . "\r\n"; if($comment) $o .= '<dfrn:comment-allow>' . intval($item['last-child']) . '</dfrn:comment-allow>' . "\r\n"; @@ -1563,6 +1571,38 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } +function fix_private_photos($s,$uid) { + $a = get_app(); + logger('fix_private_photos'); + + if(preg_match("/\[img\](.+?)\[\/img\]/is",$s,$matches)) { + $image = $matches[1]; + logger('fix_private_photos: found photo ' . $image); + if(stristr($image ,$a->get_baseurl() . '/photo/')) { + $i = basename($image); + $i = str_replace('.jpg','',$i); + $x = strpos($i,'-'); + 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", + dbesc($i), + intval($res), + intval($uid) + ); + if(count($r)) { + logger('replacing photo'); + $s = str_replace($image, 'data:image/jpg;base64,' . base64_encode($r[0]['data']), $s); + } + } + logger('fix_private_photos: replaced: ' . $s, LOGGER_DATA); + } + } + return($s); +} + + + function item_getfeedtags($item) { $ret = array(); $matches = false; diff --git a/include/main.js b/include/main.js index a251d8e3a..c7a3aea48 100644 --- a/include/main.js +++ b/include/main.js @@ -91,19 +91,20 @@ $.get("ping",function(data) { $(data).find('result').each(function() { var net = $(this).find('net').text(); - if(net == 0) { net = ''; } + if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() } $('#net-update').html(net); var home = $(this).find('home').text(); - if(home == 0) { home = ''; } + if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() } $('#home-update').html(home); var mail = $(this).find('mail').text(); - if(mail == 0) { mail = ''; } + if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() } $('#mail-update').html(mail); var intro = $(this).find('intro').text(); var register = $(this).find('register').text(); if(intro == 0) { intro = ''; } if(register != 0 && intro != '') { intro = intro+'/'+register; } if(register != 0 && intro == '') { intro = '0/'+register; } + if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() } $('#notify-update').html(intro); }); @@ -161,15 +162,11 @@ } function imgbright(node) { - $(node).attr("src",$(node).attr("src").replace('hide','show')); - $(node).css('width',24); - $(node).css('height',24); + $(node).removeClass("drophide").addClass("drop"); } function imgdull(node) { - $(node).attr("src",$(node).attr("src").replace('show','hide')); - $(node).css('width',16); - $(node).css('height',16); + $(node).removeClass("drop").addClass("drophide"); } // Since our ajax calls are asynchronous, we will give a few diff --git a/include/notifier.php b/include/notifier.php index 4cc6d7a99..b009cc870 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -20,6 +20,8 @@ function notifier_run($argv, $argc){ require_once('include/items.php'); require_once('include/bbcode.php'); + load_hooks(); + if($argc < 3) return; diff --git a/include/poller.php b/include/poller.php index b5639e034..dd2efcb76 100644 --- a/include/poller.php +++ b/include/poller.php @@ -26,6 +26,8 @@ function poller_run($argv, $argc){ $a->set_baseurl(get_config('system','url')); + load_hooks(); + logger('poller: start'); // run queue delivery process in the background @@ -61,10 +63,12 @@ function poller_run($argv, $argc){ $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : ""); + reload_plugins(); + $d = datetime_convert(); + call_hooks('cron', $d); - reload_plugins(); $contacts = q("SELECT `id` FROM `contact` WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != '' |