-
Notifications
You must be signed in to change notification settings - Fork 1
/
save.php
48 lines (40 loc) · 1.28 KB
/
save.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
use dokuwiki\plugin\struct\meta\StructException;
use dokuwiki\plugin\structpublish\meta\Assignments;
use dokuwiki\plugin\structpublish\meta\Constants;
use dokuwiki\plugin\structpublish\meta\Revision;
/**
* Action component to handle page save
*/
class action_plugin_structpublish_save extends DokuWiki_Action_Plugin
{
/** @inheritDoc */
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('COMMON_WIKIPAGE_SAVE', 'AFTER', $this, 'handleSave');
}
/**
* Handle the page save event to store revision meta data
*
* @param Doku_Event $event
* @return void
*/
public function handleSave(Doku_Event $event)
{
/** @var helper_plugin_structpublish_db $dbHelper */
$dbHelper = plugin_load('helper', 'structpublish_db');
$id = $event->data['id'];
$assignments = Assignments::getInstance();
$assignments->updatePageAssignments($id);
if (!$dbHelper->isPublishable()) {
return;
}
$revision = new Revision($id, $event->data['newRevision']);
$revision->setStatus(Constants::STATUS_DRAFT);
try {
$revision->save();
} catch (StructException $e) {
msg($e->getMessage(), -1);
}
}
}