[Module] Yii User Management Module

Thyseus,

Thanks for your interest…

I Did the installation on a Fresh Application created to understand this Module.

I’ve managed to overcome installation difficulties reading Forum and debugging, I even offered a few lines above my fixes for all issues encountered (I’ve registered those “helps” in Google Code Issues too).

After follow each one of “implementing a registration process using the YUM” tutorial, two links were shown as a result in Login Page: “register” and “Password Recovery” (The information on how to activate additional modules like Register is missing on RC5, so i took it from RC4 install_tutorial.txt)

At the tutorial you modify Registration Page after copying the default one in Views/Registration, But when i press Register Link the original page is shown instead the modified page. That’s what I mean when I say 'But the “registration” procedure it’s working as default. ’

I hope this helps to understand my problem…

Thanks again.

E.

Thyseus,

After spending several hours following step by step Yii running till get the point where the class imported, I found where the issue was.

It’s actually not an “issue” per se. But dependent on Yii default configuration.

I mean the way UrlManager processes “routes”. One of its properties establishes is the route is Case Sensitive, which by default is set on “true”

Therefore, according tutorial, I tried this configuration:




'registration' => array(


	'registrationUrl'  => array('/registration/registration'),

	'registrationView' => array('/views/registration'),

), 

Then Yii searches the original YUM route.

But, if you configure the route as follow:




'registration' => array(

	'registrationUrl'  => array('/Registration/registration'),

	'registrationView' => array('/views/registration'),

),



Where R is uppercase, Yii searches the customized registration YUM route. I’m not knowledgeable enough to explain, I just know once modification was done, I’ve achieved the expected tutorial result.

I apologize if it’s an obvious thing for Yii veterans. :)

E.

oh, now i understand the problem. It is even different:

there is a name mismatch with the word "registration". The module and the controller is called "registration", so yii does not

know which controller should be choosen. Another, maybe “more correct” solution would be to use //registration/registration/registration as a route ;)

(which reads as "module registration, controller registration, action registration")

Thyseus,

I tried:




'registration' => array(

        'registrationUrl'  => array('//registration/registration/registration'),

        'registrationView' => array('/views/registration'),

),

as I understand your suggerence, but this doesn’t work… I got a 404 :

In addition, if I try to use “captcha”, the route to get the image is registration/captcha instead Registration/captcha… I copied the “actions” function to RegisterController.php, but doesn’t work. (the url is in lowcase :S )

Please, guide me to the light :)

Thyseus,

I finally made it work

After your last reply I had the idea where was the problem.Indeed, if you follow step by step you tutorial Yii always ends running “Original” code not “Inherited” code.

I Just changed my “Class” name and all involved files.

It Worked Perfect…

However, I would really like to know if this is a “theoretical error” (due to my lack of OOP Knowledge) or just simply a tutorial miss interpretation… or Both?

I can see that: in the “original code” you have a RegistrationController. In the tutorial, I created a new one… If I don’t configure the module (in main.php) Yii resolves the original RegistrationController, until I indicate ‘Register/register’ (if you use lowcase, or get a 404 or Yii resolves your original Controller). When use the “camel case”, Yii use “my” controller, but the captcha (for instance) is “routed” to ‘register/captcha’ and the image isn’t displayed.

But, when I change the name of the controller to MyRegistrationController, and where I read "Registration" I changed to "MyRegistration" related to class or view, and I indicate in the main.php "myRegistration/registration"… all works like a charm…

Thanks in advanced for any additional enlightment :)

Hi,

I’ve install yii-user-management everything seems ok.

But when i browse to this page index.php?r=messages/messages/index, i got this error

include(YumActiveRecord.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory

I’m using themes for my development design and i’ve encoutered this issue: YUM assumes that path for views are located in “application.views.etc”. How can i tell YUM to use development’s layout in use?

I clue is: Yii::app()->theme->baseUrl.'views.layouts.main, but is not a good idea to modify the modules code…

The definitive Guide (http://www.yiiframework.com/doc/guide/1.1/en/topics.theming) has no

problems with placing view themes directly into the module:

Or, you could extend from the YumUserController and specify your own theme directory outside of the modules/ directory.


class MyProjectSpecificUserController extends YumUserController { 

...

}

If you have any idea on how we could make using yum with themes easier "out of the box"- let me know.

And if you are interesting in creating some “default themes” for yum - please also let me know ;)

Thyseus,

Thanks for your suggestion, my question is may be kind of "basic"…

Where to do I have to "inherite" YumUserController?.. In a file like MyYumController.php in /protected/controllers?

Do I have to change this?:




.....

	'components' => array(

    	'user' => array(

        	// enable cookie-based authentication

        	'class' => 'application.modules.user.components.YumWebUser',

        	'allowAutoLogin' => true,

        	'loginUrl' => array('//user/user/login'),

    	),

......



I’m trying to provide “change/edit” the pages templates to the user, with normalized sections then store the colors, fonts, div coordinates and some other parameters in a table and then “create” the theme tree folder whit the needed files inside (*.php, *.css, images…)

It’s a ‘feature’, a ‘toy’ (I know)… But I’ll need some guide from you to “understand” how to keep your code isolated from mine… In this way, I think, both will be beneficed: your YUM as a module, and my “toy” (in the near future, I hope) as an extension or module or (who knows) for your and others future use.

THANKS!!! a lot for your answers… And my appologies if I’m “bothering you” with my questions :)

E.

Ok, i try to explain it as easy as possible:

The YumUserController has all its views under webroot/app/protected/modules/user/views/user/ . As you said correctly, you can

create your own project-specific User controller in the /webroot/app/controllers folder. This would look like this:


Yii::import('application.modules.user.controllers.YumUserController');


class MyUserController extends YumUserController { 


// nice stuff here


}

Now, all views are automatically read from the /webroot/app/views/user/ folder. You can copy all views from yum in there

and you have an isolated views directory where you can change whatever you like.

I suggest you also read my small guide about modifying the yii user management registration system, cause its a similar technique used in there: http://www.yiiframework.com/wiki/195/implementing-a-registration-process-using-the-yii-user-management-module

I hope i solved all your questions, if not, let me know ;)

Thyseus,

I did as you advised me (I followed the tutorial weeks ago)…

I was able to "inherit" the class YumUserController…

I modified my Controller.php class in protected/components (oh! yeah… I’m a bad boy :P) then I’ve “centralized” the theme assignment…

There I wrote this:




  public function beforeAction($action) {

	Yii::app()->theme='XXXX'; // XXXX it's the name of the theme: webroot/themes/XXXX

	return parent::beforeAction($action);

  }



The "theme" is used in all my controllers…

But, MyUserController inherits from YumUserController, this inherits from YumController and this from Yii/framework/web/controller.php

So, Yum never knows about my "controller".

I don’t know if this is expected or I’m missing something… Again, my apologies :)

PS: I wrote beforeAction in MyUserController and there I set the values of layout properties… But now I’m trying to get all in one place… Now is when I need you guide :)

PS2: After doing this, though I managed to assign another view to YUM, it turns that should inherit all classes given that when i read actionLogin:


$this->layout = Yum::module()->loginLayout;

the default value or the config file value is assigned…

I do not have to much OOP knowledge to figure out this logic’s path, I do not understand neither why YumController inherits from controller framework and not from component (perhaps because it’s an application inside another, isn’t?).

If I could achieve this in just one place, I could do it in all and in this way accomplish both target: “out of the box” YUM themes and me being able to apply this… But it’s vital your advice.

In the mean time I’ll keep trying to see the way to get it work… Once again, sorry to bother you with my obsession and ignorance… :)

I have created two different tables in my database for the member login which will contain all the user details

How do I integrate it with the yii user management i.e. when some logs in using yum they should be able to see their data form these two tables and be able to modify it.

The two tables will have relations with other tables also.

You may use YUM to allow or not access to the views of that tables and then relate YUM users table with the one you already have.

After doing so, check that YUM has profile control and you can even add custom fields.

That way, i guess, your User table and its data wil be taken by what YUM it’s already providing.

I’m not a YUM expert, but those will be my steps to solve your concern :)

I hope it helps…

Hi Guys!

I installed the YUM, on a yii fresh install.

I was trying out the registration form. I filled all the fields I try to submit it, then I got in the error summary: "E-Mail cannot be blank." but there is not on the these field i have filled.

So, is it a bug? or is just me using this Module wrong?

something about the config?

hope hearing from you any suggestion, I’m all ears.




return array(

    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

    'name' => 'My Web Application',

    // preloading 'log' component

    'preload' => array('log'),

    // autoloading model and component classes

    'import' => array(

        'application.models.*',

        'application.components.*',

    ),

    'modules' => array(

        'user' => array(

            'debug' => false,

            'usersTable' => 'user',

            'translationTable' => 'translation',

        ),

        'registration' => array(),

        'usergroup' => array(

            'usergroupTable' => 'user_group',

            'usergroupMessagesTable' => 'user_group_message',

        ),

        'membership' => array(

            'membershipTable' => 'membership',

            'paymentTable' => 'payment',

        ),

        'friendship' => array(

            'friendshipTable' => 'friendship',

        ),

        'profile' => array(

            'privacySettingTable' => 'privacy_setting',

            'profileFieldsGroupTable' => 'profile_field_group',

            'profileFieldsTable' => 'profile_field',

            'profileTable' => 'profile',

            'profileCommentTable' => 'profile_comment',

            'profileVisitTable' => 'profile_visit',

        ),

        'role' => array(

            'rolesTable' => 'role',

            'userHasRoleTable' => 'user_role',

            'actionTable' => 'action',

            'permissionTable' => 'permission',

        ),

        'messages' => array(

            'messagesTable' => 'message',

        ),    

    ),

    // application components

    'components' => array(

        'user' => array(

// enable cookie-based authentication

            'class' => 'application.modules.user.components.YumWebUser',

            'allowAutoLogin' => true,

            'loginUrl' => array('//user/user/login'),

            'allowAutoLogin' => true,

        ),

        // uncomment the following to enable URLs in path-format


        'urlManager' => array(

            'urlFormat' => 'path',

            'rules' => array(

                '<controller:\w+>/<id:\d+>' => '<controller>/view',

                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

            ),

        ),

        'db' => array(

            'tablePrefix' => '',

            'connectionString' => 'mysql:host=localhost;dbname=mydata',

            'emulatePrepare' => true,

            'username' => 'root',

            'password' => '',

            'charset' => 'utf8',

        ),

        'errorHandler' => array(

// use 'site/error' action to display errors

            'errorAction' => 'site/error',

        ),

        'log' => array(

            'class' => 'CLogRouter',

            'routes' => array(

                array(

                    'class' => 'CFileLogRoute',

                    'levels' => 'error, warning',

                ),

            // uncomment the following to show log messages on web pages

            /*

              array(

              'class'=>'CWebLogRoute',

              ),

             */

            ),

        ),

    ),

    // application-level parameters that can be accessed

// using Yii::app()->params['paramName']

    'params' => array(

// this is used in contact page

        'adminEmail' => 'webmaster@example.com',

    ),

);

Best Regards, Oliver.

Hi Oliver,

the field ‘email’ in the profile field configuration is set to ‘required’. There are three solutions so this:

1.) Add a field ‘email’ to your registration page

2.) Make the field email non-required

3.) Remove the email field from the profile field configuration

The Profile field configuration can be found in the Admin Menu. Log in as admin/admin, go

to index.php?r=user/admin. In the menu to the right there should be a option ‘profiles’ and

‘profile field configuration’.

Of course, its problematic when the field email exists and is required in the example configuration. Thanks for pointing this problem out.

I will add the email field to the distribution.

btw: if you are further interested in the development of yum i suggest you visit the google code

repository: http://code.google.com/p/yii-user-management

Thanks thyseus,

I’ll fix this my own thanks for your reply, I would like to help you too.

I think i’ll be using this extension in several projects. so is good to keep working well

Thanks Again.

Best Regards,

Oliver.

Hi,

I’m getting this error.

Error#1:

Fatal error: Call to a member function getFriends() on a non-object in F:\Program Files\wamp\www\testdrive\protected\modules\friendship\controllers\YumFriendshipController.php on line 147

URL: index.php?r=profile/profile/view

It’s on my fresh installation.

I just configured according to your install_tutorial.txt

Still I’m getting this error.

As I figured it out in YumFriendshipController.php




public static function invitationLink($inviter, $invited) {

		if($inviter === $invited)

			return false;

		if(!is_object($inviter))

			$inviter = YumUser::model()->findByPk($inviter); // ERROR IS HERE

		if(!is_object($invited))

			$invited = YumUser::model()->findByPk($invited);


		$friends = $inviter->getFriends(true);

		if($friends && $friends[0] != NULL)

			foreach($friends as $friend) 

				if($friend->id == $invited->id)

					return false; // already friends, rejected or request pending


		return CHtml::link(Yum::t('Add as a friend'), array(

					'friendship/invite', 'user_id' => $invited->id));

	}



i am facing a problem Property "CWebUser.registrationUrl" is not defined.

I have a question: how can I add a role automatically after payment done by a user in YUM ? for example:


if( $payement == 'ok' )

   //add role "premium" to current logged in user

else 

   $this->render( 'error' , array( 'status' => 'payment failed' ) );

thanks in advanced

Where can we submit patches?