aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-21 14:56:42 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-21 14:56:42 -0400
commitc6aa42773a17d53b4572488967b99666ab97ef97 (patch)
tree8ba4a4071c3a8941e7d851ad80d48cee9c3f71bd /include
parent4979a451207c7072785c114a09fdd394f2a97734 (diff)
downloadvolse-hubzilla-c6aa42773a17d53b4572488967b99666ab97ef97.tar.gz
volse-hubzilla-c6aa42773a17d53b4572488967b99666ab97ef97.tar.bz2
volse-hubzilla-c6aa42773a17d53b4572488967b99666ab97ef97.zip
Trying to fix wiki branch starting fresh from dev
Diffstat (limited to 'include')
-rw-r--r--include/widgets.php27
-rw-r--r--include/wiki.php82
2 files changed, 109 insertions, 0 deletions
diff --git a/include/widgets.php b/include/widgets.php
index 2641a718e..acbd9bcd3 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -857,6 +857,33 @@ function widget_chatroom_members() {
return $o;
}
+function widget_wiki_list($arr) {
+
+ require_once("include/wiki.php");
+ $r = wiki_list(App::$profile['channel_hash']);
+
+ if($r) {
+ return replace_macros(get_markup_template('wikilist.tpl'), array(
+ '$header' => t('Wiki List'),
+ '$read' => $r['read'],
+ '$write' => $r['write']
+ ));
+ }
+}
+
+function widget_wiki_pages($arr) {
+
+ require_once("include/wiki.php");
+ $r = wiki_pages(App::$profile['channel_hash']);
+
+ if($r) {
+ return replace_macros(get_markup_template('wiki_page_list.tpl'), array(
+ '$header' => t('Wiki Pages'),
+ '$pages' => $r['pages']
+ ));
+ }
+}
+
function widget_bookmarkedchats($arr) {
if(! feature_enabled(App::$profile['profile_uid'],'ajaxchat'))
diff --git a/include/wiki.php b/include/wiki.php
new file mode 100644
index 000000000..4f4d978e1
--- /dev/null
+++ b/include/wiki.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * @file include/wiki.php
+ * @brief Wiki related functions.
+ */
+
+define ( 'WIKI_ITEM_RESOURCE_TYPE', 'wiki' );
+
+function wiki_create() {
+
+}
+
+function wiki_delete() {
+
+}
+
+function wiki_list($observer_hash) {
+ // TODO: query db for wikis the observer can access. Return with two lists, for read and write access
+ return array('write' => array('wiki1'), 'read' => array('wiki1', 'wiki2'));
+}
+
+function wiki_pages() {
+ // TODO: scan wiki folder for pages
+ return array('pages' => array('page1.md', 'page2.md'));
+}
+
+function wiki_create_wiki($channel, $name, $acl) {
+
+ // Generate unique resource_id using the same method as item_message_id()
+ do {
+ $dups = false;
+ $resource_id = random_string();
+ $r = q("SELECT mid FROM item WHERE resource_id = '%s' AND resource_type = '%s' AND uid = %d LIMIT 1",
+ dbesc($resource_id),
+ dbesc(WIKI_ITEM_RESOURCE_TYPE),
+ intval($channel['channel_id'])
+ );
+ if (count($r))
+ $dups = true;
+ } while ($dups == true);
+ $ac = $acl->get();
+ $mid = item_message_id();
+ $arr = array(); // Initialize the array of parameters for the post
+ $perms = $acl->get();
+ $allow_cid = expand_acl($perms['allow_cid']);
+ $players = array($channel['channel_hash'], $allow_cid[0]);
+
+ $item_hidden = 0; // TODO: Allow form creator to send post to ACL about new game automatically
+ $game_url = z_root() . '/chess/' . $channel['channel_address'] . '/' . $resource_id;
+ $arr['aid'] = $channel['channel_account_id'];
+ $arr['uid'] = $channel['channel_id'];
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_hidden'] = $item_hidden;
+ $arr['resource_type'] = WIKI_ITEM_RESOURCE_TYPE;
+ $arr['resource_id'] = $resource_id;
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $channel['channel_hash'];
+ // Store info about the type of chess item using the "title" field
+ // Other types include 'move' for children items but may in the future include
+ // additional types that will determine how the "object" field is interpreted
+ $arr['title'] = $name;
+ $arr['allow_cid'] = $ac['allow_cid'];
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_thread_top'] = 1;
+ $arr['item_private'] = intval($acl->is_private());
+ $arr['verb'] = ACTIVITY_CREATE;
+ $arr['obj_type'] = ACTIVITY_OBJ_WIKI;
+ $arr['object'] = $object;
+ $arr['body'] = '[table][tr][td][h1]New Chess Game[/h1][/td][/tr][tr][td][zrl='.$game_url.']Click here to play[/zrl][/td][/tr][/table]';
+
+ $post = item_store($arr);
+ $item_id = $post['item_id'];
+
+ if ($item_id) {
+ proc_run('php', "include/notifier.php", "activity", $item_id);
+ return array('item' => $arr, 'status' => true);
+ } else {
+ return array('item' => null, 'status' => false);
+ }
+} \ No newline at end of file