forked from gkrid/dokuwiki-plugin-bez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.php
61 lines (47 loc) · 1.59 KB
/
cli.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
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
//include base config
$inc = realpath(__DIR__.'/../../..');
define('DOKU_INC', $inc.'/');
// load and initialize the core system
require_once(DOKU_INC.'inc/init.php');
echo "baseurl: " . $conf['baseurl'] . "\n";
echo "basedir: " . $conf['basedir'] . "\n";
function help() {
echo "cli.php purge\n";
exit(0);
}
function purge() {
$action = new action_plugin_bez_base();
$action->createObjects(true);
$threads = $action->get_model()->threadFactory->get_all();
foreach ($threads as $thread) {
$thread->purge();
$action->get_model()->threadFactory->save($thread);
echo "Thread #" . $thread->id . " purged\n";
}
$thread_comments = $action->get_model()->thread_commentFactory->get_all();
foreach ($thread_comments as $thread_comment) {
$thread_comment->purge();
$action->get_model()->thread_commentFactory->save($thread_comment);
echo "Thread comment #k" . $thread_comment->id . " purged\n";
}
$tasks = $action->get_model()->taskFactory->get_all();
foreach ($tasks as $task) {
$task->purge();
$action->get_model()->taskFactory->save($task);
echo "Task #z" . $task->id . " purged\n";
}
$task_comments = $action->get_model()->task_commentFactory->get_all();
foreach ($task_comments as $task_comment) {
$task_comment->purge();
$action->get_model()->task_commentFactory->save($task_comment);
echo "Task comment #zk" . $task_comment->id . " purged\n";
}
}
switch ($argv[1]) {
case 'purge':
purge();
exit(0);
default:
help();
}