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:
27: 28: 29: 30: 31: 32: 33:
34:
35: class Mage_Adminhtml_Block_Api_User_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
36: {
37:
38: protected function _prepareForm()
39: {
40: $model = Mage::registry('api_user');
41:
42: $form = new Varien_Data_Form();
43:
44: $form->setHtmlIdPrefix('user_');
45:
46: $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Account Information')));
47:
48: if ($model->getUserId()) {
49: $fieldset->addField('user_id', 'hidden', array(
50: 'name' => 'user_id',
51: ));
52: } else {
53: if (! $model->hasData('is_active')) {
54: $model->setIsActive(1);
55: }
56: }
57:
58: $fieldset->addField('username', 'text', array(
59: 'name' => 'username',
60: 'label' => Mage::helper('adminhtml')->__('User Name'),
61: 'id' => 'username',
62: 'title' => Mage::helper('adminhtml')->__('User Name'),
63: 'required' => true,
64: ));
65:
66: $fieldset->addField('firstname', 'text', array(
67: 'name' => 'firstname',
68: 'label' => Mage::helper('adminhtml')->__('First Name'),
69: 'id' => 'firstname',
70: 'title' => Mage::helper('adminhtml')->__('First Name'),
71: 'required' => true,
72: ));
73:
74: $fieldset->addField('lastname', 'text', array(
75: 'name' => 'lastname',
76: 'label' => Mage::helper('adminhtml')->__('Last Name'),
77: 'id' => 'lastname',
78: 'title' => Mage::helper('adminhtml')->__('Last Name'),
79: 'required' => true,
80: ));
81:
82: $fieldset->addField('email', 'text', array(
83: 'name' => 'email',
84: 'label' => Mage::helper('adminhtml')->__('Email'),
85: 'id' => 'customer_email',
86: 'title' => Mage::helper('adminhtml')->__('User Email'),
87: 'class' => 'required-entry validate-email',
88: 'required' => true,
89: ));
90:
91: if ($model->getUserId()) {
92: $fieldset->addField('password', 'password', array(
93: 'name' => 'new_api_key',
94: 'label' => Mage::helper('adminhtml')->__('New API Key'),
95: 'id' => 'new_pass',
96: 'title' => Mage::helper('adminhtml')->__('New API Key'),
97: 'class' => 'input-text validate-password',
98: ));
99:
100: $fieldset->addField('confirmation', 'password', array(
101: 'name' => 'api_key_confirmation',
102: 'label' => Mage::helper('adminhtml')->__('API Key Confirmation'),
103: 'id' => 'confirmation',
104: 'class' => 'input-text validate-cpassword',
105: ));
106: }
107: else {
108: $fieldset->addField('password', 'password', array(
109: 'name' => 'api_key',
110: 'label' => Mage::helper('adminhtml')->__('API Key'),
111: 'id' => 'customer_pass',
112: 'title' => Mage::helper('adminhtml')->__('API Key'),
113: 'class' => 'input-text required-entry validate-password',
114: 'required' => true,
115: ));
116: $fieldset->addField('confirmation', 'password', array(
117: 'name' => 'api_key_confirmation',
118: 'label' => Mage::helper('adminhtml')->__('API Key Confirmation'),
119: 'id' => 'confirmation',
120: 'title' => Mage::helper('adminhtml')->__('API Key Confirmation'),
121: 'class' => 'input-text required-entry validate-cpassword',
122: 'required' => true,
123: ));
124: }
125:
126: if (Mage::getSingleton('admin/session')->getUser()->getId() != $model->getUserId()) {
127: $fieldset->addField('is_active', 'select', array(
128: 'name' => 'is_active',
129: 'label' => Mage::helper('adminhtml')->__('This account is'),
130: 'id' => 'is_active',
131: 'title' => Mage::helper('adminhtml')->__('Account status'),
132: 'class' => 'input-select',
133: 'style' => 'width: 80px',
134: 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')),
135: ));
136: }
137:
138: $fieldset->addField('user_roles', 'hidden', array(
139: 'name' => 'user_roles',
140: 'id' => '_user_roles',
141: ));
142:
143: $data = $model->getData();
144:
145: unset($data['password']);
146:
147: $form->setValues($data);
148:
149: $this->setForm($form);
150:
151: return parent::_prepareForm();
152: }
153: }
154: