aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2018-01-24 18:30:59 +0100
committerGitHub <noreply@github.com>2018-01-24 18:30:59 +0100
commitf560a3c98fc7cf4de7d86bd7f074c9995b3d240a (patch)
tree7cf16324e513afcf0446e19a0db39ec2ece21672 /Zotlabs
parent131baa9f4584b74ab76328d776c0bb5ce603da7d (diff)
parentadd9890754780c886188504647b3058c4cc146c1 (diff)
downloadvolse-hubzilla-f560a3c98fc7cf4de7d86bd7f074c9995b3d240a.tar.gz
volse-hubzilla-f560a3c98fc7cf4de7d86bd7f074c9995b3d240a.tar.bz2
volse-hubzilla-f560a3c98fc7cf4de7d86bd7f074c9995b3d240a.zip
Merge pull request #11 from redmatrix/dev
Dev
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Config.php4
-rw-r--r--Zotlabs/Lib/Enotify.php16
-rw-r--r--Zotlabs/Module/Cover_photo.php12
-rw-r--r--Zotlabs/Module/Like.php81
-rw-r--r--Zotlabs/Module/Logout.php2
-rw-r--r--Zotlabs/Module/Profile_photo.php21
-rw-r--r--Zotlabs/Module/Search.php23
-rw-r--r--Zotlabs/Module/Settings/Permcats.php4
-rw-r--r--Zotlabs/Module/Siteinfo.php1
9 files changed, 92 insertions, 72 deletions
diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php
index f9f22ba3a..c00b8efb6 100644
--- a/Zotlabs/Lib/Config.php
+++ b/Zotlabs/Lib/Config.php
@@ -142,9 +142,9 @@ class Config {
/**
- * @brief Returns a value directly from the database configuration storage.
+ * @brief Returns a record directly from the database configuration storage.
*
- * This function queries directly the database and bypasses the chached storage
+ * This function queries directly the database and bypasses the cached storage
* from get_config($family, $key).
*
* @param string $family
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index a7b4f28e8..5cf4ec31d 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -794,6 +794,20 @@ class Enotify {
: sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name']));
}
+ $edit = false;
+
+ if($item['edited'] > $item['created']) {
+ if($item['item_thread_top']) {
+ $itemem_text = sprintf( t('edited a post dated %s'), relative_date($item['created']));
+ $edit = true;
+ }
+ else {
+ $itemem_text = sprintf( t('edited a comment dated %s'), relative_date($item['created']));
+ $edit = true;
+ }
+ }
+
+
// convert this logic into a json array just like the system notifications
return array(
@@ -801,7 +815,7 @@ class Enotify {
'name' => $item['author']['xchan_name'],
'url' => $item['author']['xchan_url'],
'photo' => $item['author']['xchan_photo_s'],
- 'when' => relative_date($item['created']),
+ 'when' => relative_date(($edit)? $item['edited'] : $item['created']),
'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'),
'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])),
'notify_id' => 'undefined',
diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php
index 47bce6c2b..cfb513365 100644
--- a/Zotlabs/Module/Cover_photo.php
+++ b/Zotlabs/Module/Cover_photo.php
@@ -64,12 +64,12 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$image_id = substr($image_id,0,-2);
}
-
- $srcX = $_POST['xstart'];
- $srcY = $_POST['ystart'];
- $srcW = $_POST['xfinal'] - $srcX;
- $srcH = $_POST['yfinal'] - $srcY;
-
+
+
+ $srcX = intval($_POST['xstart']);
+ $srcY = intval($_POST['ystart']);
+ $srcW = intval($_POST['xfinal']) - $srcX;
+ $srcH = intval($_POST['yfinal']) - $srcY;
$r = q("select gender from profile where uid = %d and is_default = 1 limit 1",
intval(local_channel())
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index b07824363..6d9fde17c 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -9,9 +9,41 @@ require_once('include/items.php');
class Like extends \Zotlabs\Web\Controller {
- function get() {
+
+
+ private function reaction_to_activity($reaction) {
+
+ $acts = [
+ 'like' => ACTIVITY_LIKE ,
+ 'dislike' => ACTIVITY_DISLIKE ,
+ 'agree' => ACTIVITY_AGREE ,
+ 'disagree' => ACTIVITY_DISAGREE ,
+ 'abstain' => ACTIVITY_ABSTAIN ,
+ 'attendyes' => ACTIVITY_ATTEND ,
+ 'attendno' => ACTIVITY_ATTENDNO ,
+ 'attendmaybe' => ACTIVITY_ATTENDMAYBE
+ ];
+
+ // unlike (etc.) reactions are an undo of positive reactions, rather than a negative action.
+ // The activity is the same in undo actions and will have the same activity mapping
+
+ if(substr($reaction,0,2) === 'un') {
+ $reaction = substr($reaction,2);
+ }
+
+ if(array_key_exists($reaction,$acts)) {
+ return $acts[$reaction];
+ }
+
+ return EMPTY_STR;
+
+ }
+
+
+
+ public function get() {
- $o = '';
+ $o = EMPTY_STR;
$sys_channel = get_sys_channel();
$sys_channel_id = (($sys_channel) ? $sys_channel['channel_id'] : 0);
@@ -35,48 +67,17 @@ class Like extends \Zotlabs\Web\Controller {
if(! $verb)
$verb = 'like';
- switch($verb) {
- case 'like':
- case 'unlike':
- $activity = ACTIVITY_LIKE;
- break;
- case 'dislike':
- case 'undislike':
- $activity = ACTIVITY_DISLIKE;
- break;
- case 'agree':
- case 'unagree':
- $activity = ACTIVITY_AGREE;
- break;
- case 'disagree':
- case 'undisagree':
- $activity = ACTIVITY_DISAGREE;
- break;
- case 'abstain':
- case 'unabstain':
- $activity = ACTIVITY_ABSTAIN;
- break;
- case 'attendyes':
- case 'unattendyes':
- $activity = ACTIVITY_ATTEND;
- break;
- case 'attendno':
- case 'unattendno':
- $activity = ACTIVITY_ATTENDNO;
- break;
- case 'attendmaybe':
- case 'unattendmaybe':
- $activity = ACTIVITY_ATTENDMAYBE;
- break;
- default:
- return;
- break;
+ $activity = $this->reaction_to_activity($verb);
+
+ if(! $activity) {
+ return EMPTY_STR;
}
+
$extended_like = false;
$object = $target = null;
- $post_type = '';
- $objtype = '';
+ $post_type = EMPTY_STR;
+ $objtype = EMPTY_STR;
if(argc() == 3) {
diff --git a/Zotlabs/Module/Logout.php b/Zotlabs/Module/Logout.php
index 6aa11d110..f06e7278b 100644
--- a/Zotlabs/Module/Logout.php
+++ b/Zotlabs/Module/Logout.php
@@ -9,4 +9,4 @@ class Logout extends \Zotlabs\Web\Controller {
goaway(z_root());
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php
index 45a606d5f..222b92721 100644
--- a/Zotlabs/Module/Profile_photo.php
+++ b/Zotlabs/Module/Profile_photo.php
@@ -1,10 +1,11 @@
<?php
namespace Zotlabs\Module;
-/* @file profile_photo.php
- @brief Module-file with functions for handling of profile-photos
-
-*/
+/*
+ * @file Profile_photo.php
+ * @brief Module-file with functions for handling of profile-photos
+ *
+ */
require_once('include/photo/photo_driver.php');
@@ -55,6 +56,10 @@ class Profile_photo extends \Zotlabs\Web\Controller {
if((array_key_exists('cropfinal',$_POST)) && (intval($_POST['cropfinal']) == 1)) {
+ // logger('crop: ' . print_r($_POST,true));
+
+
+
// phase 2 - we have finished cropping
if(argc() != 2) {
@@ -86,10 +91,10 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
- $srcX = $_POST['xstart'];
- $srcY = $_POST['ystart'];
- $srcW = $_POST['xfinal'] - $srcX;
- $srcH = $_POST['yfinal'] - $srcY;
+ $srcX = intval($_POST['xstart']);
+ $srcY = intval($_POST['ystart']);
+ $srcW = intval($_POST['xfinal']) - $srcX;
+ $srcH = intval($_POST['yfinal']) - $srcY;
$r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND imgscale = %d LIMIT 1",
dbesc($image_id),
diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php
index a572a5a42..4d35b59f3 100644
--- a/Zotlabs/Module/Search.php
+++ b/Zotlabs/Module/Search.php
@@ -165,40 +165,41 @@ class Search extends \Zotlabs\Web\Controller {
if($load) {
$r = null;
- if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
- $prefix = 'distinct on (created, mid)';
- $suffix = 'ORDER BY created DESC, mid';
- } else {
- $prefix = 'distinct';
- $suffix = 'group by mid ORDER BY created DESC';
- }
if(local_channel()) {
- $r = q("SELECT $prefix mid, item.id as item_id, item.* from item
+ $r = q("SELECT mid, MAX(id) as item_id from item
WHERE ((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 )
OR ( item.uid = %d )) OR item.owner_xchan = '%s' )
$item_normal
$sql_extra
- $suffix $pager_sql ",
+ group by mid order by created desc $pager_sql ",
intval(local_channel()),
dbesc($sys['xchan_hash'])
);
}
if($r === null) {
- $r = q("SELECT $prefix mid, item.id as item_id, item.* from item
+ $r = q("SELECT mid, MAX(id) as item_id from item
WHERE (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = ''
AND item.deny_gid = '' AND item_private = 0 )
and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
$pub_sql ) OR owner_xchan = '%s')
$item_normal
$sql_extra
- $suffix $pager_sql",
+ group by mid order by created desc $pager_sql",
dbesc($sys['xchan_hash'])
);
}
+ if($r) {
+ $str = ids_to_querystr($r,'item_id');
+ $r = q("select *, id as item_id from item where id in ( " . $str . ") order by created desc ");
+ }
}
else {
$r = array();
}
+
+
+
+
}
if($r) {
diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php
index 336f69653..535399083 100644
--- a/Zotlabs/Module/Settings/Permcats.php
+++ b/Zotlabs/Module/Settings/Permcats.php
@@ -49,7 +49,7 @@ class Permcats {
if(argc() > 2)
- $name = argv(2);
+ $name = hex2bin(argv(2));
if(argc() > 3 && argv(3) === 'drop') {
\Zotlabs\Lib\Permcat::delete(local_channel(),$name);
@@ -70,7 +70,7 @@ class Permcats {
if(($pc['name']) && ($name) && ($pc['name'] == $name))
$existing = $pc['perms'];
if(! $pc['system'])
- $permcats[$pc['name']] = $pc['localname'];
+ $permcats[bin2hex($pc['name'])] = $pc['localname'];
}
}
diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php
index fafd51f65..92ee78cc6 100644
--- a/Zotlabs/Module/Siteinfo.php
+++ b/Zotlabs/Module/Siteinfo.php
@@ -5,7 +5,6 @@ namespace Zotlabs\Module;
class Siteinfo extends \Zotlabs\Web\Controller {
function init() {
-logger(print_r($_REQUEST,true));
if (argv(1) === 'json' || $_REQUEST['module_format'] === 'json') {
$data = get_site_info();
json_return_and_die($data);