@@ -45,16 +45,14 @@ public function &run(Router &$router, View &$view, array &$args) {
4545 if ($ model ->document === null ) {
4646 $ model ->error = 'NOT_FOUND ' ;
4747 } else {
48- $ flags = $ model ->document ->getOptionsBitmask ();
49-
5048 $ model ->comments = Comment::getAll (
5149 Comment::PARENT_TYPE_DOCUMENT ,
5250 $ model ->document_id
5351 );
5452
5553 $ 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 ( );
5856 $ model ->title = $ model ->document ->getTitle ();
5957
6058 if ($ router ->getRequestMethod () == 'POST ' ) {
@@ -63,7 +61,7 @@ public function &run(Router &$router, View &$view, array &$args) {
6361 }
6462
6563 $ view ->render ($ model );
66- $ model ->_responseCode = ($ model ->acl_allowed ? 200 : 403 );
64+ $ model ->_responseCode = ($ model ->acl_allowed ? 200 : 401 );
6765 return $ model ;
6866 }
6967
@@ -102,31 +100,19 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
102100 $ model ->document ->setTitle ($ model ->title );
103101 $ model ->document ->setMarkdown ($ model ->markdown );
104102 $ 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 );
113104
114- $ success = $ model ->document ->save ();
105+ $ model ->document ->incrementEdited ();
106+ $ model ->document ->commit ();
107+ $ model ->error = false ;
115108
116109 } catch (QueryException $ e ) {
117110
118111 // SQL error occurred. We can show a friendly message to the user while
119112 // also notifying this problem to staff.
120113 Logger::logException ($ e );
121-
122- $ success = false ;
123-
124- }
125-
126- if (!$ success ) {
127114 $ model ->error = 'INTERNAL_ERROR ' ;
128- } else {
129- $ model ->error = false ;
115+
130116 }
131117
132118 Logger::logEvent (
@@ -136,7 +122,7 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
136122 json_encode ([
137123 'error ' => $ model ->error ,
138124 'document_id ' => $ model ->document_id ,
139- 'options_bitmask ' => $ model ->document ->getOptionsBitmask (),
125+ 'options_bitmask ' => $ model ->document ->getOptions (),
140126 'title ' => $ model ->document ->getTitle (),
141127 'content ' => $ model ->document ->getContent (false ),
142128 ])
0 commit comments