1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: class Mage_Adminhtml_Block_Permissions_Tab_Useredit extends Mage_Adminhtml_Block_Widget_Form
27: {
28:
29: protected function _prepareForm()
30: {
31: $form = new Varien_Data_Form();
32:
33: $user = Mage::registry('user_data');
34:
35: $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Account Information')));
36:
37: $fieldset->addField('username', 'text',
38: array(
39: 'name' => 'username',
40: 'label' => Mage::helper('adminhtml')->__('User Name'),
41: 'id' => 'username',
42: 'title' => Mage::helper('adminhtml')->__('User Name'),
43: 'class' => 'required-entry',
44: 'required' => true,
45: )
46: );
47:
48: $fieldset->addField('firstname', 'text',
49: array(
50: 'name' => 'firstname',
51: 'label' => Mage::helper('adminhtml')->__('First Name'),
52: 'id' => 'firstname',
53: 'title' => Mage::helper('adminhtml')->__('First Name'),
54: 'class' => 'required-entry',
55: 'required' => true,
56: )
57: );
58:
59: $fieldset->addField('lastname', 'text',
60: array(
61: 'name' => 'lastname',
62: 'label' => Mage::helper('adminhtml')->__('Last Name'),
63: 'id' => 'lastname',
64: 'title' => Mage::helper('adminhtml')->__('Last Name'),
65: 'class' => 'required-entry',
66: 'required' => true,
67: )
68: );
69:
70: $fieldset->addField('user_id', 'hidden',
71: array(
72: 'name' => 'user_id',
73: 'id' => 'user_id',
74: )
75: );
76:
77: $fieldset->addField('email', 'text',
78: array(
79: 'name' => 'email',
80: 'label' => Mage::helper('adminhtml')->__('Email'),
81: 'id' => 'customer_email',
82: 'title' => Mage::helper('adminhtml')->__('User Email'),
83: 'class' => 'required-entry validate-email',
84: 'required' => true,
85: )
86: );
87:
88: if ($user->getUserId()) {
89: $fieldset->addField('password', 'password',
90: array(
91: 'name' => 'new_password',
92: 'label' => Mage::helper('adminhtml')->__('New Password'),
93: 'id' => 'new_pass',
94: 'title' => Mage::helper('adminhtml')->__('New Password'),
95: 'class' => 'input-text validate-password',
96: )
97: );
98:
99: $fieldset->addField('confirmation', 'password',
100: array(
101: 'name' => 'password_confirmation',
102: 'label' => Mage::helper('adminhtml')->__('Password Confirmation'),
103: 'id' => 'confirmation',
104: 'class' => 'input-text validate-cpassword',
105: )
106: );
107: }
108: else {
109: $fieldset->addField('password', 'password',
110: array(
111: 'name' => 'password',
112: 'label' => Mage::helper('adminhtml')->__('Password'),
113: 'id' => 'customer_pass',
114: 'title' => Mage::helper('adminhtml')->__('Password'),
115: 'class' => 'input-text required-entry validate-password',
116: 'required' => true,
117: )
118: );
119: $fieldset->addField('confirmation', 'password',
120: array(
121: 'name' => 'password_confirmation',
122: 'label' => Mage::helper('adminhtml')->__('Password Confirmation'),
123: 'id' => 'confirmation',
124: 'title' => Mage::helper('adminhtml')->__('Password Confirmation'),
125: 'class' => 'input-text required-entry validate-cpassword',
126: 'required' => true,
127: )
128: );
129: }
130:
131: $fieldset->addField('is_active', 'select',
132: array(
133: 'name' => 'is_active',
134: 'label' => Mage::helper('adminhtml')->__('This Account is'),
135: 'id' => 'is_active',
136: 'title' => Mage::helper('adminhtml')->__('Account Status'),
137: 'class' => 'input-select',
138: 'required' => false,
139: 'style' => 'width: 80px',
140: 'value' => '1',
141: 'values' => array(
142: array(
143: 'label' => Mage::helper('adminhtml')->__('Active'),
144: 'value' => '1',
145: ),
146: array(
147: 'label' => Mage::helper('adminhtml')->__('Inactive'),
148: 'value' => '0',
149: ),
150: ),
151: )
152: );
153:
154: $data = $user->getData();
155:
156: unset($data['password']);
157:
158: $form->setValues($data);
159:
160: $this->setForm($form);
161: }
162:
163: }
164:
165: