@@ -45,16 +45,14 @@ public function &run(Router &$router, View &$view, array &$args) {
45
45
if ($ model ->document === null ) {
46
46
$ model ->error = 'NOT_FOUND ' ;
47
47
} else {
48
- $ flags = $ model ->document ->getOptionsBitmask ();
49
-
50
48
$ model ->comments = Comment::getAll (
51
49
Comment::PARENT_TYPE_DOCUMENT ,
52
50
$ model ->document_id
53
51
);
54
52
55
53
$ model ->content = $ model ->document ->getContent (false );
56
- $ model ->markdown = ( $ flags & Document:: OPTION_MARKDOWN );
57
- $ model ->published = ( $ flags & Document:: OPTION_PUBLISHED );
54
+ $ model ->markdown = $ model -> document -> isMarkdown ( );
55
+ $ model ->published = $ model -> document -> isPublished ( );
58
56
$ model ->title = $ model ->document ->getTitle ();
59
57
60
58
if ($ router ->getRequestMethod () == 'POST ' ) {
@@ -63,7 +61,7 @@ public function &run(Router &$router, View &$view, array &$args) {
63
61
}
64
62
65
63
$ view ->render ($ model );
66
- $ model ->_responseCode = ($ model ->acl_allowed ? 200 : 403 );
64
+ $ model ->_responseCode = ($ model ->acl_allowed ? 200 : 401 );
67
65
return $ model ;
68
66
}
69
67
@@ -102,31 +100,19 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
102
100
$ model ->document ->setTitle ($ model ->title );
103
101
$ model ->document ->setMarkdown ($ model ->markdown );
104
102
$ model ->document ->setContent ($ model ->content );
105
- $ model ->document ->setPublished ($ publish );
106
-
107
- $ model ->document ->setEditedCount (
108
- $ model ->document ->getEditedCount () + 1
109
- );
110
- $ model ->document ->setEditedDateTime (
111
- new DateTime ( 'now ' , new DateTimeZone ( 'Etc/UTC ' ))
112
- );
103
+ $ model ->document ->setPublished ($ publish ? true : false );
113
104
114
- $ success = $ model ->document ->save ();
105
+ $ model ->document ->incrementEdited ();
106
+ $ model ->document ->commit ();
107
+ $ model ->error = false ;
115
108
116
109
} catch (QueryException $ e ) {
117
110
118
111
// SQL error occurred. We can show a friendly message to the user while
119
112
// also notifying this problem to staff.
120
113
Logger::logException ($ e );
121
-
122
- $ success = false ;
123
-
124
- }
125
-
126
- if (!$ success ) {
127
114
$ model ->error = 'INTERNAL_ERROR ' ;
128
- } else {
129
- $ model ->error = false ;
115
+
130
116
}
131
117
132
118
Logger::logEvent (
@@ -136,7 +122,7 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
136
122
json_encode ([
137
123
'error ' => $ model ->error ,
138
124
'document_id ' => $ model ->document_id ,
139
- 'options_bitmask ' => $ model ->document ->getOptionsBitmask (),
125
+ 'options_bitmask ' => $ model ->document ->getOptions (),
140
126
'title ' => $ model ->document ->getTitle (),
141
127
'content ' => $ model ->document ->getContent (false ),
142
128
])
0 commit comments