public function __construct($aInfo, $oTemplate = false) { parent::__construct($aInfo, $oTemplate); $CNF =& $this->_oModule->_oConfig->CNF; if (!empty($CNF['FIELD_PICTURE'])) { $this->_aImageFields[$CNF['FIELD_PICTURE']] = array('storage_object' => $CNF['OBJECT_STORAGE'], 'images_transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'], 'field_preview' => $CNF['FIELD_PICTURE_PREVIEW']); } if (!empty($CNF['FIELD_COVER'])) { $this->_aImageFields[$CNF['FIELD_COVER']] = array('storage_object' => $CNF['OBJECT_STORAGE_COVER'], 'images_transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_COVER_THUMB'], 'field_preview' => $CNF['FIELD_COVER_PREVIEW']); } if (!empty($CNF['FIELD_PICTURE_PREVIEW'])) { $this->_aImageFields[$CNF['FIELD_PICTURE_PREVIEW']] = $this->_aImageFields[$CNF['FIELD_PICTURE']]; } if (!empty($CNF['FIELD_COVER_PREVIEW'])) { $this->_aImageFields[$CNF['FIELD_COVER_PREVIEW']] = $this->_aImageFields[$CNF['FIELD_COVER']]; } $oAccountProfile = BxDolProfile::getInstanceAccountProfile(); if ($oAccountProfile) { $this->_iAccountProfileId = $oAccountProfile->id(); } }
public function actionDeleteProfileImg($iFileId, $iContentId, $sFieldPicture) { $aResult = array(); $CNF =& $this->_oConfig->CNF; $oSrorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']); if (!($aFile = $oSrorage->getFile((int) $iFileId)) || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)) || $aContentInfo[$sFieldPicture] != (int) $iFileId) { $aResult = array('error' => 1, 'msg' => _t('_sys_storage_err_file_not_found')); } $oAccountProfile = BxDolProfile::getInstanceAccountProfile(); if ($oAccountProfile) { $iAccountProfileId = $oAccountProfile->id(); } if (!$aResult && !isLogged() || !$aResult && $aFile['profile_id'] != $iAccountProfileId && !$this->_isModerator()) { $aResult = array('error' => 2, 'msg' => _t('_Access denied')); } $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate); if (!$aResult && !$oForm->_deleteFile($iContentId, $sFieldPicture, (int) $iFileId, true)) { $aResult = array('error' => 3, 'msg' => _t('_Failed')); } elseif (!$aResult) { $aResult = array('error' => 0, 'msg' => ''); } header('Content-Type: application/json; charset=utf-8'); echo json_encode($aResult); }
/** * Delete profile. * @param $ID - optional profile id to delete * @param $bForceDelete - force deletetion is case of account profile deletion * @return false on error, or true on success */ function delete($ID = false, $bForceDelete = false) { $ID = (int) $ID; if (!$ID) { $ID = $this->_iProfileID; } $aProfileInfo = $this->_oQuery->getInfoById($ID); if (!$aProfileInfo) { return false; } // delete system profiles (accounts) is not allowed, instead - delete whole account if (!$bForceDelete && 'system' == $aProfileInfo['type']) { return false; } // switch profile context if deleted profile is active profile context bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($aProfileInfo['account_id']); $aAccountInfo = $oAccount->getInfo(); if (!$bForceDelete && $ID == $aAccountInfo['profile_id']) { $oProfileAccount = BxDolProfile::getInstanceAccountProfile($aProfileInfo['account_id']); $oAccount->updateProfileContext($oProfileAccount->id()); } // create system event before deletion $isStopDeletion = false; bx_alert('profile', 'before_delete', $ID, 0, array('stop_deletion' => &$isStopDeletion)); if ($isStopDeletion) { return false; } // delete associated comments bx_import('BxDolCmts'); BxDolCmts::onAuthorDelete($ID); // delete connections bx_import('BxDolConnection'); $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends'); $oConn->onDeleteInitiatorAndContent($ID); $oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions'); $oConn->onDeleteInitiatorAndContent($ID); // delete profile's acl levels bx_import('BxDolAcl'); BxDolAcl::getInstance()->onProfileDelete($ID); // delete profile if (!$this->_oQuery->delete($ID)) { return false; } // create system event bx_alert('profile', 'delete', $ID); // unset class instance to prevent creating the instance again $this->_iProfileID = 0; $sClass = get_class($this) . '_' . $ID; unset($GLOBALS['bxDolClasses'][$sClass]); return true; }
protected function _editAccountForm($iAccountId, $sDisplayName) { $oAccount = BxDolAccount::getInstance($iAccountId); $aAccountInfo = $oAccount ? $oAccount->getInfo() : false; if (!$aAccountInfo) { return MsgBox(_t('_sys_txt_error_account_is_not_defined')); } // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedEdit($this->_iProfileId, $aAccountInfo))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance('sys_account', $sDisplayName); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } if (!$oForm->isSubmitted()) { unset($aAccountInfo['password']); } $oForm->initChecker($aAccountInfo); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } $aTrackTextFieldsChanges = array(); // track text fields changes, not-null(for example empty array) - means track, null - means don't track // update email and email setting in DB if (!$oForm->update($aAccountInfo['id'], array(), $aTrackTextFieldsChanges)) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_update')); } } // check if email was changed if (!empty($aTrackTextFieldsChanges['changed_fields']) && in_array('email', $aTrackTextFieldsChanges['changed_fields'])) { $oAccount->updateEmailConfirmed(false); } // mark email as unconfirmed // check if password was changed if ($oForm->getCleanValue('password')) { // relogin with new password bx_logout(); bx_login($aAccountInfo['id']); } // check if other text info was changed - if auto-appproval is off $isAutoApprove = $oForm->isSetPendingApproval() ? false : true; if (!$isAutoApprove) { bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstanceAccountProfile($aAccountInfo['id']); // get profile associated with account, not current porfile $aProfileInfo = $oProfile->getInfo(); unset($aTrackTextFieldsChanges['changed_fields']['email']); // email confirmation is automatic and separate, don't need to deactivate whole profile if email is changed if (BX_PROFILE_STATUS_ACTIVE == $aProfileInfo['status'] && !empty($aTrackTextFieldsChanges['changed_fields'])) { $oProfile->disapprove(BX_PROFILE_ACTION_AUTO); } // change profile to 'pending' only if some text fields were changed and profile is active } // create an alert bx_alert('account', 'edited', $aAccountInfo['id'], $aAccountInfo['id'], array('display' => $sDisplayName)); // display result message $sMsg = MsgBox(_t('_sys_txt_data_successfully_submitted')); return $sMsg . $oForm->getCode(); }
protected function _enable($mixedId, $isChecked) { $iAction = BX_PROFILE_ACTION_MANUAL; $oProfile = BxDolProfile::getInstanceAccountProfile($mixedId); return $isChecked ? $oProfile->activate($iAction) : $oProfile->suspend($iAction); }