aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Mood.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-04-18 20:38:38 -0700
committerredmatrix <git@macgirvin.com>2016-04-18 20:38:38 -0700
commit2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289 (patch)
tree2376d950ba2bdc7753336a3e2b94865c95c238f2 /Zotlabs/Module/Mood.php
parent2a61817bad96526994c0499f1fc0a843a9cc9405 (diff)
downloadvolse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.tar.gz
volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.tar.bz2
volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.zip
module updates
Diffstat (limited to 'Zotlabs/Module/Mood.php')
-rw-r--r--Zotlabs/Module/Mood.php146
1 files changed, 146 insertions, 0 deletions
diff --git a/Zotlabs/Module/Mood.php b/Zotlabs/Module/Mood.php
new file mode 100644
index 000000000..b1007fd06
--- /dev/null
+++ b/Zotlabs/Module/Mood.php
@@ -0,0 +1,146 @@
+<?php
+namespace Zotlabs\Module;
+
+require_once('include/security.php');
+require_once('include/bbcode.php');
+require_once('include/items.php');
+
+
+
+class Mood extends \Zotlabs\Web\Controller {
+
+ function init() {
+
+ if(! local_channel())
+ return;
+
+ $uid = local_channel();
+ $channel = \App::get_channel();
+ $verb = notags(trim($_GET['verb']));
+
+ if(! $verb)
+ return;
+
+ $verbs = get_mood_verbs();
+
+ if(! array_key_exists($verb,$verbs))
+ return;
+
+ $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
+
+ $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
+
+
+ logger('mood: verb ' . $verb, LOGGER_DEBUG);
+
+
+ if($parent) {
+ $r = q("select mid, owner_xchan, private, allow_cid, allow_gid, deny_cid, deny_gid
+ from item where id = %d and parent = %d and uid = %d limit 1",
+ intval($parent),
+ intval($parent),
+ intval($uid)
+ );
+ if(count($r)) {
+ $parent_mid = $r[0]['mid'];
+ $private = $r[0]['item_private'];
+ $allow_cid = $r[0]['allow_cid'];
+ $allow_gid = $r[0]['allow_gid'];
+ $deny_cid = $r[0]['deny_cid'];
+ $deny_gid = $r[0]['deny_gid'];
+ }
+ }
+ else {
+
+ $private = 0;
+
+ $allow_cid = $channel['channel_allow_cid'];
+ $allow_gid = $channel['channel_allow_gid'];
+ $deny_cid = $channel['channel_deny_cid'];
+ $deny_gid = $channel['channel_deny_gid'];
+ }
+
+ $poster = \App::get_observer();
+
+ $mid = item_message_id();
+
+ $action = sprintf( t('%1$s is %2$s','mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]);
+
+ $arr = array();
+
+ $arr['aid'] = get_account_id();
+ $arr['uid'] = $uid;
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid);
+ $arr['author_xchan'] = $poster['xchan_hash'];
+ $arr['owner_xchan'] = (($parent_mid) ? $r[0]['owner_xchan'] : $poster['xchan_hash']);
+ $arr['title'] = '';
+ $arr['allow_cid'] = $allow_cid;
+ $arr['allow_gid'] = $allow_gid;
+ $arr['deny_cid'] = $deny_cid;
+ $arr['deny_gid'] = $deny_gid;
+ $arr['item_private'] = $private;
+ $arr['verb'] = $activity;
+ $arr['body'] = $action;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['item_unseen'] = 1;
+ if(! $parent_mid)
+ $item['item_thread_top'] = 1;
+
+ if ((! $arr['plink']) && intval($arr['item_thread_top'])) {
+ $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
+ }
+
+
+ $post = item_store($arr);
+ $item_id = $post['item_id'];
+
+ if($item_id) {
+ proc_run('php',"include/notifier.php","activity", $item_id);
+ }
+
+ call_hooks('post_local_end', $arr);
+
+ if($_SESSION['return_url'])
+ goaway(z_root() . '/' . $_SESSION['return_url']);
+
+ return;
+ }
+
+
+
+ function get() {
+
+ if(! local_channel()) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
+
+
+
+ $verbs = get_mood_verbs();
+
+ $shortlist = array();
+ foreach($verbs as $k => $v)
+ if($v !== 'NOTRANSLATION')
+ $shortlist[] = array($k,$v);
+
+
+ $tpl = get_markup_template('mood_content.tpl');
+
+ $o = replace_macros($tpl,array(
+ '$title' => t('Mood'),
+ '$desc' => t('Set your current mood and tell your friends'),
+ '$verbs' => $shortlist,
+ '$parent' => $parent,
+ '$submit' => t('Submit'),
+ ));
+
+ return $o;
+
+ }
+
+}