Page 1 of 1

CompanyDirectory FE Edit goes to admin/login.php on submit

Posted: Sun Dec 16, 2012 9:06 am
by curlypinky
I am in a serious bind, I really need help.
I have CompanyDirectory installed with about 110 companies. Each company is tied to a FrontEndUser so they can edit their company listing. I tested it to make sure users could easily change their own company listing and update their account information. Everything looked good, and the site was made live. Now the submit action is suddenly behaving very strangely:

I have a Protected Content page that with content:
{CompanyDirectory action="frontendlist"}

This displays the list of companies attached to the user and the edit link.

Clicking Edit will take the user to index.php?mact=CompanyDirectory,cntnt01,fe_edit2,0&cntnt01companyid=57&cntnt01returnid=63

It populates the form data and you can edit the fields. Press submit and all the sudden you end up at /admin/login.php

Click browser Back - changes to text areas are saved, the fax field data is copied into the telephone field (if fax is NULL then the phone number is also blanked), checkbox custom field values will not save but dropdown types will.

I tried switching back to a default fe_edit template but I'm getting the same behavior. I don't have any errors in the error log, no errors are displayed.

I have also tried {CompanyDirectory action="frontendlist"} on a default Simplex template page using a default fe_edit template. Editing the listing then hitting submit returns you to the page with the companies list and shows that the company has been edited BUT any changes to checkbox fields are not saved and telephone is being written with whatever is in Fax.
It's a mess :(
I don't know what to do. I also tried replacing all the files of CompanyDirectory with a fresh download, no joy.

----------------------------------------------

Cms Version: 1.11.3

Installed Modules:

CMSMailer: 5.2.1
CMSPrinting: 1.0.3
FileManager: 1.4.2
MenuManager: 1.8.4
MicroTiny: 1.2.4
ModuleManager: 1.5.5
News: 2.12.10
Search: 1.7.7
ThemeManager: 1.1.7
TemplateExternalizer: 2.0.8
TinyMCE: 2.9.12
CGSimpleSmarty: 1.5.2
CGExtensions: 1.31.2
JQueryTools: 1.1.1
CompanyDirectory: 1.16.2
FrontEndUsers: 1.21
NeoModule: 0.5.0
NeoContentOps: 0.1.0
MysqlDump: 1.2.4
CGSmartImage: 1.9.5
CGCalendar: 1.10.0.1
FEUMailer: 0.9.4


Config Information:

php_memory_limit:
process_whole_template:
output_compression:
max_upload_size: 24000000
url_rewriting: mod_rewrite
page_extension:
query_var: page
image_manipulation_prog: GD
auto_alias_content: true
locale:
default_encoding: utf-8
admin_encoding: utf-8
set_names: true


Php Information:

phpversion: 5.2.17
md5_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_STRICT: 0
memory_limit: 64M
max_execution_time: 600
output_buffering: On
safe_mode: Off (False)
file_uploads: On (True)
post_max_size: 24M
upload_max_filesize: 24M
session_save_path: /tmp (1777)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)


Server Information:

Server Api: cgi
Server Db Type: MySQL (mysqli)
Server Db Version: 5.0.96
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable


----------------------------------------------

Re: CompanyDirectory FE Edit goes to admin/login.php on subm

Posted: Sun Dec 16, 2012 10:31 am
by curlypinky
I just figured out the problem with the phone and fax fields and the checkbox fields!

For the phone and fax issue, the default Add/Edit a Frontend Form Template has 2 instances of telephone:

Code: Select all

<div class="pagerow">
  <p class="rowtext">{$CompanyDirectory->Lang('telephone')}:</p>
  <p class="rowinput">
    <input type="text" name="{$actionid}cd_telephone" value="{$the_company->telephone}" size="20" maxlength="20"/>
  </p>
</div>
<div class="pagerow">
  <p class="rowtext">{$CompanyDirectory->Lang('fax')}:</p>
  <p class="rowinput">
    <input type="text" name="{$actionid}cd_telephone" value="{$the_company->telephone}" size="20" maxlength="20"/>
  </p>
</div>
Should be:

Code: Select all

<div class="pagerow">
  <p class="rowtext">{$CompanyDirectory->Lang('telephone')}:</p>
  <p class="rowinput">
    <input type="text" name="{$actionid}cd_telephone" value="{$the_company->telephone}" size="20" maxlength="20"/>
  </p>
</div>
<div class="pagerow">
  <p class="rowtext">{$CompanyDirectory->Lang('fax')}:</p>
  <p class="rowinput">
    <input type="text" name="{$actionid}cd_fax" value="{$the_company->fax}" size="20" maxlength="20"/>
  </p>
</div>
For the checkbox fields - when a company is edited via the Admin area the checkbox value is stored as either "true" or "false". But the default value through feu edit form is "1" and if it is edited through the feu edit form it only passes a value if the box is checked - if a checkbox is unchecked then no value is supplied to over-write the true value so once that box is checked, the value will always be true, even if you try to clear it. The easiest solution I could come up with is to put a hidden field before the checkbox of the same name to set the value to false by default. It then checks what is currently stored in the db and will check the box if it is currently true and keep the value set properly on save.
In Add/Edit a Frontend Form Template:

Code: Select all

        <input type="hidden" name="{$actionid}cd_field_7" value="false">
        <input type="checkbox" name="{$actionid}cd_field_7" value="true" {if $the_company->get_field(7)->value=="true"}checked="checked"{/if}/> Wholesale<br />
        <input type="hidden" name="{$actionid}cd_field_8" value="false">
        <input type="checkbox" name="{$actionid}cd_field_8" value="true" {if $the_company->get_field(8)->value=="true"}checked="checked"{/if}/> Retail<br /> 
So that takes care of 2 big issues. Company data is now saving. I am still wrestling with this weird redirection to the admin/login.php screen when you submit on the frontend edit screen. It saves but you end up at the admin area login instead of returning to the page you started from.

Re: CompanyDirectory FE Edit goes to admin/login.php on subm

Posted: Sun Dec 16, 2012 11:09 am
by curlypinky
Some more info, if I have an active Admin session going in the browser I do not get redirected to the admin login screen. So I am beginning to think this might be a bug?

Steps:
1. Make sure you are not logged into the Admin area
2. Login as a feuser to your directory feuser area
3. Edit a company
4. Click submit - it will take you to the admin/login.php screen
5. Click browser Back and reload, you can see your changes were saved

Next, login to the Admin then repeat steps 2-4. When you hit submit you will be returned to your originating page with the frontendlist.

Looking at the admin log it seems like the feu edit action is being tied to the active admin session:

Admin Log Entry:
[ip address] [admin_username] CompanyDirectory Edited company [Company Name] via the frontend (FEU id = 1)

I am thinking that should not be?

Thanks,
Alane