public function indexAction()
    {    	
		//Get an instance of the User Servicen and the sort parameter out of the url
		$facultylandingService = new App_UserService();   		
    	$this->view->sortParameter = $this->getRequest()->getParam('sort');  
    	
    	//If no sort is specified default to ascending order by date submitted
    	if($this->view->sortParameter == NULL) 
    	{
			$rowset = $facultylandingService->GetArtifactsForFacultyIDWithOrderAndStatus(1, 'submitted_timestamp', 2);       
			$this->view->user = $rowset->toArray(); 
    	}
    	else 
    	{
    		//Parse the sort string parameter
    		$sortTokens = explode('&', $this->view->sortParameter);
    		$orderToken = explode('=', $sortTokens[0]);
    		$sortbyToken = explode('=', $sortTokens[1]);
    		
    		//Note for now: ignoring the sort by asc/desc, sort is always done in ascending order
			$rowset = $facultylandingService->GetArtifactsForFacultyIDWithOrderAndStatus(1, $sortbyToken[1], 2);       
			$this->view->user = $rowset->toArray(); 
    	}	

    	//get the faculty member's to display on the page    	
		$name = $facultylandingService->GetFullNameForId(1);
		$this->view->currentUser = $name;     
    }
    public function indexAction()
    {    	
		$facultylandingService = new App_UserService();                           
		
		$rowset = $facultylandingService->GetArtifactsForFacultyIDWithOrderAndLimitAndStatus(1, 'submitted_timestamp', 4, 2);              
		$this->view->user = $rowset->toArray();   	

		$name = $facultylandingService->GetFullNameForId(1);
		$this->view->currentUser = $name;
    }
Пример #3
0
 public function contactAction()
 {
     $name = $this->_getParam('name');
     $ctRow = $this->userService->GetContactTypeByName($name);
     if ($ctRow != null) {
         $this->view->contactType = $ctRow;
     } else {
         $this->view->contactType = $this->view->contactTypes->current();
     }
     $this->view->users = $this->view->contactType->findDependentRowset('UsersTable');
 }
Пример #4
0
    public function adminAction()
    {
    	//partea de administrare
    	if($this->getRequest()->isPost())
		{
			$this->userService->CreateUser($this->_getParam('nume'),$this->_getParam('email'));
		}
		
		$rowset = $this->userService->GetAllUsers();
		$this->view->users = $rowset->toArray();

    }
Пример #5
0
 public function responsibilityAction()
 {
     $tasks = $this->userService->GetAllTasks();
     $this->view->tasks = array();
     foreach ($tasks as $task) {
         $tempTaskArray = array();
         $tempTaskArray['name'] = $task->name;
         $tempTaskArray['users'] = array();
         $users = $task->findManyToManyRowset('UsersTable', 'TasksUsers');
         foreach ($users as $userRow) {
             $tempTaskArray['users'][] = $userRow->name;
         }
         $this->view->tasks[] = $tempTaskArray;
     }
 }
Пример #6
0
 public function testCanGetAllContactTypes()
 {
     var_dump($this->UserService->GetAllContactTypes());
 }
Пример #7
0
 public function deleteAction()
 {
     $this->userService->DeleteUser($this->_getParam('id'));
     $this->_redirect('index');
 }
    public function processAction()
    { 
    	$request = $this->getRequest();
    	

        // Check if we have a POST request
        if (!$request->isPost()) {
            return $this->_helper->redirector('index');
        }
        

        // Get our form and validate it
        $form = $this->getForm();
        
        
        // Validate username and password for matching criteria
        if (!$form->isValid($request->getPost())) 
        {
            // Invalid entries
            $this->view->form = $form;
            return $this->render('index'); // re-render the login form
        }
        echo "valid";

        // Get our authentication adapter and check credentials
        
        /*$adapter = $this->getAuthAdapter($form->getValues());
        $auth    = Zend_Auth::getInstance();
        $result  = $auth->authenticate($adapter);
        
        if (!$result->isValid()) 
        {
            // Invalid credentials
            $form->setDescription('Invalid credentials provided');
            $this->view->form = $form;
            return $this->render('index'); // re-render the login form
        }*/
        
        // Validate against LDAP 
        
        // Validate against matrix database
        $username = $form->getValue('username');
        print_r($username);
        $password = $form->getValue('password');
        
        $userService = new App_UserService();
        $valid = $userService->ValidUserPassword($username, $password);
        
        if ($valid)
        {
	 //echo"sdfasdf";
        	//$this->error_flag = FALSE;
        	//$this->view->error_flag = $this->error_flag;
        	$userRole = $userService->GetUserRole($username);
       		
        	if ($userRole == 'U' || $userRole == 'L' || $userRole == 'G')
        	{
        		$this->_helper->redirector('index', 'student');
        	}
        	else if ($userRole == 'F')
        	{
        		$this->_helper->redirector('index', 'faculty');
        	}
        	
        	//$this->_helper->redirector('index', 'index');
        }
        else
        {
        	// Redirect to the login page
        	//$this->view->error_flag = TRUE;
        	//$this->view->error_flag = $this->error_flag;
        	
        	$this->_helper->redirector('index', 'user');
        }
        
        /*
        $dbAdapter = Zend_Db_Table::getDefaultAdapter();
        /*$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
        
        $authAdapter->setTableName('user');
        $authAdapter->setIdentityColumn('username');
		$authAdapter->setCredentialColumn('password');
        $authAdapter->setCredentialTreatment('MDS(?');
        
        // Pass to the adapter the submitted username and password
        $authAdapter->setIdentity($username);
        $authAdapter->setCredential($password);*/
        
        // We're authenticated! Redirect to the home page
        //$this->_helper->redirector('index', 'index');	
        //echo 'hi';
    }
    /**
     * KG and PA
     * Log the user in and display the correct homepage
     * This function is called when the login button is pressed.
     * 
     * First it checks the eneered username and password to determine 
     * whether the inputs could be considered valid (long enough username and password,
     * only alpha-numeric characters, etc...)
     * If not, it informs the user and stops executing
     * 
     * Then it queries the matrix user database to determine if the user is actually
     * in the database. If the user was found, it verifies their password with LDAP
     *
     * If the username/password combination was correct, the function queries the user database
     * to determine whether to display the student or faculty page. Otherwise, 
     * take the user back to the login screen and inform them of error.
     */
    
    public function processAction()
    { 
    	$request = $this->getRequest();
    	
        // Check if we have a POST request
        if (!$request->isPost()) {
            return $this->_helper->redirector('login_start');
        }
        
        // Get our form and validate it
        $form = $this->getForm();
        
        
        // Validate username and password for matching criteria
        if (!$form->isValid($request->getPost())) 
        {
            // Redirect to the login page and set error flag	
			$this->_redirect('/index/index/error_flag/TRUE');
        	exit();
        }
        
        //Get username and password
        $username = $form->getValue('username');
        $password = $form->getValue('password');
        
        //check whether user exists in the user table
        $userService = new App_UserService();
        $valid = $userService->ValidUser($username);
        
        
        //If the user exists, validate password with LDAP
        if($valid)
        {
	        $auth = Zend_Auth::getInstance();
	        $authAdapter = new Zend_Auth_Adapter_Ldap(
	                                   array(
	                                           'server' => array(
	                                           'host' => 'ldap.nccnet.noctrl.edu',
	                                           'baseDn' => 'OU=Napvil,O=NCC',
	                                           'bindRequiresDn' => true,
	                                                                   ),
	                                   ), $username, $password
	                           );
	      	$authResult = $auth->authenticate($authAdapter);
	      	if ($authResult->isValid())
	       	{
	       		$valid = TRUE;
	       	} 
	       	else
	       	{
	       		$valid = FALSE;
	       	}
        }
        
        
        if ($valid)
        {
        	$this->view->error_flag = FALSE;
        	$userRole = $userService->GetUserRole($username);
       		
        	if ($userRole == 'U' || $userRole == 'L' || $userRole == 'G')
        	//user is a student
        	{
        		$this->_helper->redirector('index', 'student');
        	}
        	else
        	//user is faculty
        	{
        		$this->_helper->redirector('index', 'faculty');
        	}
        	
        }
        else
        {
        	// Redirect to the login page and set error flag	
			$this->_redirect('/index/index/error_flag/TRUE');
        	exit();
        }
        
    }