aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-07-10 19:30:10 +0100
committerThomas Willingham <founder@kakste.com>2013-07-10 19:30:10 +0100
commit085be3a16f704a3f89bbe4d795c9ca915cc26e8a (patch)
treecd0a1b608630d5e819df221ed84a0fbd3755fc2f /include
parentd065135d909bf876f4c305d303de7642657f7e3e (diff)
parent72d737cc82f5987791c9ceba0c8b99a505886274 (diff)
downloadvolse-hubzilla-085be3a16f704a3f89bbe4d795c9ca915cc26e8a.tar.gz
volse-hubzilla-085be3a16f704a3f89bbe4d795c9ca915cc26e8a.tar.bz2
volse-hubzilla-085be3a16f704a3f89bbe4d795c9ca915cc26e8a.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r--include/ConversationObject.php33
-rw-r--r--include/ItemObject.php121
-rw-r--r--include/conversation.php12
-rw-r--r--include/profile_advanced.php35
-rw-r--r--include/taxonomy.php54
-rwxr-xr-xinclude/text.php31
-rw-r--r--include/zot.php2
7 files changed, 172 insertions, 116 deletions
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index 7cf39f757..3f5e901d3 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,24 @@ 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->writable)
+ $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..7a9e43819 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;
@@ -27,26 +25,15 @@ class Item extends BaseObject {
private $wall_to_wall = false;
private $threaded = false;
private $visiting = false;
- private $observer = null;
private $channel = null;
public function __construct($data) {
$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) {
@@ -80,7 +67,6 @@ class Item extends BaseObject {
$result = array();
$a = $this->get_app();
- $observer = $this->observer;
$item = $this->get_data();
$commentww = '';
@@ -94,6 +80,7 @@ class Item extends BaseObject {
$total_children = $this->count_descendants();
$conv = $this->get_conversation();
+ $observer = $conv->get_observer();
$lock = ((($item['item_private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
@@ -106,10 +93,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($observer['xchan_hash'] == $this->get_data_value('author_xchan')
+ || $observer['xchan_hash'] == $this->get_data_value('owner_xchan')
+ || $this->get_data_value('uid') == local_user())
$dropping = true;
if($dropping) {
@@ -118,7 +104,7 @@ class Item extends BaseObject {
'delete' => t('Delete'),
);
}
-
+// FIXME
if($observer_is_pageowner) {
$multidrop = array(
'select' => t('Select'),
@@ -175,7 +161,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 +442,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 +478,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/conversation.php b/include/conversation.php
index 410143a7a..1023c068d 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -584,17 +584,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$tags=array();
$hashtags = array();
$mentions = array();
- foreach(explode(',',$item['tag']) as $tag){
- $tag = trim($tag);
- if ($tag!="") {
- $t = bbcode($tag);
- $tags[] = $t;
- if($t[0] == '#')
- $hashtags[] = $t;
- elseif($t[0] == '@')
- $mentions[] = $t;
- }
- }
$sp = false;
$profile_link = best_link_url($item,$sp);
@@ -650,7 +639,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$tmp_item = array(
'template' => $tpl,
'toplevel' => 'toplevel_item',
- 'tags' => $tags,
'id' => (($preview) ? 'P0' : $item['item_id']),
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_url),
'profile_url' => $profile_link,
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index f008d1c8f..21606185d 100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
@@ -80,9 +80,44 @@ function advanced_profile(&$a) {
if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
+ $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_page = '%s' and uid = %d and obj_type = %d
+ order by obj_verb, term",
+ dbesc($a->profile['profile_guid']),
+ intval($a->profile['profile_uid']),
+ intval(TERM_OBJ_THING)
+ );
+
+ $things = null;
+
+ if($r) {
+ $things = array();
+
+ // Use the system obj_verbs array as a sort key, since we don't really
+ // want an alphabetic sort. To change the order, use a plugin to
+ // alter the obj_verbs() array or alter it in code. Unknown verbs come
+ // after the known ones - in no particular order.
+
+ $v = obj_verbs();
+ foreach($v as $k => $foo)
+ $things[$k] = null;
+ foreach($r as $rr) {
+ if(! $things[$rr['obj_verb']])
+ $things[$rr['obj_verb']] = array();
+ $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl']);
+ }
+ $sorted_things = array();
+ if($things)
+ foreach($things as $k => $v)
+ if(is_array($things[$k]))
+ $sorted_things[$k] = $v;
+ }
+
+ logger('mod_profile: things: ' . print_r($sorted_things,true), LOGGER_DATA);
+
return replace_macros($tpl, array(
'$title' => t('Profile'),
'$profile' => $profile,
+ '$things' => $sorted_things
));
}
diff --git a/include/taxonomy.php b/include/taxonomy.php
index e9cc0faf4..b6803743a 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -96,14 +96,23 @@ function format_term_for_display($term) {
// Tag cloud functions - need to be adpated to this database format
-function tagadelic($uid, $count = 0, $flags = 0, $type = TERM_HASHTAG) {
+function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $type = TERM_HASHTAG) {
+
+ $sql_options = '';
if($flags)
- $sql_options = " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") ";
+ $sql_options .= " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") ";
+ if($authors) {
+ if(! is_array($authors))
+ $authors = array($authors);
+ stringify_array_elms($authors,true);
+ $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
+ }
+
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
where term.uid = %d and term.type = %d
- and otype = %d and item_restrict = 0
+ and otype = %d and item_restrict = 0 and item_private = 0
$sql_options
group by term order by total desc %s",
intval($uid),
@@ -148,10 +157,10 @@ function tags_sort($a,$b) {
}
-function tagblock($link,$uid,$count = 0,$flags = 0,$type = TERM_HASHTAG) {
+function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$type = TERM_HASHTAG) {
$o = '';
$tab = 0;
- $r = tagadelic($uid,$count,$flags,$type);
+ $r = tagadelic($uid,$count,$authors,$flags,$type);
if($r) {
$o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
@@ -162,3 +171,38 @@ function tagblock($link,$uid,$count = 0,$flags = 0,$type = TERM_HASHTAG) {
}
return $o;
}
+
+
+ /**
+ * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants"
+ * We use the first person form when creating an activity, but the third person for use in activities
+ * FIXME: There is no accounting for verb gender for languages where this is significant. We may eventually
+ * require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module.
+ */
+
+
+
+function obj_verbs() {
+ $verbs = array(
+ 'has' => array( t('have'), t('has')),
+ 'wants' => array( t('want'), t('wants')),
+ 'likes' => array( t('like'), t('likes')),
+ 'dislikes' => array( t('dislike'), t('dislikes')),
+ );
+
+ $arr = array('verbs' => $verbs);
+ call_hooks('obj_verbs', $arr);
+ return $arr['verbs'];
+}
+
+
+function obj_verb_selector() {
+ $verbs = obj_verbs();
+ $o .= '<select class="obj-verb-selector" name="verb" >';
+ foreach($verbs as $k => $v) {
+ $o .= '<option value="' . urlencode($k) . '">' . $v[0] . '</option>';
+ }
+ $o .= '</select>';
+ return $o;
+
+} \ No newline at end of file
diff --git a/include/text.php b/include/text.php
index db29697f9..2d29dff31 100755
--- a/include/text.php
+++ b/include/text.php
@@ -1023,19 +1023,24 @@ function prepare_body($item,$attach = false) {
$s .= '<div class="clear"></div></div>';
}
- if(is_array($item['term']) && count($item['term'])) {
- $tstr = '';
- foreach($item['term'] as $t) {
- $t1 = format_term_for_display($t);
- if($t1) {
- if($tstr)
- $tstr .= ' ';
- $tstr .= $t1;
- }
- }
- if($tstr)
- $s .= '<br /><div class="posttags">' . $tstr . '</div>';
- }
+// At some point in time, posttags were removed from the threaded conversation templates, but remained in the search_item template.
+// Code to put them back was added into include/conversation.php and/or include/ItemObject.php but under new class names
+// Then it was discovered that the following bits remained of the old code.
+// Commented out, but we may decide to use this instead of the other version and put all the tag rendering in one place. In the other
+// location it is more theme-able.
+// if(is_array($item['term']) && count($item['term'])) {
+// $tstr = '';
+// foreach($item['term'] as $t) {
+// $t1 = format_term_for_display($t);
+// if($t1) {
+// if($tstr)
+// $tstr .= ' ';
+// $tstr .= $t1;
+// }
+// }
+// if($tstr)
+// $s .= '<br /><div class="posttags">' . $tstr . '</div>';
+// }
$writeable = ((get_observer_hash() == $item['owner_xchan']) ? true : false);
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']),