My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Installation  
installation guide
Phase-Implementation, Featured
Updated Sep 20, 2010 by mish...@gmail.com

Installation

  • Unpack files in your project/protected
  • Insert to config/main.php
  • return array(
    #...
    	// autoloading model and component classes
    	'import'=>array(
    		'application.models.*',
    		'application.components.*',
    		'application.modules.user.models.*',
    		'application.modules.user.components.*',
    	),
    #...
    	'modules'=>array(
    		'user',
    	),
    #...
    	// application components
    	'components'=>array(
    #...
    		'user'=>array(
    			// enable cookie-based authentication
    			'allowAutoLogin'=>true,
    			'loginUrl' => array('/user/login'),
    		),
    #...
    	),
    #...
    );
  • Create tables (dump files schema.mysql.sql and schema.sqlite.sql)
  • Insert items into zii.widgets.CMenu array (protected/views/layouts/main.php)
  • array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
    array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
    array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
    array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),

Login

Default users:

  • admin/admin
  • demo/demo

Module parameters

PropertyTypeDescriptionDefault
user_page_sizeintitems on page10
fields_page_sizeintitems on page10
hashstringhash methodmd5
sendActivationMailbooleanuse email for activation user accounttrue
loginNotActivbooleanallow auth for is not active userfalse
activeAfterRegisterbooleanactivate user on registration (only $sendActivationMail = false)false
autoLoginbooleanlogin after registration (need loginNotActiv or activeAfterRegister = true)true
registrationUrlarrayregitration patharray("/user/registration")
recoveryUrlarrayrecovery patharray("/user/recovery/recovery")
loginUrlarraylogin patharray("/user/login")
logoutUrlarraylogout patharray("/user/logout")
profileUrlarrayprofile patharray("/user/profile")
returnUrlarrayreturn path after loginarray("/user/profile")
returnLogoutUrlarrayreturn path after logoutarray("/user/login")
relationsarrayUser model relation from other modelsarray()
profileRelationsarrayProfile model relation from other modelsarray()
captchaarrayuse captchaarray('registration'=>true)
tableUsersstringUser model table{{users}}
tableProfilesstringProfile model table{{profiles}}
tableProfileFieldsstringProfileField model table{{profiles_fields}}

Comment by gabor.gy...@gmail.com, Mar 3, 2010

Missing 'tablePrefix' => 'tbl',

Comment by k.cheren...@gmail.com, Mar 9, 2010
'db'=>array(

'tablePrefix' => 'tbl_'
),
Comment by a.a.piku...@gmail.com, May 15, 2010

'Create User' operation produces following error:

"Undefined variable: list"

Url: /index.php?r=user/admin/create

Script: \protected\modules\user\views\admin\menu.php(3)

00001: <ul class="actions">
00002: <?php 
00003:     if (count($list)) {
00004:         foreach ($list as $item)
00005:             echo "<li>".$item."</li>";
00006:     }
00007: ?>
Comment by gui...@gmail.com, Jun 9, 2010

When clicking on "Login" or "Registration" I get this error : Non-static method UserModule?::t() should not be called statically, assuming $this from incompatible context

any idea ?

Comment by jayos...@gmail.com, Sep 12, 2010

The ProfileField section is not documented. The "range" field is useful to be able to have a field with a ComboBox which is nice, however the format of how this is specified is not documented. The format is:

1==Active;2=Inactive;3=Other

This would give a ComboBox in the following format:

Id  Value
1   Active
2   Inactive
3   Other

Although this is GREAT, it would be better to be able to have a ComboBox using a lookup into a table. I made some changes to have this functionality by specifying the "Range" field with this alternative format:

&Table;IdField;NameField;Module

The initial "&" is for the system to Identify this new format. An Example

&Country;country_id;country_name;admin

The Module is optional and is used if the table is in another module.

for this to work, I replaced the following 2 functions that are in the file "application\protected\modules\user\models\profile.php"

	private function rangeRules($str) {
		if (substr($str,0,1)=='&') {
			// es comando
			$params = explode(';', substr($str,1));
			if (isset($params[3]))
				Yii::app()->getModule($params[3]);
			$rules = CHtml::listData($params[0]::model()->findAll(), $params[1], $params[1]);
		} else {
				
			$rules = explode(';',$str);
			for ($i=0;$i<count($rules);$i++)
				$rules[$i] = current(explode("==",$rules[$i]));
		}
		return $rules;
	}
	
	static public function range($str,$fieldValue=NULL) {
		if (substr($str,0,1)=='&') {
			$params = explode(';', substr($str,1));
			if (isset($params[3]))
				Yii::app()->getModule($params[3]);
			$array = CHtml::listData($params[0]::model()->findAll(), $params[1], $params[2]);
		} else {
			$rules = explode(';',$str);
			$array = array();
			for ($i=0;$i<count($rules);$i++) {
				$item = explode("==",$rules[$i]);
				if (isset($item[0])) $array[$item[0]] = ((isset($item[1]))?$item[1]:$item[0]);
			}
		}
		if (isset($fieldValue)) 
			if (isset($array[$fieldValue])) return $array[$fieldValue]; else return '';
		else
			return $array;
	}

I hope this helps if you consider it useful, you might include it in the next version of yiiuser.

Comment by ovidiupop70, Sep 20, 2010

Nice module. Thank you for sharing.

I am very new to yii and OOP. I installed your module. It is working well, except that when I create a new user, the password is saved in clear to Db, not hashed. And of course, user cannot login because an error ocurr.

Please fix the following input errors:

  • Password is incorrect.

If I create an user as admin, the password is hashed and all look to be fine.

Comment by ovidiupop70, Sep 20, 2010

I changed next line in RegistrationController? :

$model->password=UserModule?::encrypting($model->password);
$model->verifyPassword=UserModule?::encrypting($model->verifyPassword); if ($model->save()) {
$profile->user_id=$model->id; $profile->save();

Now, the password is saved hashed in DB.

Comment by ziweiwan...@gmail.com, Sep 27, 2010

Hello! First of all,thank you for your sharing! It's a really nice module. I've got a problem:

when I click the register button, it will throw a PHP error: "mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at &quot;localhost&quot; port 25, verify your &quot;SMTP&quot; and &quot;smtp_port&quot; setting in php.ini or use ini_set()"

How can I solve it,thank you.

Comment by kasy...@gmail.com, Oct 13, 2010

how to setup the layout for this module .. ?

Comment by m.rosor...@gmail.com, Oct 18, 2010

@kasyap5. I had the same problem. not sure is the best solution but I added

// this method is called before any module controller action is performed 
// you may place customized code here 
$controller->layout = 'application.views.layouts.main'; // path to your view 

on public function beforeControllerAction on the file UserModule?.php (the configuration file module). You can try also removing $layout in Controller.php under components of the main application.

Comment by ftwo...@gmail.com, Nov 1, 2010

I copied all filed to the proper directories under protected and I am getting an error "Alias "user.UserModule?" is invalid. Make sure it points to an existing PHP file.

Comment by Laith.B...@gmail.com, Nov 25, 2010

hey ... nice module , and it will do all the required tasks of users issue, i have followed the above steps for the installation , i also created the tables in the database , but whenever i login i got the following error : " Fatal error: Call to a member function encrypting() on a non-object in D:\wamp\www\taskmgr\protected\modules\user\components\UserIdentity?.php on line 35 "

advice please !

Comment by argi...@gmail.com, Dec 14, 2010

If you get an "Alias "user.UserModule?" is invalid ERROR, then you simply have to give the necessary rights to php to access the modules directory and it's contents. (Usually happens to users with linux installations). Go to command line in the protected directory and run: chmod -R go+rx modules and you are done.

Comment by josemigu...@gmail.com, Jan 12, 2011

I'm new with Yii and I've founded your extensión... I'm trying but I've got a problem, sure that's it's easy but I don't know how to show all the text in Spanish.

I've seen a directory called messages with many translations... I've already search in the documentation and in the wiki, but I don't see anyone with this problem

Can you help me, please?

Thx a million!

Comment by adomas.j...@gmail.com, Jan 22, 2011

I get this error: CDbException

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

Any ideas? How to create this table?

Comment by geektantra@gmail.com, Jan 23, 2011

@Laith.B...@gmail.com: Solution to "Fatal error: Call to a member function encrypting() on a non-object in D:\wamp\www\taskmgr\protected\modules\user\components\UserIdentity?.php on line 35"

I was facing the same problem and got the solution. You get this solution when you are trying to login using an URL different from /user/login for example the default Yii login URL i.e. /site/login. It is not able to find the corresponding module hence is not able to call the member function encrypting in that.

Comment by srava...@gmail.com, Jan 24, 2011

Call to a member function encrypting() on a non-object in C:\xampp\htdocs\overdrive\protected\modules\user\components\UserIdentity?.php on line 35 how to solve it?

Comment by srava...@gmail.com, Jan 25, 2011

I have followed all the steps for the installation , i also created the tables in the database , but whenever i login i got the following error : " Fatal error: Call to a member function encrypting() on a non-object

Comment by djonlin...@gmail.com, Jan 26, 2011

CHANGE LAYOUT from module user to application Guys HELP, user is running as module but If I want to change layout and use application layout and theme how to do it and the best is in dynamic way.

please help Im getting crazy

Comment by Auto...@gmail.com, Feb 6, 2011

Getting an error about: "{{users}}"?

Missing instructions; after running the SQL statements, go into protected/modules/user/UserModule?.php and edit lines 78-80.

Comment by ovidiupop70, Feb 12, 2011

When use this module, you must add to urlManager next rule: 'urlManager'=>array(

'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array(
'user/<controller:\w+>/<action:\w+>'=>'user/<controller>/<action>',
.................

),

),

else pages like: Edit, Change Password will not be shown when click on their links.

Comment by soft...@gmail.com, Feb 17, 2011

Getting an error about: "{{users}}"

You don't have to edit 'protected/modules/user/UserModule?.php'. You can configure the table names in 'protected/config/main.php'.

    'modules' => array(
    ...
        'user' => array(
            'tableUsers' => 'tbl_users',
            'tableProfiles' => 'tbl_profiles',
            'tableProfileFields' => 'tbl_profiles_fields',
        ),
    ....
    ),
Comment by mor...@gmail.com, Feb 22, 2011

This is an awesome extension!

I do have a question, though. Some users are "admins" (superusers?) how do I check a specific user for that property? Just like "isGuest", is there a method to verify if the user is an administrator? "isAdmin" does not work.

I can't find any documentation about this at all. Sorry if this is in the wrong place.

Thanks!

Comment by mindoc...@gmail.com, Feb 26, 2011

Dear author, add possibility of change of Layout, for example as in the Right module (layout & appLayout)

Comment by michael%...@gtempaccount.com, Apr 7, 2011

Hi, this module looks really promising, but I'm having an issue installing... perhaps because i'm using version 1.1.7 of yii?

I followed the given instructions, and get the following message;

Fatal error: Call to a member function t() on a non-object in C:\yiiweb\userauth\protected\views\layouts\main.php on line 37

The line that triggers this is:

array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),

Is there something I have failed to configure? I have tried this with "'tablePrefix' => 'tbl'," in the db connection array, but to no avail. I have even renamed the tables to exclude the "tbl".

Any suggestions?

Comment by michael%...@gtempaccount.com, Apr 8, 2011

Follow-on to "Fatal error: Call to a member function t() on a non-object "

I just re-installed, but on a php 5.2 computer, and this time everything works great!

Will re-examine the install on the php 5.3 config.

Comment by xHiba...@gmail.com, Apr 14, 2011

I'm having the same problem that the person above me did. Though, I've checked and mine is installed on a server running php 5.2, but I still get this error. Is there something else I'm doing wrong? I added the db 'tablePrefix' => 'tbl' but it's still not working and just gives me the error when I try to add it to my nav area.

Any fixes?

Comment by xHiba...@gmail.com, Apr 14, 2011

Sorry, I meant to mention, the error I get is the one with calling a member function t() on a non-object. Thought I'd specify.

Comment by michael%...@gtempaccount.com, Apr 16, 2011

What worked for me was to add 'tablePrefix' => '' as I'm not using the table name preface.

When i remove the tablePrefix entry, i got the error.

Thanks again to the author for this very useful tool!

Comment by n.r.fisc...@web.de, May 1, 2011

Hi, thank you for sharing your work. Im very new to PHP and developing web-apps, therefor Ive got a little problem. I´ve installed the framework, copied the yii-user extension in my project/protected folder and created the databases. It looks like everything goes thru, but if I want to login as admin I got the "Password is incorrect." error. I searched in the directories, changed the pw in the database but nothing helped.

I know a little less information but could anyone give me a hint how I can solve the problem?

Thanks

Comment by n.r.fisc...@web.de, May 1, 2011

Hi again in addendum to above. If I create an new user, the created user is affiliated in the "tbl_users". But still the "Password is incorrect." error, even the new user.

Comment by chrisjoh...@gmail.com, May 2, 2011

For registration on my site a required bool field must be set to yes. How do I validate this?

Comment by dbk...@gmail.com, May 13, 2011

Hello,

Wonderful extension but I just have a few questions. So far everything works perfectly but the layout on the /user module. The first part is fine (Home, About, Blog and Contact section) but when I click on Login and Register in the menu bar the /views/layouts/main does not render and I am just left with the Login and Register models. I think this has something to do with the controller but I am not sure because I am still pretty new to Yii and I am getting the hang of it. If there is anyone who is familiar with this problem it would be much appreciated if you could weigh in. Thank you.

Comment by geertmee...@gmail.com, May 22, 2011

Hi, nice module! I made some modifications as I wanted it to be able to use the column2 standard Yii layout. I did this on the 0.3-r107 version. If interested, don't hesitate to contact me.

Cheers

Comment by jamesbur...@gmail.com, Jun 3, 2011

atal error: Call to a member function t() on a non-object in ../protected/views/layouts/main.php on line 36

I have tried adding: 'tablePrefix' => 'tbl' or 'tablePrefix' => '' as other users suggested but neither works.

Any ideas? Thanks in advance!!!

Comment by saosu...@gmail.com, Jun 8, 2011

For the issues like "The table "{{users}}" for active record class "User" cannot be found in the " please check the URL http://code.google.com/p/yii-user/issues/detail?id=6&can=1&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Reporter#c1

Comment by contacon...@gmail.com, Jun 12, 2011

REMEMBER ISSUE ON INSTALLATION 'Insert to config/main.php'

An issue on the installation code: When config the main.php is no correct the sentence to 'user'

It is not correct:

    'modules'=>array( 
              'user', 
    ), 

It is correct:

    'modules'=>array( 
               'user' => array( 
                         'tableUsers' => 'tbl_users', 
                         'tableProfiles' => 'tbl_profiles', 
                         'tableProfileFields' => 'tbl_profiles_fields', 
               ), 
    ), 

Bye

Comment by patel.na...@gmail.com, Jun 21, 2011

Hi great plugin, But Cannot understand, why no one asked about "How to implement Facebook Login" or "OpenId?"? so, please provide answer of "How can I implement FB login And OpenId? login.

Comment by chungn...@gmail.com, Jul 22, 2011

9o,o9o8

Comment by sudwebde...@gmail.com, Jul 27, 2011

Re: Fatal error: Call to a member function t() on a non-object in ../protected/views/layouts/main.php on line 36

I'm getting this too ... is it something to do with the default site controller? I've only just created a new webapp, followed the guide above.

If I don't specify a default site controller in config/main.php I get another error.

So, I've tried specifying both 'login' and 'user' and the defaults?

I'm a noob to yii - so hope I'm not being thick! ;)

Comment by sudwebde...@gmail.com, Jul 28, 2011

So it was a Noob error and for other noob's here it is.

Don't take the "insert into config/main.php" step literally. You need to take the parameters for each section and insert them into the correct place in your existing config.

For example, don't just add:

'import'=>array(
'application.models.', 'application.components.', 'application.modules.user.models.', 'application.modules.user.components.',
),
The default config/main.php already has the following defined
'import'=>array(
'application.models.', 'application.components.',
),
So add the extra lines
'application.modules.user.models.', 'application.modules.user.components.',
before the last ),

If you want to see my final config file, you can find it here: http://www.sudwebdesign.com/articles-page/46-yii/106-configuring-yii.html

Comment by fery.09...@gmail.com, Aug 3, 2011

Hi Friends, I have install this modules and it works fine. but i have create & manage category page,while the access rules only set to 'admin'. The yii modules can set anyone to superadmin & save into database. So i want to set access rules of " create & manage in category controller " to read data from database. so i change access rules code of "CategoryController?.php": Original one : 'actions'=>array('create','update'),

'users'=>array('admin'),

change to : 'actions'=>array('create','update'),

'users'=>UserModule?::getAdmins(),

then , i get the error page : "include(UserModule?.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory"

in framework\YiiBase?.php(421) line 421 include($className.'.php');

Thanks Before

Comment by cirenia....@iems.edu.mx, Aug 17, 2011

Hi! When I Create Profile Field send the next error:

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE42601?: Syntax error: 7 ERROR: error de sintaxis en o cerca de «(» LINE 1: ALTER TABLE tbl_profiles ADD "rol" INTEGER(10) NOT NULL DEF... ^. The SQL statement executed was: ALTER TABLE tbl_profiles ADD "rol" INTEGER(10) NOT NULL DEFAULT 0

Please help :'(

Comment by cirenia....@iems.edu.mx, Aug 17, 2011

I'm working with Postgres...

Comment by CoryNor...@gmail.com, Aug 18, 2011

Hey, Just a question about the code. What's the advantage of UActiveForm over CActiveForm? I'm new to yii, but doesn't CActiveForm already support ajax validation? Thanks.

Comment by aladdinh...@gmail.com, Aug 31, 2011

get Trying to get property of non-object while installing I tried all above ideas in vain.

Comment by kunalro...@gmail.com, Nov 12, 2011

Have been trying to install this module for the past 2 days now. Its throwing up an error

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.. The SQL statement executed was: CREATE TABLE IF NOT EXISTS `user_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`owner_id` int(11) NOT NULL,
`participants` text NULL,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

On these lines of codes of the file: \protected\modules\user\controllers\YumInstallController?.php(134): CDbCommand->execute()

if (isset($_POST['installUsergroup'])) {
						$sql = "CREATE TABLE IF NOT EXISTS `" . $usergroupTable . "` (
							`id` int(11) NOT NULL AUTO_INCREMENT,
							`owner_id` int(11) NOT NULL,
							`participants` text NULL,
							`title` varchar(255) NOT NULL,
							`description` text NOT NULL,
							PRIMARY KEY (`id`)
								) ENGINE=InnoDB DEFAULT CHARSET=utf8;";

						$db->createCommand($sql)->execute(); //throws exception on this line. 
						$createdTables['usergroup']['usergroupTable'] = $usergroupTable;

I have tried to use the line of code

$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);

before running the queries. Any help would be appreciated. Thanks!

Comment by changxue...@163.com, Nov 17, 2011

how to change the language pls? i see there are a few in the message box, but how to config it pls?

Comment by sh...@mayzes.org, Dec 15, 2011

I am gettting an error: Property "CWebUser.tableUsers" is not defined.

In my config/main.php

'components'=>array(

'user'=>array(
// enable cookie-based authentication 'allowAutoLogin'=>true, 'loginUrl' => array('/user/login'), 'tableUsers' => 'tbl_users', 'tableProfiles' => 'tbl_profiles', 'tableProfileFields' => 'tbl_profiles_fields',
),

And:

'db'=>array(

'connectionString' => 'xxx', 'emulatePrepare' => true, 'username' => 'xxx', 'password' => 'xxxx', 'charset' => 'utf8', 'tablePrefix' => 'tbl',
),

Any thoughts?

Comment by hanieypi...@gmail.com, Dec 26, 2011

i dont understand about installation..it said that "Create tables (dump files schema.mysql.sql and schema.sqlite.sql) " means that we need the tables name schema.mysql.sql and schema.sqlite.sql ? the attribute in the table should insert username, password and so on...?

Comment by iDr...@gmail.com, Dec 31, 2011

I had the "called to member function on a none object" problem like many others.

Since I'm newb on MVC it took me some time to realise I was missing

$profile= new Profile; on row 25 in modules/user/views/profile/edit.php

An Idea, change "tbl_users" to tbl_user by default, to fit better with default yii app and the popular "rights". Not a big problem, it was easy to change even for me but I don't thnink I'm the only one wants to use them together=)

Last but not least, thank you so much for this epic module. This was all I wanted and much more! Awesome!

Comment by giuseppe...@gmail.com, Jan 13, 2012

I've installed yii user but i got http 500 error. why?

Comment by mc...@tap-sd.org, Feb 2, 2012

If I create a profile field called "agency_id" that has a relationship to an "agency" table, how can I get the registration form to automatically generate a pull down menu of the agencies?

Comment by rolclub...@gmail.com, Feb 28, 2012

contacon - thank you for posting the correct module entry.

Comment by speeedf...@gmail.com, Mar 2, 2012

Hi!

The modul is work, but dont include the controller the css, js and html sources. What is the probleme?

Comment by adik...@gmail.com, Mar 26, 2012

/i get foloowing error:

Property "UserModule?.debug" is not defined.

What am I doing wrong?

Comment by achmadsa...@gmail.com, Apr 13, 2012

Fatal error: Call to a member function t() on a non-object in C:\xampp\htdocs\my_project\protected\views\layouts\main.php on line 34

Any ideas?


Sign in to add a comment
Powered by Google Project Hosting