コード例 #1
0
ファイル: Userregister.php プロジェクト: relyd/aidstream
 public function add($defaultFields = '', $state = 'add')
 {
     $form = array();
     $form['first_name'] = new Zend_Form_Element_Text('first_name');
     $form['first_name']->setLabel('First Name')->setRequired();
     $form['middle_name'] = new Zend_Form_Element_Text('middle_name');
     $form['middle_name']->setLabel('Middle Name');
     $form['last_name'] = new Zend_Form_Element_Text('last_name');
     $form['last_name']->setLabel('Last Name')->setRequired();
     $form['user_name'] = new Zend_Form_Element_Text('user_name');
     $form['user_name']->setLabel('User Name')->addValidator('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'user_name'))->setRequired();
     $passwordConfirmation = new App_PasswordConfirmation();
     $form['password'] = new Zend_Form_Element_Password('password');
     $form['password']->setLabel('Password')->setRequired()->addValidator($passwordConfirmation);
     $form['confirmpassword'] = new Zend_Form_Element_Password('confirmpassword');
     $form['confirmpassword']->setLabel('Confirm Password')->setAttrib('class', 'input_box confirmpassword');
     $form['confirmpassword']->setRequired()->addValidator($passwordConfirmation);
     $form['email'] = new Zend_Form_Element_Text('email');
     $form['email']->setLabel('Email')->addValidator('emailAddress', false)->addValidator('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email'))->addFilter('stringTrim')->setRequired();
     $signup = new Zend_Form_Element_Submit('Signup');
     $signup->setValue('signup')->setAttrib('id', 'Submit');
     $button = new Zend_Form_Element_Button('button');
     $button->setLabel('Check All');
     $button->setAttrib('class', 'check-uncheck');
     $this->addElements($form);
     // add clearfix div for all form items
     foreach ($form as $element) {
         $element->addDecorators(array(array(array('wrapperAll' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clearfix form-item'))));
     }
     $this->addDisplayGroup(array('first_name', 'middle_name', 'last_name', 'user_name', 'password', 'confirmpassword', 'email'), 'field1', array('legend' => 'User Information'));
     // add wrapper class for the group
     $group = $this->getDisplayGroup('field1');
     $group->setDecorators(array('FormElements', 'Fieldset', array(array('wrapperAll' => 'HtmlTag'), array('tag' => 'div', 'class' => 'default-activity-list'))));
     // add permission form
     $permissionForm = new Form_Admin_Editpermission();
     $permissionForm->edit($defaultFields);
     $permissionForm->removeDecorator('form');
     $permissionForm->removeElement('submit');
     $this->addSubForm($permissionForm, 'test');
     $this->addElement($signup);
     $this->setMethod('post');
 }
コード例 #2
0
ファイル: AdminController.php プロジェクト: relyd/aidstream
 public function editUserPermissionAction()
 {
     if (isset($_GET['user_id'])) {
         $user_id = $_GET['user_id'];
     }
     $model = new Model_Wep();
     $permissionSerialized = $model->getRowById('user_permission', 'user_id', $user_id);
     //print_r($permissionSerialized['object']);exit;
     $permissionObj = unserialize($permissionSerialized['object']);
     //print_r($permissionObj);exit;
     $default['fields'] = $permissionObj->getProperties();
     $form = new Form_Admin_Editpermission();
     $form->edit($default);
     if ($_POST) {
         try {
             $data = $_POST;
             $i = 0;
             //print_r($data);exit;
             $permissionObj = new Iati_WEP_UserPermission();
             foreach ($data['default_fields'] as $eachField) {
                 if ($eachField == 'add') {
                     $permissionObj->setProperties('add_activity_elements');
                     $permissionObj->setProperties('add_activity');
                     $defaultKey[$i++] = 'add_activity_elements';
                     $defaultKey[$i++] = 'add_activity';
                 } elseif ($eachField == 'edit') {
                     $permissionObj->setProperties('edit_activity_elements');
                     $permissionObj->setProperties('edit_activity');
                     $defaultKey[$i++] = 'edit_activity_elements';
                     $defaultKey[$i++] = 'edit_activity';
                 } else {
                     if ($eachField == 'delete') {
                         $permissionObj->setProperties('delete_activity');
                         $defaultKey[$i++] = 'delete_activity';
                     } else {
                         $permissionObj->setProperties($eachField);
                         $defaultKey[$i++] = $eachField;
                     }
                 }
                 //$defaultKey[$i] = $eachField;
                 //$i++;
             }
             $permissionObj->setProperties('view_activities');
             $fieldString = serialize($permissionObj);
             $defaultFields['object'] = $fieldString;
             $defaultFields['user_id'] = $user_id;
             $defaultFieldId = $model->updateRow('user_permission', $defaultFields, 'user_id', $user_id);
             //print_r($defaultKey);exit;
             $privilegeFields['resource'] = serialize($defaultKey);
             $privilegeFields['owner_id'] = $user_id;
             $privilegeFieldId = $model->updateRow('Privilege', $privilegeFields, 'owner_id', $user_id);
             $this->_helper->FlashMessenger->addMessage(array('message' => 'User permission updated.'));
             $this->_redirect('admin/view-profile?user_id=' . $user_id);
         } catch (Exception $e) {
             print $e;
         }
     }
     $this->view->form = $form;
     if ($identity->role != 'superadmin') {
         $this->view->blockManager()->enable('partial/primarymenu.phtml');
         $this->view->blockManager()->enable('partial/add-activity-menu.phtml');
         $this->view->blockManager()->enable('partial/usermgmtmenu.phtml');
     }
 }