Controller of Modular Structure ZEND Reviewed by Momizat on . modules/admin/controllers/IndexController.php [php] <?php class Admin_IndexController extends Zend_Controller_Action { public function init() { $this->aut modules/admin/controllers/IndexController.php [php] <?php class Admin_IndexController extends Zend_Controller_Action { public function init() { $this->aut Rating: 0

Controller of Modular Structure ZEND

modules/admin/controllers/IndexController.php

<?php
class Admin_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        $this->auth = new Zend_Session_Namespace('auther');
	$this->view->formData=$this->getRequest()->getParams();
	$this->objback = new Default_Model_DbTable_Frontend();
	if(isset($this->auth) && empty($this->auth->userid)){
	$this->_helper->flashMessenger('Session Timeout ! Login Again');
	$this->_helper->redirector->setGotoSimple("index","index","default"); 
	}
	$messages = $this->_helper->flashMessenger->getMessages();
	if(!empty($messages)){
	$this->_helper->layout->getView()->message = $messages[0];
	}
		
    }

    public function indexAction()
    {
		
       
		
    }
    public function changesPasswordAction()
    {
	$this->view->h1="Change Password";
	 $objRequest	= $this->getRequest();
	 if($objRequest->isPost())	
	{
	$post = $objRequest->getPost();
	//echo "<pre>";print_r($post);exit;
	if(!empty($post['currentpassword']) && !empty($post['newpassword'])){
		$rec=$this->objback ->getuserdetail($this->auth->userid);	
		if(empty($rec)){
		$this->_helper->flashMessenger('Invalid Username / Password');
		$this->_helper->redirector->setGotoSimple("changes-password","index","admin"); 
		}else{
			if($post['currentpassword']==$rec['password']){
				$this->objback->updatedata('tbl_admin',array('password'=>$post['newpassword']),'id',$this->auth->userid);
				$this->_helper->flashMessenger('Password changed successfully');
				$this->_helper->redirector->setGotoSimple("changes-password","index","admin"); 	
			}else{
				$this->_helper->flashMessenger('Invalid current password!');
				$this->_helper->redirector->setGotoSimple("changes-password","index","admin"); 	
			
			}
		
		}
	}else{
		$this->_helper->flashMessenger('All fields Required!');
		$this->_helper->redirector->setGotoSimple("changes-password","index","admin") ;
	}
	
	}
    }
	
	
	public function myAccountAction()
    {
	$this->view->h1="My Account";
		
	}


   
    public function logoutAction() {
        //$auth = Zend_Auth::getInstance();
       // $auth->clearIdentity();
       Zend_Session::destroy();
        $this->_helper->redirector->setGotoSimple("index","index","default");
        //$this->_redirect('/admin');
    }
   public function adminUsersAction()
    {
		$this->view->h1="All Admin Users";
		
		$this->view->rec=$this->objback->getalluser();
		//echo "<pre>";print_r($this->auth->userid);exit;
	
	}
	public function addAdminuserAction()
    {
		$this->view->h1="Add Admin User";
		 $objRequest	= $this->getRequest();
		 if($objRequest->isPost())	
		{
			$post = $objRequest->getPost();
			$params=array(
			'name'=>$post['name'],
			'email'=>$post['email'],
			'password'=>$post['password'],
			'status'=>$post['status']
			);
			$this->objback->insertdata('tbl_admin',$params);
			$this->_helper->flashMessenger('User added successfully!');
			$this->_helper->redirector->setGotoSimple("admin-users","index","admin"); 	
		}
	
	}
	public function editAdminuserAction()
    {
		$parm=$this->getRequest()->getParams();
		if(!isset($parm['id']) || empty($parm['id'])){
		$this->_helper->flashMessenger('Invalid Links');
			$this->_helper->redirector->setGotoSimple("admin-users","index","admin"); 
		}
		$this->view->rec=$this->objback ->getuserdetail($parm['id']);
		$this->view->h1="Edit Admin User";
		 $objRequest	= $this->getRequest();
		 if($objRequest->isPost())	
		{
			$post = $objRequest->getPost();
			$params=array(
			'name'=>$post['name'],
			'email'=>$post['email'],
			'password'=>$post['password'],
			'status'=>$post['status']
			);
			$this->objback->updatedata('tbl_admin',$params,'id',$parm['id']);
			$this->_helper->flashMessenger('User updated successfully!');
			$this->_helper->redirector->setGotoSimple("admin-users","index","admin"); 	
		}
	
	}
	public function deleteuserAction()
    {
		$parm=$this->getRequest()->getParams();
		if(!isset($parm['id']) || empty($parm['id'])){
		$this->_helper->flashMessenger('Invalid Links');
			$this->_helper->redirector->setGotoSimple("admin-users","admin"); 
		}
		$this->objback->deletedata('tbl_admin','id',$parm['id']);
		$this->_helper->flashMessenger('User deleted successfully!');
		$this->_helper->redirector->setGotoSimple("admin-users","admin");
	
	}
   


}
?>


Leave a Comment

© 2014 Powered By