work on implementing account/channel move (as opposed to clone)

This commit is contained in:
redmatrix 2016-03-09 00:46:17 -08:00
parent 843cc1481a
commit 256cd6baac
6 changed files with 30 additions and 25 deletions

View File

@ -1,4 +1,5 @@
<?php /** @file */
if(class_exists('BaseObject'))
return;

View File

@ -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;

View File

@ -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;

View File

@ -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]),

View File

@ -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;

View File

@ -174,8 +174,10 @@ function network_content(&$a, $update = 0, $load = false) {
if($deftag)
$x['pretext'] = $deftag;
$status_editor = status_editor($a,$x);
$o .= $status_editor;
}