aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-03-09 00:46:17 -0800
committerredmatrix <git@macgirvin.com>2016-03-09 00:46:17 -0800
commit256cd6baace37c24b39057fdee6f4d3f1428c190 (patch)
treebb2dba53d2286de76fd0452e184873e81cc8879c /include
parent843cc1481af008f35804628686459437cedf3220 (diff)
downloadvolse-hubzilla-256cd6baace37c24b39057fdee6f4d3f1428c190.tar.gz
volse-hubzilla-256cd6baace37c24b39057fdee6f4d3f1428c190.tar.bz2
volse-hubzilla-256cd6baace37c24b39057fdee6f4d3f1428c190.zip
work on implementing account/channel move (as opposed to clone)
Diffstat (limited to 'include')
-rw-r--r--include/BaseObject.php1
-rw-r--r--include/ConversationObject.php23
-rw-r--r--include/conversation.php5
-rwxr-xr-xinclude/items.php6
-rw-r--r--include/permissions.php18
5 files changed, 28 insertions, 25 deletions
diff --git a/include/BaseObject.php b/include/BaseObject.php
index 4bfac5fa0..a88978a83 100644
--- a/include/BaseObject.php
+++ b/include/BaseObject.php
@@ -1,4 +1,5 @@
<?php /** @file */
+
if(class_exists('BaseObject'))
return;
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index 7e0d67c10..66f6cca0e 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -15,6 +15,7 @@ require_once('include/items.php');
*/
class Conversation extends BaseObject {
+
private $threads = array();
private $mode = null;
private $observer = null;
@@ -52,14 +53,8 @@ class Conversation extends BaseObject {
switch($mode) {
case 'network':
-// if(array_key_exists('firehose',$a->data) && intval($a->data['firehose'])) {
-// $this->profile_owner = intval($a->data['firehose']);
-// $this->writable = false;
-// }
-// else {
- $this->profile_owner = local_channel();
- $this->writable = true;
-// }
+ $this->profile_owner = local_channel();
+ $this->writable = true;
break;
case 'channel':
$this->profile_owner = $a->profile['profile_uid'];
@@ -69,7 +64,6 @@ class Conversation extends BaseObject {
// in this mode we set profile_owner after initialisation (from conversation()) and then
// pull some trickery which allows us to re-invoke this function afterward
// it's an ugly hack so FIXME
-// $this->profile_owner = $a->profile['uid'];
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
break;
case 'page':
@@ -142,11 +136,11 @@ class Conversation extends BaseObject {
public function add_thread($item) {
$item_id = $item->get_id();
if(!$item_id) {
- logger('[ERROR] Conversation::add_thread : Item has no ID!!', LOGGER_DEBUG);
+ logger('Item has no ID!!', LOGGER_DEBUG, LOG_ERR);
return false;
}
if($this->get_thread($item->get_id())) {
- logger('[WARN] Conversation::add_thread : Thread already exists ('. $item->get_id() .').', LOGGER_DEBUG);
+ logger('Thread already exists ('. $item->get_id() .').', LOGGER_DEBUG, LOG_WARNING);
return false;
}
@@ -177,11 +171,6 @@ class Conversation extends BaseObject {
}
}
require_once('include/identity.php');
-// $sys = get_sys_channel();
-
-// if($sys && $item->get_data_value('uid') == $sys['channel_id']) {
-// $item->set_commentable(false);
-// }
$item->set_conversation($this);
$this->threads[] = $item;
@@ -209,7 +198,7 @@ class Conversation extends BaseObject {
$item_data = $item->get_template_data($conv_responses);
}
if(!$item_data) {
- logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG);
+ logger('Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG, LOG_ERR);
return false;
}
$result[] = $item_data;
diff --git a/include/conversation.php b/include/conversation.php
index 39119b2bb..676067f86 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1110,6 +1110,11 @@ function status_editor($a, $x, $popup = false) {
$o = '';
+ require_once('include/Contact.php');
+ $c = channelx_by_n($x['profile_uid']);
+ if($c && $c['channel_moved'])
+ return $o;
+
$geotag = (($x['allow_location']) ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '');
$plaintext = true;
diff --git a/include/items.php b/include/items.php
index bb4d1108e..9163016e1 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1144,9 +1144,8 @@ function import_author_rss($x) {
$photos = import_xchan_photo($x['photo']['src'],$x['url']);
if($photos) {
- /** @bug $arr is undefined in this SQL query */
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_url = '%s' and xchan_network = 'rss'",
- dbesc(datetime_convert('UTC', 'UTC', $arr['photo_updated'])),
+ dbesc(datetime_convert()),
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
@@ -1189,9 +1188,8 @@ function import_author_unknown($x) {
$photos = import_xchan_photo($x['photo']['src'],$x['url']);
if($photos) {
- /** @bug $arr is undefined in this SQL query */
$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_url = '%s' and xchan_network = 'unknown'",
- dbesc(datetime_convert('UTC','UTC',$arr['photo_updated'])),
+ dbesc(datetime_convert()),
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
diff --git a/include/permissions.php b/include/permissions.php
index e4cd9ddda..8f593640c 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -151,9 +151,13 @@ function get_all_perms($uid, $observer_xchan, $internal_use = true) {
// Check if this $uid is actually the $observer_xchan - if it's your content
// you always have permission to do anything
+ // if you've moved elsewhere, you will only have read only access
if(($observer_xchan) && ($r[0]['channel_hash'] === $observer_xchan)) {
- $ret[$perm_name] = true;
+ if($r[0]['channel_moved'] && (! $permission[2]))
+ $ret[$perm_name] = false;
+ else
+ $ret[$perm_name] = true;
continue;
}
@@ -286,7 +290,7 @@ function perm_is_allowed($uid, $observer_xchan, $permission) {
$channel_perm = $global_perms[$permission][0];
- $r = q("select %s, channel_pageflags, channel_hash from channel where channel_id = %d limit 1",
+ $r = q("select %s, channel_pageflags, channel_moved, channel_hash from channel where channel_id = %d limit 1",
dbesc($channel_perm),
intval($uid)
);
@@ -325,9 +329,15 @@ function perm_is_allowed($uid, $observer_xchan, $permission) {
return false;
// Check if this $uid is actually the $observer_xchan
+ // you will have full access unless the channel was moved -
+ // in which case you will have read_only access
- if($r[0]['channel_hash'] === $observer_xchan)
- return true;
+ if($r[0]['channel_hash'] === $observer_xchan) {
+ if($r[0]['channel_moved'] && (! $global_perms[$permission][2]))
+ return false;
+ else
+ return true;
+ }
if($r[0][$channel_perm] & PERMS_PUBLIC)
return true;