Пример #1
0
 public static function display()
 {
     if (isset($_POST['submit_user_edit_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_user_edit_account'])) {
             new EditFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $bAdminLogged = AdminCore::auth() && !User::auth();
     // Check if the admin is logged.
     $oUserModel = new UserModel();
     $oHR = new Http();
     $iProfileId = $bAdminLogged && $oHR->getExists('profile_id') ? $oHR->get('profile_id', 'int') : (new Session())->get('member_id');
     $oUser = $oUserModel->readProfile($iProfileId);
     // Birth Date with the date format for the date picker
     $sBirthDate = (new CDateTime())->get($oUser->birthDate)->date('m/d/Y');
     $oForm = new \PFBC\Form('form_user_edit_account');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_user_edit_account', 'form_user_edit_account'));
     $oForm->addElement(new \PFBC\Element\Token('edit_account'));
     if ($bAdminLogged && $oHR->getExists('profile_id')) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="m_button" href="' . Uri::get(PH7_ADMIN_MOD, 'user', 'browse') . '">' . t('Back to Browse Users') . '</a></p>'));
         $oGroupId = (new AdminCoreModel())->getMemberships();
         $aGroupName = array();
         foreach ($oGroupId as $oId) {
             // Retrieve only the activated memberships
             if ($oId->enable == 1) {
                 $aGroupName[$oId->groupId] = $oId->name;
             }
         }
         $oForm->addElement(new \PFBC\Element\Select(t('Membership Group:'), 'group_id', $aGroupName, array('value' => $oUser->groupId, 'required' => 1)));
         unset($aGroupName);
     }
     unset($oHR);
     $oForm->addElement(new \PFBC\Element\Textbox(t('First Name:'), 'first_name', array('id' => 'str_first_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oUser->firstName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_first_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Last Name:'), 'last_name', array('id' => 'str_last_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oUser->lastName, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_last_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Username:'******'username', array('description' => t('For site security, you cannot change your username.'), 'disabled' => 'disabled', 'value' => $oUser->username)));
     $oForm->addElement(new \PFBC\Element\Email(t('Email:'), 'mail', array('description' => t('For site security and to avoid spam, you cannot change your email address.'), 'disabled' => 'disabled', 'value' => $oUser->email)));
     $oForm->addElement(new \PFBC\Element\Radio(t('Gender:'), 'sex', array('female' => t('Female'), 'male' => t('Male'), 'couple' => t('Couple')), array('value' => $oUser->sex, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Checkbox(t('Interested in:'), 'match_sex', array('male' => t('Male'), 'female' => t('Female'), 'couple' => t('Couple')), array('value' => Form::getVal($oUser->matchSex), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Date(t('Date of birth:'), 'birth_date', array('id' => 'birth_date', 'onblur' => 'CValid(this.value, this.id)', 'value' => $sBirthDate, 'validation' => new \PFBC\Validation\BirthDate(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error birth_date"></span>'));
     // Generate dynamic fields
     $oFields = $oUserModel->getInfoFields($iProfileId);
     foreach ($oFields as $sColumn => $sValue) {
         $oForm = (new DynamicFieldCoreForm($oForm, $sColumn, $sValue))->generate();
     }
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script><script src="' . PH7_URL_STATIC . PH7_JS . 'geo/autocompleteCity.js"></script>'));
     $oForm->render();
 }
 public function __construct()
 {
     parent::__construct();
     $oUserModel = new UserModel();
     $iProfileId = AdminCore::auth() && !User::auth() && $this->httpRequest->getExists('profile_id') ? $this->httpRequest->get('profile_id', 'int') : $this->session->get('member_id');
     $oUser = $oUserModel->readProfile($iProfileId);
     // For Admins only!
     if (AdminCore::auth() && !User::auth() && $this->httpRequest->getExists('profile_id')) {
         if (!$this->str->equals($this->httpRequest->post('group_id'), $oUser->groupId)) {
             $oUserModel->updateMembership($this->httpRequest->post('group_id'), $iProfileId);
         }
     }
     if (!$this->str->equals($this->httpRequest->post('first_name'), $oUser->firstName)) {
         $oUserModel->updateProfile('firstName', $this->httpRequest->post('first_name'), $iProfileId);
         $this->session->set('member_first_name', $this->httpRequest->post('first_name'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'firstName' . $iProfileId . 'Members', null)->clear();
     }
     if (!$this->str->equals($this->httpRequest->post('last_name'), $oUser->lastName)) {
         $oUserModel->updateProfile('lastName', $this->httpRequest->post('last_name'), $iProfileId);
     }
     if (!$this->str->equals($this->httpRequest->post('sex'), $oUser->sex)) {
         $oUserModel->updateProfile('sex', $this->httpRequest->post('sex'), $iProfileId);
         $this->session->set('member_sex', $this->httpRequest->post('sex'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'sex' . $iProfileId . 'Members', null)->clear();
     }
     // WARNING: Be careful, you should use the \PH7\Framework\Mvc\Request\Http::ONLY_XSS_CLEAN constant, otherwise the Request\Http::post() method removes the special tags
     // and damages the SET function SQL for entry into the database.
     if (!$this->str->equals($this->httpRequest->post('match_sex', Http::ONLY_XSS_CLEAN), $oUser->matchSex)) {
         $oUserModel->updateProfile('matchSex', Form::setVal($this->httpRequest->post('match_sex', Http::ONLY_XSS_CLEAN)), $iProfileId);
     }
     if (!$this->str->equals($this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'), $oUser->birthDate)) {
         $oUserModel->updateProfile('birthDate', $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'), $iProfileId);
     }
     // Update dynamic fields.
     $oFields = $oUserModel->getInfoFields($iProfileId);
     foreach ($oFields as $sColumn => $sValue) {
         $sHRParam = $sColumn == 'description' ? Http::ONLY_XSS_CLEAN : null;
         if (!$this->str->equals($this->httpRequest->post($sColumn, $sHRParam), $sValue)) {
             $oUserModel->updateProfile($sColumn, $this->httpRequest->post($sColumn, $sHRParam), $iProfileId, 'MembersInfo');
         }
     }
     unset($oFields);
     $oUserModel->setLastEdit($iProfileId);
     /*** Clear caches ***/
     $oUserCache = new User();
     $oUserCache->clearReadProfileCache($iProfileId);
     $oUserCache->clearInfoFieldCache($iProfileId);
     // Destroy objects
     unset($oUserModel, $oUser, $oUserCache);
     \PFBC\Form::setSuccess('form_user_edit_account', t('Your profile has been saved successfully!'));
 }
Пример #3
0
 public static function display()
 {
     if (isset($_POST['submit_avatar'])) {
         if (\PFBC\Form::isValid($_POST['submit_avatar'])) {
             new AvatarFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_avatar', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_avatar', 'form_avatar'));
     $oForm->addElement(new \PFBC\Element\Token('avatar'));
     if (AdminCore::auth() && !User::auth()) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="m_button" href="' . Uri::get(PH7_ADMIN_MOD, 'user', 'browse') . '">' . t('Back to Browse Users') . '</a></p>'));
     }
     $oForm->addElement(new \PFBC\Element\File(t('Your Avatar'), 'avatar', array('accept' => 'image/*', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 public function __construct()
 {
     parent::__construct();
     $this->_bAdminLogged = AdminCore::auth() && !User::auth();
     $this->_iProfileId = (int) ($this->_bAdminLogged && $this->httpRequest->getExists('profile_id')) ? $this->httpRequest->get('profile_id') : $this->session->get('member_id');
     $this->_sUsername = $this->_bAdminLogged && $this->httpRequest->getExists('username') ? $this->httpRequest->get('username') : $this->session->get('member_username');
     $this->_sFirstName = $this->_bAdminLogged && $this->httpRequest->getExists('first_name') ? $this->httpRequest->get('first_name') : $this->session->get('member_first_name');
     $this->_sSex = $this->_bAdminLogged && $this->httpRequest->getExists('sex') ? $this->httpRequest->get('sex') : $this->session->get('member_sex');
     /** For the avatar on the index and avatar page **/
     $this->view->username = $this->_sUsername;
     $this->view->first_name = $this->_sFirstName;
     $this->view->sex = $this->_sSex;
     $this->view->avatarDesign = new AvatarDesignCore();
     // Avatar Design Class
     /** For the wallpaper on the index and design page **/
     $this->view->path_img_background = $this->_getWallpaper();
     /** For the 'display_status' function on the index and privacy page **/
     $this->design->addJs(PH7_LAYOUT . PH7_SYS . PH7_MOD . $this->registry->module . PH7_SH . PH7_TPL . PH7_TPL_MOD_NAME . PH7_SH . PH7_JS, 'common.js');
 }
Пример #5
0
 public function __construct()
 {
     parent::__construct();
     $iApproved = AdminCore::auth() || DbConfig::getSetting('avatarManualApproval') == 0 ? '1' : '0';
     if (AdminCore::auth() && !User::auth() && $this->httpRequest->getExists(array('profile_id', 'username'))) {
         $iProfileId = $this->httpRequest->get('profile_id');
         $sUsername = $this->httpRequest->get('username');
     } else {
         $iProfileId = $this->session->get('member_id');
         $sUsername = $this->session->get('member_username');
     }
     $bAvatar = (new UserCore())->setAvatar($iProfileId, $sUsername, $_FILES['avatar']['tmp_name'], $iApproved);
     if (!$bAvatar) {
         \PFBC\Form::setError('form_avatar', Form::wrongImgFileTypeMsg());
     } else {
         $sModerationText = t('Your avatar has been received! But it will be visible once approved by our moderators. Please do not send a new avatar because this is useless!');
         $sText = t('Your avatar has been updated successfully!');
         $sMsg = $iApproved == '0' ? $sModerationText : $sText;
         \PFBC\Form::setSuccess('form_avatar', $sMsg);
     }
 }
 public function __construct()
 {
     parent::__construct();
     $iApproved = AdminCore::auth() || DbConfig::getSetting('profileBackgroundManualApproval') == 0 ? '1' : '0';
     if (AdminCore::auth() && !User::auth() && $this->httpRequest->getExists(array('profile_id', 'username'))) {
         $iProfileId = $this->httpRequest->get('profile_id');
         $sUsername = $this->httpRequest->get('username');
     } else {
         $iProfileId = $this->session->get('member_id');
         $sUsername = $this->session->get('member_username');
     }
     $bWallpaper = (new UserCore())->setBackground($iProfileId, $sUsername, $_FILES['wallpaper']['tmp_name'], $iApproved);
     if (!$bWallpaper) {
         \PFBC\Form::setError('form_design', Form::wrongImgFileTypeMsg());
     } else {
         $sModerationText = t('Your Wallpaper has been received! But it will not be visible until it is approved by our moderators. Please do not send a new not.');
         $sText = t('Your Wallpaper has been updated successfully!');
         $sMsg = DbConfig::getSetting('profileBackgroundManualApproval') ? $sModerationText : $sText;
         \PFBC\Form::setSuccess('form_design', $sMsg);
     }
 }
Пример #7
0
    }
    protected function edit()
    {
        $this->_bStatus = $this->_oWallModel->edit($this->session->get('member_id'), $this->httpRequest->post('post'));
        if (!$this->_bStatus) {
            $this->_sMsg = jsonMsg(0, t('Oops, your post could not be saved. Please try again later.'));
        } else {
            $this->_sMsg = jsonMsg(1, t('Your post was saved successfully!'));
        }
        echo $this->_sMsg;
    }
    protected function delete()
    {
        $this->_bStatus = $this->_oWallModel->delete($this->session->get('member_id'), $this->httpRequest->post('post'));
        if (!$this->_bStatus) {
            $this->_sMsg = jsonMsg(0, t('Your post could not be deleted because there no exist.'));
        } else {
            $this->_sMsg = jsonMsg(1, t('Your post has been sent successfully!'));
        }
        echo $this->_sMsg;
    }
    public function __destruct()
    {
        parent::__destruct();
        unset($this->_oWallModel, $this->_oAvatarDesign, $this->_sMsg, $this->_bStatus);
    }
}
// Only for the members
if (User::auth()) {
    new WallAjax();
}
Пример #8
0
 public function __construct()
 {
     parent::__construct();
     $this->sUserAuth = User::auth();
 }
Пример #9
0
<?php

/**
 * @author         Pierre-Henry Soria <*****@*****.**>
 * @copyright      (c) 2012-2015, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Module / User / Asset / Ajax / Popup
 */
namespace PH7;

defined('PH7') or exit('Restricted access');
use PH7\Framework\Layout\Html\Design;
// Show the form only if nobody is logged!
if (!User::auth()) {
    // Ok nobody no one is connected, it displays the login form box!
    $oDesign = new Design();
    $oDesign->htmlHeader();
    $oDesign->usefulHtmlHeader();
    JoinForm::step1();
    $oDesign->htmlFooter();
}