示例#1
0
 /**
  * Constructor method to instantiate the form object
  *
  * @param  string $action
  * @param  string $method
  * @param  int    $sid
  * @return self
  */
 public function __construct($action = null, $method = 'post', $sid = 0)
 {
     parent::__construct($action, $method, null, '        ');
     $fieldGroups = array();
     $dynamicFields = false;
     $model = str_replace('Form', 'Model', get_class($this));
     $newFields = \Phire\Model\Field::getByModel($model, 0, $sid);
     if ($newFields['dynamic']) {
         $dynamicFields = true;
     }
     if ($newFields['hasFile']) {
         $this->hasFile = true;
     }
     foreach ($newFields as $key => $value) {
         if (is_numeric($key)) {
             $fieldGroups[] = $value;
         }
     }
     $fields1 = array('title' => array('type' => 'text', 'label' => $this->i18n->__('Title'), 'required' => true, 'attributes' => array('size' => 80)), 'domain' => array('type' => 'text', 'label' => $this->i18n->__('Domain'), 'required' => true, 'attributes' => array('size' => 80)), 'document_root' => array('type' => 'text', 'label' => $this->i18n->__('Document Root'), 'required' => true, 'attributes' => array('size' => 80)), 'base_path' => array('type' => 'text', 'label' => $this->i18n->__('Base Path'), 'attributes' => array('size' => 80)));
     if ($sid != 0) {
         $fields1['domain']['attributes']['onkeyup'] = "phire.updateTitle('#site-header-title', this);";
     }
     $fields2 = array('submit' => array('type' => 'submit', 'value' => $this->i18n->__('SAVE'), 'attributes' => array('class' => 'save-btn')), 'update' => array('type' => 'button', 'value' => $this->i18n->__('UPDATE'), 'attributes' => array('onclick' => "return phire.updateForm('#site-form', " . ($this->hasFile || $dynamicFields ? 'true' : 'false') . ");", 'class' => 'update-btn')), 'force_ssl' => array('type' => 'radio', 'label' => $this->i18n->__('Force SSL'), 'value' => array('0' => $this->i18n->__('No'), '1' => $this->i18n->__('Yes')), 'marked' => '0'), 'live' => array('type' => 'radio', 'label' => $this->i18n->__('Live'), 'value' => array('0' => $this->i18n->__('No'), '1' => $this->i18n->__('Yes')), 'marked' => '1'), 'id' => array('type' => 'hidden', 'value' => 0), 'update_value' => array('type' => 'hidden', 'value' => 0));
     $allFields = array($fields2);
     if (count($fieldGroups) > 0) {
         foreach ($fieldGroups as $fg) {
             $allFields[] = $fg;
         }
     }
     $allFields[] = $fields1;
     $this->initFieldsValues = $allFields;
     $this->setAttributes('id', 'site-form');
 }
示例#2
0
 /**
  * Get the init field values
  *
  * @param  int     $tid
  * @return array
  */
 protected function getInitFields($tid = 0)
 {
     $yesNo = array('1' => $this->i18n->__('Yes'), '0' => $this->i18n->__('No'));
     // Get roles for the user type
     $roles = Table\UserRoles::findAll('id ASC', array('type_id' => $tid));
     $rolesAry = array('0' => '(' . $this->i18n->__('Blocked') . ')');
     foreach ($roles->rows as $role) {
         $rolesAry[$role->id] = $role->name;
     }
     // Set up initial fields
     $fields1 = array('type' => array('type' => 'text', 'label' => $this->i18n->__('Type'), 'required' => true, 'attributes' => array('size' => 40)), 'ip_allowed' => array('type' => 'text', 'label' => $this->i18n->__('IPs Allowed'), 'attributes' => array('size' => 40)), 'ip_blocked' => array('type' => 'text', 'label' => $this->i18n->__('IPs Blocked'), 'attributes' => array('size' => 40)), 'log_emails' => array('type' => 'text', 'label' => $this->i18n->__('Log Emails'), 'attributes' => array('size' => 40)), 'log_exclude' => array('type' => 'text', 'label' => $this->i18n->__('Log Exclude'), 'attributes' => array('size' => 40)), 'controller' => array('type' => 'text', 'label' => $this->i18n->__('Controller'), 'attributes' => array('size' => 40)), 'sub_controllers' => array('type' => 'text', 'label' => $this->i18n->__('Sub Controllers'), 'attributes' => array('size' => 40)));
     if ($tid != 0) {
         $fields1['type']['attributes']['onkeyup'] = "phire.updateTitle('#user-type-title', this);";
     }
     $fields2a = array('log_in' => array('type' => 'radio', 'label' => $this->i18n->__('Allow Login'), 'value' => $yesNo, 'marked' => '1'), 'registration' => array('type' => 'radio', 'label' => $this->i18n->__('Allow Registration'), 'value' => $yesNo, 'marked' => '1'), 'registration_notification' => array('type' => 'radio', 'label' => $this->i18n->__('Registration Notification'), 'value' => $yesNo, 'marked' => '0'), 'use_captcha' => array('type' => 'radio', 'label' => $this->i18n->__('Use CAPTCHA'), 'value' => $yesNo, 'marked' => '1'), 'use_csrf' => array('type' => 'radio', 'label' => $this->i18n->__('Use CSRF'), 'value' => $yesNo, 'marked' => '1'), 'multiple_sessions' => array('type' => 'radio', 'label' => $this->i18n->__('Allow Multiple Sessions'), 'value' => $yesNo, 'marked' => '1'), 'timeout_warning' => array('type' => 'radio', 'label' => $this->i18n->__('Session Timeout Warning'), 'value' => $yesNo, 'marked' => '0'), 'mobile_access' => array('type' => 'radio', 'label' => $this->i18n->__('Allow Mobile Access'), 'value' => $yesNo, 'marked' => '1'));
     $fields2b = array('email_as_username' => array('type' => 'radio', 'label' => $this->i18n->__('Allow Email as Username'), 'value' => $yesNo, 'marked' => '0'), 'email_verification' => array('type' => 'radio', 'label' => $this->i18n->__('User Email Verification'), 'value' => $yesNo, 'marked' => '0'), 'global_access' => array('type' => 'radio', 'label' => $this->i18n->__('Allow Global Access'), 'value' => $yesNo, 'marked' => '0'), 'force_ssl' => array('type' => 'radio', 'label' => $this->i18n->__('Force SSL'), 'value' => $yesNo, 'marked' => '0'), 'track_sessions' => array('type' => 'radio', 'label' => $this->i18n->__('Track Sessions'), 'value' => $yesNo, 'marked' => '1'), 'verification' => array('type' => 'radio', 'label' => $this->i18n->__('System Email Verification'), 'value' => $yesNo, 'marked' => '1'), 'approval' => array('type' => 'radio', 'label' => $this->i18n->__('Require Approval'), 'value' => $yesNo, 'marked' => '1'), 'unsubscribe_login' => array('type' => 'radio', 'label' => $this->i18n->__('Require Login for Unsubscribe'), 'value' => $yesNo, 'marked' => '1'));
     $fieldGroups = array();
     $dynamicFields = false;
     $model = str_replace('Form', 'Model', get_class($this));
     $newFields = \Phire\Model\Field::getByModel($model, 0, $tid);
     if ($newFields['dynamic']) {
         $dynamicFields = true;
     }
     if ($newFields['hasFile']) {
         $this->hasFile = true;
     }
     foreach ($newFields as $key => $value) {
         if (is_numeric($key)) {
             $fieldGroups[] = $value;
         }
     }
     $fields4 = array();
     $fields4['submit'] = array('type' => 'submit', 'value' => $this->i18n->__('SAVE'), 'attributes' => array('class' => 'save-btn'));
     $fields4['update'] = array('type' => 'button', 'value' => $this->i18n->__('UPDATE'), 'attributes' => array('onclick' => "return phire.updateForm('#user-type-form', " . ($this->hasFile || $dynamicFields ? 'true' : 'false') . ");", 'class' => 'update-btn'));
     $fields4['id'] = array('type' => 'hidden', 'value' => 0);
     $fields4['update_value'] = array('type' => 'hidden', 'value' => 0);
     $fields4['default_role_id'] = array('type' => 'select', 'label' => $this->i18n->__('Default Role'), 'value' => $rolesAry, 'attributes' => array('style' => 'width: 200px;'));
     $fields4['password_encryption'] = array('type' => 'select', 'label' => $this->i18n->__('Password Encryption'), 'value' => array('1' => 'MD5', '2' => 'SHA1', '3' => 'Crypt', '4' => 'Bcrypt', '5' => 'Mcrypt (2-Way)', '6' => 'Crypt_MD5', '7' => 'Crypt_SHA256', '8' => 'Crypt_SHA512', '0' => $this->i18n->__('None')), 'marked' => '4', 'attributes' => array('style' => 'width: 200px;'));
     $fields4['reset_password'] = array('type' => 'select', 'label' => $this->i18n->__('Password Reset'), 'value' => $yesNo, 'marked' => '0');
     $fields4['reset_password_interval'] = array('type' => 'select', 'label' => $this->i18n->__('Password Reset Interval'), 'value' => array('--' => '--', '1st' => '1st Login', 'Every' => 'Every'), 'marked' => '0');
     $fields4['reset_password_interval_value'] = array('type' => 'text', 'attributes' => array('size' => 2, 'style' => 'margin: 0; padding: 3px 5px 3px 5px; height: 16px; font-size: 0.9em;'));
     $fields4['reset_password_interval_unit'] = array('type' => 'select', 'value' => array('--' => '--', 'Days' => 'Day(s)', 'Months' => 'Month(s)', 'Years' => 'Year(s)'));
     $fields4['allowed_attempts'] = array('type' => 'text', 'label' => $this->i18n->__('Allowed Attempts'), 'attributes' => array('size' => 3), 'value' => '0');
     $fields4['session_expiration'] = array('type' => 'text', 'label' => $this->i18n->__('Session Expiration') . ' <span style="font-size: 0.9em; font-weight: normal;">(' . $this->i18n->__('Minutes') . ')</span>', 'attributes' => array('size' => 3), 'value' => '0');
     $allFields = array($fields4, $fields1, $fields2a, $fields2b);
     if (count($fieldGroups) > 0) {
         foreach ($fieldGroups as $fg) {
             $allFields[] = $fg;
         }
     }
     return $allFields;
 }
 /**
  * Field remove method
  *
  * @return void
  */
 public function remove()
 {
     // Loop through and delete the fields
     if ($this->request->isPost()) {
         $field = new Model\Field();
         $field->remove($this->request->getPost());
     }
     Response::redirect($this->request->getBasePath() . '?removed=' . time());
 }
示例#4
0
 /**
  * Get the init field values
  *
  * @param  int         $rid
  * @param  \Pop\Config $config
  * @return array
  */
 protected function getInitFields($rid = 0, $config = null)
 {
     // Get types for the user role
     $typesAry = array();
     $types = UserTypes::findAll('id ASC');
     foreach ($types->rows as $type) {
         $typesAry[$type->id] = $type->type;
     }
     // Create initial fields
     $fields1 = array('name' => array('type' => 'text', 'label' => $this->i18n->__('Name'), 'required' => true, 'attributes' => array('size' => 75, 'style' => 'width: 600px;')));
     if ($rid != 0) {
         $fields1['name']['attributes']['onkeyup'] = "phire.updateTitle('#user-role-title', this);";
     }
     // Get any existing field values
     $fields2 = array();
     $fieldGroups = array();
     $model = str_replace('Form', 'Model', get_class($this));
     $newFields = \Phire\Model\Field::getByModel($model, 0, $rid);
     if ($newFields['hasFile']) {
         $this->hasFile = true;
     }
     foreach ($newFields as $key => $value) {
         if (is_numeric($key)) {
             $fieldGroups[] = $value;
         }
     }
     // Get available resources with their corresponding permissions
     $resources = \Phire\Model\UserRole::getResources($config);
     $classes = array('0' => '(' . $this->i18n->__('All') . ')');
     $classTypes = array();
     $classActions = array();
     foreach ($resources as $key => $resource) {
         $classes[$key] = $resource['name'];
         $classTypes[$key] = array('0' => '(' . $this->i18n->__('All') . ')');
         $classActions[$key] = array('0' => '(' . $this->i18n->__('All') . ')');
         foreach ($resource['types'] as $id => $type) {
             if ((int) $id != 0) {
                 $classTypes[$key][$id] = $type;
             }
         }
         foreach ($resource['actions'] as $permAction) {
             $classActions[$key][$permAction] = $permAction;
         }
     }
     asort($classes);
     // Get any current resource/permission fields
     if ($rid != 0) {
         $role = UserRoles::findById($rid);
         $permissions = null !== $role->permissions ? unserialize($role->permissions) : array();
         $i = 1;
         foreach ($permissions as $permission) {
             if (strpos($permission['permission'], '_') !== false) {
                 $permAry = explode('_', $permission['permission']);
                 $p = $permAry[0];
                 $t = $permAry[1];
             } else {
                 $p = $permission['permission'];
                 $t = '0';
             }
             $fields2['resource_cur_' . $i] = array('type' => 'select', 'label' => "&nbsp;", 'value' => $classes, 'marked' => $permission['resource'], 'attributes' => array('onchange' => 'phire.changePermissions(this);', 'style' => 'display: block;'));
             $fields2['permission_cur_' . $i] = array('type' => 'select', 'value' => $classActions[$permission['resource']], 'marked' => $p, 'attributes' => array('style' => 'display: block; width: 150px;'));
             $fields2['type_cur_' . $i] = array('type' => 'select', 'value' => $classTypes[$permission['resource']], 'marked' => $t, 'attributes' => array('style' => 'display: block; width: 150px;'));
             $fields2['allow_cur_' . $i] = array('type' => 'select', 'value' => array('1' => $this->i18n->__('allow'), '0' => $this->i18n->__('deny')), 'marked' => $permission['allow'], 'attributes' => array('style' => 'display: block; width: 150px;'));
             $fields2['rm_resource_' . $i] = array('type' => 'checkbox', 'value' => array($rid . '_' . $permission['resource'] . '_' . $permission['permission'] => $this->i18n->__('Remove') . '?'));
             $i++;
         }
     }
     // Create new resource/permission fields
     $fields3 = array('resource_new_1' => array('type' => 'select', 'label' => '<span class="label-pad-2"><a href="#" onclick="phire.addResource(); return false;">[+]</a> ' . $this->i18n->__('Resource') . '</span><span class="label-pad-2">' . $this->i18n->__('Action') . '</span><span class="label-pad-2">' . $this->i18n->__('Type') . '</span><span class="label-pad-2">' . $this->i18n->__('Permission') . '</span>', 'attributes' => array('onchange' => 'phire.changePermissions(this);', 'style' => 'display: block; margin: 3px 0 3px 0;'), 'value' => $classes), 'permission_new_1' => array('type' => 'select', 'attributes' => array('style' => 'display: block; width: 150px; margin: 3px 0 3px 0;'), 'value' => array('0' => '(' . $this->i18n->__('All') . ')')), 'type_new_1' => array('type' => 'select', 'attributes' => array('style' => 'display: block; width: 150px; margin: 3px 0 3px 0;'), 'value' => array('0' => '(' . $this->i18n->__('All') . ')')), 'allow_new_1' => array('type' => 'select', 'attributes' => array('style' => 'display: block; width: 150px; margin: 3px 0 3px 0;'), 'value' => array('1' => $this->i18n->__('allow'), '0' => $this->i18n->__('deny'))));
     $fields4 = array('submit' => array('type' => 'submit', 'value' => $this->i18n->__('SAVE'), 'attributes' => array('class' => 'save-btn')), 'update' => array('type' => 'button', 'value' => $this->i18n->__('UPDATE'), 'attributes' => array('onclick' => "return phire.updateForm('#user-role-form', true);", 'class' => 'update-btn')), 'type_id' => array('type' => 'select', 'required' => true, 'label' => $this->i18n->__('User Type'), 'value' => $typesAry, 'attributes' => array('style' => 'width: 200px;')), 'id' => array('type' => 'hidden', 'value' => 0), 'update_value' => array('type' => 'hidden', 'value' => 0));
     $allFields = array($fields4, $fields1);
     if (count($fieldGroups) > 0) {
         foreach ($fieldGroups as $fg) {
             $allFields[] = $fg;
         }
     }
     $allFields[] = $fields3;
     $allFields[] = $fields2;
     return $allFields;
 }
示例#5
0
 /**
  * Get the init field values
  *
  * @param  int         $id
  * @param  \Pop\Config $config
  * @return array
  */
 protected function getInitFields($id = 0, $config = null)
 {
     // Get field groups
     $groups = array('0' => '----');
     $grps = Table\FieldGroups::findAll('id ASC');
     if (isset($grps->rows[0])) {
         foreach ($grps->rows as $grp) {
             $groups[$grp->id] = $grp->name;
         }
     }
     $editors = array('source' => 'Source');
     if (file_exists($_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/assets/js/ckeditor')) {
         $editors['ckeditor'] = 'CKEditor';
     }
     if (file_exists($_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/assets/js/tinymce')) {
         $editors['tinymce'] = 'TinyMCE';
     }
     // Get any current validators
     $fields2 = array();
     $editorDisplay = 'none;';
     if ($id != 0) {
         $fld = Table\Fields::findById($id);
         if (isset($fld->id)) {
             if (strpos($fld->type, 'textarea') !== false) {
                 $editorDisplay = 'block;';
             }
             $validators = unserialize($fld->validators);
             if ($validators != '') {
                 $i = 1;
                 foreach ($validators as $key => $value) {
                     $fields2['validator_cur_' . $i] = array('type' => 'select', 'label' => '&nbsp;', 'value' => $this->validators, 'marked' => $key);
                     $fields2['validator_value_cur_' . $i] = array('type' => 'text', 'attributes' => array('size' => 10, 'style' => 'display: block; padding: 4px 4px 5px 4px; margin: 0 0 4px 0; height: 17px;'), 'value' => $value['value']);
                     $fields2['validator_message_cur_' . $i] = array('type' => 'text', 'attributes' => array('size' => 30, 'style' => 'display: block; padding: 4px 4px 5px 4px; margin: 0 0 4px 0; height: 17px;'), 'value' => $value['message']);
                     $fields2['validator_remove_cur_' . $i] = array('type' => 'checkbox', 'value' => array('Yes' => $this->i18n->__('Remove') . '?'));
                     $i++;
                 }
             }
         }
     }
     // Start creating initial fields
     $fields1 = array('type' => array('type' => 'select', 'label' => $this->i18n->__('Field Type'), 'required' => true, 'value' => array('text' => 'text', 'text-history' => 'text (history)', 'textarea' => 'textarea', 'textarea-history' => 'textarea (history)', 'select' => 'select', 'checkbox' => 'checkbox', 'radio' => 'radio', 'file' => 'file', 'hidden' => 'hidden'), 'attributes' => array('style' => 'width: 200px;', 'onchange' => 'phire.toggleEditor(this);')), 'editor' => array('type' => 'select', 'value' => $editors, 'marked' => 0, 'attributes' => array('style' => 'display: ' . $editorDisplay)), 'name' => array('type' => 'text', 'label' => $this->i18n->__('Field Name'), 'required' => true, 'attributes' => array('size' => 64)), 'label' => array('type' => 'text', 'label' => $this->i18n->__('Field Label'), 'attributes' => array('size' => 64)), 'values' => array('type' => 'text', 'label' => $this->i18n->__('Field Values') . ' <span style="font-size: 0.9em; font-weight: normal;">(' . $this->i18n->__('Pipe delimited') . ')</span>', 'attributes' => array('size' => 64)), 'default_values' => array('type' => 'text', 'label' => $this->i18n->__('Default Field Values') . ' <span style="font-size: 0.9em; font-weight: normal;">(' . $this->i18n->__('Pipe delimited') . ')</span>', 'attributes' => array('size' => 64)), 'attributes' => array('type' => 'text', 'label' => $this->i18n->__('Field Attributes'), 'attributes' => array('size' => 64)), 'validator_new_1' => array('type' => 'select', 'label' => '<a href="#" onclick="phire.addValidator(); return false;">[+]</a> ' . $this->i18n->__('Field Validators') . '<br /><span style="font-size: 0.9em;">(' . $this->i18n->__('Type / Value / Message') . ')</span>', 'value' => $this->validators, 'attributes' => array('style' => 'display: block; padding: 4px 4px 5px 4px; margin: 0 0 4px 0; height: 28px;')), 'validator_value_new_1' => array('type' => 'text', 'attributes' => array('size' => 10, 'style' => 'display: block; padding: 4px 4px 5px 4px; margin: 0 0 4px 0; height: 17px;')), 'validator_message_new_1' => array('type' => 'text', 'attributes' => array('size' => 30, 'style' => 'display: block; padding: 4px 4px 5px 4px; margin: 0 0 4px 0; height: 17px;')));
     if ($id != 0) {
         $fields1['name']['attributes']['onkeyup'] = "phire.updateTitle('#field-title', this);";
     }
     // Create next set of fields
     $fields3 = array();
     $models = Model\Field::getModels($config);
     asort($models);
     $fields3['model_new_1'] = array('type' => 'select', 'label' => '<a href="#" onclick="phire.addModel(); return false;">[+]</a> ' . $this->i18n->__('Model &amp; Type'), 'value' => $models, 'attributes' => array('style' => 'display: block; margin: 0 0 4px 0;', 'onchange' => 'phire.changeModelTypes(this);'));
     $fields3['type_id_new_1'] = array('type' => 'select', 'value' => \Phire\Project::getModelTypes($models), 'attributes' => array('style' => 'display: block; width: 200px; margin: 0 0 4px 0;'));
     if ($id != 0) {
         $field = Table\Fields::findById($id);
         $fieldToModels = null !== $field->models ? unserialize($field->models) : array();
         if (isset($fieldToModels[0])) {
             $i = 1;
             foreach ($fieldToModels as $f2m) {
                 $fields3['model_cur_' . $i] = array('type' => 'select', 'label' => '&nbsp;', 'value' => $models, 'marked' => $f2m['model'], 'attributes' => array('style' => 'display: block; margin: 0 0 4px 0;', 'onchange' => 'phire.changeModelTypes(this);'));
                 $fields3['type_id_cur_' . $i] = array('type' => 'select', 'value' => \Phire\Project::getModelTypes(str_replace('\\', '_', $f2m['model'])), 'marked' => $f2m['type_id'], 'attributes' => array('style' => 'display: block; width: 200px; margin: 0 0 4px 0;'));
                 $fields3['rm_model_cur_' . $i] = array('type' => 'checkbox', 'value' => array($field->id . '_' . $f2m['model'] . '_' . $f2m['type_id'] => 'Remove?'));
                 $i++;
             }
         }
     }
     $fields4 = array();
     $fields4['submit'] = array('type' => 'submit', 'value' => $this->i18n->__('SAVE'), 'attributes' => array('class' => 'save-btn'));
     $fields4['update'] = array('type' => 'button', 'value' => $this->i18n->__('UPDATE'), 'attributes' => array('onclick' => "return phire.updateForm('#field-form', true);", 'class' => 'update-btn'));
     $fields4['order'] = array('type' => 'text', 'label' => $this->i18n->__('Order'), 'value' => 0, 'attributes' => array('size' => 3));
     $fields4['group_id'] = array('type' => 'select', 'label' => $this->i18n->__('Field Group'), 'value' => $groups, 'attributes' => array('style' => 'display: block; width: 200px;'));
     $fields4['encryption'] = array('type' => 'select', 'label' => $this->i18n->__('Encryption'), 'value' => array('0' => $this->i18n->__('None'), '1' => 'MD5', '2' => 'SHA1', '3' => 'Crypt', '4' => 'Bcrypt', '5' => 'Mcrypt (2-Way)', '6' => 'Crypt_MD5', '7' => 'Crypt_SHA256', '8' => 'Crypt_SHA512'), 'marked' => 0, 'attributes' => array('style' => 'display: block; width: 200px;'));
     $fields4['required'] = array('type' => 'select', 'label' => $this->i18n->__('Required'), 'value' => array('0' => $this->i18n->__('No'), '1' => $this->i18n->__('Yes')), 'marked' => 0);
     $fields4['id'] = array('type' => 'hidden', 'value' => 0);
     $fields4['update_value'] = array('type' => 'hidden', 'value' => 0);
     return array($fields4, $fields1, $fields2, $fields3);
 }
示例#6
0
 /**
  * Get the init field values
  *
  * @param  int     $tid
  * @param  boolean $profile
  * @param  int     $uid
  * @param  string  $action
  * @param  boolean $register
  * @return array
  */
 protected function getInitFields($tid = 0, $profile = false, $uid = 0, $action, $register = false)
 {
     $type = Table\UserTypes::findById($tid);
     $fields1 = array();
     // Continue setting up initial user fields
     $fields1['email1'] = array('type' => 'text', 'label' => $this->i18n->__('Email'), 'required' => true, 'attributes' => array('size' => 30), 'validators' => new Validator\Email());
     if ($type->email_verification) {
         $fields1['email2'] = array('type' => 'text', 'label' => $this->i18n->__('Re-Type Email'), 'required' => true, 'attributes' => array('size' => 30), 'validators' => new Validator\Email());
     }
     // If not email as username, create username field
     if (!$type->email_as_username) {
         $fields2 = array('username' => array('type' => 'text', 'label' => $this->i18n->__('Username'), 'required' => true, 'attributes' => array('size' => 30), 'validators' => array(new Validator\AlphaNumeric(), new Validator\LengthGte(4))));
         if ($uid != 0) {
             $fields2['username']['attributes']['onkeyup'] = "phire.updateTitle('#username-title', this);";
         }
     } else {
         $fields2 = array();
         if ($uid != 0) {
             $fields1['email1']['attributes']['onkeyup'] = "phire.updateTitle('#username-title', this);";
         }
     }
     // Continue setting up initial user fields
     if ($type->login) {
         $fields3 = array('password1' => array('type' => 'password', 'label' => $this->i18n->__('Enter Password'), 'required' => true, 'attributes' => array('size' => 30), 'validators' => new Validator\LengthGte(6)), 'password2' => array('type' => 'password', 'label' => $this->i18n->__('Re-Type Password'), 'required' => true, 'attributes' => array('size' => 30), 'validators' => new Validator\LengthGte(6)));
     } else {
         $fields3 = array();
     }
     $fieldGroups = array();
     $dynamicFields = false;
     $model = str_replace('Form', 'Model', get_class($this));
     $newFields = \Phire\Model\Field::getByModel($model, $tid, $uid);
     if ($newFields['dynamic']) {
         $dynamicFields = true;
     }
     if ($newFields['hasFile']) {
         $this->hasFile = true;
     }
     foreach ($newFields as $key => $value) {
         if (is_numeric($key)) {
             $fieldGroups[] = $value;
         }
     }
     $fields4 = array();
     if ($register) {
         $site = Table\Sites::getSite();
         if ($type->use_csrf) {
             $fields4['csrf'] = array('type' => 'csrf', 'value' => \Pop\Filter\String::random(8));
         }
         if ($type->use_captcha) {
             $fields4['captcha'] = array('type' => 'captcha', 'label' => $this->i18n->__('Enter Code'), 'captcha' => '<br /><img id="captcha-image" src="' . $site->base_path . '/captcha" /><br /><a class="reload-link" href="#" onclick="document.getElementById(\'captcha-image\').src = \'' . $site->base_path . '/captcha?reload=1\';return false;">' . $this->i18n->__('Reload') . '</a>', 'attributes' => array('size' => 5));
         }
     }
     // Finish the initial fields
     $fields4['submit'] = array('type' => 'submit', 'value' => strpos($action, '/register') !== false ? $this->i18n->__('REGISTER') : $this->i18n->__('SAVE'), 'attributes' => array('class' => strpos($action, '/install/user') !== false || $profile ? 'update-btn' : 'save-btn'));
     if ($profile) {
         $fields4['submit']['label'] = '&nbsp;';
         $fields4['submit']['attributes']['style'] = 'width: 250px;';
         $fields4['profile'] = array('type' => 'hidden', 'value' => 1);
         $sess = \Pop\Web\Session::getInstance();
         if (isset($sess->reset_pwd)) {
             $fields4['reset_pwd'] = array('type' => 'hidden', 'value' => 1);
         }
     }
     if (!$profile) {
         $fields4['update'] = array('type' => 'button', 'value' => $this->i18n->__('Update'), 'attributes' => array('onclick' => "return phire.updateForm('#user-form', " . ($this->hasFile || $dynamicFields ? 'true' : 'false') . ");", 'class' => 'update-btn'));
     }
     $fields4['type_id'] = array('type' => 'hidden', 'value' => $tid);
     $fields4['id'] = array('type' => 'hidden', 'value' => 0);
     if (!$profile) {
         $fields4['update_value'] = array('type' => 'hidden', 'value' => 0);
     }
     // If not profile
     if (!$profile) {
         // Get roles for user type
         $rolesAry = array('0' => '(' . $this->i18n->__('Blocked') . ')');
         if ($tid != 0) {
             $roles = Table\UserRoles::findBy(array('type_id' => $tid), 'id ASC');
             foreach ($roles->rows as $role) {
                 $rolesAry[$role->id] = $role->name;
             }
         }
         $siteIds = array('0' => $_SERVER['HTTP_HOST']);
         $sites = Table\Sites::findAll();
         foreach ($sites->rows as $site) {
             $siteIds[(string) $site->id] = $site->domain;
         }
         $fields4['role_id'] = array('type' => 'select', 'required' => true, 'label' => $this->i18n->__('User Role'), 'value' => $rolesAry, 'marked' => $type->default_role_id);
         $fields4['verified'] = array('type' => 'select', 'label' => $this->i18n->__('Verified'), 'value' => array('1' => $this->i18n->__('Yes'), '0' => $this->i18n->__('No')), 'marked' => '0');
         $fields4['failed_attempts'] = array('type' => 'text', 'label' => $this->i18n->__('Failed Attempts'), 'attributes' => array('size' => 3));
         $fields4['site_ids'] = array('type' => 'checkbox', 'label' => $this->i18n->__('Allowed Sites'), 'value' => $siteIds);
     }
     if (strpos($action, '/install/user') !== false || $profile) {
         $allFields = array($fields1, $fields2, $fields3);
         if (count($fieldGroups) > 0) {
             foreach ($fieldGroups as $fg) {
                 $allFields[] = $fg;
             }
         }
         $allFields[] = $fields4;
     } else {
         $allFields = array($fields4, $fields1, $fields2, $fields3);
         if (count($fieldGroups) > 0) {
             foreach ($fieldGroups as $fg) {
                 $allFields[] = $fg;
             }
         }
     }
     return $allFields;
 }