public function indexAction()
 {
     $this->layout('layout/myaccount');
     $this->layout()->setVariable('mail_active', 'active');
     $userTable = $this->getServiceLocator()->get('UserTable');
     $allUsers = $userTable->fetchAll();
     $usersList = array();
     foreach ($allUsers as $user) {
         $usersList[$user->id] = $user->name . '(' . $user->email . ')';
     }
     $user = $this->getLoggedInUser();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $msgSubj = $request->getPost()->get('messageSubject');
         $msgText = $request->getPost()->get('message');
         $toUser = $request->getPost()->get('toUserId');
         $fromUser = $user->id;
         $this->sendOfflineMessage($msgSubj, $msgText, $fromUser, $toUser);
         // to prevent duplicate entries on refresh
         return $this->redirect()->toRoute('users/mail', array('action' => 'sendOfflineMessage'));
     }
     //Prepare Send Message Form
     $form = new \Zend\Form\Form();
     $form->setAttribute('method', 'post');
     $form->setAttribute('enctype', 'multipart/form-data');
     $form->add(array('name' => 'toUserId', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('type' => 'select'), 'options' => array('label' => 'To User')));
     $form->add(array('name' => 'messageSubject', 'attributes' => array('type' => 'text', 'id' => 'messageSubject', 'required' => 'required'), 'options' => array('label' => 'Subject')));
     $form->add(array('name' => 'message', 'attributes' => array('type' => 'textarea', 'id' => 'message', 'required' => 'required'), 'options' => array('label' => 'Message')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send'), 'options' => array('label' => 'Send')));
     $form->get('toUserId')->setValueOptions($usersList);
     $viewModel = new ViewModel(array('form' => $form, 'userName' => $user->name));
     return $viewModel;
 }
 /**
  * Create admin user form
  *
  * Method to create the Doctrine ORM user form for edit/create users 
  *
  * @return Zend\Form\Form
  */
 public function createUserForm($userEntity, $formName = 'LogIn')
 {
     $entityManager = $this->getEntityManager();
     $builder = new DoctrineAnnotationBuilder($entityManager);
     $this->form = $builder->createForm($userEntity);
     $this->form->setHydrator(new DoctrineHydrator($entityManager));
     $this->form->setAttribute('method', 'post');
     $this->addCommonFields();
     switch ($formName) {
         case 'SignUp':
             $this->addSignUpFields();
             $this->addSignUpFilters();
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-register'), 'name' => 'register'));
             break;
         case 'EditProfile':
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-register', array('action' => 'edit-profile')), 'name' => 'edit-profile'));
             break;
         case 'ChangePassword':
             $this->addChangePasswordFields();
             $this->addChangePasswordFilters();
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-register', array('action' => 'change-password')), 'name' => 'change-password'));
             break;
         case 'ResetPassword':
             $this->addResetPasswordFields();
             $this->addResetPasswordFilters();
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-register', array('action' => 'reset-password')), 'name' => 'reset-password'));
             break;
         case 'ChangeEmail':
             $this->addChangeEmailFields();
             $this->addChangeEmailFilters();
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-register', array('action' => 'change-email')), 'name' => 'change-email'));
             break;
         case 'ChangeSecurityQuestion':
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-register', array('action' => 'change-security-question')), 'name' => 'change-security-question'));
             break;
         case 'CreateUser':
             $this->addCreateUserFields();
             $this->addCreateUserFilters();
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-admin', array('action' => 'create-user')), 'name' => 'register'));
             break;
         case 'EditUser':
             $this->form->setAttributes(array('name' => 'register'));
             break;
         default:
             $this->addLoginFields();
             $this->addLoginFilters();
             $this->form->setAttributes(array('action' => $this->getUrlPlugin()->fromRoute('user-index', array('action' => 'login')), 'name' => 'login'));
             break;
     }
     $this->form->bind($userEntity);
     return $this->form;
 }
Esempio n. 3
0
 public function unserialiseAction()
 {
     $form = new \Zend\Form\Form();
     $form->setAttribute('method', 'post');
     $form->add(array('name' => 'code', 'attributes' => array('type' => 'textarea', 'class' => 'input-lg', 'style' => 'width:900px;height:300px;')));
     $form->bind(new \ArrayObject($this->params()->fromPost()));
     $viewModel = new ViewModel();
     $viewModel->setVariable('form', $form);
     $code = $this->params()->fromPost('code');
     if ($code) {
         $viewModel->setVariable("result", \DevelopmentLib\ArrayExporter::exportPhp54(unserialize($code)));
     }
     return $viewModel;
 }
 /**
  * Create form to update Contact System Fields
  * @return \Zend\Form\Form
  */
 public function getContactSystemFieldsForm()
 {
     //create form
     $form = new \Zend\Form\Form();
     $form->setAttribute("id", 'system-fields-form');
     $form->add(array("name" => "source_dropdown", "type" => "select", "attributes" => array("id" => "source_dropdown", "title" => "Set from existing Sources"), "options" => array("label" => "Select Source", "value_options" => array("test"))));
     $form->add(array("name" => "source", "type" => "text", "attributes" => array("id" => "source"), "options" => array("label" => "Source")));
     $form->add(array("name" => "reference_dropdown", "type" => "select", "attributes" => array("id" => "reference_dropdown", "title" => "Set from existing References"), "options" => array("label" => "Select Reference", "value_options" => array("test"))));
     $form->add(array("name" => "reference", "type" => "text", "attributes" => array("id" => "reference"), "options" => array("label" => "Reference")));
     $form->add(array("name" => "user_id", "type" => "select", "attributes" => array("id" => "user_id", "required" => "required"), "options" => array("label" => "User", "value_options" => array())));
     $form->add(array("type" => "submit", "name" => "submit", "attributes" => array("value" => "Submit")));
     /**
      * Populate Dropdowns
      */
     //users
     $objUsers = $this->getFrontUsersModel()->fetchUsers();
     $arr_users = array();
     foreach ($objUsers as $objUser) {
         if (!is_numeric($objUser->id)) {
             continue;
         }
         //end if
         $arr_users[$objUser->id] = $objUser->uname;
     }
     //end foreach
     $form->get("user_id")->setValueOptions($arr_users);
     //sources
     $objSources = $this->getFrontContactsSystemFieldsModel()->fetchDistinctContactSources();
     $arr_sources = array();
     foreach ($objSources as $objSource) {
         $arr_sources[$objSource->source] = $objSource->source;
     }
     //end foreach
     $form->get("source_dropdown")->setValueOptions($arr_sources);
     //references
     $objReferences = $this->getFrontContactsSystemFieldsModel()->fetchDistinctContactReferences();
     $arr_references = array();
     foreach ($objReferences as $objRefence) {
         $arr_references[$objRefence->reference] = $objRefence->reference;
     }
     //end foreach
     $form->get("reference_dropdown")->setValueOptions($arr_references);
     return $form;
 }
Esempio n. 5
0
    <style type="text/css">
        fieldset fieldset {
            margin-left: 2em;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h1 class="panel-title">
                Complex form with nested collections
            </h1>
        </div>

        <div class="panel-body">
            <?php 
echo $view->form()->setType('horizontal')->render($form->setAttribute('class', 'col-lg-offset-2 col-lg-8'));
?>
        </div>
    </div>

    <script src="//code.jquery.com/jquery.js"></script>
    <script src="js/tooltip.js"></script>
    <script>
        $('*[data-toggle="tooltip"]').tooltip();
    </script>
</div>
</body>
</html>
Esempio n. 6
0
 public function analyzeClassAction()
 {
     $form = new \Zend\Form\Form();
     $form->setAttribute('method', 'post');
     $form->add(array('name' => 'class', 'attributes' => array('type' => 'text', 'class' => 'input-lg')));
     $form->add(array('name' => 'code', 'attributes' => array('type' => 'textarea', 'class' => 'input-lg', 'style' => 'width:900px;height:300px;')));
     $form->bind(new \ArrayObject($this->params()->fromPost()));
     $viewModel = new ViewModel();
     $viewModel->setVariable('form', $form);
     $code = $this->params()->fromPost('code');
     eval($code);
     $reflectedClass = new \ReflectionClass($this->params()->fromPost('class'));
     var_dump($reflectedClass->getMethods());
     return $viewModel;
 }