Subversion Repositories oidplus

Rev

Rev 1279 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1279 Rev 1293
Line 172... Line 172...
172
         */
172
         */
173
        private function raMayUpload() {
173
        private function raMayUpload() {
174
                return OIDplus::config()->getValue('attachments_allow_ra_upload', 0);
174
                return OIDplus::config()->getValue('attachments_allow_ra_upload', 0);
175
        }
175
        }
176
 
176
 
-
 
177
 
177
        /**
178
        /**
178
         * @param string $actionID
-
 
179
         * @param array $params
179
         * @param array $params
180
         * @return array
180
         * @return array
181
         * @throws OIDplusException
181
         * @throws OIDplusException
182
         */
182
         */
183
        public function action(string $actionID, array $params): array {
183
        private function action_Delete(array $params): array {
184
 
-
 
185
                if ($actionID == 'deleteAttachment') {
-
 
186
                        _CheckParamExists($params, 'id');
184
                _CheckParamExists($params, 'id');
187
                        $id = $params['id'];
185
                $id = $params['id'];
188
                        $obj = OIDplusObject::parse($id);
186
                $obj = OIDplusObject::parse($id);
189
                        if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
187
                if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
190
                        if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA of "%1" to upload an attachment.',$id), null, 401);
188
                if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA of "%1" to upload an attachment.',$id), null, 401);
Line 220... Line 218...
220
                        }
218
                }
221
 
219
 
222
                        OIDplus::logger()->log("V2:[OK]OID(%1)+[OK/INFO]OIDRA(%1)+[OK/INFO]A", "Deleted attachment '%2' from object '%1'", $id, basename($uploadfile));
220
                OIDplus::logger()->log("V2:[OK]OID(%1)+[OK/INFO]OIDRA(%1)+[OK/INFO]A", "Deleted attachment '%2' from object '%1'", $id, basename($uploadfile));
223
 
221
 
224
                        return array("status" => 0);
222
                return array("status" => 0);
-
 
223
        }
225
 
224
 
-
 
225
        /**
-
 
226
         * @param array $params
-
 
227
         * @return array
-
 
228
         * @throws OIDplusException
-
 
229
         */
226
                } else if ($actionID == 'uploadAttachment') {
230
        private function action_Upload(array $params): array {
227
                        _CheckParamExists($params, 'id');
231
                _CheckParamExists($params, 'id');
228
                        $id = $params['id'];
232
                $id = $params['id'];
229
                        $obj = OIDplusObject::parse($id);
233
                $obj = OIDplusObject::parse($id);
230
                        if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
234
                if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
231
                        if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA of "%1" to upload an attachment.',$id), null, 401);
235
                if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA of "%1" to upload an attachment.',$id), null, 401);
Line 306... Line 310...
306
                        }
310
                }
307
 
311
 
308
                        OIDplus::logger()->log("V2:[OK]OID(%1)+[OK/INFO]OIDRA(%1)+[OK/INFO]A", "Uploaded attachment '%2' to object '%1'", $id, basename($uploadfile));
312
                OIDplus::logger()->log("V2:[OK]OID(%1)+[OK/INFO]OIDRA(%1)+[OK/INFO]A", "Uploaded attachment '%2' to object '%1'", $id, basename($uploadfile));
309
 
313
 
310
                        return array("status" => 0);
314
                return array("status" => 0);
-
 
315
        }
-
 
316
 
-
 
317
        /**
-
 
318
         * @param string $actionID
-
 
319
         * @param array $params
-
 
320
         * @return array
-
 
321
         * @throws OIDplusException
-
 
322
         */
-
 
323
        public function action(string $actionID, array $params): array {
-
 
324
                if ($actionID == 'deleteAttachment') {
-
 
325
                        return $this->action_Delete($params);
-
 
326
                } else if ($actionID == 'uploadAttachment') {
-
 
327
                        return $this->action_Upload($params);
311
                } else {
328
                } else {
312
                        return parent::action($actionID, $params);
329
                        return parent::action($actionID, $params);
313
                }
330
                }
314
        }
331
        }
315
 
332