Автор: Svel (svel.sontz@gmail.com)
Наследование: extends BaseFormDoctrine
Пример #1
0
 */
$editUserObj = null;
switch ($userObj->getType()) {
    case AMA_TYPE_STUDENT:
    case AMA_TYPE_AUTHOR:
        $editUserObj =& $userObj;
        break;
    case AMA_TYPE_SWITCHER:
        $userId = DataValidator::is_uinteger($_POST['id_utente']);
        if ($userId !== false) {
            $editUserObj = MultiPort::findUser($userId);
        }
        break;
}
if (!is_null($editUserObj) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $form = new UserProfileForm($languages);
    $form->fillWithPostData();
    if ($form->isValid()) {
        $user_layout = $_POST['layout'];
        $editUserObj->fillWithArrayData($_POST);
        // save extra datas if it has been forced
        if (isset($_POST['forceSaveExtra']) && $editUserObj->hasExtra()) {
            $editUserObj->setExtras($_POST);
        }
        MultiPort::setUser($editUserObj, array(), true, ADAUser::getExtraTableName());
        /**
         * Set the session user to the saved one if it's not
         * a switcher, that is not saving its own profile
         */
        if ($userObj->getType() != AMA_TYPE_SWITCHER) {
            $_SESSION['sess_userObj'] = $editUserObj;
Пример #2
0
        header("Location: edit_author.php?message={$message}");
        exit;
    }
    if ($form->isValid()) {
        $userObj->fillWithArrayData($_POST);
        MultiPort::setUser($userObj, array(), true);
        /* unset $_SESSION['service_level'] to reload it with the correct user language translation */
        unset($_SESSION['service_level']);
        $help = translateFN('Dati salvati');
        /*$navigationHistoryObj = $_SESSION['sess_navigation_history'];
          $location = $navigationHistoryObj->lastModule();
          header('Location: ' . $location);
          exit();*/
    }
} else {
    $form = new UserProfileForm($languages);
    $user_dataAr = $userObj->toArray();
    unset($user_dataAr['password']);
    $user_dataAr['email'] = $user_dataAr['e_mail'];
    unset($user_dataAr['e_mail']);
    $form->fillWithArrayData($user_dataAr);
    $help = translateFN('Modifica dati utente');
}
$label = translateFN('Modifica dati utente');
$layout_dataAr['JS_filename'] = array(JQUERY, JQUERY_UI, JQUERY_MASKEDINPUT, JQUERY_NO_CONFLICT, ROOT_DIR . '/js/include/jquery/pekeUpload/pekeUpload.js');
$layout_dataAr['CSS_filename'] = array(JQUERY_UI_CSS, ROOT_DIR . '/js/include/jquery/pekeUpload/pekeUpload.css');
$maxFileSize = (int) (ADA_FILE_UPLOAD_MAX_FILESIZE / (1024 * 1024));
$optionsAr['onload_func'] = 'initDoc(' . $maxFileSize . ',' . $userObj->getId() . ');';
// $optionsAr['onload_func'] = 'initDateField();';
/*
 * Display error message  if the password is incorrect
Пример #3
0
 /**
  * If the user is a switcher, can edit confirmation state of student
  */
 $allowEditConfirm = $userObj->getType() == AMA_TYPE_SWITCHER;
 $user_dataAr = $editUserObj->toArray();
 if ($userObj->getType() == AMA_TYPE_AUTHOR || $userObj->getType() == AMA_TYPE_TUTOR) {
     header('Location: ' . $userObj->getEditProfilePage());
     exit;
 }
 // the standard UserProfileForm is always needed.
 // Let's create it
 if ($userObj->tipo == AMA_TYPE_STUDENT && $self_instruction) {
     $self = whoami();
     //allowing to build action form
 }
 $form = new UserProfileForm($languages, $allowEditProfile, $allowEditConfirm, $self . '.php');
 unset($user_dataAr['password']);
 $user_dataAr['email'] = $user_dataAr['e_mail'];
 unset($user_dataAr['e_mail']);
 $form->fillWithArrayData($user_dataAr);
 if (!$editUserObj->hasExtra()) {
     // user has no extra, let's display it
     $data = $form->render();
 } else {
     require_once ROOT_DIR . '/include/HtmlLibrary/UserExtraModuleHtmlLib.inc.php';
     // the extra UserExtraForm is needed as well
     require_once ROOT_DIR . '/include/Forms/UserExtraForm.inc.php';
     $extraForm = new UserExtraForm($languages);
     $extraForm->fillWithArrayData($user_dataAr);
     $tabContents = array();
     /**
 /**
  * Сохранить: эмулируем Рамблер
  */
 public function testSaveRambler()
 {
     $_SERVER['HTTP_HOST'] = 'https://rambler.ef.test';
     $input = array('name' => 'Дядя Федор', 'user_service_mail' => 'unique.mail');
     $user = $this->helper->makeUser($input);
     $form = new UserProfileForm($user);
     $expected = $input;
     unset($expected['user_service_mail']);
     $expected['id'] = $user->getId();
     $form->bind($input);
     $this->assertFormIsValid($form);
     $user = $form->save();
     $this->assertEquals(1, $this->queryFind('User', $expected)->count(), 'Expected found 1 object (rambler-User)');
 }
 public function configure()
 {
     parent::configure();
     $this->widgetSchema['avatar'] = new sfWidgetFormInputFileEditable(array('label' => 'Avatar', 'file_src' => '/uploads/users/avatars/' . $this->getObject()->getAvatar(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete% %delete_label%</div>'));
     $this->validatorSchema['avatar_delete'] = new sfValidatorPass();
 }
Пример #6
0
     }
 } else {
     $userId = DataValidator::is_uinteger($_GET['id_user']);
     if ($userId === false) {
         $data = new CText('Utente non trovato');
     } else {
         $editedUserObj = MultiPort::findUser($userId);
         $formData = $editedUserObj->toArray();
         $formData['email'] = $formData['e_mail'];
         unset($formData['e_mail']);
         /**
          * @author giorgio 29/mag/2013
          *
          * added parameters to force allowEditConfirm
          */
         $data = new UserProfileForm(array(), false, true);
         $data->fillWithArrayData($formData);
     }
 }
 $label = translateFN('Modifica utente');
 $help = translateFN('Da qui il provider admin può modificare il profilo di un utente esistente');
 if (!is_null($editedUserObj)) {
     $label .= ': ' . $editedUserObj->getUserName() . ' (' . $editedUserObj->getFullName() . ')';
 }
 $layout_dataAr['JS_filename'] = array(JQUERY, JQUERY_MASKEDINPUT, JQUERY_NO_CONFLICT);
 $optionsAr['onload_func'] = 'initDateField();';
 /*
  * Display error message  if the password is incorrect
  */
 if (isset($_GET['message'])) {
     $help = $_GET['message'];