XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
ImageUploadAction.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_MODULE_PATH . '/legacy/admin/actions/ImageEditAction.class.php';
17require_once XOOPS_MODULE_PATH . '/legacy/forms/ImageUploadForm.class.php';
18
19/***
20 * @internal
21 */
23{
24 public $mCategory = null;
25
26 public function prepare(&$controller, &$xoopsUser)
27 {
28 parent::prepare($controller, $xoopsUser);
29 $controller->setDialogMode(true);
30
31 $root =& $controller->mRoot;
32 $root->mLanguageManager->loadModuleMessageCatalog('legacy');
33 }
34
35 public function &_getHandler()
36 {
37 $handler =& xoops_getmodulehandler('image', 'legacy');
38 return $handler;
39 }
40
41 public function _setupObject()
42 {
43 $this->mObjectHandler =& $this->_getHandler();
44 $this->mObject =& $this->mObjectHandler->create();
45 $this->mObject->set('imgcat_id', xoops_getrequest('imgcat_id'));
46 }
47
48 public function _setupActionForm()
49 {
50 $this->mActionForm =new Legacy_ImageUploadForm();
51 $this->mActionForm->prepare();
52 }
53
54 public function hasPermission(&$controller, &$xoopsUser)
55 {
56 $groups = [];
57 if (is_object($xoopsUser)) {
58 $groups = $xoopsUser->getGroups();
59 } else {
60 $groups = [XOOPS_GROUP_ANONYMOUS];
61 }
62
63 $handler =& xoops_getmodulehandler('imagecategory', 'legacy');
64 $this->mCategory =& $handler->get(xoops_getrequest('imgcat_id'));
65 if (!is_object($this->mCategory) || (is_object($this->mCategory) && !$this->mCategory->hasUploadPerm($groups))) {
66 return false;
67 }
68
69 return true;
70 }
71
72 public function executeViewInput(&$controller, &$xoopsUser, &$render)
73 {
74 $render->setTemplateName('legacy_image_upload.html');
75 $render->setAttribute('actionForm', $this->mActionForm);
76 $render->setAttribute('object', $this->mObject);
77
78 $render->setAttribute('category', $this->mCategory);
79 $render->setAttribute('target', xoops_getrequest('target'));
80 }
81
82 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
83 {
84 $controller->executeForward(XOOPS_URL . '/imagemanager.php?imgcat_id=' . $this->mActionForm->get('imgcat_id') . '&target=' . xoops_getrequest('target'));
85 }
86
87 public function executeViewError(&$controller, &$xoopsUser, &$render)
88 {
89 redirect_header(XOOPS_URL . '/imagemanager.php', 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
90 }
91}