diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-01-26 10:46:44 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-01-26 10:46:44 +0100 |
commit | 02e8058c5069506952e4c9979b7dfe02b5dc5480 (patch) | |
tree | 50352e4468b4b0eccef1a5889e067ccba60facb3 /Zotlabs | |
parent | 93057fae8c7ea264b4fd76878475b594c067e26b (diff) | |
download | volse-hubzilla-02e8058c5069506952e4c9979b7dfe02b5dc5480.tar.gz volse-hubzilla-02e8058c5069506952e4c9979b7dfe02b5dc5480.tar.bz2 volse-hubzilla-02e8058c5069506952e4c9979b7dfe02b5dc5480.zip |
fix renaming of wiki pages
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/NativeWikiPage.php | 16 | ||||
-rw-r--r-- | Zotlabs/Module/Wiki.php | 12 |
2 files changed, 16 insertions, 12 deletions
diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 85a1e8bed..3cc69f120 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -77,6 +77,7 @@ class NativeWikiPage { } static public function rename_page($arr) { + $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : ''); $pageNewName = ((array_key_exists('pageNewName',$arr)) ? $arr['pageNewName'] : ''); $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : ''); @@ -94,7 +95,7 @@ class NativeWikiPage { intval($channel_id), dbesc($pageNewName) ); - + if($ic) { return [ 'success' => false, 'message' => t('Destination name already exists') ]; } @@ -107,7 +108,7 @@ class NativeWikiPage { intval($channel_id), dbesc($pageUrlName) ); - + if($ic) { foreach($ic as $c) { set_iconfig($c['item_id'],'nwikipage','pagetitle',$pageNewName); @@ -213,7 +214,7 @@ class NativeWikiPage { intval($channel_id), dbesc($pageUrlName) ); - + if($ic) { foreach($ic as $c) { if($ids) @@ -224,11 +225,13 @@ class NativeWikiPage { $sql_extra = item_permissions_sql($channel_id,$observer_hash); if($revision == (-1)) - $sql_extra .= " order by revision desc "; - elseif($revision) - $sql_extra .= " and revision = " . intval($revision) . " "; + $sql_extra .= " order by revision desc "; + elseif($revision) + $sql_extra .= " and revision = " . intval($revision) . " "; $r = null; + + if($ids) { $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and id in ( $ids ) $sql_extra limit 1", dbesc($resource_id), @@ -487,6 +490,7 @@ class NativeWikiPage { return array('message' => t('Error reading wiki'), 'success' => false); } + $page = self::load_page($arr); if($page) { diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 75a620c37..d075c02aa 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -619,23 +619,23 @@ class Wiki extends \Zotlabs\Web\Controller { } // Determine if observer has permission to rename pages - $perms = Zlib\NativeWikiPage::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash); + $perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash); if(! $perms['write']) { logger('Wiki write permission denied. ' . EOL); json_return_and_die(array('success' => false)); } $renamed = Zlib\NativeWikiPage::rename_page(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName, 'pageNewName' => $pageNewName)); + if($renamed['success']) { $ob = \App::get_observer(); - $commit = wiki_git_commit(array( + $commit = Zlib\NativeWikiPage::commit(array( + 'channel_id' => $owner['channel_id'], 'commit_msg' => 'Renamed ' . urldecode($pageUrlName) . ' to ' . $renamed['page']['htmlName'], 'resource_id' => $resource_id, - 'observer' => $ob, - 'files' => array($pageUrlName . substr($renamed['page']['fileName'], -3), $renamed['page']['fileName']), - 'all' => true + 'observer_hash' => $ob['xchan_hash'], + 'pageUrlName' => $pageNewName )); - if($commit['success']) { Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$commit['item_id'],$resource_id); json_return_and_die(array('name' => $renamed['page'], 'message' => 'Wiki git repo commit made', 'success' => true)); |