aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Tasks.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/Tasks.php
parent2a61817bad96526994c0499f1fc0a843a9cc9405 (diff)
downloadvolse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.tar.gz
volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.tar.bz2
volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.zip
module updates
Diffstat (limited to 'Zotlabs/Module/Tasks.php')
-rw-r--r--Zotlabs/Module/Tasks.php112
1 files changed, 112 insertions, 0 deletions
diff --git a/Zotlabs/Module/Tasks.php b/Zotlabs/Module/Tasks.php
new file mode 100644
index 000000000..ab05f8be9
--- /dev/null
+++ b/Zotlabs/Module/Tasks.php
@@ -0,0 +1,112 @@
+<?php
+namespace Zotlabs\Module;
+
+require_once('include/event.php');
+
+
+
+class Tasks extends \Zotlabs\Web\Controller {
+
+ function init() {
+
+
+ // logger('request: ' . print_r($_REQUEST,true));
+
+ $arr = array();
+
+ if(argc() > 1 && argv(1) === 'fetch') {
+ if(argc() > 2 && argv(2) === 'all')
+ $arr['all'] = 1;
+
+ $x = tasks_fetch($arr);
+ if($x['tasks']) {
+ $x['html'] = '';
+ foreach($x['tasks'] as $y) {
+ $x['html'] .= '<div class="tasklist-item"><input type="checkbox" onchange="taskComplete(' . $y['id'] . '); return false;" /> ' . $y['summary'] . '</div>';
+ }
+ }
+ json_return_and_die($x);
+ }
+
+ }
+
+
+
+ function post() {
+
+
+ // logger('post: ' . print_r($_POST,true));
+
+
+ if(! local_channel())
+ return;
+
+ $channel = \App::get_channel();
+
+ if((argc() > 2) && (argv(1) === 'complete') && intval(argv(2))) {
+ $ret = array('success' => false);
+ $r = q("select * from event where `type` = 'task' and uid = %d and id = %d limit 1",
+ intval(local_channel()),
+ intval(argv(2))
+ );
+ if($r) {
+ $event = $r[0];
+ if($event['event_status'] === 'COMPLETED') {
+ $event['event_status'] = 'IN-PROCESS';
+ $event['event_status_date'] = NULL_DATE;
+ $event['event_percent'] = 0;
+ $event['event_sequence'] = $event['event_sequence'] + 1;
+ $event['edited'] = datetime_convert();
+ }
+ else {
+ $event['event_status'] = 'COMPLETED';
+ $event['event_status_date'] = datetime_convert();
+ $event['event_percent'] = 100;
+ $event['event_sequence'] = $event['event_sequence'] + 1;
+ $event['edited'] = datetime_convert();
+ }
+ $x = event_store_event($event);
+ if($x)
+ $ret['success'] = true;
+ }
+ json_return_and_die($ret);
+ }
+
+ if(argc() == 2 && argv(1) === 'new') {
+ $text = escape_tags(trim($_REQUEST['summary']));
+ if(! $text)
+ return array('success' => false);
+ $event = array();
+ $event['account'] = $channel['channel_account_id'];
+ $event['uid'] = $channel['channel_id'];
+ $event['event_xchan'] = $channel['channel_hash'];
+ $event['type'] = 'task';
+ $event['nofinish'] = true;
+ $event['created'] = $event['edited'] = $event['start'] = datetime_convert();
+ $event['adjust'] = 1;
+ $event['allow_cid'] = '<' . $channel['channel_hash'] . '>';
+ $event['summary'] = escape_tags($_REQUEST['summary']);
+ $x = event_store_event($event);
+ if($x)
+ $x['success'] = true;
+ else
+ $x = array('success' => false);
+ json_return_and_die($x);
+ }
+
+
+ }
+
+
+
+
+
+ function get() {
+
+ if(! local_channel())
+ return;
+
+
+ return '';
+ }
+}