yii-user extension

Hi,

I’m totally new here and this is my very first Yii application. So please take it easy on me! :)

The thing is that I can’t make yii-user extension ( http://www.yiiframework.com/extension/yii-user/ ) work.

I followed the installation instruction. Edited my config file and extracted the zipped file under protected folder. But I’m getting this error:


PHP warning


include(Controller.php): failed to open stream: No such file or directory 


C:\...\yii\framework\YiiBase.php(418)

406                 {

407                     foreach(self::$_includePaths as $path)

408                     {

409                         $classFile=$path.DIRECTORY_SEPARATOR.$className.'.php';

410                         if(is_file($classFile))

411                         {

412                             include($classFile);

413                             break;

414                         }

415                     }

416                 }

417                 else

418                     include($className.'.php');

419             }

420             else  // class name with namespace in PHP 5.3

421             {

422                 $namespace=str_replace('\\','.',ltrim($className,'\\'));

423                 if(($path=self::getPathOfAlias($namespace))!==false)

424                     include($path.'.php');

425                 else

426                     return false;

427             }

428             return class_exists($className,false) || interface_exists($className,false);

429         }

430         return true;

Line 418 is highlighted.

Do you have any idea what’s wrong?

Guys, I figured out if I edit "protected/modules/user/controllers/LoginController.php" to change


class LoginController extends Controller

to


class LoginController extends CController

then it works! But why? Is the class "Controller" replaced by "CController" in new versions of Yii or I just solved it the wrong way?!

Controller secret revealed; problem solved!

Thank you for watching! ;)

Hi!

With User extension, how can I redirect to the previous page after login, like with the built in login method?

I solved the problem. In User’s login controller (protected/modules/user/controllers/LoginController.php) the actionLogin method (after a successfull validation) checks if Yii::app()->user->returnUrl contains the ‘/index.php’ string:


if (strpos(Yii::app()->user->returnUrl,'/index.php')!==false)

	$this->redirect(Yii::app()->controller->module->returnUrl);

else

	$this->redirect(Yii::app()->user->returnUrl);

If true, it redirects to the page given in the config file, not to the calling page, and I don’t understand why? Has it any important meaning that the returnUrl contains the ‘/index.php’ string?

So I simply commented out this code snippet, and added to redirect to returnUrl. Is it a good solution?

Update: for a better solution watch: code.google.com/p/yii-user/source/diff?spec=svn118&r=118&format=side&path=/trunk/modules/user/controllers/LoginController.php

(I’m not allowed insert links yet…)

When i tried to use customized sessions with Yii-user, it wasn’t possible to log in or registrate anymore. The solution to this was that the sessionname had to be “Session”. At first i used Game Session and Game_Session. After i changed it to “Session” it worked fine together.

for the lastvisit_at error solution one is:


ALTER TABLE users CHANGE lastvisit lastvisit_at TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00';

And solution two is to alter the schema.mysql.sql file:


CREATE TABLE `cf_users` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `username` varchar(20) NOT NULL,

  `password` varchar(128) NOT NULL,

  `email` varchar(128) NOT NULL,

  `activkey` varchar(128) NOT NULL DEFAULT '',

  `create_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

  `lastvisit_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',

  `superuser` int(1) NOT NULL DEFAULT '0',

  `status` int(1) NOT NULL DEFAULT '0',

  PRIMARY KEY (`id`),

  UNIQUE KEY `username` (`username`),

  UNIQUE KEY `email` (`email`),

  KEY `status` (`status`),

  KEY `superuser` (`superuser`)

) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;