Example #1
0
 public function checkUserActiveStatus($options, $identityColumn)
 {
     $usersNs = new Zend_Session_Namespace("members");
     $user = new Security_Model_User();
     $RES = $user->fetchRow("{$identityColumn}='{$options['email']}' and status ='active'");
     if ($RES != false) {
         $usersNs->userObj = serialize($RES);
         $usersNs->userId = $RES->getId();
         $usersNs->userEmail = $RES->getEmail();
         $usersNs->userFullName = $RES->getFirstName() . " " . $RES->getLastName();
         $usersNs->userFirstName = $RES->getFirstName();
         $usersNs->userUsername = $RES->getUsername();
         //$usersNs->setExpirationSeconds(15);
         //setcookie("userName", $RES->getUsername(), time()+3600);  /* expire in 1 hour */
         /*--------- START CHECK USER PERSONAL IMAGE DIRECTORY -----------*/
         //$this->createUserDrectory($usersNs->userUsername);
         /*--------- END CHECK USER PERSONAL IMAGE DIRECTORY ------------*/
         $user_role = new Security_Model_UserRole();
         $user_role_res = $user_role->find($RES->getRoleId());
         if ($user_role_res->getStatus() != "active") {
             Zend_Session::namespaceUnset("members");
             $auth = $this->getInstance();
             $auth->clearIdentity();
             return false;
         }
         //$usersNs->userType=$user_role_res->getIdentifire();
         $usersNs->userType = "administrator";
         $usersNs->userTypeLabel = "Super Admin";
         //$usersNs->userTypeLabel=$user_role_res->getRole();
         return true;
     } else {
         $this->doLogout();
         return false;
     }
 }
Example #2
0
 public function init()
 {
     $this->addElementPrefixPath('Base_Validate', 'Base/Validate/', 'validate');
     $this->setName('frmRegistration');
     //        $this->addElementPrefixPath('Base_Decorator',
     //                            'Base/Decorator/',
     //                            'decorator');
     $this->addElement('text', 'username', array('label' => 'Username:'******'autocomplete' => "off", 'class' => 'text-input medium-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter username'))), array('Db_NoRecordExists', true, array('table' => 'user', 'field' => 'username', 'messages' => 'username already exists'))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('password', 'password', array('label' => 'Password:'******'autocomplete' => "off", 'required' => true, 'class' => 'text-input medium-input', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter password'))), array('validator' => 'StringLength', 'options' => array(6, 20)))))->getElement('password')->addValidator('IdenticalField', false, array('confirmPassword', 'Confirm Password'));
     // Add an password element
     $this->addElement('password', 'confirmPassword', array('label' => 'Confirm Password:'******'required' => true, 'class' => 'text-input medium-input', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(6, 20)))));
     // Add an password element
     // Add an first name element
     $this->addElement('text', 'firstName', array('label' => 'First Name:', 'class' => 'text-input medium-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter first name')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     // Add an last name element
     $this->addElement('text', 'lastName', array('label' => 'Last Name:', 'class' => 'text-input medium-input', 'required' => true, 'decorators' => $this->elementDecorators, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter surname')))), 'filters' => array('StringTrim')));
     $this->addElement('text', 'email', array('label' => 'Email Address:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter email')))), 'class' => 'text-input medium-input', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('text', 'dob', array('label' => 'Date of Birth:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter dob')))), 'class' => 'text-input medium-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('select', 'sex', array('label' => 'Gender:', 'class' => 'text-input small-input', 'required' => true, 'decorators' => $this->elementDecorators, 'MultiOptions' => array('male' => "Male", 'female' => "Female"), 'value' => "male"));
     $model = new Application_Model_Group();
     $arrGroup = $model->getGroups();
     // print_r($arrGroup);die();
     $this->addElement('select', 'groupId', array('label' => 'Group:', 'id' => 'groupId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select user group.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrGroup));
     $model = new Application_Model_Subgroup();
     $arrSubgroup = $model->getSubgroup();
     $this->addElement('select', 'subgroupId', array('label' => 'Sub Group:', 'id' => 'subgroupId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => false, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrSubgroup));
     $model = new Security_Model_UserRole();
     $arrUserRole = $model->getUserRole();
     $this->addElement('select', 'userRoleId', array('label' => 'User Role:', 'id' => 'userRoleId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select user Role.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrUserRole));
     $this->addElement('text', 'mobile', array('label' => 'Mobile Number:', 'class' => 'text-input medium-input', 'decorators' => $this->elementDecorators, 'required' => false, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'correspondenceAddress', array('label' => 'Correspondence Address:', 'class' => 'text-input textarea address', 'required' => false, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('file', 'profilePicture', array('class' => 'text-input medium-input', 'label' => 'Profile Picture:', 'required' => false, 'decorators' => $this->fileDecorators));
     $this->getElement('profilePicture')->addValidator('Size', false, 1024 * 1024 * 5);
     //2 MB file is allowed
     $this->getElement('profilePicture')->getValidator('Size')->setMessages(array("fileSizeTooBig" => "Maximum allowed file size is 5 MB.", "fileSizeTooSmall" => ""));
     $this->getElement('profilePicture')->addValidator('Extension', false, 'jpg,jpeg,png,gif');
     $this->getElement('profilePicture')->getValidator('Extension')->setMessages(array("fileExtensionFalse" => "Please upload jpg,jpeg,png,gif file.", "fileExtensionNotFound" => ""));
     $this->addElement('select', 'status', array('label' => 'Status:', 'id' => 'status', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select status.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => array("active" => "Active", "inactive" => "Inactive")));
     $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators));
 }
Example #3
0
 public function getUserRole()
 {
     $obj = new Security_Model_UserRole();
     $entries = $obj->fetchAll("status='active'");
     $arrUserRole = array();
     foreach ($entries as $entry) {
         $arrUserRole[$entry->getId()] = $entry->getRole();
     }
     return $arrUserRole;
 }