Skip to content

Commit

Permalink
add email to required profile fields by default
Browse files Browse the repository at this point in the history
  • Loading branch information
thyseus committed Mar 31, 2014
1 parent 2bc162b commit 936ffca
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/profile/ProfileModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ProfileModule extends CWebModule {
public $adminLayout = 'profile.views.layouts.yum';
public $layout = 'profile.views.layouts.yum';

public $requiredProfileFields = array('firstname', 'lastname');
public $requiredProfileFields = array('email', 'firstname', 'lastname');

public $profileRules = array(
array('email', 'unique'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ public function actionRegistration() {
Yum::setFlash('Thank you for your registration. Please check your email.');
$this->redirect(Yum::module()->loginUrl);
}
}
}

$this->render(Yum::module()->registrationView, array(
'form' => $form,
'profile' => $profile,
)
);
);
}

// Send the Email to the given user object.
Expand Down
4 changes: 3 additions & 1 deletion modules/registration/models/YumRegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function rules()
{
$rules = parent::rules();

$rules[] = array('username', 'required');
if(!(Yum::hasModule('registration') && Yum::module('registration')->registration_by_email))
$rules[] = array('username', 'required');

$rules[] = array('newsletter, terms', 'safe');
// password requirement is already checked in YumUser model, its sufficient
// to check for verifyPassword here
Expand Down
8 changes: 4 additions & 4 deletions modules/user/controllers/YumTranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function actionUpdate($category = null, $message = null, $language = null
{
$models = array();
foreach(Yum::getAvailableLanguages() as $language) {
$models[] = $this->loadModel($category, $message, $language);
$models[] = $this->loadTranslation($category, $message, $language);
}

if(isset($_POST['YumTranslation'])) {
Expand Down Expand Up @@ -78,7 +78,7 @@ public function actionDelete($id)
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel($id)->delete();
$this->loadTranslation($id)->delete();

// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
Expand All @@ -100,7 +100,7 @@ public function actionAdmin()
));
}

public function loadModel($category, $message, $language = null)
public function loadTranslation($category, $message, $language = null)
{
$model=YumTranslation::model()->find('category = :category and message = :message and language = :language', array(
':category' => $category,
Expand All @@ -117,7 +117,7 @@ public function loadModel($category, $message, $language = null)
return $model;
}

protected function performAjaxValidation($model)
protected function performAjaxValidation($model, $form)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='translation-form')
{
Expand Down
10 changes: 7 additions & 3 deletions modules/user/models/YumUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,14 @@ public function rules() {

$rules[] = array('username', 'unique',
'message' => Yum::t('This username already exists'));

$rules[] = array('status', 'in', 'range' => array(0, 1, 2, 3, -1, -2));
$rules[] = array('superuser', 'in', 'range' => array(0, 1));
$rules[] = array('username, createtime, lastvisit, lastpasswordchange, superuser, status', 'required');

if(!(Yum::hasModule('registration') && Yum::module('registration')->registration_by_email))
$rules[] = array('username', 'required');

$rules[] = array('createtime, lastvisit, lastpasswordchange, superuser, status', 'required');
$rules[] = array('notifyType, avatar', 'safe');
$rules[] = array('password', 'required', 'on' => array('insert', 'registration'));
$rules[] = array('createtime, lastvisit, lastaction, superuser, status', 'numerical', 'integerOnly' => true);
Expand All @@ -259,7 +263,7 @@ public function rules() {
}


if (Yum::hasModule('role'))
if (Yum::hasModule('role'))
$rules[] = array('filter_role', 'safe');

return $rules;
Expand Down

0 comments on commit 936ffca

Please sign in to comment.