OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Adding fields in a existing table

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Adding fields in a existing table

Postby rafaelmr » Thu Feb 09, 2006 9:58 am

Hi OJSers,

I would like to add in the table users the fields "city", "state", "zipcode" and "country". I created the fields in MySQL and I tried to update the follow files:
classes/user/User.inc.php
classes/user/UserDAO.inc.php

I begin doing this to add the functions and others things referring to the new fields, but after this, I can't loggin the OJS. After login the display was empty.
I updated the file dbscripts/xml/ojs_schema.xml and executed php tools/upgrade.php upgrade

What files I need to change to add this fields?

Thanks.
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby asmecher » Thu Feb 09, 2006 11:09 am

Hi Rafael,

When you say you can't log in, what specifically do you see? Is it a blank page (which is often caused by a PHP typo), a login failure message, or some other error message?

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Postby rafaelmr » Fri Feb 10, 2006 4:39 am

Hi Alec,

It's a blank page...

Regards.
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby asmecher » Fri Feb 10, 2006 11:46 am

Hi Rafael,

In my experience, blank pages are almost always caused by PHP typos. Check your server's error log to see if there's any information there, and then try backing out your modified versions of UserDAO.inc.php and User.inc.php and re-adding your changes step by step until you find out what causes the problem.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Postby rafaelmr » Mon Feb 13, 2006 9:50 am

Thank you Alec, I checked my server's log and I found an error and it was correct. But I change the news fields in respectives templates too, but they don't write the datas of them in the table.

Regards.
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby asmecher » Mon Feb 13, 2006 4:50 pm

Hi Rafael,

You'll need to change the appropriate form class, too -- see classes/user/form/ProfileForm.inc.php.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Postby rafaelmr » Tue Feb 14, 2006 7:54 am

Thank you Alec, I can insert datas in fields now.

Regards.
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby rafaelmr » Thu Feb 16, 2006 11:29 am

Hi Alec,

I create 4 new fields (state, zipcode, city, country). I change the classes/pages/templates that were necessary, but when I create a new user, those fields don't record. But if manager or new user edit theirs profiles, the fields are recorded. Can you help me?

Regards.
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby asmecher » Thu Feb 16, 2006 11:53 am

Hi Rafael,

Do you mean the registration form? See classes/user/form/RegistrationForm.inc.php.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Postby rafaelmr » Fri Feb 17, 2006 5:06 am

Hi Alec,

Yes, I updated the RegistrationForm.inc.php (we want those fields like required):

Code: Select all
function RegistrationForm() {
...
    if ($this->existingUser) {
        ...
    } else {
        ...
        $this->addCheck(new FormValidator($this, 'city', 'required', 'user.profile.form.cityRequired'));
   $this->addCheck(new FormValidator($this, 'state', 'required', 'user.profile.form.stateRequired'));
   $this->addCheck(new FormValidator($this, 'zipCode', 'required', 'user.profile.form.zipCodeRequired'));
   $this->addCheck(new FormValidator($this, 'country', 'required', 'user.profile.form.countryRequired'));
    }
}

function readInputData() {
    $this->readUserVars(
         array(
            'username', 'password', 'password2',
            'firstName', 'middleName', 'lastName', 'initials',
            'affiliation', 'email', 'phone', 'fax',
            'mailingAddress', 'city', 'state', 'zipCode', 'country',
            'biography', 'interests', 'userLocales',
            'registerAsReader', 'registerAsAuthor',
                                'registerAsReviewer', 'existingUser'
         )
      );

function execute() {
   if ($this->existingUser) {
                ...
        } else {
             $user->setCity($this->getData('city'));
      $user->setState($this->getData('state'));
      $user->setZipCode($this->getData('zipCode'));
      $user->setCountry($this->getData('country'));
                ...
        }


Regards,
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby asmecher » Fri Feb 17, 2006 10:30 am

Hi Rafael,

Check your additions to ProfileForm again -- that last change should be:
Code: Select all
} else {
        // New user
        $user = &new User();

        $user->setCity($this->getData('city'));
        $user->setState($this->getData('state'));
        $user->setZipCode($this->getData('zipCode'));
        $user->setCountry($this->getData('country'));
        ...
Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Postby rafaelmr » Mon Feb 20, 2006 10:40 am

Hi Alec,

I checked the ProfileForm and I can't find any error. I changed the follow files:

classes/user/User.inc.php
classes/user/UserDAO.inc.php
classes/user/form/ProfileForm.inc.php
classes/user/form/RegistrationForm.inc.php
classes/user/form/UserManagementForm.inc.php

pages/manager/PeopleHandler.inc.php

templates/user/register.tpl
templates/user/profile.tpl
templates/manager/people/userProfile.tpl
templates/manager/people/userProfileForm.tpl


When I update a user that exists (Edit Profile) or with the manager, the fields are updated without problems. But when I register a new user, those fields don't record.

Regards,
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby rafaelmr » Tue Feb 21, 2006 7:12 am

Hi Alec,

I re-made the actions classes of register and now they are recording. I can't understand yet what was happening, but thank you for your help.

Regards,
rafaelmr
 
Posts: 13
Joined: Fri Jan 06, 2006 10:50 am

Postby asmecher » Tue Feb 21, 2006 10:24 am

Hi Rafael,

Glad to hear it's working.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron