aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-07-08 22:01:57 -0700
committerfriendica <info@friendica.com>2013-07-08 22:01:57 -0700
commit6e012839c9807ce8c3c97bafdca7a36cf5fc58a9 (patch)
treeb3bbb574e058a45ed7d2658a3bc710704164d751 /include
parentcd40802229a39fe6eabc2dec8784a445e4cd2769 (diff)
downloadvolse-hubzilla-6e012839c9807ce8c3c97bafdca7a36cf5fc58a9.tar.gz
volse-hubzilla-6e012839c9807ce8c3c97bafdca7a36cf5fc58a9.tar.bz2
volse-hubzilla-6e012839c9807ce8c3c97bafdca7a36cf5fc58a9.zip
more work on bug #59 - hope this doesn't hork everything. Also some tweaking of the theme for the new radius control, which produced some surprising results when expert mode was toggled.
Diffstat (limited to 'include')
-rw-r--r--include/ConversationObject.php30
-rw-r--r--include/ItemObject.php116
-rw-r--r--include/zot.php2
3 files changed, 65 insertions, 83 deletions
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index 7cf39f757..e3b46ca3f 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -11,12 +11,14 @@ require_once('include/text.php');
/**
* A list of threads
*
- * We should think about making this a SPL Iterator
*/
+
class Conversation extends BaseObject {
private $threads = array();
private $mode = null;
+ private $observer = null;
private $writable = false;
+ private $commentable = false;
private $profile_owner = 0;
private $preview = false;
@@ -34,8 +36,8 @@ class Conversation extends BaseObject {
$a = $this->get_app();
- $observer = $a->get_observer();
- $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
+ $this->observer = $a->get_observer();
+ $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : '');
switch($mode) {
case 'network':
@@ -63,7 +65,6 @@ class Conversation extends BaseObject {
break;
}
$this->mode = $mode;
-
}
/**
@@ -80,6 +81,10 @@ class Conversation extends BaseObject {
return $this->writable;
}
+ public function is_commentable() {
+ return $this->commentable;
+ }
+
/**
* Check if page is a preview
*/
@@ -101,6 +106,10 @@ class Conversation extends BaseObject {
$this->set_mode($mode);
}
+ public function get_observer() {
+ return $this->observer;
+ }
+
/**
* Add a thread to the conversation
@@ -121,12 +130,21 @@ class Conversation extends BaseObject {
}
/*
- * Only add will be displayed
+ * Only add things that will be displayed
*/
- if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
+
+ if(($item->get_data_value('id') != $item->get_data_value('parent')) && (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE))) {
return false;
}
+
+ if(local_user() && $item->get_data_value('uid') == local_user())
+ $this->commentable = true;
+
+ if(($this->observer) && (! $this->writable)) {
+ $this->commentable = can_comment_on_post($this->observer['xchan_hash'],$item['data']);
+ }
+
$item->set_conversation($this);
$this->threads[] = $item;
return end($this->threads);
diff --git a/include/ItemObject.php b/include/ItemObject.php
index e057936ae..a56f66a01 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -11,12 +11,10 @@ require_once('boot.php');
* An item
*/
class Item extends BaseObject {
- private $data = array();
+ public $data = array();
private $template = 'conv_item.tpl';
private $comment_box_template = 'comment_item.tpl';
private $toplevel = false;
- private $writable = false;
- private $commentable = false;
private $children = array();
private $parent = null;
private $conversation = null;
@@ -34,19 +32,9 @@ class Item extends BaseObject {
$a = $this->get_app();
$this->data = $data;
- $this->channel = $a->get_channel();
- $this->observer = $a->get_observer();
-
$this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
- $this->writable = (((local_user()) && ($this->channel['channel_hash'] === $this->data['owner_xchan'])) ? true : false);
- $this->commentable = $this->writable;
-
- if(($this->observer) && (! $this->writable)) {
- $this->commentable = can_comment_on_post($this->observer['xchan_hash'],$data);
- }
-
// Prepare the children
if(count($data['children'])) {
foreach($data['children'] as $item) {
@@ -106,10 +94,9 @@ class Item extends BaseObject {
else
$edpost = false;
-// FIXME - this is wrong.
-// if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
-
- if($this->get_data_value('uid') == local_user())
+ if($this->observer['xchan_hash'] == $this->get_data_value('author_xchan')
+ || $this->observer['xchan_hash'] == $this->get_data_value('owner_xchan')
+ || $this->get_data_value('uid') == local_user())
$dropping = true;
if($dropping) {
@@ -175,7 +162,7 @@ class Item extends BaseObject {
);
}
- if($this->is_commentable()) {
+ if($conv->is_commentable()) {
$like = array( t("I like this \x28toggle\x29"), t("like"));
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
if ($shareable)
@@ -456,28 +443,6 @@ class Item extends BaseObject {
}
/**
- * Check if this is writable
- */
- private function is_writable() {
-
- return $this->writable;
-
-// $conv = $this->get_conversation();
-
-// return true;
-
-// if($conv) {
- // This will allow us to comment on wall-to-wall items owned by our friends
- // and community forums even if somebody else wrote the post.
-// return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'channel'));
-// }
- }
-
- private function is_commentable() {
- return $this->commentable;
- }
-
- /**
* Count the total of our descendants
*/
private function count_descendants() {
@@ -514,44 +479,43 @@ class Item extends BaseObject {
$comment_box = '';
$conv = $this->get_conversation();
- if(! $this->is_commentable())
+ if(! $conv->is_commentable())
return;
- if($conv->is_writable() || $this->is_writable()) {
- $template = get_markup_template($this->get_comment_box_template());
-
- $a = $this->get_app();
-
- $qc = ((local_user()) ? get_pconfig(local_user(),'system','qcomment') : null);
- $qcomment = (($qc) ? explode("\n",$qc) : null);
-
- $comment_box = replace_macros($template,array(
- '$return_path' => '',
- '$threaded' => $this->is_threaded(),
- '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
- '$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'),
- '$id' => $this->get_id(),
- '$parent' => $this->get_id(),
- '$qcomment' => $qcomment,
- '$profile_uid' => $conv->get_profile_owner(),
- '$mylink' => $this->observer['xchan_url'],
- '$mytitle' => t('This is you'),
- '$myphoto' => $this->observer['xchan_photo_s'],
- '$comment' => t('Comment'),
- '$submit' => t('Submit'),
- '$edbold' => t('Bold'),
- '$editalic' => t('Italic'),
- '$eduline' => t('Underline'),
- '$edquote' => t('Quote'),
- '$edcode' => t('Code'),
- '$edimg' => t('Image'),
- '$edurl' => t('Link'),
- '$edvideo' => t('Video'),
- '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
- '$indent' => $indent,
- '$sourceapp' => get_app()->sourcename
- ));
- }
+ $template = get_markup_template($this->get_comment_box_template());
+
+ $a = $this->get_app();
+ $observer = $conv->get_observer();
+
+ $qc = ((local_user()) ? get_pconfig(local_user(),'system','qcomment') : null);
+ $qcomment = (($qc) ? explode("\n",$qc) : null);
+
+ $comment_box = replace_macros($template,array(
+ '$return_path' => '',
+ '$threaded' => $this->is_threaded(),
+ '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
+ '$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'),
+ '$id' => $this->get_id(),
+ '$parent' => $this->get_id(),
+ '$qcomment' => $qcomment,
+ '$profile_uid' => $conv->get_profile_owner(),
+ '$mylink' => $observer['xchan_url'],
+ '$mytitle' => t('This is you'),
+ '$myphoto' => $observer['xchan_photo_s'],
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
+ '$edbold' => t('Bold'),
+ '$editalic' => t('Italic'),
+ '$eduline' => t('Underline'),
+ '$edquote' => t('Quote'),
+ '$edcode' => t('Code'),
+ '$edimg' => t('Image'),
+ '$edurl' => t('Link'),
+ '$edvideo' => t('Video'),
+ '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
+ '$indent' => $indent,
+ '$sourceapp' => get_app()->sourcename
+ ));
return $comment_box;
}
diff --git a/include/zot.php b/include/zot.php
index f9b40c06f..6c8a21d1a 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1354,7 +1354,7 @@ function import_directory_profile($hash,$profile) {
}
else {
$update = true;
- $x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_age, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_keywords) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
+ $x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_age, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_keywords) values ('%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
dbesc($arr['xprof_hash']),
dbesc($arr['xprof_desc']),
dbesc($arr['xprof_dob']),