Example #1
0
 public function init()
 {
     //get user lsit
     $userM = new Application_Model_User();
     $usersArr = $userM->getUsersList(null, '--- Select Author ---');
     $this->addElement('select', 'userId', array('label' => 'Author:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select author.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $usersArr));
     $categories = new Application_Model_Category();
     $categoriesArr = $categories->getCategory("--- Select Category ---", "advice");
     $this->addElement('select', 'categoryId', array('label' => 'Category:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select advice category.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $categoriesArr));
     $this->addElement('text', 'title', array('label' => 'Title :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice title')))), 'decorators' => $this->elementDecorators));
     $this->addElement('text', 'identifire', array('label' => 'URL Re-write :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice URL Re-write')))), 'decorators' => $this->elementDecorators));
     // Add an body element
     $this->addElement('textarea', 'content', array('label' => 'Content:', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page content')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     // Add an body element
     $this->addElement('textarea', 'synopsis', array('label' => 'Synopsis:', 'required' => false, 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the synopsis')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'metaTitle', array('label' => 'Meta Title :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page identifire')))), 'decorators' => $this->elementDecorators));
     $this->addElement('textarea', 'metaKeyword', array('label' => 'Meta Keyword :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'decorators' => $this->elementDecorators));
     $this->addElement('textarea', 'metaDescription', array('label' => 'Meta Description :', 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'required' => false, 'decorators' => $this->elementDecorators));
     $Name = new Zend_Form_Element_File('name');
     $Name->setLabel('Upload an image:')->setRequired(false)->addValidator('Extension', false, 'jpg,png,gif')->clearDecorators()->addDecorators($this->fileDecorators);
     $this->addElements(array($Name));
     $this->addElement('submit', 'savePublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Publish', 'label' => 'Save and Publish', 'decorators' => $this->buttonDecorators));
     $this->addElement('submit', 'saveUnpublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Unpublish', 'label' => 'Save and Unpublish', 'decorators' => $this->buttonDecorators));
     $this->addElement('submit', 'previewPage', array('required' => false, 'ignore' => true, 'title' => 'Preview Page', 'label' => 'Preview Page', 'decorators' => $this->buttonDecorators));
 }
 public function addUserPrivilegeAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_UserPrivilege();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             //$options['status']='active';
             $model = new Application_Model_User($options);
             $id = $model->save();
             if ($id) {
                 /*---------  Upload image START -------------------------*/
                 $model->uploadProfilePicture($id, $options);
                 /*---------  Upload image END -------------------------*/
                 $this->_flashMessenger->addMessage(array('success' => 'User added successfully!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/user/add-new-user'));
             } else {
                 $this->_flashMessenger->addMessage(array('error' => 'Failed to add user!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/user/add-new-user'));
             }
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Example #3
0
 public function find($id, Application_Model_User $user)
 {
     $result = $this->getDbTable()->find($id);
     if (0 === count($result)) {
         return;
     }
     $user->setOptions($result->current()->toArray());
 }
Example #4
0
 public function find($articleId, Application_Model_User $article)
 {
     $result = $this->getDbTable()->find($articleId);
     if (0 == count($result)) {
         return;
     }
     $row = $result->current();
     $article->setArticleId($row->articleId)->setArticleTitle($row->articleTitle)->setArticleValue($row->articleValue)->setArticleLastEdit($row->articleLastEdit)->setUserId($row->userId);
 }
Example #5
0
 public function recoverUsername(Application_Model_User $user)
 {
     $options['email'] = $user->getEmail();
     $options['username'] = $user->getUsername();
     $options['firstName'] = $user->getFirstName();
     $options['lastName'] = $user->getLastName();
     $Mail = new Base_Mail();
     $Mail->sendForgotUsernameMail($options);
 }
Example #6
0
 public function addAction()
 {
     if ($this->_request->isPost()) {
         $user_data = $this->_request->getParams();
         $user = new Application_Model_User();
         $user->addUser($user_data);
         //$this->view->user_data=$user_data;
         //$this->render();
     }
 }
Example #7
0
 public function fetchAll()
 {
     $resultSet = $this->getDbTable()->fetchAll();
     $users = array();
     foreach ($resultSet as $row) {
         $user = new Application_Model_User();
         $user->setUserId($row->userId)->setUserName($row->userName)->setUserPassword($row->userPassword)->setUserReg($row->userRegDate)->setUserLastLogin($row->userLastLogin);
         $users[] = $user;
     }
     return $users;
 }
Example #8
0
 public function init()
 {
     $this->setName('frmBookUser');
     $model = new Application_Model_User();
     $users = $model->getAllUsers("active");
     $this->addElement('select', 'userId', array('label' => 'Employee:', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select user.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $users));
     $this->addElement('text', 'issueDate', array('label' => 'Issue Date:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter issue date')))), 'class' => 'text-input medium-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('text', 'estimatedReturnDate', array('label' => 'Estimated Return Date:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter estimated return date')))), 'class' => 'text-input medium-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('text', 'returnDate', array('label' => 'Return Date:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter return date')))), 'class' => 'text-input medium-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators));
 }
 public function fetchAll()
 {
     $resultSet = $this->getDbTable()->fetchAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Application_Model_User();
         $entry->setId($row->id)->setPassword($row->password)->setUserName($row->username);
         $entries[] = $entry;
     }
     return $entries;
 }
Example #10
0
 public function init()
 {
     $this->setName('frmDepartment');
     $this->addElement('text', 'title', array('label' => 'Department Title:', 'autocomplete' => "off", 'class' => 'text-input medium-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter designation title'))), array('Db_NoRecordExists', true, array('table' => 'department', 'field' => 'title', 'messages' => 'department title already exists'))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('select', 'type', array('label' => 'Type:', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select department type.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => array("normal" => "Normal", "operations" => "Operations")));
     $arrUser = array();
     $user = new Application_Model_User();
     $arrUser = $user->getAllUsers("active");
     //$arrUser=array_merge(array(''=>'Select'),$arrUser);
     $this->addElement('select', 'departmentHeadId', array('label' => 'Department Head:', 'style' => 'width:193px', 'class' => 'text-input medium-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select department head.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrUser));
     $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators));
 }
Example #11
0
 public function userAction()
 {
     $user_model = new Application_Model_User();
     $users = $user_model->fetchAll();
     $this->view->users = $users;
     $review_model = new Application_Model_Review();
     $reviews = $review_model->fetchAll();
     $this->view->reviews = $reviews;
     $song_model = new Application_Model_Song();
     $songs = $song_model->fetchAll();
     $this->view->songs = $songs;
 }
Example #12
0
 public function errorAction()
 {
     //$this->_helper->layout->setLayout('home-layout');
     $errors = $this->_getParam('error_handler');
     $flag = true;
     switch ($errors->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
             //var_dump($this->_getParam('controller'));
             $userM = new Application_Model_User();
             $user = $userM->fetchRow("username='******'controller')}'");
             if ($user !== false) {
                 $flag = false;
                 //Forward to the controller
                 $this->_forward('index', 'profile', 'default', array('id' => $user->getId()));
             }
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->message = 'Page not found';
             break;
         default:
             // application error
             $this->getResponse()->setHttpResponseCode(500);
             $this->view->message = 'Application error';
             break;
     }
     // Log exception, if logger available
     if ($log = $this->getLog()) {
         $log->crit($this->view->message, $errors->exception);
     }
     // conditionally display exceptions
     //var_dump($this->getInvokeArg('displayExceptions'));
     if ($this->getInvokeArg('displayExceptions') == true) {
         $this->view->exception = $errors->exception;
     }
     $this->view->request = $errors->request;
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     $this->view->error_flag = $config->error_flag;
     //Mail
     $options['message'] = $this->view->message;
     if ($this->getInvokeArg('displayExceptions') == true) {
         $options['exception'] = $this->view->exception->getMessage();
         $options['traceString'] = $this->view->exception->getTraceAsString();
     }
     $options['params'] = $this->view->request->getParams();
     $options['requesturi'] = $this->view->request->getRequestUri();
     $options['siteurl'] = Zend_Registry::get('siteurl');
     $mail = new Base_Mail();
     if ($flag == true) {
         $mail->sendErrorMail($options);
     }
 }
Example #13
0
 public function init()
 {
     $model = new Application_Model_User();
     $arr = $model->getAllUsers();
     $arr = array_merge(array('' => 'Select'), $arr);
     $this->addElement('select', 'userId', array('label' => 'Employee:', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select employee')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arr));
     $model = new Application_Model_AppriciationType();
     $arr = $model->getAppriciationType();
     //$arr=array_merge(array(''=>'Select'),$arr);
     $this->addElement('select', 'appriciationTypeId', array('label' => 'Appriciation Type:', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select type')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arr));
     $this->addElement('text', 'appriciationDate', array('label' => 'Date:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter date')))), 'class' => 'text-input small-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'remarks', array('label' => 'Remarks:', 'class' => 'text-input textarea address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter remarks.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators));
 }
Example #14
0
 public function createAction()
 {
     //if($this->getRequest()->isPost()){
     //Récupération des données
     $user = new Application_Model_User();
     $user->setIdUser('1')->setEmailUser('*****@*****.**')->setNomUser('wallace')->setPrenomUser('grommit')->setAdresse1User('1 rue Albert')->setAdresse2User('')->setZipUser('69380')->setPasswordUser('0000')->setNbMaxEmpruntUser('3')->setDelaisEmpruntUser('24')->setServiceUser('')->setDateInscription('27/01/2014')->setBureauUser('')->setParutionIdParution('')->setActifUser('')->setValidMailUser('')->setActivationUser('');
     //Instance du Mapper
     $userMapper = new Application_Model_UserMapper();
     //Save des données
     $userMapper->save($user);
     //Réponse à la vue
     $this->view->success = 'Enregistrement effectué';
     //}
 }
Example #15
0
 public function regAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_UserRegistration();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $user = new Application_Model_User($form->getValues());
             $user->setUserReg(date('Y-m-d H:i:s', time()))->setUserLastLogin(date('Y-m-d H:i:s', time()));
             $userMapper = new Application_Model_UserMapper();
             $userMapper->save($user);
             return $this->_helper->redirector('index,', 'index');
         }
     }
     $this->view->form = $form;
 }
Example #16
0
 /**
  * Checks whether this contest ready to be saved.
  *  
  * @access protected
  * @return boolean
  */
 protected function _isValid()
 {
     if ($this->_user instanceof Application_Model_User) {
         if ($this->_user->getId()) {
             if ($this->_user->canCreateContest()) {
                 if ($this->name) {
                     if ($this->startdate && $this->enddate || $this->type == 3) {
                         if ($this->type) {
                             if ($this->already_played_msg && $this->before_contest_msg && $this->after_contest_msg) {
                                 return true;
                             } else {
                                 $this->setError('A contest requires a messages for before the contest, after the contest and already played subscibers.');
                             }
                         } else {
                             $this->setError('A contest type must be selected.');
                         }
                     } else {
                         $this->setError('You must enter a start and end date for this contest to run.');
                     }
                 } else {
                     $this->setError('You must name the contest.');
                 }
             } else {
                 $this->setError('User can not create Contests, upgrade to a Premium user for this feature.');
             }
         } else {
             $this->setError('Invalid user');
         }
     } else {
         $this->setError('A user must be supplied to create a contest');
     }
     return false;
 }
Example #17
0
 public function indexAction()
 {
     $user_session = new Zend_Session_Namespace('user');
     $this->view->defaultCurrency = '';
     $this->view->bpartnerAdminDisabled = 1;
     $this->view->supplierAdmin = 0;
     $this->view->customerAdmin = 0;
     $this->view->editDisable = 1;
     $this->view->user_id = 0;
     if (isset($user_session->user_info)) {
         $this->view->user_id = $user_session->user_info['user_id'];
         if (Application_Model_User::checkPermissionByRoleName('业务伙伴管理员')) {
             $this->view->bpartnerAdminDisabled = 0;
             $this->view->editDisable = 0;
         }
         if (Application_Model_User::checkPermissionByRoleName('供应商管理员') || Application_Model_User::checkPermissionByRoleName('系统管理员')) {
             $this->view->supplierAdmin = 1;
             $this->view->editDisable = 0;
         }
         if (Application_Model_User::checkPermissionByRoleName('客户管理员') || Application_Model_User::checkPermissionByRoleName('系统管理员')) {
             $this->view->customerAdmin = 1;
             $this->view->editDisable = 0;
         }
     }
     $currency = new Erp_Model_Setting_Currency();
     $this->view->defaultCurrency = $currency->getDefaultCurrency();
 }
Example #18
0
 /**
  * Still playing around with how I want to handle permissions.
  * This is a method that can be called before each action to 
  * see if the user can do what they are asking to.
  * 
  * @access public
  * @return void
  */
 protected function userCan()
 {
     // User can edit themselves
     if ($this->id == $this->user->getId()) {
         return true;
     }
     // TODO: Need to expand upon this? Probably...
     // we can add in what the user is trying to do, and check perms
     // on top of just ownership. This will do for now.
     if ($this->id) {
         if ($this->user->isParentOf($this->id) || $this->user->isSuperAdmin()) {
             return true;
         }
     } else {
         // If there was no id already set, we are probably adding a folder.
         // TODO: Need to handle perms somehow here.
         return true;
     }
     // Set this entity to not valid so we do not give anything away
     // TODO: Maybe make a default() method that we can reset a built entity to it's defaults.
     // defaults could be set from the entity profile.
     $this->valid = false;
     $this->error = 'User does not have permission to execute the request.';
     //$this->error = 'ID does not exist for this user.';
     return false;
 }
 public function indexAction()
 {
     $this->view->customerAdmin = 0;
     if (Application_Model_User::checkPermissionByRoleName('客户管理员') || Application_Model_User::checkPermissionByRoleName('系统管理员')) {
         $this->view->customerAdmin = 1;
     }
 }
Example #20
0
 protected function _initHeadScript()
 {
     global $CC_CONFIG;
     $view = $this->getResource('view');
     $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
     $view->headScript()->appendFile($baseUrl . '/js/libs/jquery-1.7.2.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/libs/jquery-ui-1.8.18.custom.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/libs/jquery.stickyPanel.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/qtip/jquery.qtip.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/jplayer/jquery.jplayer.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/sprintf/sprintf-0.7-beta1.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/bootstrap/bootstrap.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendScript("var baseUrl='{$baseUrl}/'");
     //scripts for now playing bar
     $view->headScript()->appendFile($baseUrl . '/js/airtime/airtime_bootstrap.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/airtime/dashboard/helperfunctions.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/airtime/dashboard/dashboard.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/airtime/dashboard/versiontooltip.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/airtime/common/common.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . '/js/airtime/common/audioplaytest.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $user = Application_Model_User::getCurrentUser();
     if (!is_null($user)) {
         $userType = $user->getType();
     } else {
         $userType = "";
     }
     $view->headScript()->appendScript("var userType = '{$userType}';");
     if (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1) {
         $view->headScript()->appendFile($baseUrl . '/js/libs/google-analytics.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     }
 }
Example #21
0
 public function init()
 {
     $this->setName('frmProject');
     $this->addElement('text', 'title', array('label' => 'Project Title:', 'autocomplete' => "off", 'class' => 'text-input medium-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter project title')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'description', array('label' => 'Description:', 'class' => 'text-input textarea address', 'required' => false, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'clientInfo', array('label' => 'Client Info.:', 'class' => 'text-input textarea address', 'required' => false, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('text', 'startDate', array('label' => 'Start Date:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter start date')))), 'class' => 'text-input small-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('text', 'endDate', array('label' => 'End Date:', 'required' => false, 'class' => 'text-input small-input', 'readonly' => 'true', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('select', 'status', array('label' => 'Status:', 'class' => 'text-input small-input', 'required' => true, 'decorators' => $this->elementDecorators, 'MultiOptions' => array('open' => "Open", 'close' => "Close"), 'value' => "open"));
     $user = new Application_Model_User();
     $arrUser = $user->getAllUsers('active');
     $this->addElement('select', 'projectManagerId', array('label' => 'Project Manager:', 'class' => 'text-input small-input', 'required' => false, 'decorators' => $this->elementDecorators, 'MultiOptions' => $arrUser));
     $this->addElement('select', 'teamLeaderId', array('label' => 'Team Leader:', 'class' => 'text-input small-input', 'required' => false, 'decorators' => $this->elementDecorators, 'MultiOptions' => $arrUser));
     $this->addElement('select', 'resource', array('label' => 'Resource:', 'class' => 'text-input small-input', 'required' => false, 'decorators' => $this->elementDecorators, 'MultiOptions' => $arrUser));
     $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators));
 }
Example #22
0
 public function editpwdAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '修改密码成功');
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     $request = $this->getRequest()->getParams();
     $pwd0 = isset($request['pwd0']) ? $request['pwd0'] : null;
     $pwd1 = isset($request['pwd1']) ? $request['pwd1'] : null;
     $pwd2 = isset($request['pwd2']) ? $request['pwd2'] : null;
     if ($pwd0 && $pwd1 && $pwd2) {
         $user = new Application_Model_User();
         if ($user->checkUserPwdById($user_id, $pwd0)) {
             $employeeInfo = $user->getEmployeeInfoById($user_id);
             $pwd = md5($employeeInfo['number'] . $pwd1);
             try {
                 $user->update(array('password' => $pwd), "id = " . $user_id);
                 $computer_name = gethostbyaddr(getenv("REMOTE_ADDR"));
                 // 计算机名
                 $now = date('Y-m-d H:i:s');
                 $data = array('operate' => '修改密码', 'target' => 'UserAccount', 'computer_name' => $computer_name, 'ip' => $_SERVER['REMOTE_ADDR'], 'time' => $now);
                 $operate = new Application_Model_Log_Operate();
                 try {
                     $operate->insert($data);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         } else {
             $result['success'] = false;
             $result['info'] = '旧密码输入错误!';
         }
     } else {
         $result['success'] = false;
         $result['info'] = '新、旧密码不能为空!';
     }
     echo Zend_Json::encode($result);
     exit;
 }
Example #23
0
 public function getReviewUserInfo($type, $file_id)
 {
     $reviewerInfo = array();
     $sql = $this->select()->from($this, array('plan_user' => new Zend_Db_Expr("GROUP_CONCAT(plan_user SEPARATOR ',')")))->where("type = '" . $type . "' and file_id = " . $file_id)->group("file_id");
     if ($this->fetchAll($sql)->count() > 0) {
         $data = $this->fetchRow($sql)->toArray();
         $reviewers = array_unique(explode(',', $data['plan_user']));
         $user = new Application_Model_User();
         foreach ($reviewers as $r) {
             $userData = $user->fetchRow("employee_id = " . $r)->toArray();
             $user_id = $userData['id'];
             $userInfo = $user->getEmployeeInfoById($user_id);
             $user_email = $userInfo['email'];
             array_push($reviewerInfo, array('user_id' => $user_id, 'email' => $user_email));
         }
     }
     return $reviewerInfo;
 }
Example #24
0
 /**
  * Método utilizado para editar Users, testando a existência de uma requisão do tipo POST.
  * Seus valores são resgatados validados e atualizados no banco de dados.
  * @param int $id
  * @method updateAction
  * @access public
  * @return resource
  */
 public function updateAction()
 {
     $form = new Application_Form_User();
     $form->setAction('/user/update');
     $users = new Application_Model_User();
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $values = $form->getValues();
             $users->update($values, 'id = ' . $values['id']);
             $this->_redirect('/user/retrieve');
         }
     } else {
         $id = $this->_getParam('id');
         $user = $users->fetchRow("id ={$id}")->toArray();
         $form->populate($user);
     }
     $this->view->form = $form;
 }
Example #25
0
 public function createAction()
 {
     $userCreateForm = new Application_Form_UserCreate();
     /** @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     if ($request->isPost() && $userCreateForm->isValid($request->getPost())) {
         $formValues = $userCreateForm->getValues();
         $userModel = new Application_Model_User();
         $userModel->setFromArray($formValues);
         $randomPassword = $this->_generateRandomPassword();
         $userModel->setAndSaltPassword($randomPassword);
         $userMapper = $this->_getUserMapper();
         $userMapper->save($userModel);
         $this->getFlashMessenger()->addSuccessMessage(sprintf('created new user with id %d and password %s', $userModel->getId(), $randomPassword));
         $this->_redirect($this->url('list'), array('exit' => true));
     }
     $this->view->assign('form', $userCreateForm);
 }
 public function init()
 {
     $this->setName('frmPrivilege');
     $model = new Application_Model_User();
     $arrUserId = $model->getIds();
     $this->addElement('select', 'userId', array('label' => 'User ID:', 'id' => 'userId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select user.')))), 'decorators' => $this->elementDecorators, 'filtcoratoers' => array('StringTrim'), 'MultiOptions' => $arrUserId));
     // $model	=	new Application_Model_Screen();
     //$arrScreenId	=	$model->getId();
     $this->addElement('select', 'screenId', array('label' => 'Screen ID:', 'id' => 'screenId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select screen.')))), 'decorators' => $this->elementDecorators, 'filtcoratoers' => array('StringTrim'), 'MultiOptions' => array("1" => "Screen1", "2" => "Screen2")));
     // $model	=	new Application_Model_Menu();
     //$arrMenuId	=	$model->getId();
     $this->addElement('select', 'menuId', array('label' => 'Menu ID:', 'id' => 'menuId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select menu.')))), 'decorators' => $this->elementDecorators, 'filtcoratoers' => array('StringTrim'), 'MultiOptions' => array("1" => "Menu1", "2" => "Menu2")));
     // $model	=	new Application_Model_Action();
     //$arrSActionId	=	$model->getId();
     $this->addElement('select', 'actionId', array('label' => 'Action ID:', 'id' => 'actionId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select action.')))), 'decorators' => $this->elementDecorators, 'filtcoratoers' => array('StringTrim'), 'MultiOptions' => array("1" => "Screen1", "2" => "Screen2")));
     $this->addElement('select', 'permissions', array('label' => 'Permissions:', 'id' => 'permissions', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select permissions.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => array("grant" => "Grant", "revoke" => "Revoke permissions")));
     $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators));
 }
Example #27
0
 public function sendRequestNotification($requestId)
 {
     $request = new Application_Model_Request();
     $request = $request->find($requestId);
     if (false === $request) {
         return false;
     }
     $departmentId = $request->getDepartmentId();
     $dept = new Application_Model_Department();
     $dept = $dept->find($departmentId);
     if ($dept === false) {
         return false;
     }
     $user = new Application_Model_User();
     $users = $user->fetchAll("department_id='{$departmentId}' and status='active' and id ='{$dept->getDepartmentHeadId()}'");
     if (count($users) == 0) {
         return false;
     }
     $emails = array();
     foreach ($users as $_user) {
         $emails[$_user->getFirstName() . " " . $_user->getLastName()] = $_user->getEmail();
     }
     if (count($emails) == 0) {
         return false;
     }
     $user = new Application_Model_User();
     $requestedBy = $user->find($request->getRequestedBy());
     $from_email = $this->settingValue('admin_email');
     $from_name = $this->settingLable('admin_email');
     /*---Template-----*/
     $template = $this->getEmailTemplate('request_notification_email');
     $htmlBody = $template['body'];
     $htmlBody = str_replace("__REQUESTER_NAME__", $requestedBy->getFirstName() . " " . $requestedBy->getLastName(), $htmlBody);
     $htmlBody = str_replace("__REQUESTER_EMAIL__", $requestedBy->getEmail(), $htmlBody);
     $htmlBody = str_replace("__REQUESTER_EMP_CODE__", $requestedBy->getEmployeeCode(), $htmlBody);
     $htmlBody = str_replace("__REQUEST__", $request->getRequest(), $htmlBody);
     /*---------------------*/
     $subject = $template['subject'];
     $this->setBodyHtml($htmlBody);
     $this->setFrom($from_email, $from_name);
     $this->addTo($emails);
     $this->setSubject($subject);
     $this->send();
 }
 /**
  * Request to login a user comes to this method
  */
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('user'));
     //If user is already loged in redirect him to dash board.
     if ($auth->hasIdentity()) {
         $this->_redirect('patient/orders');
     }
     $this->_helper->layout->setLayout('login');
     $forms = Zend_Registry::get('forms');
     $form = new Zend_Form($forms->user->login);
     $userManagement = new Application_Model_User();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $error = array();
         if ($form->isValid($data)) {
             $userName = $form->username->getValue();
             $password = $form->password->getValue();
             $remember = $this->_request->getParam('remember', 0);
             $userTable = new Application_Model_DbTable_User();
             $userExits = $userTable->fetchRow('username = "******" AND password= "******" AND deleted_at IS NULL');
             $magUser = false;
             if (!empty($userExits)) {
                 $userExits = $userExits->toArray();
                 if ($userExits['id'] == 0 || $userExits['id'] == '') {
                     $magUser = true;
                 }
                 $session = new Zend_Session_Namespace('userObj');
                 $session->__set('userObj', $userExits);
             }
             if ($magUser) {
                 $form->username->setErrors(array('Invalid username or password'));
             } else {
                 $response = $userManagement->login($userName, md5($password), $remember);
             }
             if ($response == 'success') {
                 $this->_redirect('patient/orders');
             } else {
                 $form->username->setErrors(array('Invalid username or password'));
             }
         }
     }
     $this->view->form = $form;
 }
Example #29
0
 public function __construct($p_startDT, $p_endDT, $p_opts)
 {
     $this->startDT = $p_startDT;
     $this->endDT = $p_endDT;
     $this->timezone = Application_Model_Preference::GetUserTimezone();
     $this->user = Application_Model_User::getCurrentUser();
     $this->opts = $p_opts;
     $this->epoch_now = floatval(microtime(true));
     $this->currentShow = false;
 }
Example #30
0
 function changepermissionAction()
 {
     $this->view->title = "Change user permission";
     $user = new Application_Model_User();
     $id = (int) $this->_request->getParam('id');
     $userRow = $user->fetchRow($user->select()->where('id = ?', $id));
     $userArray = $userRow->toArray();
     if ($userArray['permission'] == 0) {
         $insertValue = "1";
     }
     if ($userArray['permission'] == 1) {
         $insertValue = "0";
     }
     $data = array('permission' => $insertValue);
     $where = 'id = ' . $id;
     $user->update($data, $where);
     $this->_redirect('/users');
     return;
 }