use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\option\user\UserOptionHandler;
use wcf\system\style\StyleHandler;
use wcf\system\user\command\SetColorScheme;
use wcf\system\user\multifactor\Setup;
+use wcf\system\user\signature\SignatureCache;
use wcf\system\WCF;
use wcf\util\StringUtil;
if (!UserGroup::isAccessibleGroup($this->user->getGroupIDs())) {
throw new PermissionDeniedException();
}
+ $this->attachmentObjectID = $this->user->userID;
parent::readParameters();
}
public function save()
{
AbstractForm::save();
+ $this->htmlInputProcessor->setObjectID($this->userID);
+ MessageEmbeddedObjectManager::getInstance()->registerObjects($this->htmlInputProcessor);
// handle avatar
if ($this->avatarType != 'custom') {
'languageID' => $this->languageID,
'userTitle' => $this->userTitle,
'signature' => $this->htmlInputProcessor->getHtml(),
+ 'signatureEnableHtml' => 1,
'styleID' => $this->styleID,
]),
'groups' => $this->groupIDs,
'languageIDs' => $this->visibleLanguages,
'options' => $saveOptions,
+ 'signatureAttachmentHandler' => $this->attachmentHandler,
];
// handle changed username
if (\mb_strtolower($this->username) != \mb_strtolower($this->user->username)) {
// reload user
$this->user = new UserEditor(new User($this->userID));
+ SignatureCache::getInstance()->getSignature($this->user->getDecoratedObject());
// show success message
WCF::getTPL()->assign('success', true);
namespace wcf\system\attachment;
+use wcf\data\user\group\UserGroup;
use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\WCF;
*/
public function canDownload($objectID)
{
+ if (!MODULE_USER_SIGNATURE) {
+ return false;
+ }
if ($objectID) {
$userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
- if (!MODULE_USER_SIGNATURE) {
- return false;
+ if ($this->canEditUser($userProfile)) {
+ return true;
}
if ($userProfile->disableSignature) {
return false;
return true;
}
- return false;
+ return $this->canAddUser();
}
/**
*/
public function canUpload($objectID, $parentObjectID = 0)
{
- if (!$objectID || $objectID != WCF::getUser()->userID) {
+ if (!MODULE_USER_SIGNATURE) {
return false;
}
- if (!MODULE_USER_SIGNATURE) {
+ if (!$objectID) {
+ return $this->canAddUser();
+ }
+ $userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
+ if ($this->canEditUser($userProfile)) {
+ return true;
+ }
+
+ if ($objectID != WCF::getUser()->userID) {
return false;
}
- $userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
if ($userProfile->disableSignature) {
return false;
}
}
}
}
+
+ private function canAddUser(): bool
+ {
+ return WCF::getSession()->getPermission('admin.user.canAddUser');
+ }
+
+ private function canEditUser(UserProfile $userProfile): bool
+ {
+ return WCF::getSession()->getPermission('admin.user.canEditUser')
+ && UserGroup::isAccessibleGroup($userProfile->getGroupIDs());
+ }
}