/**
  * Gets the form for the data of the model
  * @param mixed $data Data object to preset the form
  * @return zibo\library\html\form\Form
  */
 protected function getForm($data = null)
 {
     $fields = array('preferences');
     $form = new ScaffoldForm($this->request->getBasePath() . '/' . self::ACTION_SAVE, $this->model, $data, $fields, true);
     if (!(!$this->user || $this->user && $this->user->isSuperUser())) {
         $superRoles = $this->getModel(RoleModel::NAME)->getSuperRoles();
         $hiddenRoles = $this->getHiddenRoleIds();
         $field = $form->getField('roles');
         $roles = $field->getOptions();
         foreach ($superRoles as $role) {
             if (array_key_exists($role->id, $roles)) {
                 unset($roles[$role->id]);
             }
         }
         foreach ($hiddenRoles as $role) {
             if (array_key_exists($role, $roles)) {
                 unset($roles[$role]);
             }
         }
         $field->setOptions($roles);
     }
     $form->setIsDisabled(true, 'dateLastLogin');
     $form->setIsDisabled(true, 'lastIp');
     return $form;
 }
 /**
  * Create a new comment, if a user is logged in, set his/her name and email to the newly created comment
  * @return joppa\comment\model\data\CommentData
  */
 private function createComment()
 {
     $comment = $this->models[CommentModel::NAME]->createData();
     if ($this->user) {
         $comment->name = $this->user->getUserName();
         $comment->email = $this->user->getUserEmail();
     }
     return $comment;
 }