*/
protected $worker = null;
+ public static $allowInvoke = array();
+
/**
* @see wcf\action\IAction::readParameters()
*/
throw new SystemException("'".$this->className."' does not extend 'wcf\system\SingletonFactory'");
}
- $this->actionObject = call_user_func(array($this->className, 'getInstance'));
-
// validate action name
- if (empty($this->actionName) || !method_exists($this->actionObject, $this->actionName)) {
+ if (empty($this->actionName)) {
throw new UserInputException('actionName');
}
+ // validate accessibility
+ $className = $this->className;
+ if (!property_exists($className, 'allowInvoke') || !in_array($this->actionName, $className::$allowInvoke)) {
+ throw new PermissionDeniedException();
+ }
+
+ $this->actionObject = call_user_func(array($this->className, 'getInstance'));
+
+ // check for validate method
+ $validateMethod = 'validate'.ucfirst($this->actionName);
+ if (method_exists($this->actionObject, $this->actionName)) {
+ $this->actionObject->{$validateMethod}();
+ }
+
$this->response = $this->actionObject->{$this->actionName}();
}
namespace wcf\system\importer;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\exception\SystemException;
+use wcf\system\IAJAXInvokeAction;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
* @subpackage system.importer
* @category Community Framework
*/
-class ImportHandler extends SingletonFactory {
+class ImportHandler extends SingletonFactory implements IAJAXInvokeAction {
/**
* id map cache
* @var array
*/
protected $userMergeMode = 2;
+ /**
+ * list of methods allowed for remote invoke
+ * @var array<string>
+ */
+ public static $allowInvoke = array('resetMapping');
+
/**
* @see wcf\system\SingletonFactory::init()
*/
unset($this->idMappingCache[$objectTypeID][$oldID]);
}
+ /**
+ * Validates accessibility of resetMapping().
+ */
+ public function validateResetMapping() {
+ WCF::getSession()->checkPermissions(array('admin.system.canImportData'));
+ }
+
/**
* Resets the mapping.
*/
* @category Community Framework
*/
class UserCollapsibleSidebarHandler extends SingletonFactory implements IAJAXInvokeAction {
+ /**
+ * list of methods allowed for remote invoke
+ * @var array<string>
+ */
+ public static $allowInvoke = array('toggle');
+
/**
* Toggles a sidebar.
*/