$this->_helper->redirector(null, 'error');
does not also work. i have tried the others, it won't work too :(
i get this error:
Notice: Undefined property:
Ekini_Controller_Action_Helper_MyAccessControlHelper::$_helper in
/Applications/MAMP/htdocs/zend_quickstart/application/library/Ekini/Controller/Action/Helper/MyAccessControlHelper.php
on line 73
Fatal error: Call to a member function redirector() on a non-object in
/Applications/MAMP/htdocs/zend_quickstart/application/library/Ekini/Controller/Action/Helper/MyAccessControlHelper.php
on line 73
Where line 73 is: $this->_helper->redirector(null, 'error');
also doing this: $this->_flashMessenger =
$this->_helper->getHelper('FlashMessenger');
in my ActionHelper, displays a similar error.
Jack Sleight wrote:
>
> Use either:
>
> $this->_forward($action, $controller, $module) // Internal redirect, not
> HTTP redirect
> $this->_redirect($url)
> $this->_helper->redirector($action, $controller, $module);
>
> So I guess you would probably want something like:
>
> $this->_helper->redirector(null, 'error');
>
> To redirect to the index action of the error controller, within the
> current module.
>
> wenbert wrote:
>> $this->_redirect($redirect); wont work...?
>> how do i redirect to a certain controller when im in the Action Helper
>>
>> Full Code Below:
>> <?php
>> require_once('Zend/Controller/Action/Helper/Abstract.php');
>> require_once('Zend/Loader.php');
>> require_once('default/Models/Permissions.php');
>> require_once('default/Models/Resources.php');
>> require_once('default/Models/Roles.php');
>> require_once('default/Models/UserRole.php');
>> require_once('default/Models/Users.php');
>>
>> class Ekini_Controller_Action_Helper_MyAccessControlHelper extends
>> Zend_Controller_Action_Helper_Abstract {
>>
>> /**
>> * check if logged in user has access. redirects to $redirect if no
>> access
>> * returns null if no result otherwise returns the resultset
>> *
>> */
>> public function hasAccess($redirect = '/')
>> {
>> Zend_Loader::loadClass('Zend_Auth');
>>
>> try {
>>
>> $dbAdapter = Zend_Registry::get('dbAdapter');
>>
>> $moduleName = $this->getRequest()->getModuleName();
>> $controllerName = $this->getRequest()->getControllerName();
>>
>> //get the user identity, this is null if the user is not
>> logged
>> in
>> $user = Zend_Auth::getInstance()->getIdentity();
>>
>> if ($user) {
>> if ($user->id=='1') {
>> return true;
>> }
>>
>> //get all user roles for logged in user
>> $userRoles = new UserRole();
>> $roles = $userRoles->fetchAll('user_id="'.$user->id.'"');
>>
>> foreach ($roles as $role) {
>>
>> $sql = "
>> SELECT p.*, r.*, u.*, rs.*
>> FROM users_to_roles ur
>> LEFT JOIN permissions p ON p.role_id = ur.role_id
>> LEFT JOIN users u ON ur.user_id = u.id
>> LEFT JOIN roles r ON p.role_id = r.id
>> LEFT JOIN resources rs ON p.resource_id = rs.id
>> WHERE ur.role_id=".$role->role_id."
>> ";
>>
>> $acl = $dbAdapter->fetchAll($sql);
>>
>> foreach ($acl AS $row) {
>> if ($row['resource_name'] == $controllerName AND
>> $row['module'] == $moduleName AND $row['access'] == 'allow') {
>> return true;
>> } else if ($row['resource_name'] ==
>> $controllerName
>> AND $row['module'] == $moduleName AND $row['access'] == 'deny') {
>> throw new Exception('You are not allowed to
>> access this page. (Group Denied)') ;
>> } else {
>> throw new Exception('You are not allowed to
>> access this page. (Denied)') ;
>> }
>> }
>>
>> }
>> } else {
>> throw new Exception('You are not logged in.') ;
>> }
>>
>>
>> } catch (Exception $e) {
>> //$this->_flashMessenger->addMessage($e->getMessage());
>>
>> //im just doing this since i don't know how to redirect yet
>> :(
>> echo $e->getMessage();
>> die();
>>
>> //$this->_redirect($redirect);
>> //THIS WONT WORK
>> }
>> }
>> }
>>
>
> --
> Jack
>
>
--
View this message in context:
http://www.nabble.com/How-do-i-redirect-to-another-controller-inside-my-Action-Helper--tf4252603s16154.html#a12104447
Sent from the Zend Framework mailing list archive at Nabble.com.