function __construct($template, $subscriptionId = null, $userId = null)
{
parent::__construct($template);
$subscriptionId = isset($subscriptionId) ? (int) $subscriptionId : null;
$this->userId = isset($userId) ? (int) $userId : null;
$this->subscription = null;
$this->subscriptionTypes = null;
$subscriptionDao = DAORegistry::getDAO('SubscriptionDAO');
$this->validStatus =& $subscriptionDao->getStatusOptions();
$countryDao = DAORegistry::getDAO('CountryDAO');
$this->validCountries =& $countryDao->getCountries();
// User is provided and valid
$this->addCheck(new FormValidator($this, 'userId', 'required', 'manager.subscriptions.form.userIdRequired'));
$this->addCheck(new FormValidatorCustom($this, 'userId', 'required', 'manager.subscriptions.form.userIdValid', create_function('$userId', '$userDao = DAORegistry::getDAO(\'UserDAO\'); return $userDao->userExistsById($userId);')));
// User name, country, and url valid
$this->addCheck(new FormValidator($this, 'userFirstName', 'required', 'user.profile.form.firstNameRequired'));
$this->addCheck(new FormValidator($this, 'userLastName', 'required', 'user.profile.form.lastNameRequired'));
$this->addCheck(new FormValidatorUrl($this, 'userUrl', 'optional', 'user.profile.form.urlInvalid'));
$this->addCheck(new FormValidatorInSet($this, 'userCountry', 'optional', 'manager.subscriptions.form.countryValid', array_keys($this->validCountries)));
// Subscription status is provided and valid
$this->addCheck(new FormValidator($this, 'status', 'required', 'manager.subscriptions.form.statusRequired'));
$this->addCheck(new FormValidatorInSet($this, 'status', 'required', 'manager.subscriptions.form.statusValid', array_keys($this->validStatus)));
// Subscription type is provided
$this->addCheck(new FormValidator($this, 'typeId', 'required', 'manager.subscriptions.form.typeIdRequired'));
// Notify email flag is valid value
$this->addCheck(new FormValidatorInSet($this, 'notifyEmail', 'optional', 'manager.subscriptions.form.notifyEmailValid', array('1')));
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}