esotalk / esoTalk

Fat-free forum software.
GNU General Public License v2.0
1.47k stars 237 forks source link

Error saving settings when display image is selected returns upload error #348

Closed amdrade closed 9 years ago

amdrade commented 9 years ago

Checking the option to show image at the top, choosing the image and saving after returning to the settings screen you must send the picture again if you want to make some other change

amdrade commented 9 years ago

My proposed solution in ../core/controllers/admin/ETSettingsAdminController.class.php changes the type checking forumHeader

    if ($form->validPostBack("save")) {
        $forumHeader = false;
        if ($form->getValue("forumHeader") == "image"){
            if ($form->getValue("forumHeaderOld") != "image"){
                $forumHeader = $this->uploadHeaderImage($form);
            }else{
                $forumHeader = !empty($_FILES["forumHeaderImage"]['tmp_name']) ? $this->uploadHeaderImage($form) : C("esoTalk.forumLogo");
            }
        }

        // Construct an array of config options to write.
        $config = array(
            "esoTalk.forumTitle" => $form->getValue("forumTitle"),
            "esoTalk.language" => $form->getValue("language"),
            //"esoTalk.forumLogo" => $form->getValue("forumHeader") == "image" ? $this->uploadHeaderImage($form) : false,
            "esoTalk.forumLogo" => $forumHeader,
            "esoTalk.defaultRoute" => $form->getValue("defaultRoute"),
            "esoTalk.visibleToGuests" => $form->getValue("forumVisibleToGuests"),
            "esoTalk.members.visibleToGuests" => $form->getValue("forumVisibleToGuests") and $form->getValue("memberListVisibleToGuests"),
            "esoTalk.registration.open" => $form->getValue("registrationOpen"),
            "esoTalk.registration.requireConfirmation" => in_array($v = $form->getValue("requireConfirmation"), array(false, "email", "approval")) ? $v : false,
        );

and in ../core/views/admin/settings.php add the input $form->input("forumHeaderOld", "hidden", array("value" => $form->values['forumHeader'])); if a new configuration, try to send the image, the image was chosen replace if not keep the previous

tvb commented 9 years ago

It is easier for @tobscure to make a pull request for this.

tvb commented 9 years ago

I noticed this myself few days back. Kind of an annoying issue. Thank you for the pull-request.

tvb commented 9 years ago

Duplicate with https://github.com/esotalk/esoTalk/issues/328