|
|
@@ -126,10 +126,33 @@ class BxBaseFormAccount extends BxTemplFormView
|
|
|
|
|
|
protected $_bSetPendingApproval = false;
|
|
|
|
|
|
+ protected $_sGhostTemplate = 'account_form_ghost_template.html';
|
|
|
+
|
|
|
public function __construct($aInfo, $oTemplate)
|
|
|
{
|
|
|
parent::__construct($aInfo, $oTemplate);
|
|
|
+
|
|
|
$this->_bSetPendingApproval = !(bool)getParam('sys_account_autoapproval');
|
|
|
+
|
|
|
+ if(($sField = 'picture') && isset($this->aInputs[$sField])) {
|
|
|
+ /**
|
|
|
+ * Note. For now Account Picture is available in edit form only.
|
|
|
+ * To make it available on create form Uploader should correctly support
|
|
|
+ * uploading by visitor.
|
|
|
+ */
|
|
|
+ if($this->aParams['display'] == 'sys_account_settings_info')
|
|
|
+ $this->aInputs[$sField] = array_merge($this->aInputs[$sField], [
|
|
|
+ 'storage_object' => 'sys_accounts_pictures',
|
|
|
+ 'uploaders' => !empty($this->aInputs[$sField]['value']) ? unserialize($this->aInputs[$sField]['value']) : ['sys_crop'],
|
|
|
+ 'images_transcoder' => 'sys_accounts_thumb',
|
|
|
+ 'storage_private' => 0,
|
|
|
+ 'multiple' => false,
|
|
|
+ 'content_id' => 0,
|
|
|
+ 'ghost_template' => ''
|
|
|
+ ]);
|
|
|
+ else
|
|
|
+ unset($this->aInputs[$sField]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function isValid ()
|
|
|
@@ -175,6 +198,20 @@ class BxBaseFormAccount extends BxTemplFormView
|
|
|
return ($this->_bSetPendingApproval = $b);
|
|
|
}
|
|
|
|
|
|
+ public function initChecker ($aValues = [], $aSpecificValues = [])
|
|
|
+ {
|
|
|
+ $bValues = $aValues && !empty($aValues['id']);
|
|
|
+
|
|
|
+ if(($sField = 'picture') && isset($this->aInputs[$sField])) {
|
|
|
+ if($bValues)
|
|
|
+ $this->aInputs[$sField]['content_id'] = $aValues['id'];
|
|
|
+
|
|
|
+ $this->aInputs[$sField]['ghost_template'] = $this->oTemplate->parseHtmlByName($this->_sGhostTemplate, $this->_getGhostTmplVars($sField));
|
|
|
+ }
|
|
|
+
|
|
|
+ parent::initChecker($aValues, $aSpecificValues);
|
|
|
+ }
|
|
|
+
|
|
|
public function insert ($aValsToAdd = array(), $isIgnore = false)
|
|
|
{
|
|
|
$iNow = time();
|
|
|
@@ -255,6 +292,41 @@ class BxBaseFormAccount extends BxTemplFormView
|
|
|
return $bResult;
|
|
|
}
|
|
|
|
|
|
+ public function processFiles($sFieldFile, $iAccountId = 0, $isAssociateWithContent = false)
|
|
|
+ {
|
|
|
+ if (!isset($this->aInputs[$sFieldFile]))
|
|
|
+ return true;
|
|
|
+
|
|
|
+ $mixedFileIds = $this->getCleanValue($sFieldFile);
|
|
|
+ if(!$mixedFileIds)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ $oStorage = BxDolStorage::getObjectInstance($this->aInputs[$sFieldFile]['storage_object']);
|
|
|
+ if (!$oStorage)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ $iProfileId = 0;
|
|
|
+ if($iAccountId && ($aAccountInfo = BxDolAccountQuery::getInstance()->getInfoById($iAccountId)))
|
|
|
+ $iProfileId = $aAccountInfo['profile_id'];
|
|
|
+ else
|
|
|
+ $iProfileId = bx_get_logged_profile_id();
|
|
|
+
|
|
|
+ $aGhostFiles = $oStorage->getGhosts ($iProfileId, $isAssociateWithContent ? 0 : $iAccountId, true, $this->_isAdmin());
|
|
|
+ if(!empty($aGhostFiles) && is_array($aGhostFiles))
|
|
|
+ foreach($aGhostFiles as $aFile) {
|
|
|
+ if(is_array($mixedFileIds) && !in_array($aFile['id'], $mixedFileIds))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if($aFile['private'])
|
|
|
+ $oStorage->setFilePrivate ($aFile['id'], 1);
|
|
|
+
|
|
|
+ if($iAccountId)
|
|
|
+ $oStorage->updateGhostsContentId ($aFile['id'], $iProfileId, $iAccountId, $this->_isAdmin());
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
protected function genCustomInputAgreement ($aInput)
|
|
|
{
|
|
|
$oPermalink = BxDolPermalinks::getInstance();
|
|
|
@@ -265,6 +337,23 @@ class BxBaseFormAccount extends BxTemplFormView
|
|
|
{
|
|
|
$this->aInputs['do_submit']['error'] = $s;
|
|
|
}
|
|
|
+
|
|
|
+ protected function _isAdmin()
|
|
|
+ {
|
|
|
+ return BxDolAcl::getInstance()->isMemberLevelInSet([MEMBERSHIP_ID_MODERATOR, MEMBERSHIP_ID_ADMINISTRATOR]);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function _getGhostTmplVars($sField)
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ 'name' => $this->aInputs[$sField]['name'],
|
|
|
+ 'content_id' => $this->aInputs[$sField]['content_id'],
|
|
|
+ 'bx_if:set_thumb' => [
|
|
|
+ 'condition' => false,
|
|
|
+ 'content' => [],
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** @} */
|