[Module] Yii User Management Module

when i try to install on a vanilla yii i get this error

CWebUser does not have a method named "isAdmin".

i fixed the errors and other various errors sprinkled around the module

i added auto detection for webapplicationend to change views via end if enabled

fixed paths correctly, default layouts are now edited in default application location

here are my changes

You should contact thyseus about submitting your changes directly to the repository :slight_smile:

I took a quick look at your changes and they look good.

Also i like the idea of providing a ‘default front and back-end’ in the Yum module that can

be switched off, if you want the module to integrate in the existing Web Application layout. Are there

any skilled backend Designers that likes to do this? (I have my skills in coding, i lack design skills…)

Would be cool to integrate your bugfixes and changes into svn trunk/

Do you know about the repository at http://code.google.com/p/yii-user-management/ ?

Hi great work there, especially for noob like me to understand how modules and submodules works. Not sure below are errors but hope it helps you develop a more refine version.

I just downloaded 0.5 and yii 1.1.1

INSTALLED ON NEW TESTDRIVE

======================================

  1. Created fresh testdrive and the database according InstallTutorial.txt

  1. http://localhost/testdrive/index.php?r=user/install

    CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field ‘match’ doesn’t have a default value

    same goes to range,error_message,other_validator,default,timestamp fields

  2. have to manually add “default ‘0’” to all the fields to go through installation. MySQL ver 5.0.51


  1. login as admin.

  2. click on manage roles

  3. click on UserCreator

Error 404

The system is unable to find the requested action "role".


[s]7) logout

8) access via url testdrive/index.php?r=user/role/role/admin

  1. create role

  2. able to save.[/s]

I logout from the default testdrive menu…not the one under operations menu. I think a note in your installation guide to remind users to change the menu login url is great for new users like myself. Otherwise it cause some frustration login/out and seeing thinks don’t work


  1. Operation Menu -> Manage "p"rofile Fields

======================================

INSTALLED ON EXISTING BLOG DEMO

======================================

When I tried installing this on "blog" demo (with db and tables all created) I got these error:

Error 500

The table "users" for active record class "User" cannot be found in the database.

Please make this installable on blog demo rather than fresh testdrive because it will be a more complete base application for us to understand yii better…


THANK YOU VERY MUCH!!

Hello.

This looks like a very good module. I installed it, but modified the names of the tables and I can’t get it to work.

In the Install Tutorial included, step 7 says:

What and where should I change this for the module to work?

Thank you.

Hello,

I’ve took a brief overview of the extension’s code and it looks really impressive. Congrats for that!

I have the same problem as @transistor. The exception fired is: ‘The table “users” for active record class “User” cannot be found in the database.’

Can we download or checkout the db tables structure, or should we retrieve it from the code or should it be created automatically from the install page?

Thanks in advance!

Regards,

mirrorps

I was having a problem with updating of a user’s Profile. I added an ‘About Me’ profile field with type “TEXT”. When I tried to update the profile field I was getting this error: ‘About Me is too long (maximum is 0 characters).’

The fix for this was to edit user/models/Profile.php around line 45 you need to change:




        if ($field->field_type =='VARCHAR')

                      ||$field->field_type=='TEXT')

        {

                $field_rule = array($field->varname,

                                'length',

                                'max'=>$field->field_size,

                                'min' => $field->field_size_min);


                if ($field->error_message)

                        $field_rule['message'] = Yii::t("UserModule.user", $field->error_message);

                array_push($rules,$field_rule);

        }



To:




        if ($field->field_type =='VARCHAR')

        {

               $field_rule = array($field->varname,

                                'length',

                                'max'=>$field->field_size,

                                'min' => $field->field_size_min);


                if ($field->error_message)

                       $field_rule['message'] = Yii::t("UserModule.user", $field->error_message);

                 array_push($rules,$field_rule);

        }




        if ($field->field_type=='TEXT')

        {

                $field_rule = array($field->varname,

                                'length',

                                'min' => $field->field_size_min);


                if ($field->error_message)

                        $field_rule['message'] = Yii::t("UserModule.user", $field->error_message);

                array_push($rules,$field_rule);

        }



VARCHAR and TEXT fields cannot have the same rules because a Profile Field of type TEXT has the “Max Length” field set to ‘0’ and it is readonly so we cannot edit it.

Hope this helps some people out there.

I found a bunch of other small bugs but can’t remember them all. If you want to give me access to the SVN I will go through a clean install and submit bug fixes for you.

i added some fixes, specifically during install where it would not create the db field.

there were many table fields with {{ prefixing the tables which caused issues so they were removed.

there is a bug in the registration page where ccapthca widget is called not displaying anything, could someone please review this and tell me how you would fix it (im not the best with widgets).

installed on vanilla yii 1.1.2.

I apologize for the bad mistake in the yii-user 0.5 release many people are encountering.

Please take a look on the SVN repository to see what the new yii-user0.6 will bring. I think the overall quality of the module has been improved a lot, and many of these small bugs should have been fixed.

Especially since i got some much appreciated help from Poland :) (see changelog for Credits)

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

Install was easy, I registered a user, everything appears to be running smoothly. Until I went to login as the admin user and I get the following error when visiting /user/user/admin




Source File


/home/hoppin/public_html/framework/base/CComponent.php(237)


00225:      * @since 1.0.2

00226:      */

00227:     public function __call($name,$parameters)

00228:     {

00229:         if($this->_m!==null)

00230:         {

00231:             foreach($this->_m as $object)

00232:             {

00233:                 if($object->getEnabled() && method_exists($object,$name))

00234:                     return call_user_func_array(array($object,$name),$parameters);

00235:             }

00236:         }

00237: throw new CException(Yii::t('yii','{class} does not have a method named "{name}".',

00238:             array('{class}'=>get_class($this), '{name}'=>$name)));

00239:     }

00240: 

00241:     /**

00242:      * Returns the named behavior object.

00243:      * The name 'asa' stands for 'as a'.

00244:      * @param string the behavior name

00245:      * @return IBehavior the behavior object, or null if the behavior does not exist

00246:      * @since 1.0.2

00247:      */

00248:     public function asa($behavior)

00249:     {


Stack Trace


#0 [internal function]: CComponent->__call('hasUsers', Array)

#1 /home/hoppin/public_html/framework/base/CComponent.php(587) : eval()'d code(1): CWebUser->hasUsers()

#2 /home/hoppin/public_html/framework/base/CComponent.php(587): eval()

#3 /home/hoppin/public_html/framework/web/auth/CAccessControlFilter.php(337): CComponent->evaluateExpression('Yii::app()->use...', Array)

#4 /home/hoppin/public_html/framework/web/auth/CAccessControlFilter.php(240): CAccessRule->isExpressionMatched(Object(CWebUser))

#5 /home/hoppin/public_html/framework/web/auth/CAccessControlFilter.php(111): CAccessRule->isUserAllowed(Object(CWebUser), Object(UserController), Object(CInlineAction), '173.65.219.135', 'GET')

#6 /home/hoppin/public_html/framework/web/filters/CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain))

#7 /home/hoppin/public_html/framework/web/CController.php(999): CFilter->filter(Object(CFilterChain))

#8 /home/hoppin/public_html/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))

#9 /home/hoppin/public_html/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))

#10 /home/hoppin/public_html/framework/web/CController.php(283): CFilterChain->run()

#11 /home/hoppin/public_html/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#12 /home/hoppin/public_html/framework/web/CWebApplication.php(320): CController->run('admin')

#13 /home/hoppin/public_html/framework/web/CWebApplication.php(120): CWebApplication->runController('user/user/admin')

#14 /home/hoppin/public_html/framework/base/CApplication.php(135): CWebApplication->processRequest()

#15 /home/hoppin/public_html/index.php(12): CApplication->run()

#16 {main}



Any idea’s what could be causing this? It’s a clean installation of 0.5 w/ a clean Yii framework install.

Ok now the problem is this I do want to mention that this started happening when wiped my 0.5 install and installed 0.6 svn.




CException

Description


CWebUser does not have a method named "isAdmin".

Source File


/home/hoppin/public_html/framework/base/CComponent.php(237)


00225:      * @since 1.0.2

00226:      */

00227:     public function __call($name,$parameters)

00228:     {

00229:         if($this->_m!==null)

00230:         {

00231:             foreach($this->_m as $object)

00232:             {

00233:                 if($object->getEnabled() && method_exists($object,$name))

00234:                     return call_user_func_array(array($object,$name),$parameters);

00235:             }

00236:         }

00237: throw new CException(Yii::t('yii','{class} does not have a method named "{name}".',

00238:             array('{class}'=>get_class($this), '{name}'=>$name)));

00239:     }

00240: 

00241:     /**

00242:      * Returns the named behavior object.

00243:      * The name 'asa' stands for 'as a'.

00244:      * @param string the behavior name

00245:      * @return IBehavior the behavior object, or null if the behavior does not exist

00246:      * @since 1.0.2

00247:      */

00248:     public function asa($behavior)

00249:     {


Stack Trace


#0 [internal function]: CComponent->__call('isAdmin', Array)

#1 /home/hoppin/public_html/protected/modules/user/controllers/YumUserController.php(26): CWebUser->isAdmin()

#2 /home/hoppin/public_html/framework/web/CController.php(998): YumUserController->accessRules()

#3 /home/hoppin/public_html/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))

#4 /home/hoppin/public_html/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))

#5 /home/hoppin/public_html/framework/web/CController.php(283): CFilterChain->run()

#6 /home/hoppin/public_html/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#7 /home/hoppin/public_html/framework/web/CWebApplication.php(320): CController->run('login')

#8 /home/hoppin/public_html/framework/web/CWebApplication.php(120): CWebApplication->runController('user/user/login')

#9 /home/hoppin/public_html/framework/base/CApplication.php(135): CWebApplication->processRequest()

#10 /home/hoppin/public_html/index.php(12): CApplication->run()

#11 {main}


2010-05-21 09:35:23 Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_mono/2.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_perl/2.0.4 Perl/v5.8.8 Yii Framework/1.1.2



thanks for this Bug Report, we will take care of this in the 0.6 release. It really should only take a few more days, so stay tuned :)

Only way I could get this to load was using "mithereal" zip file above Thanks.

but now have a problem mentioned above:

when trying to login index.php/user/user/login

"CWebUser does not have a method named "isAdmin"."

here’s the Stack Trace

#0 [internal function]: CComponent->__call(‘isAdmin’, Array)

#1 C:\wamp\www\***\protected\modules\user\controllers\YumUserController.php(26): CWebUser->isAdmin()

#2 C:\wamp\www\framework\web\CController.php(998): YumUserController->accessRules()

#3 C:\wamp\www\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))

#4 C:\wamp\www\framework\web\filters\CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))

#5 C:\wamp\www\framework\web\CController.php(283): CFilterChain->run()

#6 C:\wamp\www\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#7 C:\wamp\www\framework\web\CWebApplication.php(320): CController->run(‘login’)

#8 C:\wamp\www\framework\web\CWebApplication.php(120): CWebApplication->runController(‘user/user/login’)

#9 C:\wamp\www\framework\base\CApplication.php(135): CWebApplication->processRequest()

#10 C:\wamp\www\***\index.php(12): CApplication->run()

#11 {main}

Congrats on release 0.6 :slight_smile:

First of all, I’m completely new to Yii, as a matter of fact, this is my first PHP framework ever, but thanks to all the “pain” and “suffering” that your extension has caused me, I’ve got a better understanding of it, than by reading the tutorials :smiley:

Now, the "pain and suffering" were due to the following problem:

     - In 0.6, if you install it on a completely new webapp, after going step by step through the install documentation, everything goes well, login, go to "Manage Profile Fields" and you will get an error: 

[size="5"]

The table "{{profile_fields}}" for active record class "YumProfileField" cannot be found in the database.[/size]

I spent quiet some time trying to figure this out, but due to my "noobiness" in Yii, I was unsuccessful.

However, in 0.5 it doesn’t happen, but I also noticed, huge difference in directory structure between 0.5 and 0.6:

0.5: ../protected/modules/user/modules will have:

                                   - messages/


                                   - profiles/


                                   - role/

0.6: ../protected/modules/user/modules will have exact same directories as modules/user/*

Any thoughts? So far I’m enjoying Yii and definitely benefiting from your extension, which I find to be awesome! :slight_smile:

Hi,

I’m new in the use of Yii and I’ve choosen to use Yum for the user management (from SVN r89),

here are a few difficulties (and suggestion) that I encountered during the setup process:

* The online wiki is outdated, it should reference the txt file in the docs directory


* The "Install Demo data" has a few bugs due to missed insertion of NOT NULL fields (without default value) as:


	+ `timestamp` in profileTable


	+ `hint`, `match`, `range`, `error_message`, `other_validator`, `default` in profileFieldsTable


	


		I solved these modifiing the YumInstallController.php





			if(isset($_POST['installProfiles']))


			{


				$sql = "INSERT INTO `".$profileTable."` (`profile_id`, `timestamp`, `user_id`, `lastname`, `firstname`, `email`) VALUES


					(1, 1, 0, 'admin','admin','webmaster@example.com'),


					(2, 2, 0, 'demo','demo','demo@example.com')";


				$db->createCommand($sql)->execute();





				$sql = "INSERT INTO `".$profileFieldsTable."` (`varname`, `title`, `field_type`, `field_size`, `required`, `visible`, `hint`, `match`, `range`, `error_message`, `other_validator`, `default`) VALUES


					('email', 'E-Mail', 'VARCHAR', 255, 1, 2, '', '', '', '', '', ''), 


					('firstname', 'First name', 'VARCHAR', 255, 1, 2, '', '', '', '', '', ''), 


					('lastname', 'Last name', 'VARCHAR', 255, 1, 2, '', '', '', '', '', '')";


				$db->createCommand($sql)->execute();


			}


			


	+ I used different table names in the install process and:


		- I had to discover myself wich parameters to put in the module configuration. It was specified only in submodules.txt


		- In the YumUser.php Model there was a duplicate line that I had to comment to let my personalized name work:


		


			public function tableName()


			{


				if (isset(Yii::app()->controller->module->usersTable))


					$this->_tableName = Yii::app()->controller->module->usersTable;


				elseif (isset(Yii::app()->modules['user']['usersTable'])) 


					$this->_tableName = Yii::app()->modules['user']['usersTable'];


				else


					$this->_tableName = '{{users}}'; // fallback if nothing is set


					//$this->_tableName = 'users'; // fallback if nothing is set			<<------- THIS IS THE LINE		





				return YumHelper::resolveTableName($this->_tableName,$this->getDbConnection());


			}

After this simple issues my understanding stopped because I’m still very new to yii,

but I think there is some problem with the profiles when the view tries to access the ->profile.

I hope I’ve been usefull, good work :wink:

hello everybody,

great module, I love it!

I’m using the Yii dev branch for development (because it has the theming bug fixed) and I’m getting this error message after my user session expires:




trim() expects parameter 1 to be string, array given



If I log in again, it’s fine …




00225:     {

00226:         unset($params[$this->routeVar]);

00227:         foreach($params as &$param)

00228:             if($param===null)

00229:                 $param='';

00230:         if(isset($params['#']))

00231:         {

00232:             $anchor='#'.$params['#'];

00233:             unset($params['#']);

00234:         }

00235:         else

00236:             $anchor='';

00237: $route=trim($route,'/'); // !!!!!!!!!!!!!!   THIS IS THE LINE         !!!!!!!!!

00238:         foreach($this->_rules as $rule)

00239:         {

00240:             if(($url=$rule->createUrl($this,$route,$params,$ampersand))!==false)

00241:                 return $rule->hasHostInfo ? $url.$anchor : $this->getBaseUrl().'/'.$url.$anchor;

00242:         }

00243:         return $this->createUrlDefault($route,$params,$ampersand).$anchor;

00244:     }

00245: 

00246:     /**

00247:      * Contructs a URL based on default settings.

00248:      * @param string the controller and the action (e.g. article/read)

00249:      * @param array list of GET parameters




–iM

Hi!

Thanks for the great module! It’s very usefull!

Yet i encountered a problem: It is told, that integrating with SRBAC should not be a problem. Yet I had to realize that there is a huge problem:

I’m trying to use Yii-user-management module for everything it offers - except roles. Thus i have to overwrite the default Authentication Methods:


'components'=>array(

		'user'=>array(

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

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

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

		),

and autoload all classes:


 'import'=>array(  

  'application.modules.user.models.*',

	[...]



doing so Yum overwrites the checkAccess()-Method with it’s own. Trying to use this Method as follows:


if(Yii::app()->user->checkAccess('View Post'))

{

	echo "This is a Test!";

}

does not work anymore with the rules specified in SRBAC.

Is there any solution to my problem? I’m trying to avoid changing to much in the source code of Yum to be able to upgrade easily once a new version is released. Hope you can help!

regards

Hi again!

renaming the Method checkAccess() in components\WebUser.php to yumCheckAccess() - or anything else - solves the problem. I submitted a Issue. I hope this will be fixed to avoid future problems.

Also I’m not shure if I ask to much here, but it would really be great if the authors of yii-user-management and SRBAC would join efforts. Eg it’d be great if SRBAC could be enabled as a module of yii-user-management.

regards

Why do you use such "long" routes (user/user/profile, user/user/logout, user/user/login)?

May be user/profile, user/logout, user/login ?