diff options
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r-- | Zotlabs/Lib/Api_router.php | 24 | ||||
-rw-r--r-- | Zotlabs/Lib/Apps.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 68 | ||||
-rw-r--r-- | Zotlabs/Lib/ExtendedZip.php | 57 | ||||
-rw-r--r-- | Zotlabs/Lib/SuperCurl.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/System.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 18 |
7 files changed, 150 insertions, 23 deletions
diff --git a/Zotlabs/Lib/Api_router.php b/Zotlabs/Lib/Api_router.php new file mode 100644 index 000000000..404678bd9 --- /dev/null +++ b/Zotlabs/Lib/Api_router.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Lib; + + +class Api_router { + + static private $routes = array(); + + static function register($path,$fn,$auth_required) { + self::$routes[$path] = [ 'func' => $fn, 'auth' => $auth_required ]; + } + + static function find($path) { + if(array_key_exists($path,self::$routes)) + return self::$routes[$path]; + return null; + } + + static function dbg() { + return self::$routes; + } + +}
\ No newline at end of file diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 19ed1b612..a646d8a30 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -112,7 +112,7 @@ class Apps { static public function app_name_compare($a,$b) { - return strcmp($a['name'],$b['name']); + return strcasecmp($a['name'],$b['name']); } diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 56c717468..9a8628968 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -70,7 +70,22 @@ class Enotify { $hostname = substr($hostname,0,strpos($hostname,':')); // Do not translate 'noreply' as it must be a legal 7-bit email address - $sender_email = 'noreply' . '@' . $hostname; + + $reply_email = get_config('system','reply_address'); + if(! $reply_email) + $reply_email = 'noreply' . '@' . $hostname; + + $sender_email = get_config('system','from_email'); + if(! $sender_email) + $sender_email = 'Administrator' . '@' . \App::get_hostname(); + + + $sender_name = get_config('system','from_email_name'); + if(! $sender_name) + $sender_name = \Zotlabs\Lib\System::get_site_name(); + + + $additional_mail_header = ""; @@ -101,7 +116,7 @@ class Enotify { if ($params['type'] == NOTIFY_MAIL) { logger('notification: mail'); - $subject = sprintf( t('[Hubzilla:Notify] New mail received at %s'),$sitename); + $subject = sprintf( t('[$Projectname:Notify] New mail received at %s'),$sitename); $preamble = sprintf( t('%1$s, %2$s sent you a new private message at %3$s.'),$recip['channel_name'], $sender['xchan_name'],$sitename); $epreamble = sprintf( t('%1$s sent you %2$s.'),'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a private message') . '[/zrl]'); @@ -116,10 +131,13 @@ class Enotify { $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a sepearate notification preference + // ignore like/unlike activity on posts - they probably require a separate notification preference - if (array_key_exists('item',$params) && (! visible_activity($params['item']))) + if (array_key_exists('item',$params) && (! visible_activity($params['item']))) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); return; + } $parent_mid = $params['parent_mid']; @@ -189,7 +207,7 @@ class Enotify { // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. - $subject = sprintf( t('[Hubzilla:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); + $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s commented on an item/conversation you have been following.'), $recip['channel_name'], $sender['xchan_name']); $epreamble = $dest_str; @@ -199,7 +217,7 @@ class Enotify { } if($params['type'] == NOTIFY_WALL) { - $subject = sprintf( t('[Hubzilla:Notify] %s posted to your profile wall') , $sender['xchan_name']); + $subject = sprintf( t('[$Projectname:Notify] %s posted to your profile wall') , $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s posted to your profile wall at %3$s') , $recip['channel_name'], $sender['xchan_name'], $sitename); @@ -227,7 +245,7 @@ class Enotify { return; } - $subject = sprintf( t('[Hubzilla:Notify] %s tagged you') , $sender['xchan_name']); + $subject = sprintf( t('[$Projectname:Notify] %s tagged you') , $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s tagged you at %3$s') , $recip['channel_name'], $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s, %2$s [zrl=%3$s]tagged you[/zrl].') , $recip['channel_name'], @@ -241,7 +259,7 @@ class Enotify { } if ($params['type'] == NOTIFY_POKE) { - $subject = sprintf( t('[Hubzilla:Notify] %1$s poked you') , $sender['xchan_name']); + $subject = sprintf( t('[$Projectname:Notify] %1$s poked you') , $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s poked you at %3$s') , $recip['channel_name'], $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s, %2$s [zrl=%2$s]poked you[/zrl].') , $recip['channel_name'], @@ -259,7 +277,7 @@ class Enotify { } if ($params['type'] == NOTIFY_TAGSHARE) { - $subject = sprintf( t('[Hubzilla:Notify] %s tagged your post') , $sender['xchan_name']); + $subject = sprintf( t('[$Projectname:Notify] %s tagged your post') , $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s tagged your post at %3$s') , $recip['channel_name'],$sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s, %2$s tagged [zrl=%3$s]your post[/zrl]') , $recip['channel_name'], @@ -273,7 +291,7 @@ class Enotify { } if ($params['type'] == NOTIFY_INTRO) { - $subject = sprintf( t('[Hubzilla:Notify] Introduction received')); + $subject = sprintf( t('[$Projectname:Notify] Introduction received')); $preamble = sprintf( t('%1$s, you\'ve received an new connection request from \'%2$s\' at %3$s'), $recip['channel_name'], $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s, you\'ve received [zrl=%2$s]a new connection request[/zrl] from %3$s.'), $recip['channel_name'], @@ -288,7 +306,7 @@ class Enotify { } if ($params['type'] == NOTIFY_SUGGEST) { - $subject = sprintf( t('[Hubzilla:Notify] Friend suggestion received')); + $subject = sprintf( t('[$Projectname:Notify] Friend suggestion received')); $preamble = sprintf( t('%1$s, you\'ve received a friend suggestion from \'%2$s\' at %3$s'), $recip['channel_name'], $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s, you\'ve received [zrl=%2$s]a friend suggestion[/zrl] for %3$s from %4$s.'), $recip['channel_name'], @@ -386,8 +404,11 @@ class Enotify { // Mark some notifications as seen right away // Note! The notification have to be created, because they are used to send emails // So easiest solution to hide them from Notices is to mark them as seen right away. - // Another option would be to not add them to the DB, and change how emails are handled (probably would be better that way) + // Another option would be to not add them to the DB, and change how emails are handled + // (probably would be better that way) + $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); + if (!$always_show_in_notices) { if (($params['type'] == NOTIFY_WALL) || ($params['type'] == NOTIFY_MAIL) || ($params['type'] == NOTIFY_INTRO)) { $seen = 1; @@ -459,7 +480,7 @@ class Enotify { // use $_SESSION['zid_override'] to force zid() to use // the recipient address instead of the current observer - $_SESSION['zid_override'] = $recip['channel_address'] . '@' . \App::get_hostname(); + $_SESSION['zid_override'] = channel_reddress($recip); $_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address']; $textversion = zidify_links($textversion); @@ -515,7 +536,7 @@ class Enotify { $private_activity = true; case NOTIFY_MAIL: $datarray['textversion'] = $datarray['htmlversion'] = $datarray['title'] = ''; - $datarray['subject'] = preg_replace('/' . preg_quote(t('[Hubzilla:Notify]')) . '/','$0*',$datarray['subject']); + $datarray['subject'] = preg_replace('/' . preg_quote(t('[$Projectname:Notify]')) . '/','$0*',$datarray['subject']); break; default: break; @@ -577,7 +598,7 @@ class Enotify { self::send(array( 'fromName' => $sender_name, 'fromEmail' => $sender_email, - 'replyTo' => $sender_email, + 'replyTo' => $reply_email, 'toEmail' => $recip['account_email'], 'messageSubject' => $datarray['subject'], 'htmlVersion' => $email_html_body, @@ -606,6 +627,16 @@ class Enotify { */ static public function send($params) { + $params['sent'] = false; + $params['result'] = false; + + call_hooks('email_send', $params); + + if($params['sent']) { + logger("notification: enotify::send (addon) returns " . $params['result'], LOGGER_DEBUG); + return $params['result']; + } + $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8'); @@ -646,6 +677,7 @@ class Enotify { $messageHeader // message headers ); logger("notification: enotify::send returns " . $res, LOGGER_DEBUG); + return $res; } static public function format($item) { @@ -654,12 +686,12 @@ class Enotify { require_once('include/conversation.php'); - // Call localize_item with the "brief" flag to get a one line status for activities. + // Call localize_item to get a one line status for activities. // This should set $item['localized'] to indicate we have a brief summary. localize_item($item); - if($item_localize) { + if($item['localize']) { $itemem_text = $item['localize']; } else { @@ -671,7 +703,7 @@ class Enotify { // convert this logic into a json array just like the system notifications return array( - 'notify_link' => $item['llink'], + 'notify_link' => $item['llink'], 'name' => $item['author']['xchan_name'], 'url' => $item['author']['xchan_url'], 'photo' => $item['author']['xchan_photo_s'], diff --git a/Zotlabs/Lib/ExtendedZip.php b/Zotlabs/Lib/ExtendedZip.php new file mode 100644 index 000000000..a40110c55 --- /dev/null +++ b/Zotlabs/Lib/ExtendedZip.php @@ -0,0 +1,57 @@ +<?php + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +namespace Zotlabs\Lib; + +/** + * Description of ExtendedZip + * + * @author andrew + */ +class ExtendedZip extends \ZipArchive { + + // Member function to add a whole file system subtree to the archive + public function addTree($dirname, $localname = '') { + if ($localname) + $this->addEmptyDir($localname); + $this->_addTree($dirname, $localname); + } + + // Internal function, to recurse + protected function _addTree($dirname, $localname) { + $dir = opendir($dirname); + while ($filename = readdir($dir)) { + // Discard . and .. + if ($filename == '.' || $filename == '..') + continue; + + // Proceed according to type + $path = $dirname . '/' . $filename; + $localpath = $localname ? ($localname . '/' . $filename) : $filename; + if (is_dir($path)) { + // Directory: add & recurse + $this->addEmptyDir($localpath); + $this->_addTree($path, $localpath); + } + else if (is_file($path)) { + // File: just add + $this->addFile($path, $localpath); + } + } + closedir($dir); + } + + // Helper function + public static function zipTree($dirname, $zipFilename, $flags = 0, $localname = '') { + $zip = new self(); + $zip->open($zipFilename, $flags); + $zip->addTree($dirname, $localname); + $zip->close(); + } + +} diff --git a/Zotlabs/Lib/SuperCurl.php b/Zotlabs/Lib/SuperCurl.php index 1c8583ff5..462a62b36 100644 --- a/Zotlabs/Lib/SuperCurl.php +++ b/Zotlabs/Lib/SuperCurl.php @@ -105,7 +105,7 @@ class SuperCurl { $opts['cookie'] = 'PHPSESSID=' . trim(file_get_contents('store/[data]/cookien_' . $this->magicauth)); $c = channelx_by_n($this->magicauth); if($c) - $url = zid($this->url,$c['channel_address'] . '@' . \App::get_hostname()); + $url = zid($this->url,channel_reddress($c)); } if($this->custom) $opts['custom'] = $this->custom; diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 4479bf597..6ccfd664c 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -45,7 +45,7 @@ class System { static public function get_server_role() { if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['server_role']) return \App::$config['system']['server_role']; - return 'pro'; + return 'standard'; } static public function get_std_version() { diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index eee3b2a4f..a3e871810 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -174,6 +174,11 @@ class ThreadItem { $responses = get_responses($conv_responses,$response_verbs,$this,$item); + $my_responses = []; + foreach($response_verbs as $v) { + $my_responses[$v] = (($conv_responses[$v][$item['mid'] . '-m']) ? 1 : 0); + } + $like_count = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid']] : ''); $like_list = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid'] . '-l'] : ''); if (count($like_list) > MAX_LIKERS) { @@ -246,10 +251,11 @@ class ThreadItem { } $server_role = get_config('system','server_role'); + $has_bookmarks = false; if(is_array($item['term'])) { foreach($item['term'] as $t) { - if(($server_role != 'basic') && ($t['ttype'] == TERM_BOOKMARK)) + if((get_account_techlevel() > 0) && ($t['ttype'] == TERM_BOOKMARK)) $has_bookmarks = true; } } @@ -343,7 +349,7 @@ class ThreadItem { 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : ''), - 'expiretime' => (($item['expires'] !== NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), + 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), 'lock' => $lock, 'verified' => $verified, 'unverified' => $unverified, @@ -380,6 +386,7 @@ class ThreadItem { 'list_unseen_txt' => $list_unseen_txt, 'markseen' => t('Mark all seen'), 'responses' => $responses, + 'my_responses' => $my_responses, 'like_count' => $like_count, 'like_list' => $like_list, 'like_list_part' => $like_list_part, @@ -396,6 +403,7 @@ class ThreadItem { 'comment' => $this->get_comment_box($indent), 'previewing' => ($conv->is_preview() ? ' preview ' : ''), 'wait' => t('Please wait'), + 'submid' => substr($item['mid'],0,32), 'thread_level' => $thread_level ); @@ -411,6 +419,12 @@ class ThreadItem { if($visible_comments === false) $visible_comments = 3; +// needed for scroll to comment from notification but needs more work +// as we do not want to open all comments unless there is actually an #item_xx anchor +// and the url fragment is not sent to the server. +// if(in_array(\App::$module,['display','update_display'])) +// $visible_comments = 99999; + if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) { foreach($children as $child) { $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1); |