update.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /**
  2. * Loads the profile page
  3. *
  4. * @class MODx.page.Profile
  5. * @extends MODx.Component
  6. * @param {Object} config An object of configuration properties
  7. * @xtype modx-page-profile
  8. */
  9. MODx.page.Profile = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. components: [{
  13. xtype: 'modx-panel-profile'
  14. ,user: config.user
  15. }]
  16. });
  17. MODx.page.Profile.superclass.constructor.call(this,config);
  18. };
  19. Ext.extend(MODx.page.Profile,MODx.Component);
  20. Ext.reg('modx-page-profile',MODx.page.Profile);
  21. MODx.panel.Profile = function(config) {
  22. config = config || {};
  23. Ext.applyIf(config,{
  24. id: 'modx-panel-profile'
  25. ,url: MODx.config.connector_url
  26. ,baseParams: {
  27. action: 'security/profile'
  28. }
  29. ,layout: 'anchor'
  30. ,cls: 'container'
  31. ,bodyStyle: 'background: none;'
  32. ,border: false
  33. ,items: [{
  34. html: _('profile')
  35. ,id: 'modx-profile-header'
  36. ,xtype: 'modx-header'
  37. },this.getTabs(config)]
  38. });
  39. MODx.panel.Profile.superclass.constructor.call(this,config);
  40. };
  41. Ext.extend(MODx.panel.Profile,MODx.Panel, {
  42. getTabs: function(config) {
  43. var items = [{
  44. xtype: 'modx-panel-profile-update'
  45. ,id: 'modx-panel-profile-update'
  46. ,user: config.user
  47. ,preventRender: true
  48. }];
  49. if (MODx.perm.change_password) {
  50. items.push({
  51. xtype: 'modx-panel-profile-password-change'
  52. ,id: 'modx-panel-profile-password-change'
  53. ,user: config.user
  54. ,preventRender: true
  55. });
  56. }
  57. if (MODx.perm.view_document) {
  58. items.push({
  59. title: _('profile_recent_resources')
  60. ,bodyStyle: 'padding: 15px;'
  61. ,id: 'modx-profile-recent-docs'
  62. ,autoHeight: true
  63. ,layout: 'anchor'
  64. ,items: [{
  65. html: '<p>'+_('profile_recent_resources_desc')+'</p><br />'
  66. ,id: 'modx-profile-recent-docs-msg'
  67. ,border: false
  68. },{
  69. xtype: 'modx-grid-user-recent-resource'
  70. ,user: config.user
  71. ,preventRender: true
  72. }]
  73. });
  74. }
  75. return MODx.getPageStructure(items);
  76. }
  77. });
  78. Ext.reg('modx-panel-profile',MODx.panel.Profile);
  79. /**
  80. * The information panel for the profile
  81. *
  82. * @class MODx.panel.UpdateProfile
  83. * @extends MODx.FormPanel
  84. * @param {Object} config An object of config properties
  85. * @xtype: panel-profile-update
  86. */
  87. MODx.panel.UpdateProfile = function(config) {
  88. config = config || {};
  89. Ext.applyIf(config,{
  90. title: _('general_information')
  91. ,id: 'modx-panel-profile-update'
  92. ,url: MODx.config.connector_url
  93. ,baseParams: {
  94. action: 'security/profile/update'
  95. ,id: config.user
  96. }
  97. ,layout: 'form'
  98. ,buttonAlign: 'right'
  99. ,cls: 'container form-with-labels'
  100. ,labelAlign: 'top'
  101. ,defaults: {
  102. border: false
  103. ,msgTarget: 'under'
  104. ,anchor: '100%'
  105. }
  106. ,labelWidth: 150
  107. ,items: [{
  108. xtype: 'textfield'
  109. ,fieldLabel: _('user_full_name')
  110. ,name: 'fullname'
  111. ,maxLength: 255
  112. ,allowBlank: false
  113. },{
  114. xtype: 'textfield'
  115. ,fieldLabel: _('email')
  116. ,name: 'email'
  117. ,vtype: 'email'
  118. ,allowBlank: false
  119. },{
  120. fieldLabel: _('user_photo')
  121. ,name: 'photo'
  122. ,xtype: 'modx-combo-browser'
  123. ,hideFiles: true
  124. ,source: MODx.config['photo_profile_source'] || MODx.config.default_media_source
  125. ,hideSourceCombo: true
  126. },{
  127. xtype: 'textfield'
  128. ,fieldLabel: _('user_phone')
  129. ,name: 'phone'
  130. ,anchor: '50%'
  131. },{
  132. xtype: 'textfield'
  133. ,fieldLabel: _('user_mobile')
  134. ,name: 'mobilephone'
  135. ,anchor: '50%'
  136. },{
  137. xtype: 'textfield'
  138. ,fieldLabel: _('user_fax')
  139. ,name: 'fax'
  140. ,anchor: '50%'
  141. },{
  142. xtype: 'datefield'
  143. ,fieldLabel: _('user_dob')
  144. ,name: 'dob'
  145. ,anchor: '50%'
  146. },{
  147. xtype: 'textfield'
  148. ,fieldLabel: _('user_state')
  149. ,name: 'state'
  150. ,maxLength: 50
  151. ,anchor: '50%'
  152. },{
  153. xtype: 'textfield'
  154. ,fieldLabel: _('user_zip')
  155. ,name: 'zip'
  156. ,maxLength: 20
  157. ,anchor: '50%'
  158. }]
  159. // TODO: this button should be in a actionbar like any other panel
  160. ,buttons: [{
  161. text: _('save')
  162. ,scope: this
  163. ,handler: this.submit
  164. ,cls:'primary-button'
  165. }]
  166. ,listeners: {
  167. 'setup': {fn:this.setup,scope:this}
  168. }
  169. });
  170. MODx.panel.UpdateProfile.superclass.constructor.call(this,config);
  171. };
  172. Ext.extend(MODx.panel.UpdateProfile,MODx.FormPanel,{
  173. setup: function() {
  174. MODx.Ajax.request({
  175. url: MODx.config.connector_url
  176. ,params: {
  177. action: 'security/profile/get'
  178. ,id: this.config.user
  179. }
  180. ,listeners: {
  181. 'success': {fn:function(r) {
  182. this.getForm().setValues(r.object);
  183. },scope:this}
  184. }
  185. });
  186. }
  187. });
  188. Ext.reg('modx-panel-profile-update',MODx.panel.UpdateProfile);
  189. /**
  190. * A panel for changing the user password
  191. *
  192. * @class MODx.panel.ChangeProfilePassword
  193. * @extends MODx.FormPanel
  194. * @param {Object} config An object of config properties
  195. * @xtype modx-panel-profile-password-change
  196. */
  197. MODx.panel.ChangeProfilePassword = function(config) {
  198. config = config || {};
  199. Ext.applyIf(config,{
  200. title: _('reset_password')
  201. ,url: MODx.config.connector_url
  202. ,baseParams: {
  203. action: 'security/profile/changepassword'
  204. ,id: config.user
  205. }
  206. // ,frame: true
  207. ,layout: 'form'
  208. ,buttonAlign: 'right'
  209. ,labelAlign: 'top'
  210. ,cls: 'container form-with-labels'
  211. // ,cls: 'main-wrapper'
  212. ,defaults: { border: false ,msgTarget: 'under' }
  213. ,labelWidth: 150
  214. ,items: [{
  215. xtype: 'textfield'
  216. ,fieldLabel: _('password_old')
  217. ,name: 'password_old'
  218. ,inputType: 'password'
  219. ,maxLength: 255
  220. ,anchor: '100%'
  221. },{
  222. xtype: 'textfield'
  223. ,fieldLabel: _('change_password_new')
  224. ,name: 'password_new'
  225. ,inputType: 'password'
  226. ,maxLength: 255
  227. ,anchor: '100%'
  228. },{
  229. xtype: 'textfield'
  230. ,fieldLabel: _('change_password_confirm')
  231. ,name: 'password_confirm'
  232. ,id: 'modx-password-confirm'
  233. ,inputType: 'password'
  234. ,maxLength: 255
  235. ,anchor: '100%'
  236. },{
  237. xtype: 'xcheckbox'
  238. ,boxLabel: _('password_method_screen')
  239. ,name: 'password_method_screen'
  240. ,id: 'modx-password-method-screen'
  241. ,inputValue: true
  242. ,hideLabel: true
  243. ,checked: true
  244. }]
  245. // TODO: this button should be in a actionbar like any other panel
  246. ,buttons: [{
  247. text: _('save')
  248. ,id: 'modx-abtn-save'
  249. ,cls: 'primary-button'
  250. ,scope: this
  251. ,handler: this.submit
  252. }]
  253. ,listeners: {
  254. 'success': {fn:this.success,scope:this}
  255. }
  256. });
  257. MODx.panel.ChangeProfilePassword.superclass.constructor.call(this,config);
  258. };
  259. Ext.extend(MODx.panel.ChangeProfilePassword,MODx.FormPanel,{
  260. success: function(o) {
  261. MODx.msg.alert(_('success'),o.result.message);
  262. }
  263. });
  264. Ext.reg('modx-panel-profile-password-change',MODx.panel.ChangeProfilePassword);