aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Channel.php2
-rw-r--r--Zotlabs/Module/Dircensor.php52
-rw-r--r--Zotlabs/Module/Directory.php43
-rw-r--r--Zotlabs/Module/Dirsearch.php54
-rw-r--r--Zotlabs/Module/Embedphotos.php2
-rw-r--r--Zotlabs/Module/Help.php5
-rw-r--r--Zotlabs/Module/Sse_bs.php23
-rw-r--r--Zotlabs/Photo/PhotoGd.php18
-rw-r--r--Zotlabs/Photo/PhotoImagick.php30
-rw-r--r--Zotlabs/Storage/File.php2
-rwxr-xr-xboot.php11
-rw-r--r--include/attach.php19
-rw-r--r--include/photo/photo_driver.php2
-rw-r--r--include/text.php1
-rw-r--r--view/js/main.js28
-rwxr-xr-xview/tpl/direntry.tpl3
-rw-r--r--view/tpl/notifications_widget.tpl2
17 files changed, 222 insertions, 75 deletions
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 20a5418c2..5529db70e 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -470,7 +470,7 @@ class Channel extends Controller {
}
// Add pinned content
- if(! $decoded && ! $search) {
+ if(! x($_REQUEST,'mid') && ! $search) {
$pinned = new \Zotlabs\Widget\Pinned;
$r = $pinned->widget(intval(App::$profile['profile_uid']), [ITEM_TYPE_POST]);
$o .= $r['html'];
diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php
new file mode 100644
index 000000000..0fa65e948
--- /dev/null
+++ b/Zotlabs/Module/Dircensor.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Web\Controller;
+
+
+class Dircensor extends Controller {
+
+ function get() {
+ if(! is_site_admin()) {
+ return;
+ }
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ if (! ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE)) {
+ return;
+ }
+
+ $xchan = argv(1);
+ if(! $xchan) {
+ return;
+ }
+
+ $r = q("select * from xchan where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if(! $r) {
+ return;
+ }
+
+ $val = (($r[0]['xchan_censored']) ? 0 : 1);
+
+ q("update xchan set xchan_censored = $val where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if($val) {
+ info( t('Entry censored') . EOL);
+ }
+ else {
+ info( t('Entry uncensored') . EOL);
+ }
+
+ goaway(z_root() . '/directory');
+
+ }
+
+}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index dee22721d..3eafd9f71 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -2,15 +2,19 @@
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/socgraph.php');
require_once('include/dir_fns.php');
require_once('include/bbcode.php');
+require_once('include/html2plain.php');
-class Directory extends \Zotlabs\Web\Controller {
+class Directory extends Controller {
function init() {
- \App::set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
if(local_channel() && x($_GET,'ignore')) {
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
@@ -21,7 +25,7 @@ class Directory extends \Zotlabs\Web\Controller {
}
if(local_channel())
- \App::$profile_uid = local_channel();
+ App::$profile_uid = local_channel();
$observer = get_observer_hash();
$global_changed = false;
@@ -140,9 +144,15 @@ class Directory extends \Zotlabs\Web\Controller {
$dirmode = intval(get_config('system','directory_mode'));
+ $directory_admin = false;
+
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
$url = z_root() . '/dirsearch';
- }
+ if (is_site_admin()) {
+ $directory_admin = true;
+ }
+ }
+
if(! $url) {
$directory = find_upstream_directory($dirmode);
if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url']))
@@ -182,7 +192,7 @@ class Directory extends \Zotlabs\Web\Controller {
$query .= '&t=' . $token;
if(! $globaldir)
- $query .= '&hub=' . \App::get_hostname();
+ $query .= '&hub=' . App::get_hostname();
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
@@ -204,8 +214,8 @@ class Directory extends \Zotlabs\Web\Controller {
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
- if(\App::$pager['page'] != 1)
- $query .= '&p=' . \App::$pager['page'];
+ if(App::$pager['page'] != 1)
+ $query .= '&p=' . App::$pager['page'];
logger('mod_directory: query: ' . $query);
@@ -283,12 +293,15 @@ class Directory extends \Zotlabs\Web\Controller {
$marital = ((x($profile,'marital') == 1) ? t('Status: ') . $profile['marital']: False);
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage: ') : False);
- $homepageurl = ((x($profile,'homepage') == 1) ? $profile['homepage'] : '');
-
- $hometown = ((x($profile,'hometown') == 1) ? $profile['hometown'] : False);
+ $homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : '');
- $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'])) : False);
+ $hometown = ((x($profile,'hometown') == 1) ? html2plain($profile['hometown']) : False);
+ $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'], ['tryoembed' => false])) : False);
+ if ($about && $safe_mode) {
+ $about = html2plain($about);
+ }
+
$keywords = ((x($profile,'keywords')) ? $profile['keywords'] : '');
@@ -343,9 +356,11 @@ class Directory extends \Zotlabs\Web\Controller {
'canrate' => (($rating_enabled && local_channel()) ? true : false),
'pdesc' => $pdesc,
'pdesc_label' => t('Description:'),
+ 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] : ''),
+ 'censor_label' => (($rr['censored']) ? t('Uncensor') : t('Censor')),
'marital' => $marital,
'homepage' => $homepage,
- 'homepageurl' => linkify($homepageurl, true),
+ 'homepageurl' => (($safe_mode) ? $homepageurl : linkify($homepageurl)),
'hometown' => $hometown,
'hometown_label' => t('Hometown:'),
'about' => $about,
@@ -387,7 +402,7 @@ class Directory extends \Zotlabs\Web\Controller {
ksort($entries); // Sort array by key so that foreach-constructs work as expected
if($j['keywords']) {
- \App::$data['directory_keywords'] = $j['keywords'];
+ App::$data['directory_keywords'] = $j['keywords'];
}
logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
@@ -438,7 +453,7 @@ class Directory extends \Zotlabs\Web\Controller {
echo $o;
killme();
}
- if(\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
+ if(App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
goaway(z_root() . '/chanview/?f=&address=' . $search);
}
info( t("No entries (some entries may be hidden).") . EOL);
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 92b33df0c..62af75f4c 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -1,14 +1,17 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/dir_fns.php');
-class Dirsearch extends \Zotlabs\Web\Controller {
+class Dirsearch extends Controller {
function init() {
- \App::set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
}
@@ -25,7 +28,8 @@ class Dirsearch extends \Zotlabs\Web\Controller {
$ret['message'] = t('This site is not a directory server');
json_return_and_die($ret);
}
-
+
+
$access_token = $_REQUEST['t'];
$token = get_config('system','realm_token');
@@ -286,29 +290,29 @@ class Dirsearch extends \Zotlabs\Web\Controller {
else
$entry['total_ratings'] = 0;
- $entry['name'] = $rr['xchan_name'];
- $entry['hash'] = $rr['xchan_hash'];
-
+ $entry['name'] = $rr['xchan_name'];
+ $entry['hash'] = $rr['xchan_hash'];
+ $entry['censored'] = $rr['xchan_censored'];
+ $entry['selfcensored'] = $rr['xchan_selfcensored'];
$entry['public_forum'] = (intval($rr['xchan_pubforum']) ? true : false);
-
- $entry['url'] = $rr['xchan_url'];
- $entry['photo_l'] = $rr['xchan_photo_l'];
- $entry['photo'] = $rr['xchan_photo_m'];
- $entry['address'] = $rr['xchan_addr'];
- $entry['description'] = $rr['xprof_desc'];
- $entry['locale'] = $rr['xprof_locale'];
- $entry['region'] = $rr['xprof_region'];
- $entry['postcode'] = $rr['xprof_postcode'];
- $entry['country'] = $rr['xprof_country'];
- $entry['birthday'] = $rr['xprof_dob'];
- $entry['age'] = $rr['xprof_age'];
- $entry['gender'] = $rr['xprof_gender'];
- $entry['marital'] = $rr['xprof_marital'];
- $entry['sexual'] = $rr['xprof_sexual'];
- $entry['about'] = $rr['xprof_about'];
- $entry['homepage'] = $rr['xprof_homepage'];
- $entry['hometown'] = $rr['xprof_hometown'];
- $entry['keywords'] = $rr['xprof_keywords'];
+ $entry['url'] = $rr['xchan_url'];
+ $entry['photo_l'] = $rr['xchan_photo_l'];
+ $entry['photo'] = $rr['xchan_photo_m'];
+ $entry['address'] = $rr['xchan_addr'];
+ $entry['description'] = $rr['xprof_desc'];
+ $entry['locale'] = $rr['xprof_locale'];
+ $entry['region'] = $rr['xprof_region'];
+ $entry['postcode'] = $rr['xprof_postcode'];
+ $entry['country'] = $rr['xprof_country'];
+ $entry['birthday'] = $rr['xprof_dob'];
+ $entry['age'] = $rr['xprof_age'];
+ $entry['gender'] = $rr['xprof_gender'];
+ $entry['marital'] = $rr['xprof_marital'];
+ $entry['sexual'] = $rr['xprof_sexual'];
+ $entry['about'] = $rr['xprof_about'];
+ $entry['homepage'] = $rr['xprof_homepage'];
+ $entry['hometown'] = $rr['xprof_hometown'];
+ $entry['keywords'] = $rr['xprof_keywords'];
$entries[] = $entry;
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index 6a88513dc..9b0884197 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -68,6 +68,8 @@ class Embedphotos extends \Zotlabs\Web\Controller {
$ext = '.png';
elseif($r[0]['mimetype'] === 'image/gif')
$ext = '.gif';
+ elseif($r[0]['mimetype'] === 'image/webp')
+ $exp = '.webp';
else
$ext = EMPTY_STR;
diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php
index f1b1acaef..ce05035b3 100644
--- a/Zotlabs/Module/Help.php
+++ b/Zotlabs/Module/Help.php
@@ -66,7 +66,10 @@ class Help extends \Zotlabs\Web\Controller {
case IMAGETYPE_PNG:
header("Content-Type: image/png");
break;
- default:
+ case IMAGETYPE_WEBP:
+ header("Content-Type: image/webp");
+ break;
+ default:
break;
}
header("Content-Length: " . filesize($realpath));
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 5e00593ef..4340876ea 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -77,10 +77,6 @@ class Sse_bs extends Controller {
default:
}
- set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert());
- set_xconfig(self::$ob_hash, 'sse', 'notifications', []); // reset the cache
- set_xconfig(self::$ob_hash, 'sse', 'language', App::$language);
-
if(self::$offset && $f) {
$result = self::$f(true);
json_return_and_die($result);
@@ -99,6 +95,10 @@ class Sse_bs extends Controller {
self::bs_register()
);
+ set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert());
+ set_xconfig(self::$ob_hash, 'sse', 'notifications', []); // reset the cache
+ set_xconfig(self::$ob_hash, 'sse', 'language', App::$language);
+
json_return_and_die($result);
}
@@ -390,22 +390,29 @@ class Sse_bs extends Controller {
$p_str = ids_to_querystr($p, 'parent');
$p_sql = (($p_str) ? "OR parent IN ( $p_str )" : '');
- $r = q("select count(id) as unseen from item
+ $r = q("select mid from item
where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $sql_extra $item_normal",
intval(self::$uid),
dbesc($forums[$x]['xchan_hash']),
dbesc($forums[$x]['xchan_hash'])
);
- if($r[0]['unseen']) {
+ if($r) {
+ $mids = flatten_array_recursive($r);
+
+
+ foreach($mids as $mid)
+ $b64mids[] = 'b64.' . base64url_encode($mid);
+
$forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']);
$forums[$x]['name'] = $forums[$x]['xchan_name'];
$forums[$x]['addr'] = $forums[$x]['xchan_addr'];
$forums[$x]['url'] = $forums[$x]['xchan_url'];
$forums[$x]['photo'] = $forums[$x]['xchan_photo_s'];
- $forums[$x]['unseen'] = $r[0]['unseen'];
+ $forums[$x]['unseen'] = count($b64mids);
$forums[$x]['private_forum'] = (($forums[$x]['private_forum']) ? 'lock' : '');
$forums[$x]['message'] = (($forums[$x]['private_forum']) ? t('Private forum') : t('Public forum'));
+ $forums[$x]['mids'] = json_encode($b64mids);
unset($forums[$x]['abook_id']);
unset($forums[$x]['xchan_hash']);
@@ -413,7 +420,7 @@ class Sse_bs extends Controller {
unset($forums[$x]['xchan_url']);
unset($forums[$x]['xchan_photo_s']);
- $i = $i + $r[0]['unseen'];
+ $i = $i + count($mids);
}
else {
diff --git a/Zotlabs/Photo/PhotoGd.php b/Zotlabs/Photo/PhotoGd.php
index 4054e1866..c54fa6a7d 100644
--- a/Zotlabs/Photo/PhotoGd.php
+++ b/Zotlabs/Photo/PhotoGd.php
@@ -13,12 +13,16 @@ class PhotoGd extends PhotoDriver {
* @see \Zotlabs\Photo\PhotoDriver::supportedTypes()
*/
public function supportedTypes() {
+
$t = [];
+
$t['image/jpeg'] = 'jpg';
if(imagetypes() & IMG_PNG)
$t['image/png'] = 'png';
if(imagetypes() & IMG_GIF)
$t['image/gif'] = 'gif';
+ if(imagetypes() & IMG_WEBP)
+ $t['image/webp'] = 'webp';
return $t;
}
@@ -142,6 +146,7 @@ class PhotoGd extends PhotoDriver {
* @see \Zotlabs\Photo\PhotoDriver::imageString()
*/
public function imageString() {
+
if(! $this->is_valid())
return false;
@@ -150,23 +155,32 @@ class PhotoGd extends PhotoDriver {
ob_start();
switch($this->getType()){
+
case 'image/png':
$quality = get_config('system', 'png_quality');
if((! $quality) || ($quality > 9))
$quality = PNG_QUALITY;
-
\imagepng($this->image, NULL, $quality);
break;
+
+ case 'image/webp':
+ $quality = get_config('system', 'webp_quality');
+ if((! $quality) || ($quality > 100))
+ $quality = WEBP_QUALITY;
+ \imagewebp($this->image, NULL, $quality);
+ break;
+
case 'image/jpeg':
// gd can lack imagejpeg(), but we verify during installation it is available
+
default:
$quality = get_config('system', 'jpeg_quality');
if((! $quality) || ($quality > 100))
$quality = JPEG_QUALITY;
-
\imagejpeg($this->image, NULL, $quality);
break;
}
+
$string = ob_get_contents();
ob_end_clean();
diff --git a/Zotlabs/Photo/PhotoImagick.php b/Zotlabs/Photo/PhotoImagick.php
index a7026e8ca..0a08d19e6 100644
--- a/Zotlabs/Photo/PhotoImagick.php
+++ b/Zotlabs/Photo/PhotoImagick.php
@@ -8,19 +8,16 @@ namespace Zotlabs\Photo;
class PhotoImagick extends PhotoDriver {
public function supportedTypes() {
- return [
+
+ $ret = [
'image/jpeg' => 'jpg',
'image/png' => 'png',
- 'image/gif' => 'gif',
+ 'image/gif' => 'gif'
];
- }
+ if(\Imagick::queryFormats("WEBP"))
+ $ret['image/webp'] = 'webp';
- private function get_FormatsMap() {
- return [
- 'image/jpeg' => 'JPG',
- 'image/png' => 'PNG',
- 'image/gif' => 'GIF',
- ];
+ return $ret;
}
@@ -42,8 +39,8 @@ class PhotoImagick extends PhotoDriver {
* Setup the image to the format it will be saved to
*/
- $map = $this->get_FormatsMap();
- $format = $map[$type];
+ $map = $this->supportedTypes();
+ $format = strtoupper($map[$type]);
if($this->image) {
$this->image->setFormat($format);
@@ -58,6 +55,7 @@ class PhotoImagick extends PhotoDriver {
* setup the compression here, so we'll do it only once
*/
switch($this->getType()) {
+
case 'image/png':
$quality = get_config('system', 'png_quality');
if((! $quality) || ($quality > 9))
@@ -73,11 +71,21 @@ class PhotoImagick extends PhotoDriver {
$quality = $quality * 10;
$this->image->setCompressionQuality($quality);
break;
+
case 'image/jpeg':
$quality = get_config('system', 'jpeg_quality');
if((! $quality) || ($quality > 100))
$quality = JPEG_QUALITY;
$this->image->setCompressionQuality($quality);
+ break;
+
+ case 'image/webp':
+ $quality = get_config('system', 'webp_quality');
+ if((! $quality) || ($quality > 100))
+ $quality = WEBP_QUALITY;
+ $this->image->setCompressionQuality($quality);
+ break;
+
default:
break;
}
diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php
index 4610aceb7..36aff1e05 100644
--- a/Zotlabs/Storage/File.php
+++ b/Zotlabs/Storage/File.php
@@ -169,7 +169,7 @@ class File extends DAV\Node implements DAV\IFile {
}
$gis = @getimagesize($f);
logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
- if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
+ if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG || $gis[2] === IMAGETYPE_WEBP)) {
$is_photo = 1;
}
diff --git a/boot.php b/boot.php
index bc1e2a319..c98ab007d 100755
--- a/boot.php
+++ b/boot.php
@@ -105,6 +105,11 @@ define ( 'JPEG_QUALITY', 100 );
define ( 'PNG_QUALITY', 8 );
/**
+ * App::$config['system']['webp_quality'] from 1 (maximum compressed) to 100 (uncompressed)
+ */
+define ( 'WEBP_QUALITY', 80 );
+
+/**
* Language detection parameters
*/
define ( 'LANGUAGE_DETECT_MIN_LENGTH', 128 );
@@ -899,11 +904,12 @@ class App {
// Serve raw files from the file system in certain cases.
$filext = pathinfo(self::$cmd, PATHINFO_EXTENSION);
- $serve_rawfiles=[
+ $serve_rawfiles = [
'jpg'=>'image/jpeg',
'jpeg'=>'image/jpeg',
'gif'=>'image/gif',
'png'=>'image/png',
+ 'webp'=>'image/webp',
'ico'=>'image/vnd.microsoft.icon',
'css'=>'text/css',
'js'=>'text/javascript',
@@ -913,7 +919,8 @@ class App {
'ttf'=>'font/ttf',
'woff'=>'font/woff',
'woff2'=>'font/woff2',
- 'svg'=>'image/svg+xml'];
+ 'svg'=>'image/svg+xml'
+ ];
if (array_key_exists($filext, $serve_rawfiles) && file_exists(self::$cmd)) {
$staticfilecwd = getcwd();
diff --git a/include/attach.php b/include/attach.php
index 80efe0838..952270949 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -56,6 +56,7 @@ function z_mime_content_type($filename) {
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
+ 'webp' => 'image/webp',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
@@ -616,7 +617,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$is_photo = 0;
$gis = @getimagesize($src);
logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
- if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
+ if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG || $gis[2] === IMAGETYPE_WEBP)) {
$is_photo = 1;
if($gis[2] === IMAGETYPE_GIF)
$def_extension = '.gif';
@@ -624,6 +625,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$def_extension = '.jpg';
if($gis[2] === IMAGETYPE_PNG)
$def_extension = '.png';
+ if($gis[2] === IMAGETYPE_WEBP)
+ $def_extension = '.webp';
}
// If we know it's a photo, over-ride the type in case the source system could not determine what it was
@@ -908,7 +911,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
- if($is_photo) {
+ if($is_photo && $r) {
$args = array( 'source' => $source, 'visible' => $visible, 'resource_id' => $hash, 'album' => $pathname, 'os_syspath' => $os_basepath . $os_relpath, 'os_path' => $os_path, 'display_path' => $display_path, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct, 'options' => $options );
if($arr['contact_allow'])
@@ -942,9 +945,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$args['deliver'] = $dosync;
$p = photo_upload($channel,$observer,$args);
- if($p['success']) {
- $ret['body'] = $p['body'];
+ if($p['success'])
+ $ret['body'] = $p['body'];
+ else {
+ // Attach as ordinary file if image processing is failed
+ $x = q("UPDATE attach SET is_photo = 0 WHERE hash = '%s'",
+ dbesc($hash)
+ );
}
+
}
if(($options !== 'update') && ($remove_when_processed))
@@ -2654,5 +2663,3 @@ function save_chunk($channel,$start,$end,$len) {
$result['length'] = intval(filesize($new_path));
return $result;
}
-
-
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index c11580bdc..284206161 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -135,6 +135,8 @@ function guess_image_type($filename, $headers = '') {
$type = 'image/gif';
elseif(strpos(strtolower($filename),'png') !== false)
$type = 'image/png';
+ elseif(strpos(strtolower($filename),'webp') !== false)
+ $type = 'image/webp';
}
}
diff --git a/include/text.php b/include/text.php
index eba41521d..87ed9f658 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2992,6 +2992,7 @@ function getIconFromType($type) {
'image/jpeg' => 'fa-picture-o',
'image/png' => 'fa-picture-o',
'image/gif' => 'fa-picture-o',
+ 'image/webp' => 'fa-picture-o',
'image/svg+xml' => 'fa-picture-o',
//Archive
'application/zip' => 'fa-file-archive-o',
diff --git a/view/js/main.js b/view/js/main.js
index 1baf1ca1f..84fa44d4a 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -696,11 +696,11 @@ function updateConvItems(mode,data) {
// take care of the notifications count updates
$('.thread-wrapper', data).each(function() {
- //var nmid = $(this).data('b64mid');
var nmids = $(this).data('b64mids');
nmids.forEach(function(nmid, index) {
sse_mids.push(nmid);
+
if($('.notification[data-b64mid=\'' + nmid + '\']').length) {
$('.notification[data-b64mid=\'' + nmid + '\']').each(function() {
var n = this.parentElement.id.split('-');
@@ -708,6 +708,27 @@ function updateConvItems(mode,data) {
});
sse_mids = [];
}
+
+ // special handling for forum notifications
+ $('.notification-forum').filter(function() {
+ var fmids = decodeURIComponent($(this).data('b64mids'));
+ var n = this.parentElement.id.split('-');
+ if(fmids.indexOf(nmid) > -1) {
+ var fcount = Number($('.' + n[1] + '-update').html());
+ fcount--;
+ $('.' + n[1] + '-update').html(fcount);
+ if(fcount < 1)
+ $('.' + n[1] + '-button').fadeOut();
+
+ var count = Number($(this).find('.badge-secondary').html());
+ count--;
+ $(this).find('.badge-secondary').html(count);
+ if(count < 1)
+ $(this).remove();
+ }
+ });
+
+
});
sse_setNotificationsStatus();
@@ -1743,7 +1764,7 @@ function sse_handleNotifications(obj, replace, followup) {
}
function sse_handleNotificationsItems(notifyType, data, replace, followup) {
- var notifications_tpl = ((notifyType == 'forums') ? unescape($("#nav-notifications-forums-template[rel=template]").html()) : unescape($("#nav-notifications-template[rel=template]").html()));
+ var notifications_tpl = ((notifyType == 'forums') ? decodeURIComponent($("#nav-notifications-forums-template[rel=template]").html()) : decodeURIComponent($("#nav-notifications-template[rel=template]").html()));
var notify_menu = $("#nav-" + notifyType + "-menu");
var notify_loading = $("#nav-" + notifyType + "-loading");
var notify_count = $("." + notifyType + "-update");
@@ -1757,7 +1778,8 @@ function sse_handleNotificationsItems(notifyType, data, replace, followup) {
if(sse_mids.indexOf(this.b64mid) >= 0) {
return sse_updateNotifications(notifyType, this.b64mid, false);
}
- html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum);
+
+ html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum, encodeURIComponent(this.mids));
notify_menu.append(html);
});
diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl
index f7ec7db23..175d813c5 100755
--- a/view/tpl/direntry.tpl
+++ b/view/tpl/direntry.tpl
@@ -7,6 +7,9 @@
{{if $entry.ignlink}}
<a class="directory-ignore btn btn-warning btn-sm" href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a>
{{/if}}
+ {{if $entry.censor}}
+ <a class="directory-censor btn btn-danger btn-sm" href="{{$entry.censor}}"> {{$entry.censor_label}}</a>
+ {{/if}}
{{if $entry.connect}}
<a class="btn btn-success btn-sm" href="{{$entry.connect}}"><i class="fa fa-plus connect-icon"></i> {{$entry.conn_label}}</a>
{{/if}}
diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl
index 057d5b491..9191c2470 100644
--- a/view/tpl/notifications_widget.tpl
+++ b/view/tpl/notifications_widget.tpl
@@ -143,7 +143,7 @@
</a>
</div>
<div id="nav-notifications-forums-template" rel="template">
- <a class="list-group-item clearfix notification notification-forum" href="{0}" title="{4} - {3}" data-b64mid="{7}" data-notify_id="{8}" data-thread_top="{9}" data-contact_name="{2}" data-contact_addr="{3}">
+ <a class="list-group-item clearfix notification notification-forum" href="{0}" title="{4} - {3}" data-b64mid="{7}" data-notify_id="{8}" data-thread_top="{9}" data-contact_name="{2}" data-contact_addr="{3}" data-b64mids='{12}'>
<span class="float-right badge badge-secondary">{10}</span>
<img class="menu-img-1" src="{1}">
<span class="">{2}</span>