aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2017-05-03 20:44:54 -0400
committerAndrew Manning <tamanning@zoho.com>2017-05-03 20:44:54 -0400
commit06d2d31777d0ab205c1f2a0258acfbc0462c9a60 (patch)
tree28b03be55fdab2e1094831af7cf6f320324dc925 /Zotlabs
parente99be61d4995bece3c7af703b22ebe1be149a7fd (diff)
parentd6a3f7765adbbf5f58c08964932d25d3c0364439 (diff)
downloadvolse-hubzilla-06d2d31777d0ab205c1f2a0258acfbc0462c9a60.tar.gz
volse-hubzilla-06d2d31777d0ab205c1f2a0258acfbc0462c9a60.tar.bz2
volse-hubzilla-06d2d31777d0ab205c1f2a0258acfbc0462c9a60.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Access/AccessList.php128
-rw-r--r--Zotlabs/Daemon/Onepoll.php24
-rw-r--r--Zotlabs/Module/Mail.php26
-rw-r--r--Zotlabs/Module/Setup.php7
-rw-r--r--Zotlabs/Module/Zotfeed.php3
5 files changed, 151 insertions, 37 deletions
diff --git a/Zotlabs/Access/AccessList.php b/Zotlabs/Access/AccessList.php
index b073f9d3c..6471b0b1d 100644
--- a/Zotlabs/Access/AccessList.php
+++ b/Zotlabs/Access/AccessList.php
@@ -2,21 +2,55 @@
namespace Zotlabs\Access;
-
+/**
+ * @brief AccessList class.
+ *
+ * A class to hold an AccessList object with allowed and denied contacts and
+ * groups.
+ */
class AccessList {
-
+ /**
+ * @brief Allow contacts
+ * @var string
+ */
private $allow_cid;
+ /**
+ * @brief Allow groups
+ * @var string
+ */
private $allow_gid;
+ /**
+ * @brief Deny contacts
+ * @var string
+ */
private $deny_cid;
+ /**
+ * @brief Deny groups
+ * @var string
+ */
private $deny_gid;
+ /**
+ * @brief Indicates if we are using the default constructor values or
+ * values that have been set explicitly.
+ * @var boolean
+ */
+ private $explicit;
- /* indicates if we are using the default constructor values or values that have been set explicitly. */
-
- private $explicit;
+ /**
+ * @brief Constructor for AccessList class.
+ *
+ * @note The array to pass to the constructor is different from the array
+ * that you provide to the set() or set_from_array() functions.
+ *
+ * @param array $channel A channel array, where these entries are evaluated:
+ * * \e string \b channel_allow_cid => string of allowed cids
+ * * \e string \b channel_allow_gid => string of allowed gids
+ * * \e string \b channel_deny_cid => string of denied cids
+ * * \e string \b channel_deny_gid => string of denied gids
+ */
function __construct($channel) {
-
- if($channel) {
+ if($channel) {
$this->allow_cid = $channel['channel_allow_cid'];
$this->allow_gid = $channel['channel_allow_gid'];
$this->deny_cid = $channel['channel_deny_cid'];
@@ -32,61 +66,95 @@ class AccessList {
$this->explicit = false;
}
+ /**
+ * @brief Get if we are using the default constructor values
+ * or values that have been set explicitly.
+ *
+ * @return boolean
+ */
function get_explicit() {
return $this->explicit;
}
/**
- * Set AccessList from strings such as those in already
- * existing stored data items
+ * @brief Set access list from strings such as those in already
+ * existing stored data items.
+ *
+ * @note The array to pass to this set function is different from the array
+ * that you provide to the constructor or set_from_array().
+ *
+ * @param array $arr
+ * * \e string \b allow_cid => string of allowed cids
+ * * \e string \b allow_gid => string of allowed gids
+ * * \e string \b deny_cid => string of denied cids
+ * * \e string \b deny_gid => string of denied gids
+ * @param boolean $explicit (optional) default true
*/
-
- function set($arr,$explicit = true) {
+ function set($arr, $explicit = true) {
$this->allow_cid = $arr['allow_cid'];
$this->allow_gid = $arr['allow_gid'];
$this->deny_cid = $arr['deny_cid'];
$this->deny_gid = $arr['deny_gid'];
- $this->explicit = $explicit;
+ $this->explicit = $explicit;
}
/**
- * return an array consisting of the current
- * access list components where the elements
- * are directly storable.
+ * @brief Return an array consisting of the current access list components
+ * where the elements are directly storable.
+ *
+ * @return Associative array with:
+ * * \e string \b allow_cid => string of allowed cids
+ * * \e string \b allow_gid => string of allowed gids
+ * * \e string \b deny_cid => string of denied cids
+ * * \e string \b deny_gid => string of denied gids
*/
-
function get() {
- return array(
+ return [
'allow_cid' => $this->allow_cid,
'allow_gid' => $this->allow_gid,
'deny_cid' => $this->deny_cid,
'deny_gid' => $this->deny_gid,
- );
+ ];
}
/**
- * Set AccessList from arrays, such as those provided by
- * acl_selector(). For convenience, a string (or non-array) input is
- * assumed to be a comma-separated list and auto-converted into an array.
- */
-
- function set_from_array($arr,$explicit = true) {
- $this->allow_cid = perms2str((is_array($arr['contact_allow']))
- ? $arr['contact_allow'] : explode(',',$arr['contact_allow']));
+ * @brief Set access list components from arrays, such as those provided by
+ * acl_selector().
+ *
+ * For convenience, a string (or non-array) input is assumed to be a
+ * comma-separated list and auto-converted into an array.
+ *
+ * @note The array to pass to this set function is different from the array
+ * that you provide to the constructor or set().
+ *
+ * @param array $arr An associative array with:
+ * * \e array|string \b contact_allow => array with cids or comma-seperated string
+ * * \e array|string \b group_allow => array with gids or comma-seperated string
+ * * \e array|string \b contact_deny => array with cids or comma-seperated string
+ * * \e array|string \b group_deny => array with gids or comma-seperated string
+ * @param boolean $explicit (optional) default true
+ */
+ function set_from_array($arr, $explicit = true) {
+ $this->allow_cid = perms2str((is_array($arr['contact_allow']))
+ ? $arr['contact_allow'] : explode(',', $arr['contact_allow']));
$this->allow_gid = perms2str((is_array($arr['group_allow']))
- ? $arr['group_allow'] : explode(',',$arr['group_allow']));
+ ? $arr['group_allow'] : explode(',', $arr['group_allow']));
$this->deny_cid = perms2str((is_array($arr['contact_deny']))
- ? $arr['contact_deny'] : explode(',',$arr['contact_deny']));
+ ? $arr['contact_deny'] : explode(',', $arr['contact_deny']));
$this->deny_gid = perms2str((is_array($arr['group_deny']))
- ? $arr['group_deny'] : explode(',',$arr['group_deny']));
+ ? $arr['group_deny'] : explode(',', $arr['group_deny']));
$this->explicit = $explicit;
}
+ /**
+ * @brief Returns true if any access lists component is set.
+ *
+ * @return boolean Return true if any of allow_* deny_* values is set.
+ */
function is_private() {
return (($this->allow_cid || $this->allow_gid || $this->deny_cid || $this->deny_gid) ? true : false);
}
}
-
diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php
index 33b244dc5..920916828 100644
--- a/Zotlabs/Daemon/Onepoll.php
+++ b/Zotlabs/Daemon/Onepoll.php
@@ -118,13 +118,29 @@ class Onepoll {
if($fetch_feed) {
- $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']);
- $feedurl .= '?f=&mindate=' . urlencode($last_update);
+ if(strpos($contact['xchan_connurl'],z_root()) === 0) {
+ // local channel - save a network fetch
+ $c = channelx_by_hash($contact['xchan_hash']);
+ if($c) {
+ $x = [
+ 'success' => true,
+ 'body' => json_encode( [
+ 'success' => true,
+ 'messages' => zot_feed($c['channel_id'], $importer['xchan_hash'], [ 'mindate' => $last_update ])
+ ])
+ ];
+ }
+ }
+ else {
+ // remote fetch
- $x = z_fetch_url($feedurl);
+ $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']);
+ $feedurl .= '?f=&mindate=' . urlencode($last_update) . '&zid=' . $importer['channel_address'] . '@' . \App::get_hostname();
+ $recurse = 0;
+ $x = z_fetch_url($feedurl, false, $recurse, [ 'session' => true ]);
+ }
logger('feed_update: ' . print_r($x,true), LOGGER_DATA);
-
}
if(($x) && ($x['success'])) {
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php
index 52f1ddf32..d605a78a9 100644
--- a/Zotlabs/Module/Mail.php
+++ b/Zotlabs/Module/Mail.php
@@ -178,6 +178,25 @@ class Mail extends \Zotlabs\Web\Controller {
'$header' => t('Messages'),
));
+ if(argc() == 3 && intval(argv(1)) && argv(2) === 'download') {
+
+ $r = q("select * from mail where id = %d and channel_id = %d",
+ intval(argv(1)),
+ intval(local_channel())
+ );
+
+ if($r) {
+
+ header('Content-type: ' . $r[0]['mail_mimetype']);
+ header('Content-disposition: attachment; filename="' . t('message') . '-' . $r[0]['id'] . '"' );
+ $body = (($r[0]['mail_obscured']) ? base64url_decode(str_rot47($r[0]['body'])) : $r[0]['body']);
+ echo $body;
+ killme();
+ }
+
+ }
+
+
if((argc() == 4) && (argv(2) === 'drop')) {
if(! intval(argv(3)))
return;
@@ -370,6 +389,11 @@ class Mail extends \Zotlabs\Web\Controller {
foreach($messages as $message) {
$s = theme_attachments($message);
+
+ if($message['mail_raw'])
+ $message['body'] = mail_prepare_binary([ 'id' => $message['id'] ]);
+ else
+ $message['body'] = zidify_links(smilies(bbcode($message['body'])));
$mails[] = array(
'mailbox' => $mailbox,
@@ -382,7 +406,7 @@ class Mail extends \Zotlabs\Web\Controller {
'to_url' => chanlink_hash($message['to_xchan']),
'to_photo' => $message['to']['xchan_photo_s'],
'subject' => $message['title'],
- 'body' => zidify_links(smilies(bbcode($message['body']))),
+ 'body' => $message['body'],
'attachments' => $s,
'delete' => t('Delete message'),
'dreport' => t('Delivery report'),
diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php
index 593ba643f..d4c31fd4e 100644
--- a/Zotlabs/Module/Setup.php
+++ b/Zotlabs/Module/Setup.php
@@ -508,6 +508,7 @@ class Setup extends \Zotlabs\Web\Controller {
$this->check_add($ck_funcs, t('PDO database PHP module'), true, true);
$this->check_add($ck_funcs, t('mb_string PHP module'), true, true);
$this->check_add($ck_funcs, t('xml PHP module'), true, true);
+ $this->check_add($ck_funcs, t('zip PHP module'), true, true);
if(function_exists('apache_get_modules')){
if (! in_array('mod_rewrite', apache_get_modules())) {
@@ -550,8 +551,12 @@ class Setup extends \Zotlabs\Web\Controller {
$ck_funcs[4]['help'] = t('Error: mb_string PHP module required but not installed.');
}
if(! extension_loaded('xml')) {
+ $ck_funcs[5]['status'] = false;
+ $ck_funcs[5]['help'] = t('Error: xml PHP module required for DAV but not installed.');
+ }
+ if(! extension_loaded('zip')) {
$ck_funcs[6]['status'] = false;
- $ck_funcs[6]['help'] = t('Error: xml PHP module required for DAV but not installed.');
+ $ck_funcs[6]['help'] = t('Error: zip PHP module required but not installed.');
}
$checks = array_merge($checks, $ck_funcs);
diff --git a/Zotlabs/Module/Zotfeed.php b/Zotlabs/Module/Zotfeed.php
index 6b505c890..381e3acb2 100644
--- a/Zotlabs/Module/Zotfeed.php
+++ b/Zotlabs/Module/Zotfeed.php
@@ -22,7 +22,8 @@ class Zotfeed extends \Zotlabs\Web\Controller {
$observer = \App::get_observer();
-
+ logger('observer: ' . get_observer_hash(), LOGGER_DEBUG);
+
$channel_address = ((argc() > 1) ? argv(1) : '');
if($channel_address) {
$r = q("select channel_id, channel_name from channel where channel_address = '%s' and channel_removed = 0 limit 1",