From 86002a2f7b51b08880629166c9836b18f7eecf98 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Thu, 24 Nov 2016 18:24:15 -0500 Subject: Make a git commit when a new page is created, recording who created the page. --- Zotlabs/Module/Wiki.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module/Wiki.php') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 0c848bc7c..8069afc7c 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -382,7 +382,18 @@ class Wiki extends \Zotlabs\Web\Controller { } $page = wiki_create_page($name, $resource_id); if ($page['success']) { - json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.urlencode($page['page']['urlName']), 'success' => true)); + $ob = \App::get_observer(); + $commit = wiki_git_commit(array( + 'commit_msg' => t('New page created'), + 'resource_id' => $resource_id, + 'observer' => $ob, + 'files' => array($page['page']['urlName'].'.md') + )); + if($commit['success']) { + json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.urlencode($page['page']['urlName']), 'success' => true)); + } else { + json_return_and_die(array('message' => 'Error making git commit','url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.urlencode($page['page']['urlName']),'success' => false)); + } } else { logger('Error creating page'); json_return_and_die(array('message' => 'Error creating page.', 'success' => false)); -- cgit v1.2.3