Added main stream code

1 parent aa93a603
Showing with 11459 additions and 0 deletions
/**
* Main application luncher
*
*/
Ext.application({
name: 'MyMA',
controllers: ['Viewport', 'ProgramMenu', 'Taskpanel', 'Program', 'Users', 'User', 'Aliases', 'Alias', 'Transports'],
enableQuickTips: true
});
/**
* Contains Common overrides and extentions
*
*/
/**
* Adds functions with predefined configs
*/
Ext.override(Ext.Msg, {
onShow: function() {
this.callParent(arguments);
this.center();
// This will fix trace information block
if(!Ext.isEmpty(Ext.query('div.x-msg-trace')) && !Ext.isEmpty(Ext.query('div.x-msg-error'))) {
var error = Ext.get(Ext.query('div.x-msg-error')),
trace = Ext.get(Ext.query('div.x-msg-trace'));
if(trace.first().getHeight() + error.first().getHeight() > this.body.getHeight()) {
trace.first().setHeight(this.body.getHeight() - error.first().getHeight());
}
}
},
showInfo: function(config) {
Ext.Msg.show(Ext.apply({
autoScroll: true,
title: 'Info',
msg: '',
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
}, config || {}))
},
showError: function(cfg) {
if(Ext.isObject(cfg.msg)) {
if(cfg.msg.tpl) {
if(Ext.isArray(cfg.msg.tpl) || Ext.isString(cfg.msg.tpl)) {
cfg.msg = new Ext.XTemplate(Ext.isArray(cfg.msg.tpl) ? cfg.msg.tpl.join('') : cfg.msg.tpl).apply(cfg.msg.data || {});
}
else if(cfg.msg.tpl.isTemplate) {
cfg.msg = cfg.msg.tpl.apply(cfg.msg.data || {});
}
}
else if(cfg.msg.error) {
cfg.msg = new Ext.XTemplate(
'<div class="x-msg-error">',
'<tpl if="code">Error code: {code}<br/></tpl>',
'<tpl if="type">Error type: {type}<br/></tpl>',
'Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>',
'<tpl if="file">File: {file}<br/></tpl>',
'<tpl if="line">Line: {line}<br/></tpl>',
'</div>',
'<tpl if="traces">',
'<div class="x-msg-trace"><tpl for="traces">',
'({line}) {file}: <div class="x-msg-trace-detail">',
'<tpl if="type == \'-&gt;\'">{class}-&gt;{function}()</tpl>',
'<tpl if="args && args.length &gt; 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>',
'</div>',
'</tpl></div>',
'</tpl>'
).apply(cfg.msg.error);
}
}
Ext.Msg.show(Ext.apply({
autoScroll: true,
title: 'Error',
msg: '',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
}, cfg || {}))
}
});
/**
* Adds default settings to the Ext.data.Connection
* The main goal is to change onComplete function to handle common server exceptions
*/
Ext.override(Ext.data.Connection, {
// Default request path
url: '.',
// Default timeoute
timeout: 380000,
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.emptyFn,
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.emptyFn,
/**
* Finds meta tag in the document to set application base url
* @return {string}
*/
getBaseUrl: function() {
if(!Ext.isDefined(this.baseUrl)) {
this.baseUrl = (Ext.query('meta[name=application-url]')[0] || { content: '.' }).content;
this.baseUrl.replace(/[\/\\]+$/, "");
this.url = this.baseUrl;
}
return this.url;
},
/**
* Returns RESTful url using base url and passed route
* @return {string}
*/
getRestUrl: function() {
var route = [];
Ext.iterate(arguments, function(value) {
this.push(value);
}, route);
route = route.join('/');
route.replace(/^[\/\\]+/, "");
return [this.getBaseUrl(), '/index.php/', route].join('');
},
/**
* To be called when the request has come back from the server
* This override needs to catch specific server exceptions and stop callback execution
* @private
* @param {Object} request
* @return {Object} The response
*/
onComplete : function(request) {
var me = this,
options = request.options,
result,
success,
response;
try {
result = me.parseStatus(request.xhr.status);
} catch (e) {
// in some browsers we can't access the status if the readyState is not 4, so the request has failed
result = {
success : false,
isException : false
};
}
success = result.success;
// Run success
if (success) {
response = me.createResponse(request);
me.fireEvent('requestcomplete', me, response, options);
Ext.callback(options.success, options.scope, [response, options]);
} else {
if (result.isException || request.aborted || request.timedout) {
response = me.createException(request);
} else {
response = me.createResponse(request);
}
// Keep unauthorized statuses
if(Ext.isEmpty(me.getGuest()) && (response.status != 404 || response.status != 500)) {
me.setGuest(true);
}
else {
if(options.proxy && options.proxy.isProxy) {
var data = response.responseText ? Ext.decode(response.responseText) : {};
Ext.Msg.showError({
title: data.error.title || 'Error',
msg: {
error: data.error
},
buttons: Ext.Msg.OK
});
}
else {
me.fireEvent('requestexception', me, response, options);
}
Ext.callback(options.failure, options.scope, [response, options]);
}
}
if (!Ext.isDefined(me.isGuest)) {
Ext.callback(options.callback, options.scope, [options, success, response]);
}
delete me.requests[request.id];
return response;
}
});
/**
* Changes for the toolbar element
*/
Ext.override(Ext.Toolbar, {
// Adds function to the toolbar to return input element's values
getValues: function() {
var params = {},
items = this.query('searchfield,textfield,numberfield,checkbox,radio,combo');
Ext.each(items, function(item){
this[item.name || item.itemId || item.getId()] = item.getValue();
}, params);
return params;
}
});
/**
* Additional component to initiate query request on enter key event
*/
Ext.define('Ext.form.SearchField', {
extend: 'Ext.form.field.Text',
alias: 'widget.searchfield',
enableKeyEvents: true,
// If field is in the toolbar than this option may points to button
// or put here function
handler: null,
// Add specialkey listener
initComponent: function() {
this.callParent();
if(!Ext.isEmpty(this.handler)) {
this.on('specialkey', this.checkEnterKey, this);
}
},
// Handle enter key presses, execute the search if the field has a value
checkEnterKey: function(field, e) {
var value = this.getValue();
if (e.getKey() === e.ENTER) {
if(Ext.isFunction(this.handler)) {
this.handler();
}
else if(Ext.isString(this.handler)) {
var point = this.up('toolbar').query('#' + this.handler);
if(point.length > 0 && point[0].getXType() == 'button') {
point[0].fireEvent('click',point[0]);
}
}
}
}
});
\ No newline at end of file
/**
* Conroller: Alias
*
*/
Ext.define('MyMA.controller.Alias', {
extend: 'Ext.app.Controller',
views: ['Alias'],
refs: [{
selector: 'alias',
ref: 'aliasWindow'
}],
init: function() {
this.control({
'alias > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getAliasWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','alias', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
scope: {
controller: this,
win: this.getAliasWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Aliases').getStore('Aliases').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.Aliases', {
extend: 'Ext.app.Controller',
stores: ['Aliases'],
views: ['Aliases','Alias'],
refs: [{
selector: 'aliases > grid',
ref: 'aliasesList'
}],
init: function() {
this.control({
'aliases > grid > toolbar > #addrecord': {
click: this.showForm
},
'aliases > grid > toolbar > #search': {
click: this.onSearch
},
'aliases actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'alias'
});
widget.setTitle('Alias: ' + record.get('alias'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'alias',
title: 'New Alias'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getAliasesList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.Program', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
var control = {};
Ext.each(this.refs, function(item){
this.control[item.selector] = {
beforeclose: this.me.programStop,
hide: this.me.programState,
show: this.me.programState,
minimize: this.me.programMinimize
}
}, {
control: control,
me: this
});
this.control(control);
},
/**
* Register controll for the created "Program"
* @param String, selector name
*/
registerControl: function(selector) {
var selector = selector || null,
ctrl = {};
if(!selector) {
return;
}
ctrl[selector] = {
beforeclose: this.programStop,
hide: this.programState,
show: this.programState,
minimize: this.programMinimize
};
this.control(ctrl);
}, // end registerControl()
/**
* Hides widget and sets status to the Store object
* @param {Object} item
*/
programMinimize: function(item) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
this.getTaskPanel().items.get(record.get('control')).toggle(false);
item.hide();
this.programState(item);
}, // end programMinimize()
/**
* Writes program state to the Store object
* @param {Object} item
* @param {Object} opt
*/
programState: function(item, opt) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
record.set('state', item.isHidden() ? 'hide' : 'show');
}, // end programState()
/**
* Destroyes wiget and removes program information from the Store
* @param {Object} item
* @param {Object} record
*/
programStop: function(item, record) {
var record = record || Ext.undefined;
if (!record['data']) {
(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
}));
}
if(item.animateTarget) {
item.animateTarget = null;
}
if(record && record['data']) {
this.getTaskPanel().items.get(record.get('control')).destroy();
this.getStore('Programs').remove(record);
}
} // end programStop()
});
Ext.define('MyMA.controller.ProgramMenu', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'programmenu > menu': {
click: this.LaunchProgram
}
});
},
LaunchProgram: function(menu, item) {
if (item.itemId == 'logout') {
this.getController('Viewport').Logout();
}
else {
this.getController('Taskpanel').addProgram({
name: item.widgetName,
title: item.text
});
}
}
});
Ext.define('MyMA.controller.Taskpanel', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
this.control({
'taskpanel > button': {
toggle: this.programState
}
});
},
/**
* Add program to the task panel
* @param data
*/
addProgram: function(data) {
var data = data || {
name: null
},
store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'name',
value: data.name
})))
{
try {
var widget = Ext.widget(data.name),
progId = (store.max('id') || 0) + 1;
}
catch(e) {
return false;
}
var Button = this.getTaskPanel().add({
xtype: 'button',
ui: 'program-button',
height: 28,
text: data.title || widget.title,
enableToggle: true,
pressed: true,
programId: progId
});
record = store.add({
id: progId,
title: data.title || widget.title,
name: data.name,
state: 'show',
item: widget.getId(),
control: Button.getId()
})[0];
this.getController('Program').registerControl(data.name);
widget.animateTarget = Button.getId();
widget.setTitle(data.title);
widget.show();
}
else {
this.getTaskPanel().items.get(record.get('control')).toggle(true);
if((widget = Ext.getCmp(record.get('item')))) {
widget.show();
}
}
return widget ? widget : null;
},
/**
* Get reference function
* @param {Object} Button
*/
callRef: function(selector) {
var me = this;
try {
for (var i = 0, ln = this.refs.length; i < ln; i++) {
if (this.refs[i]['selector'] == selector) {
return me['get' + Ext.String.capitalize(this.refs[i]['ref'])]();
}
}
}
catch(e) { }
return null;
},
programState: function(Button) {
var store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'id',
value: Button.programId
})))
{
return false;
}
if ((widget = Ext.getCmp(record.get('item')))) {
widget[record.get('state') == 'show' ? 'hide' : 'show']();
}
},
/**
* Close all process those are registed in the Programs storage
*/
closeAll: function() {
this.getStore('Programs').each(function(record){
if ((widget = Ext.getCmp(record.get('item')))) {
widget.hide();
this.getTaskPanel().items.get(record.get('control')).destroy();
}
}, this);
}
});
Ext.define('MyMA.controller.Transports', {
extend: 'Ext.app.Controller',
stores: ['Transports'],
views: ['Transports'],
refs: [{
selector: 'transports > grid',
ref: 'transportsList'
}],
init: function() {
this.control({
'transports > grid > toolbar > #addrecord': {
click: this.addRecord
},
'transports > grid > toolbar > #search': {
click: this.onSearch
},
'transports actioncolumn': {
click: this.onActionColumn
},
'transports > grid': {
edit: this.onEditAction
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
if(!this.record.get('id')) {
this.store.remove(this.record);
}
else {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Add record to the store and start editing
*/
addRecord: function(Button) {
this.getTransportsList().getStore().insert(0, this.getTransportsList().getStore().model.create({
id: 0,
domain: null,
transport: 'virtual'
}));
},
/**
* Search action
*/
onSearch: function(Button) {
this.getTransportsList().getStore().reload({ params: Button.up('toolbar').getValues() });
},
/**
* Fires when edit complete and record was updated
* @param {object}, Ext.grid.plugin.Editing
* @param {object}, An edit event
*/
onEditAction: function(editor, e) {
e.record.save({
scope: e,
success: function(record) {
this.store.reload();
}
});
}
});
Ext.define('MyMA.controller.User', {
extend: 'Ext.app.Controller',
views: ['User'],
refs: [{
selector: 'user',
ref: 'userWindow'
}],
init: function() {
this.control({
'user > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getUserWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','user', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
params: Ext.applyIf(Ext.copyTo({}, form.getValues(), 'smtp,imap,manager'), {
smtp: 0,
imap: 0,
manager: 0
}),
scope: {
controller: this,
win: this.getUserWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Users').getStore('Users').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users', 'Choice'],
views: ['Users', 'User'],
refs: [{
selector: 'users > grid',
ref: 'usersList'
}, {
selector: 'users',
ref: 'usersWindow'
}],
init: function() {
this.control({
'users > grid > toolbar > #addrecord': {
click: this.showForm
},
'users > grid > toolbar > #search': {
click: this.onSearch
},
'users actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'user'
});
widget.setTitle('User: ' + record.get('name'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to conform remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'user',
title: 'New User'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getUsersList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
/**
* Controller: Viewport
*
*/
Ext.define('MyMA.controller.Viewport', {
extend: 'Ext.app.Controller',
views: ['Viewport', 'Authorize'],
refs: [{
selector: 'viewport',
ref: 'appView'
}, {
selector: 'authorize',
ref: 'authPanel'
}, {
selector: 'authorize > form',
ref: 'authForm'
}],
/**
*
*/
isGuest: Ext.undefined,
/**
* A template method that is called when your application boots.
* It is called before the Application's launch function is executed so gives a hook
* point to run any code before your Viewport is created.
*/
init: function(app) {
// Bind Guest to the Ext.data.Connection
Ext.override(Ext.data.Connection, {
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.Function.bind(this.setGuest, this),
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.Function.bind(this.getGuest, this)
});
this.control({
'authorize > form > toolbar > button': {
click: this.Authorize
}
});
this.Authorize();
},
/**
* Authorize
* if passed main application view, the first step need to query
* @param object, main application view
*/
Authorize: function() {
if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) {
form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT',
clientValidation: true,
scope: this,
success: this.successLogin
})
}
}
else {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api', 'login'),
scope: this,
callback: function(){
if (!this.isGuest && !this.getAppView()) {
this.setGuest(false);
this.getView('Viewport').create();
}
}
});
}
},
/**
* Return isGuest value
* @param state
*/
getGuest: function() {
return this.isGuest;
},
/**
* Set isGuest flag value
* @param object, this controller
* @param boolean, state to set
*/
setGuest: function(state) {
this.isGuest = Ext.isBoolean(state) ? state : true;
if(this.isGuest && !this.getAuthPanel()) {
this.getView('Authorize').create();
}
},
/**
* private
*/
successLogin: function(form, action) {
this.getAuthPanel().close();
if(!this.getAppView()) {
this.getView('Viewport').create();
}
},
/**
* Logout
* public
*/
Logout: function() {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api','login', 'logout', 0),
method: 'PUT',
scope: this,
callback: function() {
if(this.getAppView()) {
this.getController('Taskpanel').closeAll();
this.getAppView().destroy();
}
this.setGuest(this, true);
}
});
}
});
Ext.define('MyMA.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users', 'Choice'],
views: ['Users', 'User'],
refs: [{
selector: 'users > grid',
ref: 'usersList'
}, {
selector: 'users',
ref: 'usersWindow'
}],
init: function() {
this.control({
'users > grid > toolbar > #addrecord': {
click: this.showForm
},
'users > grid > toolbar > #search': {
click: this.onSearch
},
'users actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'user'
});
widget.setTitle('User: ' + record.get('name'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to conform remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'user',
title: 'New User'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getUsersList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.ProgramMenu', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'programmenu > menu': {
click: this.LaunchProgram
}
});
},
LaunchProgram: function(menu, item) {
if (item.itemId == 'logout') {
this.getController('Viewport').Logout();
}
else {
this.getController('Taskpanel').addProgram({
name: item.widgetName,
title: item.text
});
}
}
});
Ext.define('MyMA.controller.Program', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
var control = {};
Ext.each(this.refs, function(item){
this.control[item.selector] = {
beforeclose: this.me.programStop,
hide: this.me.programState,
show: this.me.programState,
minimize: this.me.programMinimize
}
}, {
control: control,
me: this
});
this.control(control);
},
/**
* Register controll for the created "Program"
* @param String, selector name
*/
registerControl: function(selector) {
var selector = selector || null,
ctrl = {};
if(!selector) {
return;
}
ctrl[selector] = {
beforeclose: this.programStop,
hide: this.programState,
show: this.programState,
minimize: this.programMinimize
};
this.control(ctrl);
}, // end registerControl()
/**
* Hides widget and sets status to the Store object
* @param {Object} item
*/
programMinimize: function(item) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
this.getTaskPanel().items.get(record.get('control')).toggle(false);
item.hide();
this.programState(item);
}, // end programMinimize()
/**
* Writes program state to the Store object
* @param {Object} item
* @param {Object} opt
*/
programState: function(item, opt) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
record.set('state', item.isHidden() ? 'hide' : 'show');
}, // end programState()
/**
* Destroyes wiget and removes program information from the Store
* @param {Object} item
* @param {Object} record
*/
programStop: function(item, record) {
var record = record || Ext.undefined;
if (!record['data']) {
(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
}));
}
if(item.animateTarget) {
item.animateTarget = null;
}
if(record && record['data']) {
this.getTaskPanel().items.get(record.get('control')).destroy();
this.getStore('Programs').remove(record);
}
} // end programStop()
});
/**
* Controller: Viewport
*
*/
Ext.define('MyMA.controller.Viewport', {
extend: 'Ext.app.Controller',
views: ['Viewport', 'Authorize'],
refs: [{
selector: 'viewport',
ref: 'appView'
}, {
selector: 'authorize',
ref: 'authPanel'
}, {
selector: 'authorize > form',
ref: 'authForm'
}],
/**
*
*/
isGuest: Ext.undefined,
/**
* A template method that is called when your application boots.
* It is called before the Application's launch function is executed so gives a hook
* point to run any code before your Viewport is created.
*/
init: function(app) {
// Bind Guest to the Ext.data.Connection
Ext.override(Ext.data.Connection, {
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.Function.bind(this.setGuest, this),
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.Function.bind(this.getGuest, this)
});
this.control({
'authorize > form > toolbar > button': {
click: this.Authorize
}
});
this.Authorize();
},
/**
* Authorize
* if passed main application view, the first step need to query
* @param object, main application view
*/
Authorize: function() {
if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) {
form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT',
clientValidation: true,
scope: this,
success: this.successLogin
})
}
}
else {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api', 'login'),
scope: this,
callback: function(){
if (!this.isGuest && !this.getAppView()) {
this.setGuest(false);
this.getView('Viewport').create();
}
}
});
}
},
/**
* Return isGuest value
* @param state
*/
getGuest: function() {
return this.isGuest;
},
/**
* Set isGuest flag value
* @param object, this controller
* @param boolean, state to set
*/
setGuest: function(state) {
this.isGuest = Ext.isBoolean(state) ? state : true;
if(this.isGuest && !this.getAuthPanel()) {
this.getView('Authorize').create();
}
},
/**
* private
*/
successLogin: function(form, action) {
this.getAuthPanel().close();
if(!this.getAppView()) {
this.getView('Viewport').create();
}
},
/**
* Logout
* public
*/
Logout: function() {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api','login', 'logout', 0),
method: 'PUT',
scope: this,
callback: function() {
if(this.getAppView()) {
this.getController('Taskpanel').closeAll();
this.getAppView().destroy();
}
this.setGuest(this, true);
}
});
}
});
/**
* Conroller: Alias
*
*/
Ext.define('MyMA.controller.Alias', {
extend: 'Ext.app.Controller',
views: ['Alias'],
refs: [{
selector: 'alias',
ref: 'aliasWindow'
}],
init: function() {
this.control({
'alias > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getAliasWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','alias', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
scope: {
controller: this,
win: this.getAliasWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Aliases').getStore('Aliases').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.User', {
extend: 'Ext.app.Controller',
views: ['User'],
refs: [{
selector: 'user',
ref: 'userWindow'
}],
init: function() {
this.control({
'user > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getUserWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','user', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
params: Ext.applyIf(Ext.copyTo({}, form.getValues(), 'smtp,imap,manager'), {
smtp: 0,
imap: 0,
manager: 0
}),
scope: {
controller: this,
win: this.getUserWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Users').getStore('Users').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.Aliases', {
extend: 'Ext.app.Controller',
stores: ['Aliases'],
views: ['Aliases','Alias'],
refs: [{
selector: 'aliases > grid',
ref: 'aliasesList'
}],
init: function() {
this.control({
'aliases > grid > toolbar > #addrecord': {
click: this.showForm
},
'aliases > grid > toolbar > #search': {
click: this.onSearch
},
'aliases actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'alias'
});
widget.setTitle('Alias: ' + record.get('alias'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'alias',
title: 'New Alias'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getAliasesList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.Transports', {
extend: 'Ext.app.Controller',
stores: ['Transports'],
views: ['Transports'],
refs: [{
selector: 'transports > grid',
ref: 'transportsList'
}],
init: function() {
this.control({
'transports > grid > toolbar > #addrecord': {
click: this.addRecord
},
'transports > grid > toolbar > #search': {
click: this.onSearch
},
'transports actioncolumn': {
click: this.onActionColumn
},
'transports > grid': {
edit: this.onEditAction
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
if(!this.record.get('id')) {
this.store.remove(this.record);
}
else {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Add record to the store and start editing
*/
addRecord: function(Button) {
this.getTransportsList().getStore().insert(0, this.getTransportsList().getStore().model.create({
id: 0,
domain: null,
transport: 'virtual'
}));
},
/**
* Search action
*/
onSearch: function(Button) {
this.getTransportsList().getStore().reload({ params: Button.up('toolbar').getValues() });
},
/**
* Fires when edit complete and record was updated
* @param {object}, Ext.grid.plugin.Editing
* @param {object}, An edit event
*/
onEditAction: function(editor, e) {
e.record.save({
scope: e,
success: function(record) {
this.store.reload();
}
});
}
});
Ext.define('MyMA.controller.Taskpanel', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
this.control({
'taskpanel > button': {
toggle: this.programState
}
});
},
/**
* Add program to the task panel
* @param data
*/
addProgram: function(data) {
var data = data || {
name: null
},
store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'name',
value: data.name
})))
{
try {
var widget = Ext.widget(data.name),
progId = (store.max('id') || 0) + 1;
}
catch(e) {
return false;
}
var Button = this.getTaskPanel().add({
xtype: 'button',
ui: 'program-button',
height: 28,
text: data.title || widget.title,
enableToggle: true,
pressed: true,
programId: progId
});
record = store.add({
id: progId,
title: data.title || widget.title,
name: data.name,
state: 'show',
item: widget.getId(),
control: Button.getId()
})[0];
this.getController('Program').registerControl(data.name);
widget.animateTarget = Button.getId();
widget.setTitle(data.title);
widget.show();
}
else {
this.getTaskPanel().items.get(record.get('control')).toggle(true);
if((widget = Ext.getCmp(record.get('item')))) {
widget.show();
}
}
return widget ? widget : null;
},
/**
* Get reference function
* @param {Object} Button
*/
callRef: function(selector) {
var me = this;
try {
for (var i = 0, ln = this.refs.length; i < ln; i++) {
if (this.refs[i]['selector'] == selector) {
return me['get' + Ext.String.capitalize(this.refs[i]['ref'])]();
}
}
}
catch(e) { }
return null;
},
programState: function(Button) {
var store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'id',
value: Button.programId
})))
{
return false;
}
if ((widget = Ext.getCmp(record.get('item')))) {
widget[record.get('state') == 'show' ? 'hide' : 'show']();
}
},
/**
* Close all process those are registed in the Programs storage
*/
closeAll: function() {
this.getStore('Programs').each(function(record){
if ((widget = Ext.getCmp(record.get('item')))) {
widget.hide();
this.getTaskPanel().items.get(record.get('control')).destroy();
}
}, this);
}
});
Ext.define('MyMA.model.Aliases', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'alias',
type: 'string'
}, {
name: 'recipient',
type: 'string'
}, {
name: 'comment',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'alias'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Brief', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'results'
}
}
});
Ext.define('MyMA.model.Transports', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'domain',
type: 'string'
}, {
name: 'transport',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'transport'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Users', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'login',
type: 'string'
}, {
name: 'passwd',
type: 'string'
}, {
name: 'uid',
type: 'int',
defaultValue: 8
}, {
name: 'gid',
type: 'int',
defaultValue: 12
}, {
name: 'maildir',
type: 'string'
}, {
name: 'smtp',
type: 'int'
}, {
name: 'imap',
type: 'int'
}, {
name: 'quota',
type: 'int',
defaultValue: 10000000
}, {
name: 'manager',
type: 'int'
}],
validations: [{
type: 'format',
field: 'maildir',
matcher: /^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api/user'),
reader: {
type: 'json',
root: 'results'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Users', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'login',
type: 'string'
}, {
name: 'passwd',
type: 'string'
}, {
name: 'uid',
type: 'int',
defaultValue: 8
}, {
name: 'gid',
type: 'int',
defaultValue: 12
}, {
name: 'maildir',
type: 'string'
}, {
name: 'smtp',
type: 'int'
}, {
name: 'imap',
type: 'int'
}, {
name: 'quota',
type: 'int',
defaultValue: 10000000
}, {
name: 'manager',
type: 'int'
}],
validations: [{
type: 'format',
field: 'maildir',
matcher: /^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api/user'),
reader: {
type: 'json',
root: 'results'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Brief', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'results'
}
}
});
Ext.define('MyMA.model.Aliases', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'alias',
type: 'string'
}, {
name: 'recipient',
type: 'string'
}, {
name: 'comment',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'alias'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Transports', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'domain',
type: 'string'
}, {
name: 'transport',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'transport'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.view.Alias', {
extend: 'Ext.window.Window',
alias: 'widget.alias',
layout: 'fit',
title: 'Alias',
width: 400,
constrainHeader: true,
closeAction: 'destroy',
buttons: [{
xtype: 'button',
itemId: 'savedata',
text: 'Save',
scope: this
}],
items: [{
xtype: 'form',
frame: true,
monitorValid: true,
defaults: {
xtype: 'textfield',
anchor: '100%',
allowBlank: false
},
items: [{
xtype: 'hidden',
name: 'id'
}, {
fieldLabel: 'Alias',
name: 'alias',
vtype: 'email'
}, {
fieldLabel: 'Recipient',
name: 'recipient',
vtype: 'email'
}, {
fieldLabel: 'Comment',
xtype: 'textarea',
name: 'comment'
}]
}]
});
Ext.define('MyMA.view.Aliases', {
extend: 'Ext.window.Window',
alias: 'widget.aliases',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop'
},
listeners: {
/**
* This event is fired through the GridView.
* Add listeners to the GridView object Fired when a drop operation has been completed and the data has been moved or copied
* @param {} node
* @param {} data
* @param {} overModel
* @param {} dropPosition
* @param {} eOpts
*/
beforedrop: function(node, data, overModel, dropPosition, eOpts) {
Ext.each(data.records, function(record) {
if(record.get('alias') != this.groupName) {
record.set('alias', this.groupName);
record.save({
action: 'update',
scope: this,
failure: function(record) {
record.store.reload();
}
});
}
}, {
data: data,
groupName: this.getFeature('alias-groups').getGroupName(node),
model: overModel
});
}
}
},
tbar: [{
xtype: 'button',
itemId: 'addrecord',
iconCls: 'x-ibtn-add',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Aliases'
},
features: [{
ftype: 'grouping',
id: 'alias-groups',
groupHeaderTpl: 'Group: {name} ({rows.length})',
startCollapsed: false
}],
selModel: {
selType: 'rowmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Recipient',
dataIndex: 'recipient',
flex: 1
}, {
header: 'Alias',
hidden: true,
dataIndex: 'alias'
}, {
header: 'Comment',
dataIndex: 'comment',
flex: 1
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
selType: 'rowmodel',
multiSelect: true,
store: 'Aliases'
}]
});
Ext.define('MyMA.view.Authorize', {
extend: 'Ext.Window',
alias: 'widget.authorize',
layout: 'fit',
autoShow: true,
layout: 'fit',
width: 350,
closable: false,
constrain: true,
draggable: false,
resizable: false,
modal: true,
cls: 'x-window-authbaner',
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
ui: 'authform-baner',
height: 43,
html: '{LOGIN @ MAIL . PANEL }'
}],
items: [{
xtype: 'form',
url: 'index.php',
monitorValid: true,
frame: false,
border: false,
defaults: {
anchor: '100%'
},
buttons: [{
text: 'Login'
}],
items: [{
fieldLabel: 'Login',
xtype: 'textfield',
allowBlank: false,
name: 'login'
}, {
fieldLabel: 'Password',
xtype: 'textfield',
name: 'pass',
inputType: 'password'
}]
}]
});
Ext.define('MyMA.view.ProgramMenu', {
extend: 'Ext.Button',
alias: 'widget.programmenu',
text: 'Menu',
height: 30,
ui: 'program-menu',
menu: [{
text: 'Users',
widgetName: 'users'
}, {
text: 'Aliases',
widgetName: 'aliases'
}, {
text: 'Transports',
widgetName: 'transports'
}, '-', {
text: 'Logout',
itemId: 'logout'
}]
});
Ext.define('MyMA.view.Taskpanel', {
extend: 'Ext.Toolbar',
alias: 'widget.taskpanel',
ui: 'programbar',
height: 28,
style: {
border: 0,
padding: 0
},
autoScroll: true,
items: []
});
Ext.define('MyMA.view.Transports', {
extend: 'Ext.window.Window',
alias: 'widget.transports',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
tbar: [{
xtype: 'button',
itemId: 'addrecord',
iconCls: 'x-ibtn-add',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Transports'
},
columns: [{
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Domain',
dataIndex: 'domain',
editor: {
xtype: 'textfield',
allowBlank: false
},
flex: 1
}, {
header: 'Transport',
dataIndex: 'transport'
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1
})
],
store: 'Transports'
}]
});
Ext.define('MyMA.view.User', {
extend: 'Ext.window.Window',
alias: 'widget.user',
layout: 'fit',
title: 'User',
width: 400,
constrainHeader: true,
closeAction: 'destroy',
buttons: [{
xtype: 'button',
itemId: 'savedata',
text: 'Save',
scope: this
}],
items: [{
xtype: 'form',
frame: true,
monitorValid: true,
defaults: {
xtype: 'textfield',
anchor: '100%',
allowBlank: false
},
items: [{
xtype: 'hidden',
name: 'id'
}, {
xtype: 'checkbox',
fieldLabel: 'Manager',
name: 'manager',
inputValue: 1
}, {
xtype: 'checkbox',
fieldLabel: 'SMTP',
name: 'smtp',
inputValue: 1
}, {
xtype: 'checkbox',
fieldLabel: 'IMAP',
name: 'imap',
inputValue: 1
}, {
fieldLabel: 'Name',
name: 'name'
}, {
fieldLabel: 'Login',
name: 'login',
vtype: 'email'
}, {
fieldLabel: 'Password',
name: 'passwd'
}, {
xtype: 'numberfield',
allowDecimal: false,
fieldLabel: 'UID',
name: 'uid',
anchor: '50%',
value: 8
}, {
xtype: 'numberfield',
allowDecimal: false,
fieldLabel: 'GID',
name: 'gid',
anchor: '50%',
value: 12
}, {
fieldLabel: 'Mail directory',
name: 'maildir'
}, {
xtype: 'numberfield',
name: 'quota',
allowDecimal: false,
fieldLabel: 'Quota',
anchor: '60%',
value: 100000000
}]
}]
});
Ext.define('MyMA.view.Users', {
extend: 'Ext.window.Window',
alias: 'widget.users',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
listeners: {
/**
* Initiate data save through proxy
* @param editor : Ext.grid.plugin.Editing
* @param object
* grid - The grid
* record - The record that was edited
* field - The field name that was edited
* value - The value being set
* row - The grid table row
* column - The grid Column defining the column that was edited.
* rowIdx - The row index that was edited
* colIdx - The column index that was edited
* originalValue - The original value for the field, before the edit (only when using CellEditing)
* originalValues - The original values for the field, before the edit (only when using RowEditing)
* newValues - The new values being set (only when using RowEditing)
* view - The grid view (only when using RowEditing)
* store - The grid store (only when using RowEditing)
*/
edit: function(editor, data) {
if(data.originalValue == data.value) {
return;
}
data.record.save({
action: 'update',
scope: data,
success: function() {
this.record.commit();
//this.view.refresh();
}
});
}
},
tbar: [{
xtype: 'button',
iconCls: 'x-ibtn-add',
itemId: 'addrecord',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Users'
},
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
selModel: {
selType: 'cellmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield'
},
flex: 1
}, {
header: 'Login',
dataIndex: 'login',
width: 120
}, {
header: 'Password',
hidden: true,
dataIndex: 'passwd'
}, {
header: 'uid',
dataIndex: 'uid',
width: 40
}, {
header: 'gid',
dataIndex: 'gid',
width: 40
}, {
header: 'Mail directory',
dataIndex: 'maildir'
}, {
header: 'SMTP',
dataIndex: 'smtp',
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'IMAP',
dataIndex: 'imap',
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'Quota',
dataIndex: 'quota',
editor: {
xtype: 'numberfield',
allowDecimal: false
}
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
store: 'Users'
}]
});
Ext.define('MyMA.view.Viewport', {
extend: 'Ext.container.Viewport',
requires: [
'MyMA.view.ProgramMenu',
'MyMA.view.Taskpanel',
'MyMA.view.Users',
'MyMA.view.Aliases'
],
layout: 'fit',
statics: {
ready: false
},
items: {
xtype: 'panel',
layout: 'fit',
border: false,
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
height: 30,
ui: 'programbar-panel',
items: [{
xtype: 'programmenu',
width: 100
}, '-', {
xtype: 'taskpanel',
flex: 1
}]
}],
items: [{
xtype: 'panel',
border: false,
ui: 'desk-panel',
bodyCls: 'x-desk-panel-bg',
layout: {
type: 'fit'
}
}]
}
});
Ext.define('MyMA.view.ProgramMenu', {
extend: 'Ext.Button',
alias: 'widget.programmenu',
text: 'Menu',
height: 30,
ui: 'program-menu',
menu: [{
text: 'Users',
widgetName: 'users'
}, {
text: 'Aliases',
widgetName: 'aliases'
}, {
text: 'Transports',
widgetName: 'transports'
}, '-', {
text: 'Logout',
itemId: 'logout'
}]
});
Ext.define('MyMA.view.Taskpanel', {
extend: 'Ext.Toolbar',
alias: 'widget.taskpanel',
ui: 'programbar',
height: 28,
style: {
border: 0,
padding: 0
},
autoScroll: true,
items: []
});
Ext.define('MyMA.view.Aliases', {
extend: 'Ext.window.Window',
alias: 'widget.aliases',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop'
},
listeners: {
/**
* This event is fired through the GridView.
* Add listeners to the GridView object Fired when a drop operation has been completed and the data has been moved or copied
* @param {} node
* @param {} data
* @param {} overModel
* @param {} dropPosition
* @param {} eOpts
*/
beforedrop: function(node, data, overModel, dropPosition, eOpts) {
Ext.each(data.records, function(record) {
if(record.get('alias') != this.groupName) {
record.set('alias', this.groupName);
record.save({
action: 'update',
scope: this,
failure: function(record) {
record.store.reload();
}
});
}
}, {
data: data,
groupName: this.getFeature('alias-groups').getGroupName(node),
model: overModel
});
}
}
},
tbar: [{
xtype: 'button',
itemId: 'addrecord',
iconCls: 'x-ibtn-add',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Aliases'
},
features: [{
ftype: 'grouping',
id: 'alias-groups',
groupHeaderTpl: 'Group: {name} ({rows.length})',
startCollapsed: false
}],
selModel: {
selType: 'rowmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Recipient',
dataIndex: 'recipient',
flex: 1
}, {
header: 'Alias',
hidden: true,
dataIndex: 'alias'
}, {
header: 'Comment',
dataIndex: 'comment',
flex: 1
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
selType: 'rowmodel',
multiSelect: true,
store: 'Aliases'
}]
});
Ext.define('MyMA.view.Alias', {
extend: 'Ext.window.Window',
alias: 'widget.alias',
layout: 'fit',
title: 'Alias',
width: 400,
constrainHeader: true,
closeAction: 'destroy',
buttons: [{
xtype: 'button',
itemId: 'savedata',
text: 'Save',
scope: this
}],
items: [{
xtype: 'form',
frame: true,
monitorValid: true,
defaults: {
xtype: 'textfield',
anchor: '100%',
allowBlank: false
},
items: [{
xtype: 'hidden',
name: 'id'
}, {
fieldLabel: 'Alias',
name: 'alias',
vtype: 'email'
}, {
fieldLabel: 'Recipient',
name: 'recipient',
vtype: 'email'
}, {
fieldLabel: 'Comment',
xtype: 'textarea',
name: 'comment'
}]
}]
});
Ext.define('MyMA.view.Users', {
extend: 'Ext.window.Window',
alias: 'widget.users',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
listeners: {
/**
* Initiate data save through proxy
* @param editor : Ext.grid.plugin.Editing
* @param object
* grid - The grid
* record - The record that was edited
* field - The field name that was edited
* value - The value being set
* row - The grid table row
* column - The grid Column defining the column that was edited.
* rowIdx - The row index that was edited
* colIdx - The column index that was edited
* originalValue - The original value for the field, before the edit (only when using CellEditing)
* originalValues - The original values for the field, before the edit (only when using RowEditing)
* newValues - The new values being set (only when using RowEditing)
* view - The grid view (only when using RowEditing)
* store - The grid store (only when using RowEditing)
*/
edit: function(editor, data) {
if(data.originalValue == data.value) {
return;
}
data.record.save({
action: 'update',
scope: data,
success: function() {
this.record.commit();
//this.view.refresh();
}
});
}
},
tbar: [{
xtype: 'button',
iconCls: 'x-ibtn-add',
itemId: 'addrecord',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Users'
},
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
selModel: {
selType: 'cellmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield'
},
flex: 1
}, {
header: 'Login',
dataIndex: 'login',
width: 120
}, {
header: 'Password',
hidden: true,
dataIndex: 'passwd'
}, {
header: 'uid',
dataIndex: 'uid',
width: 40
}, {
header: 'gid',
dataIndex: 'gid',
width: 40
}, {
header: 'Mail directory',
dataIndex: 'maildir'
}, {
header: 'SMTP',
dataIndex: 'smtp',
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'IMAP',
dataIndex: 'imap',
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'Quota',
dataIndex: 'quota',
editor: {
xtype: 'numberfield',
allowDecimal: false
}
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
store: 'Users'
}]
});
Ext.define('MyMA.view.User', {
extend: 'Ext.window.Window',
alias: 'widget.user',
layout: 'fit',
title: 'User',
width: 400,
constrainHeader: true,
closeAction: 'destroy',
buttons: [{
xtype: 'button',
itemId: 'savedata',
text: 'Save',
scope: this
}],
items: [{
xtype: 'form',
frame: true,
monitorValid: true,
defaults: {
xtype: 'textfield',
anchor: '100%',
allowBlank: false
},
items: [{
xtype: 'hidden',
name: 'id'
}, {
xtype: 'checkbox',
fieldLabel: 'Manager',
name: 'manager',
inputValue: 1
}, {
xtype: 'checkbox',
fieldLabel: 'SMTP',
name: 'smtp',
inputValue: 1
}, {
xtype: 'checkbox',
fieldLabel: 'IMAP',
name: 'imap',
inputValue: 1
}, {
fieldLabel: 'Name',
name: 'name'
}, {
fieldLabel: 'Login',
name: 'login',
vtype: 'email'
}, {
fieldLabel: 'Password',
name: 'passwd'
}, {
xtype: 'numberfield',
allowDecimal: false,
fieldLabel: 'UID',
name: 'uid',
anchor: '50%',
value: 8
}, {
xtype: 'numberfield',
allowDecimal: false,
fieldLabel: 'GID',
name: 'gid',
anchor: '50%',
value: 12
}, {
fieldLabel: 'Mail directory',
name: 'maildir'
}, {
xtype: 'numberfield',
name: 'quota',
allowDecimal: false,
fieldLabel: 'Quota',
anchor: '60%',
value: 100000000
}]
}]
});
Ext.define('MyMA.view.Viewport', {
extend: 'Ext.container.Viewport',
requires: [
'MyMA.view.ProgramMenu',
'MyMA.view.Taskpanel',
'MyMA.view.Users',
'MyMA.view.Aliases'
],
layout: 'fit',
statics: {
ready: false
},
items: {
xtype: 'panel',
layout: 'fit',
border: false,
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
height: 30,
ui: 'programbar-panel',
items: [{
xtype: 'programmenu',
width: 100
}, '-', {
xtype: 'taskpanel',
flex: 1
}]
}],
items: [{
xtype: 'panel',
border: false,
ui: 'desk-panel',
bodyCls: 'x-desk-panel-bg',
layout: {
type: 'fit'
}
}]
}
});
Ext.define('MyMA.view.Authorize', {
extend: 'Ext.Window',
alias: 'widget.authorize',
layout: 'fit',
autoShow: true,
layout: 'fit',
width: 350,
closable: false,
constrain: true,
draggable: false,
resizable: false,
modal: true,
cls: 'x-window-authbaner',
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
ui: 'authform-baner',
height: 43,
html: '{LOGIN @ MAIL . PANEL }'
}],
items: [{
xtype: 'form',
url: 'index.php',
monitorValid: true,
frame: false,
border: false,
defaults: {
anchor: '100%'
},
buttons: [{
text: 'Login'
}],
items: [{
fieldLabel: 'Login',
xtype: 'textfield',
allowBlank: false,
name: 'login'
}, {
fieldLabel: 'Password',
xtype: 'textfield',
name: 'pass',
inputType: 'password'
}]
}]
});
Ext.define('MyMA.view.Transports', {
extend: 'Ext.window.Window',
alias: 'widget.transports',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
tbar: [{
xtype: 'button',
itemId: 'addrecord',
iconCls: 'x-ibtn-add',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Transports'
},
columns: [{
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Domain',
dataIndex: 'domain',
editor: {
xtype: 'textfield',
allowBlank: false
},
flex: 1
}, {
header: 'Transport',
dataIndex: 'transport'
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1
})
],
store: 'Transports'
}]
});
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
<?php
/**
* This is the bootstrap file for test application.
* This file should be removed when the application is deployed for production.
*/
// change the following paths if necessary
$yii=dirname(__FILE__).'/../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/test.php';
// remove the following line when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
require_once($yii);
Yii::createWebApplication($config)->run();
<?php
// change the following paths if necessary
$yii=dirname(__FILE__).'/../framework/yii.php';
//$webappl=dirname(__FILE__).'/protected/components/WebApplication.php';
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEVELOP') or define('YII_DEVELOP',true);
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
/*require_once($webappl);
Yii::createApplication('WebApplication', $config)->run();*/
Yii::createWebApplication($config)->run();
Yii::app()->clientScript->scriptMap=array(
'jquery.js'=>false,
);
<?php
/**
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
*/
class Controller extends /*WRestController*/ CController
{
/**
*
*/
private $_error = array();
/**
* Initializes the controller. This method is called by the application
* before the controller starts to execute.
*/
public function init()
{
parent::init();
// Let completely bypass Yii's default error displaying mechanism
// by registering onError and onException event listeners
Yii::app()->attachEventHandler('onError',array($this,'handleError'));
Yii::app()->attachEventHandler('onException',array($this,'handleError'));
}
/**
* Handling all errors and exceptions for all controllers
* To check if there was error or exception need use construction like
*
* if ($event instanceof CExceptionEvent) { ... }
* elseif($event instanceof CErrorEvent) { ... }
*
* @param {object} event
*/
public function handleError(CEvent $event)
{
$error = ($event instanceof CExceptionEvent) ? $event->exception : $event;
if($event instanceof CExceptionEvent) {
if(($trace = $this->getExactTrace($error)) === null) {
$fileName = $error->getFile();
$errorLine = $error->getLine();
}
else {
$fileName = $trace['file'];
$errorLine = $trace['line'];
}
$trace = $error->getTrace();
foreach($trace as $i => $t) {
if(!isset($t['file'])) {
$trace[$i]['file']='unknown';
}
if(!isset($t['line'])) {
$trace[$i]['line']=0;
}
if(!isset($t['function'])) {
$trace[$i]['function']='unknown';
}
unset($trace[$i]['object']);
}
}
elseif($event instanceof CErrorEvent) {
$trace = debug_backtrace();
// skip the first 3 stacks as they do not tell the error position
if(count($trace) > 3) {
$trace = array_slice($trace,3);
}
$traceString = '';
foreach($trace as $i=>$t) {
if(!isset($t['file'])) {
$trace[$i]['file']='unknown';
}
if(!isset($t['line'])) {
$trace[$i]['line']=0;
}
if(!isset($t['function'])) {
$trace[$i]['function']='unknown';
}
$traceString .= "#$i {$trace[$i]['file']}({$trace[$i]['line']}): ";
if(isset($t['object']) && is_object($t['object'])) {
$traceString.=get_class($t['object']).'->';
}
$traceString.="{$trace[$i]['function']}()\n";
unset($trace[$i]['object']);
}
switch($error->code) {
case E_WARNING:
$type = 'PHP warning';
break;
case E_NOTICE:
$type = 'PHP notice';
break;
case E_USER_ERROR:
$type = 'User error';
break;
case E_USER_WARNING:
$type = 'User warning';
break;
case E_USER_NOTICE:
$type = 'User notice';
break;
case E_RECOVERABLE_ERROR:
$type = 'Recoverable error';
break;
default:
$type = 'PHP error';
}
}
else {
return;
}
$this->_error =array(
'code' => ($error instanceof CHttpException) ? $error->statusCode : 500,
'type' => $type ? $type : get_class($error),
'message' => ($error instanceof CException) ? $error->getMessage() : $error->message,
'file' => $fileName ? $fileName : $error->file,
'line' => $errorLine ? $errorLine : $error->line,
'trace' => ($error instanceof CException) ? $error->getTraceAsString() : $traceString,
'traces' => $trace
);
if(YII_DEBUG) {
$this->sendResponse($this->_error['code'], array(
'success' => false,
'error' => $this->_error
));
}
else {
if(Yii::app()->user->isGuest) {
$this->sendResponse(401, array(
'success' => false
));
}
else {
$this->sendResponse($this->_error['code'], array(
'success' => false,
'error' => array(
'message' => $this->_error['message']
))
);
}
}
// Stop rising error / exception
$event->handled = true;
}
/**
* Returns the exact trace where the problem occurs.
* @param Exception $exception the uncaught exception
* @return array the exact trace where the problem occurs
*/
protected function getExactTrace($exception)
{
$traces = $exception->getTrace();
foreach($traces as $trace)
{
// property access exception
if(isset($trace['function']) && ($trace['function']==='__get' || $trace['function']==='__set'))
return $trace;
}
return null;
}
/**
* Access filter control
*/
public function filters()
{
return array(
array(
'application.filters.AccessControl - index,authorize,error'
)
);
}
public function showJSON($params)
{
$params = !is_array($params) || empty($params) ? array() : $params;
echo "(" . CJSON::encode($params) . ")";
Yii::app()->end();
}
/**
* This is the action to handle external exceptions.
*/
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest) {
$this->showJSON(array(
"success" => false,
"error" => $error['code'],
"message" => $error['message']
));
}
else {
$this->render('error', $error);
}
}
}
}
\ No newline at end of file
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
/**
* Authenticated person ID
* @var string
*/
private $_id;
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
if(empty($this->username)) {
$this->errorCode=self::ERROR_USERNAME_INVALID;
return !$this->errorCode;
}
$manager = Manager::model()->find(array(
"select" => array("`id`", "`name`", "`login`"),
"condition" => implode(" AND ", array(
"`manager` = :manager",
"`login` = :login",
"`passwd` = :pass"
)),
"params" => array(
":manager" => 1,
":login" => $this->username,
":pass" => $this->password
)
));
if($manager===null) {
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
else {
$this->_id = $manager->id;
// Write manager short info
$this->setState('__fullname', empty($manager->name) ? $manager->login : $manager->name);
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
\ No newline at end of file
<?php
/**
* This is main web application component
*/
class WebApplication extends CWebApplication {
private $_controllerPath;
private $_viewPath;
private $_systemViewPath;
private $_layoutPath;
private $_controller;
private $_theme;
protected function init()
{
register_shutdown_function(array($this, 'onShutdownHandler'));
parent::init();
}
public function onShutdownHandler()
{
// 1. error_get_last() returns NULL if error handled via set_error_handler
// 2. error_get_last() returns error even if error_reporting level less then error
$e = error_get_last();
$errorsToHandle = E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING;
if(!is_null($e) && ($e['type'] & $errorsToHandle)) {
$msg = 'Fatal error: '.$e['message'];
// it's better to set errorAction = null to use system view "error.php" instead of run another controller/action (less possibility of additional errors)
yii::app()->errorHandler->errorAction = null;
// handling error
yii::app()->handleError($e['type'], $msg, $e['file'], $e['line']);
}
}
/**
* Creates the controller and performs the specified action.
* @param string $route the route of the current request. See {@link createController} for more details.
* @throws CHttpException if the controller could not be created.
*/
public function runController($route)
{
if(($ca=$this->createController($route))!==null)
{
list($controller,$actionID)=$ca;
$oldController=$this->_controller;
$this->_controller=$controller;
$controller->init();
$controller->run($actionID);
$this->_controller=$oldController;
}
else {
if(Yii::app()->request->isAjaxRequest) {
throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',
array('{route}'=>$route===''?$this->defaultController:$route)));
}
else {
$this->runController($this->defaultController . "/index");
}
}
}
}
\ No newline at end of file
<?php
/**
* This class adds some additional functionality to the base class
*/
class WebUser extends CWebUser {
/**
* Returns login information
*/
public function getLogin() {
return $this->getName();
}
/**
* Returns name of the authorized person
*/
public function getFullName() {
return $this->getState('__fullname');
}
/**
* Returns page title as full name of the authorized
*/
public function getTitle() {
return $this->getFullName();
}
}
\ No newline at end of file
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components
'components'=>array(
'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
// uncomment the following to use a MySQL database
/*
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
*/
),
);
\ No newline at end of file
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Mail Admin',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.extensions.wrest.*'
),
'modules'=>array(
// uncomment the following to enable the Gii tool
/*
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
*/
),
// application components
'components'=>array(
'clientScript' => array(
'scriptMap' => array(
'jquery.js' => false,
'jquery.yiiactiveform.js' => false
)
),
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>require(dirname(__FILE__).'/routes.php')
),
'request' => array(
'class' => 'CHttpRequest'
),
'authManager'=>array(
'class'=>'CDbAuthManager',
'itemTable' => 'users',
'connectionID'=>'db'
),
'user'=>array(
// enable cookie-based authentication
'class' => 'WebUser',
'allowAutoLogin'=>true
),
'session' => array(
'sessionTableName' => 'websessions',
'class' => 'system.web.CDbHttpSession',
'connectionID' => 'db'
),
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=mail',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8'
),
'errorHandler'=>array(
'errorAction'=>'api/error/error'
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning, trace, profile, info'
)
)
)
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com'
),
);
\ No newline at end of file
<?php
return array(
array('api/<model>/delete', 'pattern'=>'api/<model:\w+>/<_id:\d+>', 'verb'=>'DELETE'),
array('api/<model>/update', 'pattern'=>'api/<model:\w+>/<_id:\d+>', 'verb'=>'PUT'),
array('api/<model>/list', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),
array('api/<model>/get', 'pattern'=>'api/<model:\w+>/<_id:\d+>', 'verb'=>'GET'),
array('api/<model>/create', 'pattern'=>'api/<model:\w+>', 'verb'=>'POST')
);
\ No newline at end of file
<?php
return CMap::mergeArray(
require(dirname(__FILE__).'/main.php'),
array(
'components'=>array(
'fixture'=>array(
'class'=>'system.test.CDbFixtureManager',
),
/* uncomment the following to provide test database connection
'db'=>array(
'connectionString'=>'DSN for test database',
),
*/
),
)
);
<?php
class SiteController extends WRestController
{
private $_identity;
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index');
}
}
\ No newline at end of file
<?php
/**
* Alias action handler
*/
class AliasController extends WRestController
{
protected $_modelName = "alias";
public function actions() //determine which of the standard actions will support the controller
{
return array(
'list' => array( //use for get list of objects
'class' => 'WRestListAction',
'filterBy' => array(
'compare' => array(
'column' => array(
'alias' => 'query',
'recipient' => 'query',
'comment' => 'query'
),
'partial' => true,
'operator' => 'OR'
)
),
'limit' => 'limit',
'page' => 'page',
'order' => 'order'
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
'create' => array(
'class' => 'WRestCreateAction',
'scenario' => 'update'
),
'update' => array(
'class' => 'WRestUpdateAction',
'scenario' => 'update'
)
);
}
}
<?php
/**
* This is error handler configured as global
*
*/
class ErrorController extends WRestController
{
public function actionError() {
if($error = Yii::app()->errorHandler->error) {
if(YII_DEBUG) {
$this->sendResponse($error['code'], array(
'success' => false,
'error' => $error
));
}
else {
if(Yii::app()->user->isGuest) {
$this->sendResponse(401, array(
'success' => false
));
}
else {
$this->sendResponse($error['code'], array(
'success' => false,
'error' => array(
'message' => $error['message']
))
);
}
}
}
else {
Yii::app()->end();
}
}
}
\ No newline at end of file
<?php
/**
* Controls authorization moments or request to identify who is logged in currently
*
*/
class LoginController extends WRestController
{
/**
* Authorize identity
*/
private $_identity;
/**
* Use model with this controller
*/
protected $_modelName = "manager";
/**
* Default action
*/
public $defaultAction = "Identity";
/**
* Link List action to the identity
*/
public function actionList() {
$this->actionIdentity();
} // end actionList()
/**
* Link Get action to the identity
*/
public function actionGet() {
$this->actionIdentity();
} // end actionGet()
/**
* Default actions
*/
public function actionIdentity()
{
if(Yii::app()->user->isGuest) {
$this->sendResponse(401, array(
"success" => false
));
}
else {
$this->sendResponse(200, array(
"success" => true,
"results" => array(
"login" => Yii::app()->user->getLogin(),
"name" => Yii::app()->user->getFullName()
)
));
}
} // end actionIdentity()
/**
* Authorization method
*/
public function actionAuthorize()
{
if(Yii::app()->user->isGuest) {
$login = $this->getRequest()->getParam("login");
$pass = $this->getRequest()->getParam("pass");
$this->_identity = new UserIdentity($login, $pass);
if(!$this->_identity->authenticate()) {
$this->sendResponse(401, array(
"success" => false,
"details" => 'Wrong authentication data'
));
}
else {
Yii::app()->user->login($this->_identity);
$this->sendResponse(200, array(
"success" => true,
"results" => array(
"login" => Yii::app()->user->getLogin(),
"name" => Yii::app()->user->getFullName()
)
));
}
}
}
/**
* Logs out the current user and redirect to home page.
*/
public function actionLogout()
{
Yii::app()->user->logout();
if(!Yii::app()->request->isAjaxRequest) {
$this->redirect(Yii::app()->homeUrl);
}
else {
$this->sendResponse(200, array("url" => Yii::app()->homeUrl));
}
}
}
<?php
/**
* Transport action handler
*/
class TransportController extends WRestController
{
protected $_modelName = "transport";
public function actions() //determine which of the standard actions will support the controller
{
return array(
'list' => array( //use for get list of objects
'class' => 'WRestListAction',
'filterBy' => array(
'compare' => array(
'column' => array(
'domain' => 'query'
),
'partial' => true,
'operator' => 'OR'
)
),
'limit' => 'limit',
'page' => 'page',
'order' => 'order'
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
'create' => array(
'class' => 'WRestCreateAction',
'scenario' => 'update'
),
'update' => array(
'class' => 'WRestUpdateAction',
'scenario' => 'update'
)
);
}
}
<?php
/**
* User action handler
*/
class UserController extends WRestController
{
/**
* Define model for the controller
*/
protected $_modelName = "user";
/**
* Determine which of the standard actions will support the controller
*/
public function actions()
{
return array(
'list' => array(
'class' => 'WRestListAction',
'filterBy' => array(
'compare' => array(
'column' => array(
'name' => 'query',
'login' => 'query'
),
'partial' => true,
'operator' => 'OR'
)
),
'limit' => 'limit',
'page' => 'page',
'order' => 'order'
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
'create' => 'WRestCreateAction',
'update' => array(
'class' => 'WRestUpdateAction',
'scenario' => 'update'
)
);
}
}
CREATE TABLE tbl_user (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(128) NOT NULL,
password VARCHAR(128) NOT NULL,
email VARCHAR(128) NOT NULL
);
INSERT INTO tbl_user (username, password, email) VALUES ('test1', 'pass1', 'test1@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test2', 'pass2', 'test2@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test3', 'pass3', 'test3@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test4', 'pass4', 'test4@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test5', 'pass5', 'test5@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test6', 'pass6', 'test6@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test7', 'pass7', 'test7@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test8', 'pass8', 'test8@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test9', 'pass9', 'test9@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test10', 'pass10', 'test10@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test11', 'pass11', 'test11@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test12', 'pass12', 'test12@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test13', 'pass13', 'test13@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test14', 'pass14', 'test14@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test15', 'pass15', 'test15@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test16', 'pass16', 'test16@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test17', 'pass17', 'test17@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test18', 'pass18', 'test18@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test19', 'pass19', 'test19@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test20', 'pass20', 'test20@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test21', 'pass21', 'test21@example.com');
CREATE TABLE tbl_user (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
username VARCHAR(128) NOT NULL,
password VARCHAR(128) NOT NULL,
email VARCHAR(128) NOT NULL
);
INSERT INTO tbl_user (username, password, email) VALUES ('test1', 'pass1', 'test1@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test2', 'pass2', 'test2@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test3', 'pass3', 'test3@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test4', 'pass4', 'test4@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test5', 'pass5', 'test5@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test6', 'pass6', 'test6@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test7', 'pass7', 'test7@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test8', 'pass8', 'test8@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test9', 'pass9', 'test9@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test10', 'pass10', 'test10@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test11', 'pass11', 'test11@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test12', 'pass12', 'test12@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test13', 'pass13', 'test13@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test14', 'pass14', 'test14@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test15', 'pass15', 'test15@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test16', 'pass16', 'test16@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test17', 'pass17', 'test17@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test18', 'pass18', 'test18@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test19', 'pass19', 'test19@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test20', 'pass20', 'test20@example.com');
INSERT INTO tbl_user (username, password, email) VALUES ('test21', 'pass21', 'test21@example.com');
No preview for this file type
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class JsonResponse extends WRestResponse{
public function getContentType()
{
return "application/json";
}
public function setParams($params = array())
{
$this->_body = CJSON::encode($params);
return $this;
}
}
Yii Rest Extension
===================
Extension organize REST API on Yii app
[Weavora's](http://weavora.com) Git Repo - [https://github.com/weavora/wrest](https://github.com/weavora/wrest)
**Features**:
* Fast configuration
* Provide simple REST CRUD interface (get, list, update, create, delete actions)
* CRUD actions integrate with Model scenarios
Configuration
-----
1) Download and extract source into protected/extensions/ folder.
2) There are config settings for import section below:
```php
<?php
// main.php
return array(
...
'import' => array(
...
'ext.wrest.*',
),
...
);
```
3) Add REST routes
```php
<?php
// main.php
...
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
...
//rest url patterns
array('api/<model>/delete', 'pattern'=>'api/<model:\w+>/<_id:\d+>', 'verb'=>'DELETE'),
array('api/<model>/update', 'pattern'=>'api/<model:\w+>/<_id:\d+>', 'verb'=>'PUT'),
array('api/<model>/list', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),
array('api/<model>/get', 'pattern'=>'api/<model:\w+>/<_id:\d+>', 'verb'=>'GET'),
array('api/<model>/create', 'pattern'=>'api/<model:\w+>', 'verb'=>'POST'),
...
),
),
...
```
4) All your models must use WRestModelBehavior:
```php
<?php
// /models/User.php
class User extends CActiveRecord{
...
public function behaviors()
{
return array(
...
'RestModelBehavior' => array(
'class' => 'WRestModelBehavior',
)
...
);
}
...
}
```
5) Create 'api' folder in /protected/controllers/. Here will be determined all your REST API controllers.
6) Extend all your REST controlles from WRestController instead of Controller.
Usage
-----
1) Create model, determine relations, behavior etc.
```php
<?php
// /models/User.php
class User extends CActiveRecord
{
public function tableName()
{
return "user";
}
public static function model($className = __CLASS__)
{
return parent::model($className);
}
public function behaviors()
{
return array(
'RestModelBehavior' => array(
'class' => 'WRestModelBehavior',
)
);
}
public function rules(){
return array(
array('username, password', 'required'),
array('email', 'safe'),
);
}
}
```
2) Create controller in /protected/controllers/api folder, extend it's from WRestController and define allow rest actions
```php
<?php
// api/UserController.php
class UserController extends WRestController{
protected $_modelName = "user"; //model to be used as resource
public function actions() //determine which of the standard actions will support the controller
{
return array(
'list' => array( //use for get list of objects
'class' => 'WRestListAction',
'filterBy' => array( //this param user in `where` expression when forming an db query
'account_id' => 'account_id', // 'name_in_table' => 'request_param_name'
),
'limit' => 'limit', //request parameter name, which will contain limit of object
'page' => 'page', //request parameter name, which will contain requested page num
'order' => 'order', //request parameter name, which will contain ordering for sort
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
'create' => 'WRestCreateAction', //provide 'scenario' param
'update' => array(
'class' => 'WRestUpdateAction',
'scenario' => 'update', //as well as in WRestCreateAction optional param
);
}
}
```
REST API call samples
=======================
If you use RestClient class, then you can call api next way:
```php
<?php
// apiCallSample.php
require 'RestClient.php';
$client = new RestClient('http://api_url/api/', '', '');
$response = $client->get('user'); //return the list of objects {{id:1, username:'Jack'}, {id:2, username:'Nick'}}
$response = $client->get('user/1'); //return single object with requested id, for example {id:1, username:'Jack'}
$response = $client->update('user/1', array('username' => 'new user name')); //update user data
$response = $client->delete('user/1'); //delete user with requested id
$response = $client->post('user', array('username'=>'name', 'password' => 'pass', 'email' => 'email@email.com'));//create new user
```
Custom action sample
--------------------
```php
<?php
// api/UserController.php
class UserController extends WRestController{
protected $_modelName = "user"; //model to be used as resource
...
public function actionFriends($id)
{
$user = User::model()->findByPk($id);
$friends = $user->findFriends();
if(empty($user))
$this->sendResponse(404);
$users = array();
foreach($friends as $friend){
$users = $friend->getAllAttributes();
}
$this->sendResponse(200, $users);
}
...
}
```
Use with Access layer filter
-----------------
For provide access layer for REST actions use [wacf](https://github.com/weavora/yii-wacf)
```php
<?php
// api/UserController.php
class UserController extends WRestController
{
protected $modelName = "user";
public function filters()
{
return array(
'accessControl',
);
}
public function accessRules()
{
return array(
array(
'allow',
'actions' => array('get', 'list', 'create'),
'roles' => array('member'),
),
array(
'allow',
'roles' => array('member'),
'actions' => array('delete', 'update'),
'resource' => array(
'model' => 'User',
'params' => 'id',
'ownerField' => 'account_id',
),
),
array(
'deny',
),
);
}
public function actions()
{
return array(
'list' => array(
'class' => 'WRestListAction',
'filterBy' => array(
'account_id' => 'account_id',
),
'limit' => 'limit',
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
'create' => 'WRestCreateAction',
'update' => 'WRestUpdateAction',
);
}
}
```
\ No newline at end of file
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
/**
* Simple client for testing
*/
class RestClient
{
//---
protected $apiKey = null;
protected $sharedKey = null;
protected $urlBase = null;
public function __construct($urlBase, $apiKey, $sharedKey)
{
$this->urlBase = $urlBase;
$this->apiKey = $apiKey;
$this->sharedKey = $sharedKey;
}
public function get($url, $params = array('format' => 'json'))
{
return $this->httpRequest($url, $params, 'GET');
}
public function post($url, $params = array('format' => 'json'))
{
return $this->httpRequest($url, $params, 'POST');
}
public function delete($url, $params = array('format' => 'json'))
{
return $this->httpRequest($url, $params, 'DELETE');
}
public function put($url, $params = array('format' => 'json'))
{
return $this->httpRequest($url, $params, 'PUT');
}
protected function _convertParams($params)
{
return $result = http_build_query($params);
}
public function getHttpCode()
{
return $this->httpCode;
}
public function httpRequest($url, $postfields = array(), $method = "GET")
{
$postfields = array_merge($postfields, array('format' => 'json'));
foreach ($postfields as $key => $value) {
if (is_null($value)) {
unset($postfields[$key]);
}
}
$url = $this->urlBase . $url;
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_HEADER, false);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
$postfields = $this->_convertParams($postfields);
switch ($method) {
case 'GET':
$url .= "?" . $postfields;
break;
case 'POST':
curl_setopt($ci, CURLOPT_POST, true);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
case 'PUT':
// curl_setopt($ci, CURLOPT_PUT, true);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, "PUT");
break;
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->httpCode = curl_getinfo($ci, CURLINFO_HTTP_CODE);
curl_close($ci);
return (array) json_decode($response);
}
}
\ No newline at end of file
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WHttpRequest extends CHttpRequest
{
private $_restParams = array();
/**
* Default response format
* either 'json' or 'xml'
*/
private $_format = 'json';
private $_formatAttributeName = 'format';
protected $_availableFormats = array('json','xml');
public function getPut($name, $defaultValue = null)
{
if ($this->_restParams === array())
$this->_restParams = array_merge($this->getIsPutRequest() ? $this->getRestParams() : array(), $this->_restParams);
return isset($this->_restParams[$name]) ? $this->_restParams[$name] : $defaultValue;
}
public function getDelete($name, $defaultValue = null)
{
if ($this->_restParams === array())
$this->_restParams = array_merge($this->getIsDeleteRequest() ? $this->getRestParams() : array(), $this->_restParams);
return isset($this->_restParams[$name]) ? $this->_restParams[$name] : $defaultValue;
}
/**
* return all posible params from request
* @return array()
*/
public function getAllRestParams($ignorInlineParams = false)
{
if ($this->_restParams === array())
$this->_restParams = array_merge(($this->getIsDeleteRequest() || $this->getIsPutRequest()) ? $this->getRestParams() : $_REQUEST, $this->_restParams);
if($ignorInlineParams){
$result = array();
foreach ($this->_restParams as $key => $val){
if(!preg_match('|^_|si', $key)){
$result[$key] = $val;
}
}
return $result;
}
return $this->_restParams;
}
public function parseJsonParams(){
if(!isset($_SERVER['CONTENT_TYPE'])){
return $this->_restParams;
}
$contentType = strtok($_SERVER['CONTENT_TYPE'], ';');
if($contentType == 'application/json'){
$requestBody = file_get_contents("php://input");
$this->_restParams = array_merge((array)json_decode($requestBody), $this->_restParams);
}
return $this->_restParams;
}
/**
* Returns the named GET or POST parameter value.
* If the GET or POST parameter does not exist, the second parameter to this method will be returned.
* If both GET and POST contains such a named parameter, the GET parameter takes precedence.
* @param string $name the GET parameter name
* @param mixed $defaultValue the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value
* @since 1.0.4
* @see getQuery
* @see getPost
*/
public function getParam($name,$defaultValue=null)
{
if(!isset($_GET[$name]) && isset($_GET['_'.$name])){
$name = '_'.$name;
}
$param = isset($_GET[$name]) ? $_GET[$name] : null;
if(!$param)
$param = isset($_GET[$name]) ? $_GET[$name] : null;
if(!$param)
$param = isset($this->_restParams[$name]) ? $this->_restParams[$name] : null;
return $param ? $param : $defaultValue;
}
public function setFormat($format = null)
{
if ($format && in_array($format, $this->_availableFormats)) {
$this->_format = $format;
}
if (!$this->_format) {
//get format from one of requests type
$format = Yii::app()->request->getParam($this->_formatAttributeName);
$format = (empty($format)) ? Yii::app()->request->getPut($this->_formatAttributeName) : $format;
$format = (empty($format)) ? Yii::app()->request->getDelete($this->_formatAttributeName) : $format;
$this->_format = $format;
}
}
public function getFormat(){
return $this->_format;
}
}
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
Yii::import("ext." . basename(__DIR__) . '.actions.*');
Yii::import("ext." . basename(__DIR__) . '.behaviors.*');
abstract class WRestController extends Controller
{
/**
* @var WRestResponse
*/
public $response = null;
protected $_modelName = "";
protected $_responseFormat = null;
public function init(){
$this->_modelName = ucfirst($this->_modelName);
Yii::app()->setComponent('request', Yii::createComponent(array(
'class' => 'ext.wrest.WHttpRequest',
)));
$this->request->parseJsonParams();
$this->request->getAllRestParams();
$this->request->setFormat($this->_responseFormat);
$this->response = WRestResponse::factory($this->request->getFormat());
return parent::init();
}
/**
* @desc
* @param type $status
* @param string $body
* @param type $content_type
*/
public function sendResponse($status = 200, $bodyParams = array())
{
if ($status != 200) {
$bodyParams = CMap::mergeArray($this->response->getErrorMessage($status), $bodyParams);
}
else {
if(!isset($bodyParams['success'])) {
if(isset($bodyParams['total'])) {
$total = (int)$bodyParams['total'];
unset($bodyParams['total']);
}
$bodyParams = array(
"success" => true,
"results" => $bodyParams
);
if(isset($total)) {
$bodyParams['total'] = (int)$total;
}
}
}
$this->response->setStatus($status);
$this->sendHeaders();
echo $this->response->setParams($bodyParams)->getBody();
Yii::app()->end();
}
public function sendHeaders()
{
$headers = $this->response->getHeaders();
foreach ($headers as $header){
header($header);
}
}
/**
* @return CActiveRecord
*/
public function getModel($scenario = '')
{
$id = $this->request->getParam('id');
$modelName = ucfirst($this->_modelName);
if (empty($this->_modelName) && class_exists($modelName)) {
$this->sendResponse(400);
}
if ($id) {
$model = call_user_func(array($modelName, 'model'));
$model = $model->findByPk($id);
if (is_null($model)) {
$this->sendResponse(400);
}
} else {
$model = new $modelName();
}
if ($scenario && $model)
$model->setScenario($scenario);
return $model;
}
/**
* @return WHttpRequest
*/
public function getRequest()
{
return Yii::app()->request;
}
}
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
abstract class WRestResponse
{
protected $_body = '';
protected $status = 200;
public abstract function getContentType();
public abstract function setParams($params = array());
public function getBody()
{
return $this->_body;
}
/**
*
* @param string $type
* @return WRestResponse
*/
public static function factory($type)
{
$className = ucfirst($type) . "Response";
return new $className();
}
/**
*
* @param string $status
* @return WRestResponse
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
public function getStatusCodeMessage($status, $isCode = true)
{
$codes = Array(
200 => array('OK' => 'OK'),
400 => array('Bad Request' => 'Bad Request'),
401 => array('Unauthorized' => 'You must be authorized to view this page.'),
402 => array('Payment Required' => 'Payment Required'),
403 => array('Forbidden' => 'Forbidden'),
404 => array('Not Found' => 'The requested URL was not found.'),
500 => array('Internal Server Error' => 'The server encountered an error processing your request.'),
501 => array('Not Implemented' => 'The requested method is not implemented.'),
);
$result = "";
if (isset($codes[$status])) {
$code = ($isCode) ? array_keys($codes[$status]) : array_values($codes[$status]);
$result = array_pop($code);
}
return $result;
}
public function getErrorMessage($status){
return array(
'error' => array(
'code' => $status,
'title' => $this->getStatusCodeMessage($status),
'message' => $this->getStatusCodeMessage($status, false)
)
);
}
public function getHeaders(){
$headers = array();
$status = $this->status;
// set the status
$statusHeader = 'HTTP/1.1 ' . $status . ' ' . $this->getStatusCodeMessage($status);
$headers[] = $statusHeader;
// and the content type
$headers[] = 'Content-type: ' . $this->getContentType();
return $headers;
}
public function getStatus(){
return $this->status;
}
}
\ No newline at end of file
<?php
/**
* This class is based on the JsonResponse class by Weavora Team and the code from various posters on http://snipplr.com/view/3491/
*
* @author Fredrik Wollsén <fredrik@neam.se>
* @link http://neam.se
* @license MIT
*/
class XmlResponse extends WRestResponse
{
public function getContentType()
{
return "application/xml";
}
public function setParams($params = array())
{
// Associative single-valued array is treated as the root element
if (is_array($params) && count($params) == 1 && ($keys = array_keys($params)) && !is_numeric($keys[0])) //count($params) == 1 && ($keys = array_keys($params)) && !is_int($keys[0])
{
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$keys[0]} />");
$data = $params[$keys[0]];
$this->_body = self::toXml($data, null, $xml);
} else
{
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><response />");
$this->_body = self::toXml($params, null, $xml);
}
return $this;
}
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
* @return string XML
*/
public static function toXML($data, $defaultKey = null, &$xml = null)
{
if (is_null($defaultKey)) $defaultKey = 'element';
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if (ini_get('zend.ze1_compatibility_mode') == 1)
ini_set('zend.ze1_compatibility_mode', 0);
// loop through the data passed in.
foreach ($data as $key => $value)
{
// no numeric keys in our xml please!
if (is_numeric($key))
{
$numeric = 1;
$key = $defaultKey;
}
// delete any char not allowed in XML element names
$key = preg_replace('/[^a-z0-9\-\_\.\:]/i', '', $key);
if (is_object($value))
{
$value = get_object_vars($value);
}
// if there is another array found recrusively call this function
if (is_array($value))
{
$node = self::is_assoc($value) || $numeric ? $xml->addChild($key) : $xml;
// recrusive call.
if ($numeric)
$key = 'anon';
self::toXml($value, $key, $node);
} else
{
// add single node.
$value = htmlspecialchars($value);
$xml->addChild($key, $value);
}
}
// pass back as XML
//return $xml->asXML();
//
// if you want the XML to be formatted, use the below instead to return the XML
$doc = new DOMDocument('1.0');
$doc->preserveWhiteSpace = false;
$doc->loadXML($xml->asXML());
$doc->formatOutput = true;
return $doc->saveXML();
}
/**
* Convert an XML document to a multi dimensional array
* Pass in an XML document (or SimpleXMLElement object) and this recrusively loops through and builds a representative array
*
* @param string $xml - XML document - can optionally be a SimpleXMLElement object
* @return array ARRAY
*/
public static function toArray($xml)
{
if (is_string($xml))
$xml = new SimpleXMLElement($xml);
$children = $xml->children();
if (!$children)
return (string) $xml;
$arr = array();
foreach ($children as $key => $node)
{
$node = ArrayToXML::toArray($node);
// support for 'anon' non-associative arrays
if ($key == 'anon')
$key = count($arr);
// if the node is already set, put it into an array
if (isset($arr[$key]))
{
if (!is_array($arr[$key]) || $arr[$key][0] == null)
$arr[$key] = array($arr[$key]);
$arr[$key][] = $node;
} else
{
$arr[$key] = $node;
}
}
return $arr;
}
// determine if a variable is an associative array
public static function is_assoc($array)
{
return (is_array($array) && 0 !== count(array_diff_key($array, array_keys(array_keys($array)))));
}
}
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WRestCreateAction extends CAction
{
public $scenario = '';
public function run()
{
$requestAttributes = Yii::app()->request->getAllRestParams();
$model = $this->controller->getModel($this->scenario);
$paramsList = $model->getCreateAttributes();
$attributes = array();
foreach ($paramsList as $key) {
if (isset($requestAttributes[$key])) {
$attributes[$key] = $requestAttributes[$key];
}
}
$model->attributes = $attributes;
if ($model->save()) {
$this->controller->sendResponse(200, $model->getAllAttributes());
} else {
$this->controller->sendResponse(500, array('errors' => $model->getErrors()));
}
}
}
\ No newline at end of file
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WRestDeleteAction extends CAction
{
public function run()
{
$model = $this->controller->getModel();
if ($model->delete()) {
$this->controller->sendResponse(200, array('id' => $model->id));
} else {
$this->controller->sendResponse(500);
}
}
}
\ No newline at end of file
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WRestGetAction extends CAction
{
public function run()
{
$model = $this->controller->getModel();
$this->controller->sendResponse(200, $model->getAllAttributes());
}
}
\ No newline at end of file
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WRestListAction extends CAction
{
public $filterBy = array();
public $page = 'page';
public $limit = 'limit';
public $order = 'order';
public function run()
{
$c = new CDbCriteria();
foreach ($this->filterBy as $key => $val) {
if ($key == 'compare' && is_array($val)) {
if(!isset($val['column'])) {
continue;
}
if(is_string($val['column'])) {
$column = explode(',', $val['column']);
}
else {
$column = $val['column'];
}
foreach($column as $col => $param)
{
$param = trim($param);
// Let us suppose that there was string comma separated
if(is_numeric($col)) {
$col = $param;
}
$this->setCompare($c, $col, $param,
isset($val['partial']) ? $val['partial'] : false,
isset($val['operator']) ? $val['operator'] : false);
}
}
else {
$this->setCompare($c, $key, $val);
}
}
$model = $this->controller->getModel();
$c->limit = (int)(($limit = Yii::app()->request->getParam($this->limit)) ? $limit : -1);
$page = (int)Yii::app()->request->getParam($this->page) - 1;
$c->offset = ($offset = $limit * $page) ? $offset : 0;
$c->order = ($order = Yii::app()->request->getParam($this->order)) ? $order : $model->getMetaData()->tableSchema->primaryKey;
$models = $model->findAll($c);
$result = array();
if ($models) {
foreach ($models as $item) {
$result[] = $item->getAllAttributes();
}
}
$result = array_merge($result, array(
'total' => $model->count($c)
));
$this->controller->sendResponse(200, $result);
}
/**
* Set compare condition
* @param object, CDbCriteria (required)
* @param string, column name (required)
* @param mix, column value (required)
* @param boolean, partial match (default false)
* @param string, operator (default AND)
*/
private function setCompare( &$criteria, $column, $value, $partialMatch = false, $operator = 'AND' )
{
if(empty($column)) {
return null;
}
if (!is_null(Yii::app()->request->getParam($value))) {
$criteria->compare($column, Yii::app()->request->getParam($value), $partialMatch, $operator);
}
}
}
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WRestUpdateAction extends CAction
{
public $scenario = '';
public function run()
{
$requestAttributes = Yii::app()->request->getAllRestParams();
$model = $this->controller->getModel($this->scenario);
$paramsList = $model->getUpdateAttributes();
$attributes = array();
foreach ($paramsList as $key) {
if (isset($requestAttributes[$key])) {
$attributes[$key] = $requestAttributes[$key];
}
}
$model->attributes = $attributes;
if ($model->save()) {
$this->controller->sendResponse(200, $model->getAllAttributes());
} else {
$this->controller->sendResponse(403, array('errors' => $model->getErrors()));
}
}
}
\ No newline at end of file
<?php
/**
* @author Weavora Team <hello@weavora.com>
* @link http://weavora.com
* @copyright Copyright (c) 2011 Weavora LLC
*/
class WRestModelBehavior extends CActiveRecordBehavior
{
public function getAllAttributes()
{
$owner = $this->getOwner();
return $owner->getAttributes();
}
public function getCreateAttributes()
{
return $this->_getAttributesByScenario('insert');
}
public function getUpdateAttributes()
{
return $this->_getAttributesByScenario('update');
}
private function _getAttributesByScenario($scenario){
$owner = $this->getOwner();
$owner->setScenario($scenario);
$validators = $owner->getValidators();
$attributes = array();
foreach ($validators as $validator){
$attributes = array_merge($attributes, $validator->attributes);
}
return $attributes;
}
}
\ No newline at end of file
<?php
// apiCallSample.php
require 'RestClient.php';
$client = new RestClient('http://localhost/mymailadmin/public/', '', '');
$response = $client->get('user'); //return the list of objects {{id:1, username:'Jack'}, {id:2, username:'Nick'}}
print_r($response);
\ No newline at end of file
<?php
/**
* PHPUnit
*
* Copyright (c) 2002-2011, Sebastian Bergmann <sebastian@phpunit.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package PHPUnit
* @subpackage TextUI
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @copyright 2002-2011 Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @link http://www.phpunit.de/
* @since File available since Release 2.0.0
*/
require_once 'PHP/Timer.php';
class WUnit_ResultPrinter extends PHPUnit_TextUI_ResultPrinter
{
protected $outputBuffer = "";
public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE, $debug = FALSE)
{
parent::__construct($out, $verbose, $colors, $debug);
}
public function write($buffer)
{
if ($this->out) {
fwrite($this->out, $buffer);
if ($this->autoFlush) {
$this->incrementalFlush();
}
} else {
if (PHP_SAPI != 'cli') {
$buffer = htmlspecialchars($buffer);
}
$this->outputBuffer .= $buffer;
if ($this->autoFlush) {
$this->incrementalFlush();
}
}
}
public function printResult(PHPUnit_Framework_TestResult $result)
{
parent::printResult($result);
print $this->outputBuffer;
}
}
<?php
error_reporting( E_ALL | E_STRICT );
require(dirname(__FILE__).'/../../../../../framework/yiit.php');
require dirname(__FILE__).'/ResultPrinter.php';
Yii::createWebApplication(require(dirname(__FILE__) . '/../../../config/main.php'));
\ No newline at end of file
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$users=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
}
}
\ No newline at end of file
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
'assetManager' => array(
'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'../assets',
),
//'db'=>array(
// 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
//),
// uncomment the following to use a MySQL database
// 'db'=>array(
// 'connectionString' => 'mysql:host=weavora-1;dbname=wfrom2',
// 'emulatePrepare' => true,
// 'username' => 'dev',
// 'password' => 'dev',
// 'charset' => 'utf8',
// ),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
'params'=>array(
'adminEmail'=>'webmaster@example.com',
),
);
\ No newline at end of file
<?php
class TestController extends CController
{
public function actionIndex()
{
Yii::app()->end(200);
}
}
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<!-- blueprint CSS framework -->
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>
<body>
<div class="container" id="page">
<div id="header">
<div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
<div id="user-info">
<?php echo Yii::app()->user->isGuest ? "You are not loged in" : "You are loged in as ".Yii::app()->user->getName();?>
</div>
</div><!-- header -->
<div id="mainmenu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/test/index')),
array('label'=>'Contact', 'url'=>array('/test/contact')),
array('label'=>'Login', 'url'=>array('/test/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/test/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
</div><!-- mainmenu -->
<div id="content">
<?php echo $content; ?>
</div>
<div class="clear"></div>
<div id="footer">
Copyright &copy; <?php echo date('Y'); ?> by My Company.<br/>
All Rights Reserved.<br/>
<?php echo Yii::powered(); ?>
</div><!-- footer -->
</div><!-- page -->
</body>
</html>
<?php
$this->pageTitle=Yii::app()->name . ' - Contact Us';
?>
<h1>Contact Us</h1>
<?php if(Yii::app()->user->hasFlash('contact')): ?>
<div class="flash-success">
<?php echo Yii::app()->user->getFlash('contact'); ?>
</div>
<?php else: ?>
<p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
</p>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'contact-form',
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name'); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'subject'); ?>
<?php echo $form->textField($model,'subject',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->error($model,'subject'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'body'); ?>
<?php echo $form->textArea($model,'body',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'body'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php endif; ?>
\ No newline at end of file
<?php
$this->pageTitle = Yii::app()->name . ' - Test Form functionality';
?>
<h1>Test Form Functionality</h1>
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'contact-form',
'htmlOptions' => array('enctype'=>'multipart/form-data')
));
?>
<div class="row">
<?php echo $form->labelEx($model, 'textField'); ?>
<?php echo $form->textField($model, 'textField'); ?>
<?php echo $form->error($model, 'textField'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'checkBox'); ?>
<?php echo $form->checkBox($model, 'checkBox'); ?>
<?php echo $form->error($model, 'checkBox'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'dropDownList'); ?>
<?php echo $form->checkBoxList($model, 'dropDownList', array('1' => 'Select first item', '2' => 'Select second item',)); ?>
<?php echo $form->error($model, 'dropDownList'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'passwordField'); ?>
<?php echo $form->passwordField($model, 'passwordField'); ?>
<?php echo $form->error($model, 'passwordField'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'textArea'); ?>
<?php echo $form->textArea($model, 'textArea'); ?>
<?php echo $form->error($model, 'textArea'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'fileField'); ?>
<?php echo $form->fileField($model, 'fileField'); ?>
<?php echo $form->error($model, 'fileField'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('submit'); ?>
</div>
<?php $this->endWidget(); ?>
<div class="row">
<?php echo $form->textField; ?>
</div>
<div class="row">
<?php echo $form->checkBox ? "CheckBox is checked": "Not check"; ?>
</div>
<div class="row">
<?php echo $form->dropDownList; ?>
</div>
<div class="row">
<?php echo $form->passwordField; ?>
</div>
<div class="row">
<?php echo $form->textArea; ?>
</div>
<div class="row">
<?php echo $uploadedFileSaved ? $form->fileField->getName() : ""; ?>
</div>
<?php $this->pageTitle=Yii::app()->name; ?>
<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>
<h2 class="cssclass">cool</h2>
<p>Congratulations! You have successfully created your Yii application.</p>
<p>You may change the content of this page by modifying the following two files:</p>
<ul>
<li>View file: <tt><?php echo __FILE__; ?></tt></li>
<li>Layout file: <tt><?php echo $this->getLayoutFile('main'); ?></tt></li>
</ul>
<p>For more details on how to further develop this application, please read
the <a href="http://www.yiiframework.com/doc/">documentation</a>.
Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
should you have any questions.</p>
\ No newline at end of file
<?php
$this->pageTitle = Yii::app()->name . ' - Login';
?>
<h1>Login</h1>
<p>Please fill out the following form with your login credentials:</p>
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'login-form',
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<div class="row">
<?php echo $form->labelEx($model, 'username'); ?>
<?php echo $form->textField($model, 'username'); ?>
<?php echo $form->error($model, 'username'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'password'); ?>
<?php echo $form->passwordField($model, 'password'); ?>
<?php echo $form->error($model, 'password'); ?>
<p class="hint">
Hint: You may login with <tt>demo/demo</tt> or <tt>admin/admin</tt>.
</p>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model, 'rememberMe'); ?>
<?php echo $form->label($model, 'rememberMe'); ?>
<?php echo $form->error($model, 'rememberMe'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Login'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php foreach($server as $key=>$value):?>
<b><?php echo $key . "=" . $value;?></b>
<?php endforeach;?>
\ No newline at end of file
<phpunit bootstrap="bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
printerClass="WUnit_ResultPrinter"
stopOnFailure="false"
verbose="true"
strict="true"
>
</phpunit>
\ No newline at end of file
<?php
class WRestResponseTest extends CTestCase
{
/**
* @var JsonResponse
*/
static $response = null;
public function setUp()
{
static::$response = new JsonResponse();
}
public function testRestPesonseObj()
{
$response = WRestResponse::factory('json');
$this->assertTrue($response instanceof WRestResponse);
$this->assertTrue($response instanceof JsonResponse);
$this->assertTrue(static::$response instanceof WRestResponse);
//test default param for new obj
$this->assertEmpty(static::$response->getBody());
$this->assertEquals(static::$response->getStatus(), 200);
}
public function testStatuses()
{
$this->assertTrue(static::$response->setStatus(200) instanceof WRestResponse);
static::$response->setStatus(200);
$this->assertEquals(static::$response->getStatus(), 200);
$this->assertEquals(static::$response->getStatusCodeMessage(200), "OK");
static::$response->setStatus(400);
$this->assertEquals(static::$response->getStatus(), 400);
$this->assertEquals(static::$response->getStatusCodeMessage(400), "Bad Request");
$this->assertEquals(static::$response->getStatusCodeMessage(401), "Unauthorized");
$this->assertEquals(static::$response->getStatusCodeMessage(401, false), "You must be authorized to view this page.");
$this->assertEquals(static::$response->getStatusCodeMessage(402), "Payment Required");
$this->assertEquals(static::$response->getStatusCodeMessage(403), "Forbidden");
$this->assertEquals(static::$response->getStatusCodeMessage(404), "Not Found");
$this->assertEquals(static::$response->getStatusCodeMessage(500), "Internal Server Error");
$this->assertEquals(static::$response->getStatusCodeMessage(501), "Not Implemented");
$this->assertEquals(static::$response->getStatusCodeMessage(9999), ""); //test unexisting code
}
public function testGetErrorMessage(){
$error = static::$response->getErrorMessage(500);
$expectedValue = array(
'code' => 500,
'title' => 'Internal Server Error',
'message' => 'The server encountered an error processing your request.',
);
$this->assertEquals($error, $expectedValue);
}
public function testGetHeaders(){
$expectedValue = array(
'HTTP/1.1 200 OK',
'Content-type: '.static::$response->getContentType(),
);
static::$response->setStatus(200);
$headers = static::$response->getHeaders();
$this->assertEquals($headers, $expectedValue);
}
public function testGetContentType(){
$expectedValue = "application/json";
$this->assertEquals(static::$response->getContentType(), $expectedValue);
}
public function testGetBody(){
$data = array(
'data' => 'someData',
);
$expectedValue = json_encode($data);
static::$response->setParams($data);
$this->assertEquals($expectedValue, static::$response->getBody());
}
}
\ No newline at end of file
<?php
/**
* This class controls requests to the API
* All request those are from guest must be rejected
*/
class AccessControl extends CFilter
{
protected function preFilter($filterChain)
{
if(Yii::app()->user->isGuest) {
throw new CHttpException(401, 'Unauthorized request');
}
return true;
}
}
<?php
/**
* Common model function
*
*/
abstract class ActiveRecord extends CActiveRecord
{
/**
* @param integer, record start
* @param integer, record limit number
*/
public function limited($start = 0, $limit = 100)
{
$this->getDbCriteria()->mergeWith(array(
'offset' => $start,
'limit' => $limit
));
return $this;
}
/**
* Finds out sort parameters
*/
public static function getSort( $sort )
{
if(!is_array($sort) || count($sort) == 0) {
return '';
}
$_str = array();
array_walk($sort, create_function('$item, $key, $_tmp', '
$_tmp[0][] = $item["property"] . " " . $item["direction"];
'), array( &$_str ));
return implode(", ", $_str);
}
}
<?php
/**
* Alias model
*
*/
class Alias extends ActiveRecord
{
/**
* REST behavior
*/
public function behaviors()
{
return array(
'RestModelBehavior' => array(
'class' => 'WRestModelBehavior',
)
);
}
/**
* Returns current model
*/
public static function model( $className = __CLASS__ )
{
return parent::model($className);
}
/**
* Return table name to which this model is related
*/
public function tableName()
{
return 'aliases';
}
/**
* Return table primary key name
*/
public function primaryKey()
{
return 'id';
}
/**
* Model rules
*/
public function rules(){
return array(
array('alias, recipient, comment', 'default', 'on' => 'insert'),
array('alias, recipient', 'required', 'on' => 'insert'),
array('id, alias, recipient, comment', 'default', 'on' => 'update')
);
}
}
\ No newline at end of file
<?php
/**
* Manager
*
*/
class Manager extends CActiveRecord
{
/**
* REST behavior
*/
public function behaviors()
{
return array(
'RestModelBehavior' => array(
'class' => 'WRestModelBehavior',
)
);
}
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return 'users';
}
public function primaryKey()
{
return 'id';
}
}
<?php
/**
* Transport model
*
*/
class Transport extends ActiveRecord
{
/**
* REST behavior
*/
public function behaviors()
{
return array(
'RestModelBehavior' => array(
'class' => 'WRestModelBehavior',
)
);
}
/**
* Returns current model
*/
public static function model( $className = __CLASS__ )
{
return parent::model($className);
}
/**
* Return table name to which this model is related
*/
public function tableName()
{
return 'transport';
}
/**
* Return table primary key name
*/
public function primaryKey()
{
return 'id';
}
/**
* Model rules
*/
public function rules(){
return array(
array('domain, transport', 'required', 'on' => 'insert'),
array('domain, transport', 'required', 'on' => 'update')
);
}
}
<?php
/**
* User model
*
*/
class User extends ActiveRecord
{
/**
* REST behavior
*/
public function behaviors()
{
return array(
'RestModelBehavior' => array(
'class' => 'WRestModelBehavior',
)
);
}
/**
* Returns current model
*/
public static function model( $className = __CLASS__ )
{
return parent::model($className);
}
/**
* Return table name to which this model is related
*/
public function tableName()
{
return 'users';
}
/**
* Return table primary key name
*/
public function primaryKey()
{
return 'id';
}
/**
* Model rules
*/
public function rules()
{
return array(
array('name, login, passwd, uid, gid, maildir, smtp, imap, quota, manager', 'default', 'on' => 'update'),
array('login, passwd, maildir', 'required', 'on' => 'update'),
array('smtp, imap, manager', 'numerical', 'on' => 'update', 'allowEmpty' => false, 'integerOnly' => true),
array('login', 'email', 'on' => 'update'),
array('name, login, passwd, uid, gid, maildir, smtp, imap, quota, manager', 'default', 'on' => 'insert'),
array('login, passwd, maildir', 'required', 'on' => 'insert'),
array('smtp, imap, manager', 'numerical', 'on' => 'insert', 'allowEmpty' => false, 'integerOnly' => true),
array('login', 'email', 'on' => 'insert')
);
}
}
2012/10/15 12:10:54 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:10:54 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:06 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:11:26 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:13:03 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:13:03 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:13:03 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:13:03 [trace] [system.CModule] Loading "coreMessages" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:13:03 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system is unable to find the requested action "index".' in /home/develop/www/mymailadmin/framework/web/CController.php:484
Stack trace:
#0 /home/develop/www/mymailadmin/framework/web/CController.php(271): CController->missingAction('')
#1 /home/develop/www/mymailadmin/framework/web/CWebApplication.php(283): CController->run('')
#2 /home/develop/www/mymailadmin/framework/web/CWebApplication.php(142): CWebApplication->runController('api/transport')
#3 /home/develop/www/mymailadmin/framework/base/CApplication.php(162): CWebApplication->processRequest()
#4 /home/develop/www/mymailadmin/public/index.php(18): CApplication->run()
#5 {main}
REQUEST_URI=/mymailadmin/public/index.php/api/transport?_dc=1350288783171
HTTP_REFERER=http://localhost/mymailadmin/public/
---
2012/10/15 12:14:19 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:19 [trace] [system.CModule] Loading "clientScript" application component
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:20 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:14:25 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:03 [trace] [system.CModule] Loading "clientScript" application component
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:04 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:15:08 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "clientScript" application component
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:23:03 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/views/site/index.php (2)
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "clientScript" application component
in /home/develop/www/mymailadmin/public/protected/controllers/SiteController.php (16)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:37 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (17)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (17)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [trace] [system.CModule] Loading "coreMessages" application component
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (30)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:25:45 [error] [exception.CException] exception 'CException' with message 'Property "Transport.virtual" is not defined.' in /home/develop/www/mymailadmin/framework/base/CComponent.php:131
Stack trace:
#0 /home/develop/www/mymailadmin/framework/db/ar/CActiveRecord.php(144): CComponent->__get('virtual')
#1 /home/develop/www/mymailadmin/framework/validators/CRequiredValidator.php(52): CActiveRecord->__get('virtual')
#2 /home/develop/www/mymailadmin/framework/validators/CValidator.php(214): CRequiredValidator->validateAttribute(Object(Transport), 'virtual')
#3 /home/develop/www/mymailadmin/framework/base/CModel.php(158): CValidator->validate(Object(Transport), NULL)
#4 /home/develop/www/mymailadmin/framework/db/ar/CActiveRecord.php(795): CModel->validate(NULL)
#5 /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php(30): CActiveRecord->save()
#6 /home/develop/www/mymailadmin/framework/web/actions/CAction.php(75): WRestCreateAction->run()
#7 /home/develop/www/mymailadmin/framework/web/CController.php(309): CAction->runWithParams(Array)
#8 /home/develop/www/mymailadmin/framework/web/filters/CFilterChain.php(134): CController->runAction(Object(WRestCreateAction))
#9 /home/develop/www/mymailadmin/framework/web/filters/CFilter.php(41): CFilterChain->run()
#10 /home/develop/www/mymailadmin/framework/web/filters/CFilterChain.php(131): CFilter->filter(Object(CFilterChain))
#11 /home/develop/www/mymailadmin/framework/web/CController.php(292): CFilterChain->run()
#12 /home/develop/www/mymailadmin/framework/web/CController.php(266): CController->runActionWithFilters(Object(WRestCreateAction), Array)
#13 /home/develop/www/mymailadmin/framework/web/CWebApplication.php(283): CController->run('create')
#14 /home/develop/www/mymailadmin/framework/web/CWebApplication.php(142): CWebApplication->runController('api/transport/c...')
#15 /home/develop/www/mymailadmin/framework/base/CApplication.php(162): CWebApplication->processRequest()
#16 /home/develop/www/mymailadmin/public/index.php(18): CApplication->run()
#17 {main}
REQUEST_URI=/mymailadmin/public/index.php/api/transport?_dc=1350289545188
HTTP_REFERER=http://localhost/mymailadmin/public/
---
2012/10/15 12:26:00 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (17)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (17)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [trace] [system.CModule] Loading "coreMessages" application component
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (30)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:26:00 [error] [exception.CException] exception 'CException' with message 'Property "Transport.virtual" is not defined.' in /home/develop/www/mymailadmin/framework/base/CComponent.php:131
Stack trace:
#0 /home/develop/www/mymailadmin/framework/db/ar/CActiveRecord.php(144): CComponent->__get('virtual')
#1 /home/develop/www/mymailadmin/framework/validators/CRequiredValidator.php(52): CActiveRecord->__get('virtual')
#2 /home/develop/www/mymailadmin/framework/validators/CValidator.php(214): CRequiredValidator->validateAttribute(Object(Transport), 'virtual')
#3 /home/develop/www/mymailadmin/framework/base/CModel.php(158): CValidator->validate(Object(Transport), NULL)
#4 /home/develop/www/mymailadmin/framework/db/ar/CActiveRecord.php(795): CModel->validate(NULL)
#5 /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php(30): CActiveRecord->save()
#6 /home/develop/www/mymailadmin/framework/web/actions/CAction.php(75): WRestCreateAction->run()
#7 /home/develop/www/mymailadmin/framework/web/CController.php(309): CAction->runWithParams(Array)
#8 /home/develop/www/mymailadmin/framework/web/filters/CFilterChain.php(134): CController->runAction(Object(WRestCreateAction))
#9 /home/develop/www/mymailadmin/framework/web/filters/CFilter.php(41): CFilterChain->run()
#10 /home/develop/www/mymailadmin/framework/web/filters/CFilterChain.php(131): CFilter->filter(Object(CFilterChain))
#11 /home/develop/www/mymailadmin/framework/web/CController.php(292): CFilterChain->run()
#12 /home/develop/www/mymailadmin/framework/web/CController.php(266): CController->runActionWithFilters(Object(WRestCreateAction), Array)
#13 /home/develop/www/mymailadmin/framework/web/CWebApplication.php(283): CController->run('create')
#14 /home/develop/www/mymailadmin/framework/web/CWebApplication.php(142): CWebApplication->runController('api/transport/c...')
#15 /home/develop/www/mymailadmin/framework/base/CApplication.php(162): CWebApplication->processRequest()
#16 /home/develop/www/mymailadmin/public/index.php(18): CApplication->run()
#17 {main}
REQUEST_URI=/mymailadmin/public/index.php/api/transport?_dc=1350289560808
HTTP_REFERER=http://localhost/mymailadmin/public/
---
2012/10/15 12:27:19 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (17)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (17)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.ar.CActiveRecord] Transport.insert()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (30)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Executing SQL: INSERT INTO `transport` (`domain`, `transport`) VALUES (:yp0, :yp1)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestCreateAction.php (30)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:19 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:22 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/models/Transport.php (27)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (91)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (13)
2012/10/15 12:27:26 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/models/Transport.php (27)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (91)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (13)
2012/10/15 12:27:26 [trace] [system.db.ar.CActiveRecord] Transport.findByPk()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (92)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (13)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` WHERE `t`.`id`=11 LIMIT 1
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (92)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (13)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.ar.CActiveRecord] Transport.delete()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (14)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.ar.CActiveRecord] Transport.deleteByPk()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (14)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:26 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `transport` WHERE `transport`.`id`=11
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestDeleteAction.php (14)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.CModule] Loading "log" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.CModule] Loading "request" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.CModule] Loading "urlManager" application component
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.web.filters.CFilterChain] Running filter AccessControl.filter()
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.CModule] Loading "user" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.CModule] Loading "session" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.CModule] Loading "db" application component
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbConnection] Opening DB connection
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbCommand] Executing SQL: DELETE FROM `websessions` WHERE expire<:expire
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbCommand] Querying SQL: SELECT `data`
FROM `websessions`
WHERE expire>:expire AND id=:id
in /home/develop/www/mymailadmin/public/protected/filters/AccessControl.php (10)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `transport`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/WRestController.php (98)
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (53)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.ar.CActiveRecord] Transport.findAll()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `transport` `t` ORDER BY id LIMIT 100
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (59)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.ar.CActiveRecord] Transport.count()
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
2012/10/15 12:27:29 [trace] [system.db.CDbCommand] Querying SQL: SELECT COUNT(*) FROM `transport` `t`
in /home/develop/www/mymailadmin/public/protected/extensions/wrest/actions/WRestListAction.php (69)
in /home/develop/www/mymailadmin/public/index.php (18)
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
<?php
/**
* Change the following URL based on your server configuration
* Make sure the URL ends with a slash so that we can use relative URLs in test cases
*/
define('TEST_BASE_URL','http://localhost/testdrive/index-test.php/');
/**
* The base class for functional test cases.
* In this class, we set the base URL for the test application.
* We also provide some common methods to be used by concrete test classes.
*/
class WebTestCase extends CWebTestCase
{
/**
* Sets up before each test method runs.
* This mainly sets the base URL for the test application.
*/
protected function setUp()
{
parent::setUp();
$this->setBrowserUrl(TEST_BASE_URL);
}
}
<?php
// change the following paths if necessary
$yiit=dirname(__FILE__).'/../../../framework/yiit.php';
$config=dirname(__FILE__).'/../config/test.php';
require_once($yiit);
require_once(dirname(__FILE__).'/WebTestCase.php');
Yii::createWebApplication($config);
<?php
class SiteTest extends WebTestCase
{
public function testIndex()
{
$this->open('');
$this->assertTextPresent('Welcome');
}
public function testContact()
{
$this->open('?r=site/contact');
$this->assertTextPresent('Contact Us');
$this->assertElementPresent('name=ContactForm[name]');
$this->type('name=ContactForm[name]','tester');
$this->type('name=ContactForm[email]','tester@example.com');
$this->type('name=ContactForm[subject]','test subject');
$this->click("//input[@value='Submit']");
$this->waitForTextPresent('Body cannot be blank.');
}
public function testLoginLogout()
{
$this->open('');
// ensure the user is logged out
if($this->isTextPresent('Logout'))
$this->clickAndWait('link=Logout (demo)');
// test login process, including validation
$this->clickAndWait('link=Login');
$this->assertElementPresent('name=LoginForm[username]');
$this->type('name=LoginForm[username]','demo');
$this->click("//input[@value='Login']");
$this->waitForTextPresent('Password cannot be blank.');
$this->type('name=LoginForm[password]','demo');
$this->clickAndWait("//input[@value='Login']");
$this->assertTextNotPresent('Password cannot be blank.');
$this->assertTextPresent('Logout');
// test logout process
$this->assertTextNotPresent('Login');
$this->clickAndWait('link=Logout (demo)');
$this->assertTextPresent('Login');
}
}
<phpunit bootstrap="bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<selenium>
<browser name="Internet Explorer" browser="*iexplore" />
<browser name="Firefox" browser="*firefox" />
</selenium>
</phpunit>
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="<?php print Yii::app()->request->baseUrl; ?>/css/application.css">
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/scripts/ext-all-debug.js"></script>
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/scripts/app-debug.js"></script>
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="<?php print Yii::app()->request->baseUrl; ?>/css/application.css">
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/scripts/bootstrap.js"></script>
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/app/Overrides.js"></script>
<script type="text/javascript">
Ext.Loader.setConfig({
enabled: true
});
Ext.override(Ext.app.Application, {
appFolder: "<?php print Yii::app()->request->baseUrl; ?>/app",
});
</script>
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/app/Application.js"></script>
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="<?php print Yii::app()->request->baseUrl; ?>/css/application.min.css">
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/scripts/ext-all.js"></script>
<script type="text/javascript" src="<?php print Yii::app()->request->baseUrl; ?>/scripts/app.js"></script>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<meta name="application-url" content="<?php print Yii::app()->request->baseUrl; ?>" />
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<?php if(YII_DEVELOP) $this->renderPartial("/layouts/_develop"); ?>
<?php
if(!defined('YII_DEVELOP') || !YII_DEVELOP) {
if(YII_DEBUG) $this->renderPartial("/layouts/_debug");
else if(!defined('YII_DEBUG') || !YII_DEBUG) $this->renderPartial("/layouts/_production");
}
?>
</head>
<body>
<?php echo $content; ?>
</body>
</html>
<?php
$this->pageTitle=Yii::app()->name . ' - ' . Yii::app()->user->getTitle();
#!/usr/bin/env php
<?php
require_once(dirname(__FILE__).'/yiic.php');
@echo off
rem -------------------------------------------------------------
rem Yii command line script for Windows.
rem This is the bootstrap script for running yiic on Windows.
rem -------------------------------------------------------------
@setlocal
set BIN_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%BIN_PATH%yiic.php" %*
@endlocal
\ No newline at end of file
<?php
// change the following paths if necessary
$yiic=dirname(__FILE__).'/../../framework/yiic.php';
$config=dirname(__FILE__).'/config/console.php';
require_once($yiic);
// This line changes the location of your images when creating UIs to be relative instead of within the ExtJS directory.
// You MUST set this to true/string value if you are creating new UIs + supporting legacy browsers.
// This only applies to new UIs. It does not apply to default component images (i.e. when changing $base-color)
// The value can either be true, in which case the image path will be "../images/"
// or a string, of where the path is
// $relative-image-path-for-uis: '../images/ui/';
// Local prefixes
$prefix-icon-btn: 'ibtn-' !default;
// Global variables must be here
$base-color: #f0f0f0;
$toolbar-separator-color: #aca899;
//tips
$tip-base-color: $base-color;
//buttons
$button-default-color: #eeeeee !default;
$button-default-base-color: #206d9b;
$button-default-base-color-over: #1b7aaa;
$button-default-base-color-focus: $button-default-base-color-over;
$button-default-base-color-pressed: #1290c0;
$button-default-base-color-disabled: adjust-color($base-color, $hue: 0deg, $saturation: -55.556%, $lightness: 12.745%) !default; //F7F7F7
$button-default-border-color: #bbbbbb;
$button-default-border-color-over: #9d9d9d;
$button-default-border-color-focus: $button-default-border-color-over;
$button-default-border-color-pressed: $button-default-border-color-over;
$button-default-border-color-disabled: adjust-color($button-default-base-color-disabled, $hue: 0deg, $saturation: 0%, $lightness: -8.627%) !default;
$button-default-background-gradient: 'matte';
$button-default-background-gradient-over: 'matte';
$button-default-background-gradient-focus: 'matte';
$button-default-background-gradient-pressed: 'matte-reverse';
$button-default-background-gradient-disabled: 'matte';
$button-default-background-gradient-color-stops: null;
$button-default-background-gradient-color-stops-over: null;
$button-default-background-gradient-color-stops-focus: null;
$button-default-background-gradient-color-stops-pressed: null;
$button-default-background-gradient-color-stops-disabled: null;
$button-toolbar-base-color: $button-default-base-color;
$button-toolbar-color-over: $button-default-color !default;
$button-toolbar-border-color: transparent !default;
$button-toolbar-border-color-over: $button-default-border-color-over;
$button-toolbar-border-color-focus: $button-default-border-color-focus;
$button-toolbar-border-color-pressed: $button-default-border-color-pressed;
$button-toolbar-border-color-disabled: $button-default-border-color-disabled;
$button-toolbar-background-color: transparent !default;
$button-toolbar-background-color-over: $button-default-base-color-over;
$button-toolbar-background-color-focus: $button-default-base-color-focus;
$button-toolbar-background-color-pressed: $button-default-base-color-pressed;
$button-toolbar-background-color-disabled: transparent;
$button-toolbar-background-gradient: null;
$button-toolbar-background-gradient-over: 'matte';
$button-toolbar-background-gradient-focus: 'matte';
$button-toolbar-background-gradient-pressed: 'matte-reverse';
$button-toolbar-background-gradient-disabled: null;
$button-toolbar-background-gradient-color-stops: null;
$button-toolbar-background-gradient-color-stops-over: null;
$button-toolbar-background-gradient-color-stops-focus: null;
$button-toolbar-background-gradient-color-stops-pressed: null;
$button-toolbar-background-gradient-color-stops-disabled: null;
@import 'compass';
@import 'ext4/default/all';
@include extjs-window-ui (
'default',
$ui-padding: 0 0 20px 0,
$ui-border-radius: 5px,
$ui-border-color: #a1a1a1,
$ui-inner-border-color: transparent,
$ui-header-color: null,
$ui-header-font-size: $window-header-font-size,
$ui-header-font-weight: $window-header-font-weight,
$ui-body-border-color: transparent,
$ui-body-background-color: $base-color,
$ui-body-color: null,
$ui-background-color: $base-color
);
@include extjs-panel-ui(
'default',
$ui-base-color: $panel-base-color,
$ui-border-width: $panel-border-width,
$ui-border-color: $panel-border-color,
$ui-border-radius: $panel-border-radius,
$ui-header-color: $panel-header-color,
$ui-header-font-size: $panel-header-font-size,
$ui-header-font-weight: $panel-header-font-weight,
$ui-header-border-color: $panel-header-border-color,
$ui-header-background-color: $panel-header-background-color,
$ui-header-background-gradient: $panel-header-background-gradient,
$ui-body-color: $panel-body-color,
$ui-body-border-color: $panel-body-border-color,
$ui-body-border-width: 1px,
$ui-body-background-color: transparent
);
@include extjs-panel-ui(
'desk-panel',
$ui-base-color: $panel-base-color,
$ui-border-width: $panel-border-width,
$ui-border-color: $panel-border-color,
$ui-border-radius: $panel-border-radius,
$ui-header-color: $panel-header-color,
$ui-header-font-size: $panel-header-font-size,
$ui-header-font-weight: $panel-header-font-weight,
$ui-header-border-color: $panel-header-border-color,
$ui-header-background-color: $panel-header-background-color,
$ui-header-background-gradient: $panel-header-background-gradient,
$ui-body-color: $panel-body-color,
$ui-body-border-color: $panel-body-border-color,
$ui-body-border-width: 1px,
$ui-body-background-color: #EEE
);
.#{$prefix}desk-panel-bg {
background-image: url('../images/ui/panel/AT.png');
background-repeat: no-repeat;
background-position: right bottom;
}
.#{$prefix}window-authbaner {
background-image: url('../images/ui/toolbar/navbg.jpg');
background-repeat: repeat-x;
background-position: top;
}
@include extjs-toolbar-ui(
'default',
$background-color: #f0f0f0,
$background-gradient: null,
$border-color: transparent
);
@include extjs-toolbar-ui(
'authform-baner',
$background-color: transparent,
$background-gradient: null,
$border-color: transparent
);
@include extjs-toolbar-ui(
'programbar-panel',
$background-color: #1a7cab,
$background-gradient: 'bevel',
$border-color: #c0c0c0
);
.#{$prefix}programbar-panel {
padding: 0px;
}
@include extjs-toolbar-ui(
'programbar',
$background-color: transparent,
$background-gradient: null
);
@include extjs-button-ui (
'program-menu-toolbar-small',
$border-radius: 5px,
$border-width: 1px,
$border-color: #236794,
$border-color-over: null,
$border-color-focus: null,
$border-color-pressed: null,
$border-color-disabled: null,
$padding: 0px,
$text-padding: null,
$background-color: null,
$background-color-over: #236794,
$background-color-focus: #236794,
$background-color-pressed: #236794,
$background-color-disabled: null,
$background-gradient: null,
$background-gradient-over: 'bevel',
$background-gradient-focus: 'bevel',
$background-gradient-pressed: 'bevel',
$background-gradient-disabled: null,
$color: #fff,
$color-over: #fff,
$color-focus: #fff,
$color-pressed: #fff,
$color-disabled: #c0c0c0,
$font-size: null,
$font-size-over: null,
$font-size-focus: null,
$font-size-pressed: null,
$font-size-disabled: null,
$font-weight: bold,
$font-weight-over: bold,
$font-weight-focus: bold,
$font-weight-pressed: bold,
$font-weight-disabled: null,
$font-family: 'arial',
$font-family-over: 'arial',
$font-family-focus: 'arial',
$font-family-pressed: 'arial',
$font-family-disabled: 'arial',
$icon-size: null
);
@include extjs-button-ui (
'program-button-toolbar-small',
$border-radius: 5px,
$border-width: 1px,
$border-color: #236794,
$border-color-over: null,
$border-color-focus: null,
$border-color-pressed: null,
$border-color-disabled: null,
$padding: 0px 10px,
$text-padding: null,
$background-color: null,
$background-color-over: #236794,
$background-color-focus: #236794,
$background-color-pressed: #5695BF,
$background-color-disabled: null,
$background-gradient: null,
$background-gradient-over: 'bevel',
$background-gradient-focus: 'bevel',
$background-gradient-pressed: 'bevel',
$background-gradient-disabled: null,
$color: #D2EAFA,
$color-over: #fff,
$color-focus: #fff,
$color-pressed: #fff,
$color-disabled: #c0c0c0,
$font-size: null,
$font-size-over: null,
$font-size-focus: null,
$font-size-pressed: null,
$font-size-disabled: null,
$font-weight: bold,
$font-weight-over: bold,
$font-weight-focus: bold,
$font-weight-pressed: bold,
$font-weight-disabled: null,
$font-family: 'arial',
$font-family-over: 'arial',
$font-family-focus: 'arial',
$font-family-pressed: 'arial',
$font-family-disabled: 'arial',
$icon-size: null
);
@mixin grid-action-btn (
$ui,
$image: null
) {
.#{$prefix}#{$prefix-icon-btn}#{$ui} {
background: theme-background-image($theme-name, $image) no-repeat transparent;
}
}
/**
* Element icons
*/
.#{$prefix}#{$prefix-icon-btn}def, .#{$prefix}#{$prefix-icon-btn}def-dis {
width: 18px;
height: 17px;
cursor: pointer;
}
.#{$prefix}#{$prefix-icon-btn}def-dis {
background-position: 0 -16px !important;
cursor: default !important;
}
/**
* Trace text style
*/
.#{$prefix}msg-error {
margin-bottom: 4px;
}
.#{$prefix}msg-trace, .#{$prefix}msg-trace-detail {
font-size: 12px;
color: #404040;
margin-bottom: 16px;
}
.#{$prefix}msg-trace {
overflow: scroll;
}
.#{$prefix}msg-trace-detail {
padding-left: 20px;
}
// Put here icons list
@include grid-action-btn ('edit', 'ui/icons/item-edit.png');
@include grid-action-btn ('delete', 'ui/icons/item-delete.png');
@include grid-action-btn ('add', 'ui/icons/item-add.png');
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resources/sass folder
# <root>/resources/sass
sass_path = File.join(File.dirname(__FILE__));
# css_path: the directory you want your CSS files to be.
# Generally this is a folder in the parent directory of your Sass files
# <root>/resources/css
css_path = File.join(sass_path, "..", "css");
# output_style: The output style for your compiled CSS
# nested, expanded, compact, compressed
# More information can be found here http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#output_style
#output_style = :compressed
output_style = :expanded;
project_type = :stand_alone;
# We need to load in the Ext4 themes folder, which includes all it's default styling, images, variables and mixins
load File.join(sass_path, '..', '..', 'ext', 'resources', 'themes');
/* Welcome to Compass. Use this file to write IE specific override styles.
* Import this file using the following HTML or equivalent:
* <!--[if IE]>
* <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
* <![endif]--> */
/* Welcome to Compass. Use this file to define print styles.
* Import this file using the following HTML or equivalent:
* <link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" /> */
/* Welcome to Compass.
* In this file you should write your main styles. (or centralize your imports)
* Import this file using the following HTML or equivalent:
* <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" /> */
@import "compass/reset";
/**
* Contains Common overrides and extentions
*
*/
/**
* Adds functions with predefined configs
*/
Ext.override(Ext.Msg, {
onShow: function() {
this.callParent(arguments);
this.center();
// This will fix trace information block
if(!Ext.isEmpty(Ext.query('div.x-msg-trace')) && !Ext.isEmpty(Ext.query('div.x-msg-error'))) {
var error = Ext.get(Ext.query('div.x-msg-error')),
trace = Ext.get(Ext.query('div.x-msg-trace'));
if(trace.first().getHeight() + error.first().getHeight() > this.body.getHeight()) {
trace.first().setHeight(this.body.getHeight() - error.first().getHeight());
}
}
},
showInfo: function(config) {
Ext.Msg.show(Ext.apply({
autoScroll: true,
title: 'Info',
msg: '',
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
}, config || {}))
},
showError: function(cfg) {
if(Ext.isObject(cfg.msg)) {
if(cfg.msg.tpl) {
if(Ext.isArray(cfg.msg.tpl) || Ext.isString(cfg.msg.tpl)) {
cfg.msg = new Ext.XTemplate(Ext.isArray(cfg.msg.tpl) ? cfg.msg.tpl.join('') : cfg.msg.tpl).apply(cfg.msg.data || {});
}
else if(cfg.msg.tpl.isTemplate) {
cfg.msg = cfg.msg.tpl.apply(cfg.msg.data || {});
}
}
else if(cfg.msg.error) {
cfg.msg = new Ext.XTemplate(
'<div class="x-msg-error">',
'<tpl if="code">Error code: {code}<br/></tpl>',
'<tpl if="type">Error type: {type}<br/></tpl>',
'Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>',
'<tpl if="file">File: {file}<br/></tpl>',
'<tpl if="line">Line: {line}<br/></tpl>',
'</div>',
'<tpl if="traces">',
'<div class="x-msg-trace"><tpl for="traces">',
'({line}) {file}: <div class="x-msg-trace-detail">',
'<tpl if="type == \'-&gt;\'">{class}-&gt;{function}()</tpl>',
'<tpl if="args && args.length &gt; 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>',
'</div>',
'</tpl></div>',
'</tpl>'
).apply(cfg.msg.error);
}
}
Ext.Msg.show(Ext.apply({
autoScroll: true,
title: 'Error',
msg: '',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
}, cfg || {}))
}
});
/**
* Adds default settings to the Ext.data.Connection
* The main goal is to change onComplete function to handle common server exceptions
*/
Ext.override(Ext.data.Connection, {
// Default request path
url: '.',
// Default timeoute
timeout: 380000,
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.emptyFn,
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.emptyFn,
/**
* Finds meta tag in the document to set application base url
* @return {string}
*/
getBaseUrl: function() {
if(!Ext.isDefined(this.baseUrl)) {
this.baseUrl = (Ext.query('meta[name=application-url]')[0] || { content: '.' }).content;
this.baseUrl.replace(/[\/\\]+$/, "");
this.url = this.baseUrl;
}
return this.url;
},
/**
* Returns RESTful url using base url and passed route
* @return {string}
*/
getRestUrl: function() {
var route = [];
Ext.iterate(arguments, function(value) {
this.push(value);
}, route);
route = route.join('/');
route.replace(/^[\/\\]+/, "");
return [this.getBaseUrl(), '/index.php/', route].join('');
},
/**
* To be called when the request has come back from the server
* This override needs to catch specific server exceptions and stop callback execution
* @private
* @param {Object} request
* @return {Object} The response
*/
onComplete : function(request) {
var me = this,
options = request.options,
result,
success,
response;
try {
result = me.parseStatus(request.xhr.status);
} catch (e) {
// in some browsers we can't access the status if the readyState is not 4, so the request has failed
result = {
success : false,
isException : false
};
}
success = result.success;
// Run success
if (success) {
response = me.createResponse(request);
me.fireEvent('requestcomplete', me, response, options);
Ext.callback(options.success, options.scope, [response, options]);
} else {
if (result.isException || request.aborted || request.timedout) {
response = me.createException(request);
} else {
response = me.createResponse(request);
}
// Keep unauthorized statuses
if(Ext.isEmpty(me.getGuest()) && (response.status != 404 || response.status != 500)) {
me.setGuest(true);
}
else {
if(options.proxy && options.proxy.isProxy) {
var data = response.responseText ? Ext.decode(response.responseText) : {};
Ext.Msg.showError({
title: data.error.title || 'Error',
msg: {
error: data.error
},
buttons: Ext.Msg.OK
});
}
else {
me.fireEvent('requestexception', me, response, options);
}
Ext.callback(options.failure, options.scope, [response, options]);
}
}
if (!Ext.isDefined(me.isGuest)) {
Ext.callback(options.callback, options.scope, [options, success, response]);
}
delete me.requests[request.id];
return response;
}
});
/**
* Changes for the toolbar element
*/
Ext.override(Ext.Toolbar, {
// Adds function to the toolbar to return input element's values
getValues: function() {
var params = {},
items = this.query('searchfield,textfield,numberfield,checkbox,radio,combo');
Ext.each(items, function(item){
this[item.name || item.itemId || item.getId()] = item.getValue();
}, params);
return params;
}
});
/**
* Additional component to initiate query request on enter key event
*/
Ext.define('Ext.form.SearchField', {
extend: 'Ext.form.field.Text',
alias: 'widget.searchfield',
enableKeyEvents: true,
// If field is in the toolbar than this option may points to button
// or put here function
handler: null,
// Add specialkey listener
initComponent: function() {
this.callParent();
if(!Ext.isEmpty(this.handler)) {
this.on('specialkey', this.checkEnterKey, this);
}
},
// Handle enter key presses, execute the search if the field has a value
checkEnterKey: function(field, e) {
var value = this.getValue();
if (e.getKey() === e.ENTER) {
if(Ext.isFunction(this.handler)) {
this.handler();
}
else if(Ext.isString(this.handler)) {
var point = this.up('toolbar').query('#' + this.handler);
if(point.length > 0 && point[0].getXType() == 'button') {
point[0].fireEvent('click',point[0]);
}
}
}
}
});Ext.define('MyMA.view.ProgramMenu', {
extend: 'Ext.Button',
alias: 'widget.programmenu',
text: 'Menu',
height: 30,
ui: 'program-menu',
menu: [{
text: 'Users',
widgetName: 'users'
}, {
text: 'Aliases',
widgetName: 'aliases'
}, {
text: 'Transports',
widgetName: 'transports'
}, '-', {
text: 'Logout',
itemId: 'logout'
}]
});
Ext.define('MyMA.view.Taskpanel', {
extend: 'Ext.Toolbar',
alias: 'widget.taskpanel',
ui: 'programbar',
height: 28,
style: {
border: 0,
padding: 0
},
autoScroll: true,
items: []
});
Ext.define('MyMA.view.Aliases', {
extend: 'Ext.window.Window',
alias: 'widget.aliases',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop'
},
listeners: {
/**
* This event is fired through the GridView.
* Add listeners to the GridView object Fired when a drop operation has been completed and the data has been moved or copied
* @param {} node
* @param {} data
* @param {} overModel
* @param {} dropPosition
* @param {} eOpts
*/
beforedrop: function(node, data, overModel, dropPosition, eOpts) {
Ext.each(data.records, function(record) {
if(record.get('alias') != this.groupName) {
record.set('alias', this.groupName);
record.save({
action: 'update',
scope: this,
failure: function(record) {
record.store.reload();
}
});
}
}, {
data: data,
groupName: this.getFeature('alias-groups').getGroupName(node),
model: overModel
});
}
}
},
tbar: [{
xtype: 'button',
itemId: 'addrecord',
iconCls: 'x-ibtn-add',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Aliases'
},
features: [{
ftype: 'grouping',
id: 'alias-groups',
groupHeaderTpl: 'Group: {name} ({rows.length})',
startCollapsed: false
}],
selModel: {
selType: 'rowmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Recipient',
dataIndex: 'recipient',
flex: 1
}, {
header: 'Alias',
hidden: true,
dataIndex: 'alias'
}, {
header: 'Comment',
dataIndex: 'comment',
flex: 1
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
selType: 'rowmodel',
multiSelect: true,
store: 'Aliases'
}]
});
Ext.define('MyMA.view.Alias', {
extend: 'Ext.window.Window',
alias: 'widget.alias',
layout: 'fit',
title: 'Alias',
width: 400,
constrainHeader: true,
closeAction: 'destroy',
buttons: [{
xtype: 'button',
itemId: 'savedata',
text: 'Save',
scope: this
}],
items: [{
xtype: 'form',
frame: true,
monitorValid: true,
defaults: {
xtype: 'textfield',
anchor: '100%',
allowBlank: false
},
items: [{
xtype: 'hidden',
name: 'id'
}, {
fieldLabel: 'Alias',
name: 'alias',
vtype: 'email'
}, {
fieldLabel: 'Recipient',
name: 'recipient',
vtype: 'email'
}, {
fieldLabel: 'Comment',
xtype: 'textarea',
name: 'comment'
}]
}]
});
Ext.define('MyMA.view.Users', {
extend: 'Ext.window.Window',
alias: 'widget.users',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
listeners: {
/**
* Initiate data save through proxy
* @param editor : Ext.grid.plugin.Editing
* @param object
* grid - The grid
* record - The record that was edited
* field - The field name that was edited
* value - The value being set
* row - The grid table row
* column - The grid Column defining the column that was edited.
* rowIdx - The row index that was edited
* colIdx - The column index that was edited
* originalValue - The original value for the field, before the edit (only when using CellEditing)
* originalValues - The original values for the field, before the edit (only when using RowEditing)
* newValues - The new values being set (only when using RowEditing)
* view - The grid view (only when using RowEditing)
* store - The grid store (only when using RowEditing)
*/
edit: function(editor, data) {
if(data.originalValue == data.value) {
return;
}
data.record.save({
action: 'update',
scope: data,
success: function() {
this.record.commit();
//this.view.refresh();
}
});
}
},
tbar: [{
xtype: 'button',
iconCls: 'x-ibtn-add',
itemId: 'addrecord',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Users'
},
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
selModel: {
selType: 'cellmodel'
},
columns: [{
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-edit x-ibtn-def';
}
}]
}, {
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield'
},
flex: 1
}, {
header: 'Login',
dataIndex: 'login',
width: 120
}, {
header: 'Password',
hidden: true,
dataIndex: 'passwd'
}, {
header: 'uid',
dataIndex: 'uid',
width: 40
}, {
header: 'gid',
dataIndex: 'gid',
width: 40
}, {
header: 'Mail directory',
dataIndex: 'maildir'
}, {
header: 'SMTP',
dataIndex: 'smtp',
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'IMAP',
dataIndex: 'imap',
editor: {
xtype: 'combo',
valueField: 'id',
displayField: 'name',
triggerAction: 'all',
editable: false,
store: 'Choice'
},
renderer: function(value) {
if(value==1) {
return 'Yes';
}
return 'No';
}
}, {
header: 'Quota',
dataIndex: 'quota',
editor: {
xtype: 'numberfield',
allowDecimal: false
}
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
store: 'Users'
}]
});
Ext.define('MyMA.view.User', {
extend: 'Ext.window.Window',
alias: 'widget.user',
layout: 'fit',
title: 'User',
width: 400,
constrainHeader: true,
closeAction: 'destroy',
buttons: [{
xtype: 'button',
itemId: 'savedata',
text: 'Save',
scope: this
}],
items: [{
xtype: 'form',
frame: true,
monitorValid: true,
defaults: {
xtype: 'textfield',
anchor: '100%',
allowBlank: false
},
items: [{
xtype: 'hidden',
name: 'id'
}, {
xtype: 'checkbox',
fieldLabel: 'Manager',
name: 'manager',
inputValue: 1
}, {
xtype: 'checkbox',
fieldLabel: 'SMTP',
name: 'smtp',
inputValue: 1
}, {
xtype: 'checkbox',
fieldLabel: 'IMAP',
name: 'imap',
inputValue: 1
}, {
fieldLabel: 'Name',
name: 'name'
}, {
fieldLabel: 'Login',
name: 'login',
vtype: 'email'
}, {
fieldLabel: 'Password',
name: 'passwd'
}, {
xtype: 'numberfield',
allowDecimal: false,
fieldLabel: 'UID',
name: 'uid',
anchor: '50%',
value: 8
}, {
xtype: 'numberfield',
allowDecimal: false,
fieldLabel: 'GID',
name: 'gid',
anchor: '50%',
value: 12
}, {
fieldLabel: 'Mail directory',
name: 'maildir'
}, {
xtype: 'numberfield',
name: 'quota',
allowDecimal: false,
fieldLabel: 'Quota',
anchor: '60%',
value: 100000000
}]
}]
});
Ext.define('MyMA.view.Viewport', {
extend: 'Ext.container.Viewport',
requires: [
'MyMA.view.ProgramMenu',
'MyMA.view.Taskpanel',
'MyMA.view.Users',
'MyMA.view.Aliases'
],
layout: 'fit',
statics: {
ready: false
},
items: {
xtype: 'panel',
layout: 'fit',
border: false,
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
height: 30,
ui: 'programbar-panel',
items: [{
xtype: 'programmenu',
width: 100
}, '-', {
xtype: 'taskpanel',
flex: 1
}]
}],
items: [{
xtype: 'panel',
border: false,
ui: 'desk-panel',
bodyCls: 'x-desk-panel-bg',
layout: {
type: 'fit'
}
}]
}
});
Ext.define('MyMA.view.Authorize', {
extend: 'Ext.Window',
alias: 'widget.authorize',
layout: 'fit',
autoShow: true,
layout: 'fit',
width: 350,
closable: false,
constrain: true,
draggable: false,
resizable: false,
modal: true,
cls: 'x-window-authbaner',
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
ui: 'authform-baner',
height: 43,
html: '{LOGIN @ MAIL . PANEL }'
}],
items: [{
xtype: 'form',
url: 'index.php',
monitorValid: true,
frame: false,
border: false,
defaults: {
anchor: '100%'
},
buttons: [{
text: 'Login'
}],
items: [{
fieldLabel: 'Login',
xtype: 'textfield',
allowBlank: false,
name: 'login'
}, {
fieldLabel: 'Password',
xtype: 'textfield',
name: 'pass',
inputType: 'password'
}]
}]
});
Ext.define('MyMA.view.Transports', {
extend: 'Ext.window.Window',
alias: 'widget.transports',
layout: 'fit',
minimizable: true,
constrainHeader: true,
closeAction: 'destroy',
width: 900,
listeners: {
render: function(win) {
if(Ext.getBody().getHeight() > 500) {
win.setHeight(Ext.getBody().getHeight() - 150);
}
}
},
items: [{
xtype: 'grid',
border: false,
tbar: [{
xtype: 'button',
itemId: 'addrecord',
iconCls: 'x-ibtn-add',
text: 'New Item'
}, {
xtype: 'tbseparator',
width: 5
}, {
xtype: 'searchfield',
handler: 'search',
name: 'query'
}, {
xtype: 'tbspacer',
width: 5
}, {
xtype: 'button',
itemId: 'search',
text: 'Search'
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true,
store: 'Transports'
},
columns: [{
header: 'ID',
dataIndex: 'id',
width: 40
}, {
header: 'Domain',
dataIndex: 'domain',
editor: {
xtype: 'textfield',
allowBlank: false
},
flex: 1
}, {
header: 'Transport',
dataIndex: 'transport'
}, {
xtype: 'actioncolumn',
width: 30,
items: [{
getClass: function() {
return 'x-ibtn-delete x-ibtn-def';
}
}]
}],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1
})
],
store: 'Transports'
}]
});
Ext.define('MyMA.model.Users', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'login',
type: 'string'
}, {
name: 'passwd',
type: 'string'
}, {
name: 'uid',
type: 'int',
defaultValue: 8
}, {
name: 'gid',
type: 'int',
defaultValue: 12
}, {
name: 'maildir',
type: 'string'
}, {
name: 'smtp',
type: 'int'
}, {
name: 'imap',
type: 'int'
}, {
name: 'quota',
type: 'int',
defaultValue: 10000000
}, {
name: 'manager',
type: 'int'
}],
validations: [{
type: 'format',
field: 'maildir',
matcher: /^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api/user'),
reader: {
type: 'json',
root: 'results'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Brief', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'results'
}
}
});
Ext.define('MyMA.model.Aliases', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'alias',
type: 'string'
}, {
name: 'recipient',
type: 'string'
}, {
name: 'comment',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'alias'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.model.Transports', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'domain',
type: 'string'
}, {
name: 'transport',
type: 'string'
}],
proxy: {
type: 'rest',
url: Ext.Ajax.getRestUrl('api', 'transport'),
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
writer: {
type: 'json',
allowSingle: true
}
}
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.store.Users', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Users',
model: 'MyMA.model.Users',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Programs', {
extend: 'Ext.data.ArrayStore',
fields: ['id', 'name', 'state', 'item', 'title', 'control'],
data: [],
/**
* Get item record from process storage
* @param object
*/
getProccess: function(data) {
var data = data || {
property: 'id',
value: null
},
idx = -1;
if((idx = this.find(data.property, data.value, 0, false, true, true)) > -1) {
return this.getAt(idx);
}
return null;
}
});
Ext.define('MyMA.store.Aliases', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Aliases',
model: 'MyMA.model.Aliases',
groupField: 'alias',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Transports', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Transports',
model: 'MyMA.model.Transports',
remoteSort: true,
pageSize: 100
});
Ext.define('MyMA.store.Choice', {
extend: 'Ext.data.Store',
requires: 'MyMA.model.Brief',
model: 'MyMA.model.Brief',
data: [{
id: 0,
name: 'No'
}, {
id: 1,
name: 'Yes'
}]
});
Ext.define('MyMA.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users', 'Choice'],
views: ['Users', 'User'],
refs: [{
selector: 'users > grid',
ref: 'usersList'
}, {
selector: 'users',
ref: 'usersWindow'
}],
init: function() {
this.control({
'users > grid > toolbar > #addrecord': {
click: this.showForm
},
'users > grid > toolbar > #search': {
click: this.onSearch
},
'users actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'user'
});
widget.setTitle('User: ' + record.get('name'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to conform remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'user',
title: 'New User'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getUsersList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.ProgramMenu', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'programmenu > menu': {
click: this.LaunchProgram
}
});
},
LaunchProgram: function(menu, item) {
if (item.itemId == 'logout') {
this.getController('Viewport').Logout();
}
else {
this.getController('Taskpanel').addProgram({
name: item.widgetName,
title: item.text
});
}
}
});
Ext.define('MyMA.controller.Program', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
var control = {};
Ext.each(this.refs, function(item){
this.control[item.selector] = {
beforeclose: this.me.programStop,
hide: this.me.programState,
show: this.me.programState,
minimize: this.me.programMinimize
}
}, {
control: control,
me: this
});
this.control(control);
},
/**
* Register controll for the created "Program"
* @param String, selector name
*/
registerControl: function(selector) {
var selector = selector || null,
ctrl = {};
if(!selector) {
return;
}
ctrl[selector] = {
beforeclose: this.programStop,
hide: this.programState,
show: this.programState,
minimize: this.programMinimize
};
this.control(ctrl);
}, // end registerControl()
/**
* Hides widget and sets status to the Store object
* @param {Object} item
*/
programMinimize: function(item) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
this.getTaskPanel().items.get(record.get('control')).toggle(false);
item.hide();
this.programState(item);
}, // end programMinimize()
/**
* Writes program state to the Store object
* @param {Object} item
* @param {Object} opt
*/
programState: function(item, opt) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
record.set('state', item.isHidden() ? 'hide' : 'show');
}, // end programState()
/**
* Destroyes wiget and removes program information from the Store
* @param {Object} item
* @param {Object} record
*/
programStop: function(item, record) {
var record = record || Ext.undefined;
if (!record['data']) {
(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
}));
}
if(item.animateTarget) {
item.animateTarget = null;
}
if(record && record['data']) {
this.getTaskPanel().items.get(record.get('control')).destroy();
this.getStore('Programs').remove(record);
}
} // end programStop()
});
/**
* Controller: Viewport
*
*/
Ext.define('MyMA.controller.Viewport', {
extend: 'Ext.app.Controller',
views: ['Viewport', 'Authorize'],
refs: [{
selector: 'viewport',
ref: 'appView'
}, {
selector: 'authorize',
ref: 'authPanel'
}, {
selector: 'authorize > form',
ref: 'authForm'
}],
/**
*
*/
isGuest: Ext.undefined,
/**
* A template method that is called when your application boots.
* It is called before the Application's launch function is executed so gives a hook
* point to run any code before your Viewport is created.
*/
init: function(app) {
// Bind Guest to the Ext.data.Connection
Ext.override(Ext.data.Connection, {
/**
* Set guest state to the authorization controller
*/
setGuest: Ext.Function.bind(this.setGuest, this),
/**
* Return isGuest current value
* @return {Boolean}
*/
getGuest: Ext.Function.bind(this.getGuest, this)
});
this.control({
'authorize > form > toolbar > button': {
click: this.Authorize
}
});
this.Authorize();
},
/**
* Authorize
* if passed main application view, the first step need to query
* @param object, main application view
*/
Authorize: function() {
if (this.getAuthPanel()) {
var form = this.getAuthPanel().down('form').getForm();
if(form.isValid()) {
form.submit({
url: Ext.Ajax.getRestUrl('api','login', 'authorize', 0),
method: 'PUT',
clientValidation: true,
scope: this,
success: this.successLogin
})
}
}
else {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api', 'login'),
scope: this,
callback: function(){
if (!this.isGuest && !this.getAppView()) {
this.setGuest(false);
this.getView('Viewport').create();
}
}
});
}
},
/**
* Return isGuest value
* @param state
*/
getGuest: function() {
return this.isGuest;
},
/**
* Set isGuest flag value
* @param object, this controller
* @param boolean, state to set
*/
setGuest: function(state) {
this.isGuest = Ext.isBoolean(state) ? state : true;
if(this.isGuest && !this.getAuthPanel()) {
this.getView('Authorize').create();
}
},
/**
* private
*/
successLogin: function(form, action) {
this.getAuthPanel().close();
if(!this.getAppView()) {
this.getView('Viewport').create();
}
},
/**
* Logout
* public
*/
Logout: function() {
Ext.Ajax.request({
url: Ext.Ajax.getRestUrl('api','login', 'logout', 0),
method: 'PUT',
scope: this,
callback: function() {
if(this.getAppView()) {
this.getController('Taskpanel').closeAll();
this.getAppView().destroy();
}
this.setGuest(this, true);
}
});
}
});
/**
* Conroller: Alias
*
*/
Ext.define('MyMA.controller.Alias', {
extend: 'Ext.app.Controller',
views: ['Alias'],
refs: [{
selector: 'alias',
ref: 'aliasWindow'
}],
init: function() {
this.control({
'alias > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getAliasWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','alias', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
scope: {
controller: this,
win: this.getAliasWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Aliases').getStore('Aliases').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.User', {
extend: 'Ext.app.Controller',
views: ['User'],
refs: [{
selector: 'user',
ref: 'userWindow'
}],
init: function() {
this.control({
'user > toolbar > #savedata': {
click: this.saveData
}
});
},
saveData: function(Button) {
var form = this.getUserWindow().down('form').getForm(),
id = form.getValues().id || null;
if(!form.isValid()) {
return false;
}
form.submit({
url: Ext.Ajax.getRestUrl('api','user', id),
clientValidation: true,
method: id > 0 ? 'PUT' : 'POST',
params: Ext.applyIf(Ext.copyTo({}, form.getValues(), 'smtp,imap,manager'), {
smtp: 0,
imap: 0,
manager: 0
}),
scope: {
controller: this,
win: this.getUserWindow()
},
success: this.onSuccessSubmit,
failure: this.onFailSubmit
});
},
/**
*
*/
onSuccessSubmit: function(form, action) {
this.win.close();
this.controller.getController('Users').getStore('Users').reload({
params: {
start: 0
}
});
Ext.Msg.showInfo({
msg: 'Data saved'
})
},
/**
*
*/
onFailSubmit: function(form, action) {
try {
var data = Ext.decode(action.response.responseText);
throw(data);
}
catch(e) {
Ext.Msg.showError({
msg: e
});
}
}
});
Ext.define('MyMA.controller.Aliases', {
extend: 'Ext.app.Controller',
stores: ['Aliases'],
views: ['Aliases','Alias'],
refs: [{
selector: 'aliases > grid',
ref: 'aliasesList'
}],
init: function() {
this.control({
'aliases > grid > toolbar > #addrecord': {
click: this.showForm
},
'aliases > grid > toolbar > #search': {
click: this.onSearch
},
'aliases actioncolumn': {
click: this.onActionColumn
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-edit')) {
var record = scope.store.getAt(rowIndex);
var widget = this.getController('Taskpanel').addProgram({
name: 'alias'
});
widget.setTitle('Alias: ' + record.get('alias'));
widget.down('form').getForm().loadRecord(record);
}
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Show form to add new record or edit existing data
* @param {Object} Button
*/
showForm: function(Button) {
this.getController('Taskpanel').addProgram({
name: 'alias',
title: 'New Alias'
});
},
/**
* Search action
*/
onSearch: function(Button) {
this.getAliasesList().getStore().reload({ params: Button.up('toolbar').getValues() });
}
});
Ext.define('MyMA.controller.Transports', {
extend: 'Ext.app.Controller',
stores: ['Transports'],
views: ['Transports'],
refs: [{
selector: 'transports > grid',
ref: 'transportsList'
}],
init: function() {
this.control({
'transports > grid > toolbar > #addrecord': {
click: this.addRecord
},
'transports > grid > toolbar > #search': {
click: this.onSearch
},
'transports actioncolumn': {
click: this.onActionColumn
},
'transports > grid': {
edit: this.onEditAction
}
});
},
/**
* Handles action columns click
* @param {Object} grid view
* @param {HTMLElement} Element
* @param {Integer} row index
* @param {Integer} column index
* @param {Object} Event object
* @param {Object} Scope object
* @param {Object}
*/
onActionColumn: function(gridview, el, rowIndex, colIndex, e, scope, rowEl) {
if(e.getTarget('.x-ibtn-delete')) {
var record = scope.store.getAt(rowIndex);
Ext.Msg.confirm('Info', 'Press Yes to confirm remove action', function(button) {
if (button === 'yes') {
if(!this.record.get('id')) {
this.store.remove(this.record);
}
else {
this.record.destroy({
scope: this,
success: function() {
this.store.remove(this.record)
}
});
}
}
}, {
store: scope.store,
record: record
});
}
},
/**
* Add record to the store and start editing
*/
addRecord: function(Button) {
this.getTransportsList().getStore().insert(0, this.getTransportsList().getStore().model.create({
id: 0,
domain: null,
transport: 'virtual'
}));
},
/**
* Search action
*/
onSearch: function(Button) {
this.getTransportsList().getStore().reload({ params: Button.up('toolbar').getValues() });
},
/**
* Fires when edit complete and record was updated
* @param {object}, Ext.grid.plugin.Editing
* @param {object}, An edit event
*/
onEditAction: function(editor, e) {
e.record.save({
scope: e,
success: function(record) {
this.store.reload();
}
});
}
});
Ext.define('MyMA.controller.Taskpanel', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
this.control({
'taskpanel > button': {
toggle: this.programState
}
});
},
/**
* Add program to the task panel
* @param data
*/
addProgram: function(data) {
var data = data || {
name: null
},
store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'name',
value: data.name
})))
{
try {
var widget = Ext.widget(data.name),
progId = (store.max('id') || 0) + 1;
}
catch(e) {
return false;
}
var Button = this.getTaskPanel().add({
xtype: 'button',
ui: 'program-button',
height: 28,
text: data.title || widget.title,
enableToggle: true,
pressed: true,
programId: progId
});
record = store.add({
id: progId,
title: data.title || widget.title,
name: data.name,
state: 'show',
item: widget.getId(),
control: Button.getId()
})[0];
this.getController('Program').registerControl(data.name);
widget.animateTarget = Button.getId();
widget.setTitle(data.title);
widget.show();
}
else {
this.getTaskPanel().items.get(record.get('control')).toggle(true);
if((widget = Ext.getCmp(record.get('item')))) {
widget.show();
}
}
return widget ? widget : null;
},
/**
* Get reference function
* @param {Object} Button
*/
callRef: function(selector) {
var me = this;
try {
for (var i = 0, ln = this.refs.length; i < ln; i++) {
if (this.refs[i]['selector'] == selector) {
return me['get' + Ext.String.capitalize(this.refs[i]['ref'])]();
}
}
}
catch(e) { }
return null;
},
programState: function(Button) {
var store = this.getStore('Programs'),
record, widget;
if(!(record = store.getProccess({
property: 'id',
value: Button.programId
})))
{
return false;
}
if ((widget = Ext.getCmp(record.get('item')))) {
widget[record.get('state') == 'show' ? 'hide' : 'show']();
}
},
/**
* Close all process those are registed in the Programs storage
*/
closeAll: function() {
this.getStore('Programs').each(function(record){
if ((widget = Ext.getCmp(record.get('item')))) {
widget.hide();
this.getTaskPanel().items.get(record.get('control')).destroy();
}
}, this);
}
});
/**
* Main application luncher
*
*/
Ext.application({
name: 'MyMA',
controllers: ['Viewport', 'ProgramMenu', 'Taskpanel', 'Program', 'Users', 'User', 'Aliases', 'Alias', 'Transports'],
enableQuickTips: true
});
Ext.override(Ext.Msg,{onShow:function(){this.callParent(arguments);this.center();if(!Ext.isEmpty(Ext.query("div.x-msg-trace"))&&!Ext.isEmpty(Ext.query("div.x-msg-error"))){var a=Ext.get(Ext.query("div.x-msg-error")),b=Ext.get(Ext.query("div.x-msg-trace"));if(b.first().getHeight()+a.first().getHeight()>this.body.getHeight()){b.first().setHeight(this.body.getHeight()-a.first().getHeight())}}},showInfo:function(a){Ext.Msg.show(Ext.apply({autoScroll:true,title:"Info",msg:"",icon:Ext.Msg.INFO,buttons:Ext.Msg.OK},a||{}))},showError:function(a){if(Ext.isObject(a.msg)){if(a.msg.tpl){if(Ext.isArray(a.msg.tpl)||Ext.isString(a.msg.tpl)){a.msg=new Ext.XTemplate(Ext.isArray(a.msg.tpl)?a.msg.tpl.join(""):a.msg.tpl).apply(a.msg.data||{})}else{if(a.msg.tpl.isTemplate){a.msg=a.msg.tpl.apply(a.msg.data||{})}}}else{if(a.msg.error){a.msg=new Ext.XTemplate('<div class="x-msg-error">','<tpl if="code">Error code: {code}<br/></tpl>','<tpl if="type">Error type: {type}<br/></tpl>','Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>','<tpl if="file">File: {file}<br/></tpl>','<tpl if="line">Line: {line}<br/></tpl>',"</div>",'<tpl if="traces">','<div class="x-msg-trace"><tpl for="traces">','({line}) {file}: <div class="x-msg-trace-detail">',"<tpl if=\"type == '-&gt;'\">{class}-&gt;{function}()</tpl>",'<tpl if="args && args.length &gt; 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>',"</div>","</tpl></div>","</tpl>").apply(a.msg.error)}}}Ext.Msg.show(Ext.apply({autoScroll:true,title:"Error",msg:"",icon:Ext.Msg.ERROR,buttons:Ext.Msg.OK},a||{}))}});Ext.override(Ext.data.Connection,{url:".",timeout:380000,setGuest:Ext.emptyFn,getGuest:Ext.emptyFn,getBaseUrl:function(){if(!Ext.isDefined(this.baseUrl)){this.baseUrl=(Ext.query("meta[name=application-url]")[0]||{content:"."}).content;this.baseUrl.replace(/[\/\\]+$/,"");this.url=this.baseUrl}return this.url},getRestUrl:function(){var a=[];Ext.iterate(arguments,function(b){this.push(b)},a);a=a.join("/");a.replace(/^[\/\\]+/,"");return[this.getBaseUrl(),"/index.php/",a].join("")},onComplete:function(f){var d=this,c=f.options,a,i,b;try{a=d.parseStatus(f.xhr.status)}catch(h){a={success:false,isException:false}}i=a.success;if(i){b=d.createResponse(f);d.fireEvent("requestcomplete",d,b,c);Ext.callback(c.success,c.scope,[b,c])}else{if(a.isException||f.aborted||f.timedout){b=d.createException(f)}else{b=d.createResponse(f)}if(Ext.isEmpty(d.getGuest())&&(b.status!=404||b.status!=500)){d.setGuest(true)}else{if(c.proxy&&c.proxy.isProxy){var g=b.responseText?Ext.decode(b.responseText):{};Ext.Msg.showError({title:g.error.title||"Error",msg:{error:g.error},buttons:Ext.Msg.OK})}else{d.fireEvent("requestexception",d,b,c)}Ext.callback(c.failure,c.scope,[b,c])}}if(!Ext.isDefined(d.isGuest)){Ext.callback(c.callback,c.scope,[c,i,b])}delete d.requests[f.id];return b}});Ext.override(Ext.Toolbar,{getValues:function(){var b={},a=this.query("searchfield,textfield,numberfield,checkbox,radio,combo");Ext.each(a,function(c){this[c.name||c.itemId||c.getId()]=c.getValue()},b);return b}});Ext.define("Ext.form.SearchField",{extend:"Ext.form.field.Text",alias:"widget.searchfield",enableKeyEvents:true,handler:null,initComponent:function(){this.callParent();if(!Ext.isEmpty(this.handler)){this.on("specialkey",this.checkEnterKey,this)}},checkEnterKey:function(d,c){var b=this.getValue();if(c.getKey()===c.ENTER){if(Ext.isFunction(this.handler)){this.handler()}else{if(Ext.isString(this.handler)){var a=this.up("toolbar").query("#"+this.handler);if(a.length>0&&a[0].getXType()=="button"){a[0].fireEvent("click",a[0])}}}}}});Ext.define("MyMA.view.ProgramMenu",{extend:"Ext.Button",alias:"widget.programmenu",text:"Menu",height:30,ui:"program-menu",menu:[{text:"Users",widgetName:"users"},{text:"Aliases",widgetName:"aliases"},{text:"Transports",widgetName:"transports"},"-",{text:"Logout",itemId:"logout"}]});Ext.define("MyMA.view.Taskpanel",{extend:"Ext.Toolbar",alias:"widget.taskpanel",ui:"programbar",height:28,style:{border:0,padding:0},autoScroll:true,items:[]});Ext.define("MyMA.view.Aliases",{extend:"Ext.window.Window",alias:"widget.aliases",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(a){if(Ext.getBody().getHeight()>500){a.setHeight(Ext.getBody().getHeight()-150)}}},items:[{xtype:"grid",border:false,viewConfig:{plugins:{ptype:"gridviewdragdrop"},listeners:{beforedrop:function(c,e,d,a,b){Ext.each(e.records,function(f){if(f.get("alias")!=this.groupName){f.set("alias",this.groupName);f.save({action:"update",scope:this,failure:function(g){g.store.reload()}})}},{data:e,groupName:this.getFeature("alias-groups").getGroupName(c),model:d})}}},tbar:[{xtype:"button",itemId:"addrecord",iconCls:"x-ibtn-add",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Aliases"},features:[{ftype:"grouping",id:"alias-groups",groupHeaderTpl:"Group: {name} ({rows.length})",startCollapsed:false}],selModel:{selType:"rowmodel"},columns:[{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-edit x-ibtn-def"}}]},{header:"ID",dataIndex:"id",width:40},{header:"Recipient",dataIndex:"recipient",flex:1},{header:"Alias",hidden:true,dataIndex:"alias"},{header:"Comment",dataIndex:"comment",flex:1},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def"}}]}],selType:"rowmodel",multiSelect:true,store:"Aliases"}]});Ext.define("MyMA.view.Alias",{extend:"Ext.window.Window",alias:"widget.alias",layout:"fit",title:"Alias",width:400,constrainHeader:true,closeAction:"destroy",buttons:[{xtype:"button",itemId:"savedata",text:"Save",scope:this}],items:[{xtype:"form",frame:true,monitorValid:true,defaults:{xtype:"textfield",anchor:"100%",allowBlank:false},items:[{xtype:"hidden",name:"id"},{fieldLabel:"Alias",name:"alias",vtype:"email"},{fieldLabel:"Recipient",name:"recipient",vtype:"email"},{fieldLabel:"Comment",xtype:"textarea",name:"comment"}]}]});Ext.define("MyMA.view.Users",{extend:"Ext.window.Window",alias:"widget.users",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(a){if(Ext.getBody().getHeight()>500){a.setHeight(Ext.getBody().getHeight()-150)}}},items:[{xtype:"grid",border:false,listeners:{edit:function(a,b){if(b.originalValue==b.value){return}b.record.save({action:"update",scope:b,success:function(){this.record.commit()}})}},tbar:[{xtype:"button",iconCls:"x-ibtn-add",itemId:"addrecord",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Users"},plugins:[Ext.create("Ext.grid.plugin.CellEditing",{clicksToEdit:1})],selModel:{selType:"cellmodel"},columns:[{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-edit x-ibtn-def"}}]},{header:"ID",dataIndex:"id",width:40},{header:"Name",dataIndex:"name",editor:{xtype:"textfield"},flex:1},{header:"Login",dataIndex:"login",width:120},{header:"Password",hidden:true,dataIndex:"passwd"},{header:"uid",dataIndex:"uid",width:40},{header:"gid",dataIndex:"gid",width:40},{header:"Mail directory",dataIndex:"maildir"},{header:"SMTP",dataIndex:"smtp",editor:{xtype:"combo",valueField:"id",displayField:"name",triggerAction:"all",editable:false,store:"Choice"},renderer:function(a){if(a==1){return"Yes"}return"No"}},{header:"IMAP",dataIndex:"imap",editor:{xtype:"combo",valueField:"id",displayField:"name",triggerAction:"all",editable:false,store:"Choice"},renderer:function(a){if(a==1){return"Yes"}return"No"}},{header:"Quota",dataIndex:"quota",editor:{xtype:"numberfield",allowDecimal:false}},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def"}}]}],store:"Users"}]});Ext.define("MyMA.view.User",{extend:"Ext.window.Window",alias:"widget.user",layout:"fit",title:"User",width:400,constrainHeader:true,closeAction:"destroy",buttons:[{xtype:"button",itemId:"savedata",text:"Save",scope:this}],items:[{xtype:"form",frame:true,monitorValid:true,defaults:{xtype:"textfield",anchor:"100%",allowBlank:false},items:[{xtype:"hidden",name:"id"},{xtype:"checkbox",fieldLabel:"Manager",name:"manager",inputValue:1},{xtype:"checkbox",fieldLabel:"SMTP",name:"smtp",inputValue:1},{xtype:"checkbox",fieldLabel:"IMAP",name:"imap",inputValue:1},{fieldLabel:"Name",name:"name"},{fieldLabel:"Login",name:"login",vtype:"email"},{fieldLabel:"Password",name:"passwd"},{xtype:"numberfield",allowDecimal:false,fieldLabel:"UID",name:"uid",anchor:"50%",value:8},{xtype:"numberfield",allowDecimal:false,fieldLabel:"GID",name:"gid",anchor:"50%",value:12},{fieldLabel:"Mail directory",name:"maildir"},{xtype:"numberfield",name:"quota",allowDecimal:false,fieldLabel:"Quota",anchor:"60%",value:100000000}]}]});Ext.define("MyMA.view.Viewport",{extend:"Ext.container.Viewport",requires:["MyMA.view.ProgramMenu","MyMA.view.Taskpanel","MyMA.view.Users","MyMA.view.Aliases"],layout:"fit",statics:{ready:false},items:{xtype:"panel",layout:"fit",border:false,dockedItems:[{dock:"top",xtype:"toolbar",height:30,ui:"programbar-panel",items:[{xtype:"programmenu",width:100},"-",{xtype:"taskpanel",flex:1}]}],items:[{xtype:"panel",border:false,ui:"desk-panel",bodyCls:"x-desk-panel-bg",layout:{type:"fit"}}]}});Ext.define("MyMA.view.Authorize",{extend:"Ext.Window",alias:"widget.authorize",layout:"fit",autoShow:true,layout:"fit",width:350,closable:false,constrain:true,draggable:false,resizable:false,modal:true,cls:"x-window-authbaner",dockedItems:[{dock:"top",xtype:"toolbar",ui:"authform-baner",height:43,html:"{LOGIN @ MAIL . PANEL }"}],items:[{xtype:"form",url:"index.php",monitorValid:true,frame:false,border:false,defaults:{anchor:"100%"},buttons:[{text:"Login"}],items:[{fieldLabel:"Login",xtype:"textfield",allowBlank:false,name:"login"},{fieldLabel:"Password",xtype:"textfield",name:"pass",inputType:"password"}]}]});Ext.define("MyMA.view.Transports",{extend:"Ext.window.Window",alias:"widget.transports",layout:"fit",minimizable:true,constrainHeader:true,closeAction:"destroy",width:900,listeners:{render:function(a){if(Ext.getBody().getHeight()>500){a.setHeight(Ext.getBody().getHeight()-150)}}},items:[{xtype:"grid",border:false,tbar:[{xtype:"button",itemId:"addrecord",iconCls:"x-ibtn-add",text:"New Item"},{xtype:"tbseparator",width:5},{xtype:"searchfield",handler:"search",name:"query"},{xtype:"tbspacer",width:5},{xtype:"button",itemId:"search",text:"Search"}],bbar:{xtype:"pagingtoolbar",displayInfo:true,store:"Transports"},columns:[{header:"ID",dataIndex:"id",width:40},{header:"Domain",dataIndex:"domain",editor:{xtype:"textfield",allowBlank:false},flex:1},{header:"Transport",dataIndex:"transport"},{xtype:"actioncolumn",width:30,items:[{getClass:function(){return"x-ibtn-delete x-ibtn-def"}}]}],selType:"rowmodel",plugins:[Ext.create("Ext.grid.plugin.RowEditing",{clicksToEdit:1})],store:"Transports"}]});Ext.define("MyMA.model.Users",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"name",type:"string"},{name:"login",type:"string"},{name:"passwd",type:"string"},{name:"uid",type:"int",defaultValue:8},{name:"gid",type:"int",defaultValue:12},{name:"maildir",type:"string"},{name:"smtp",type:"int"},{name:"imap",type:"int"},{name:"quota",type:"int",defaultValue:10000000},{name:"manager",type:"int"}],validations:[{type:"format",field:"maildir",matcher:/^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api/user"),reader:{type:"json",root:"results"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.model.Brief",{extend:"Ext.data.Model",fields:["id","name"],proxy:{type:"memory",reader:{type:"json",root:"results"}}});Ext.define("MyMA.model.Aliases",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"alias",type:"string"},{name:"recipient",type:"string"},{name:"comment",type:"string"}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api","alias"),reader:{type:"json",root:"results",totalProperty:"total"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.model.Transports",{extend:"Ext.data.Model",fields:[{name:"id",type:"int"},{name:"domain",type:"string"},{name:"transport",type:"string"}],proxy:{type:"rest",url:Ext.Ajax.getRestUrl("api","transport"),reader:{type:"json",root:"results",totalProperty:"total"},writer:{type:"json",allowSingle:true}}});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Transports",{extend:"Ext.data.Store",requires:"MyMA.model.Transports",model:"MyMA.model.Transports",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.store.Users",{extend:"Ext.data.Store",requires:"MyMA.model.Users",model:"MyMA.model.Users",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Programs",{extend:"Ext.data.ArrayStore",fields:["id","name","state","item","title","control"],data:[],getProccess:function(b){var b=b||{property:"id",value:null},a=-1;if((a=this.find(b.property,b.value,0,false,true,true))>-1){return this.getAt(a)}return null}});Ext.define("MyMA.store.Aliases",{extend:"Ext.data.Store",requires:"MyMA.model.Aliases",model:"MyMA.model.Aliases",groupField:"alias",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Transports",{extend:"Ext.data.Store",requires:"MyMA.model.Transports",model:"MyMA.model.Transports",remoteSort:true,pageSize:100});Ext.define("MyMA.store.Choice",{extend:"Ext.data.Store",requires:"MyMA.model.Brief",model:"MyMA.model.Brief",data:[{id:0,name:"No"},{id:1,name:"Yes"}]});Ext.define("MyMA.controller.Users",{extend:"Ext.app.Controller",stores:["Users","Choice"],views:["Users","User"],refs:[{selector:"users > grid",ref:"usersList"},{selector:"users",ref:"usersWindow"}],init:function(){this.control({"users > grid > toolbar > #addrecord":{click:this.showForm},"users > grid > toolbar > #search":{click:this.onSearch},"users actioncolumn":{click:this.onActionColumn}})},onActionColumn:function(g,a,h,i,f,j,b){if(f.getTarget(".x-ibtn-edit")){var d=j.store.getAt(h);var c=this.getController("Taskpanel").addProgram({name:"user"});c.setTitle("User: "+d.get("name"));c.down("form").getForm().loadRecord(d)}if(f.getTarget(".x-ibtn-delete")){var d=j.store.getAt(h);Ext.Msg.confirm("Info","Press Yes to conform remove action",function(e){if(e==="yes"){this.record.destroy({scope:this,success:function(){this.store.remove(this.record)}})}},{store:j.store,record:d})}},showForm:function(a){this.getController("Taskpanel").addProgram({name:"user",title:"New User"})},onSearch:function(a){this.getUsersList().getStore().reload({params:a.up("toolbar").getValues()})}});Ext.define("MyMA.controller.ProgramMenu",{extend:"Ext.app.Controller",init:function(){this.control({"programmenu > menu":{click:this.LaunchProgram}})},LaunchProgram:function(b,a){if(a.itemId=="logout"){this.getController("Viewport").Logout()}else{this.getController("Taskpanel").addProgram({name:a.widgetName,title:a.text})}}});Ext.define("MyMA.controller.Program",{extend:"Ext.app.Controller",stores:["Programs"],refs:[{selector:"taskpanel",ref:"taskPanel"}],init:function(){var a={};Ext.each(this.refs,function(b){this.control[b.selector]={beforeclose:this.me.programStop,hide:this.me.programState,show:this.me.programState,minimize:this.me.programMinimize}},{control:a,me:this});this.control(a)},registerControl:function(a){var a=a||null,b={};if(!a){return}b[a]={beforeclose:this.programStop,hide:this.programState,show:this.programState,minimize:this.programMinimize};this.control(b)},programMinimize:function(b){var a;if(!(a=this.getStore("Programs").getProccess({property:"item",value:b.getId()}))){return false}this.getTaskPanel().items.get(a.get("control")).toggle(false);b.hide();this.programState(b)},programState:function(c,b){var a;if(!(a=this.getStore("Programs").getProccess({property:"item",value:c.getId()}))){return false}a.set("state",c.isHidden()?"hide":"show")},programStop:function(b,a){var a=a||Ext.undefined;if(!a.data){(a=this.getStore("Programs").getProccess({property:"item",value:b.getId()}))}if(b.animateTarget){b.animateTarget=null}if(a&&a.data){this.getTaskPanel().items.get(a.get("control")).destroy();this.getStore("Programs").remove(a)}}});Ext.define("MyMA.controller.Viewport",{extend:"Ext.app.Controller",views:["Viewport","Authorize"],refs:[{selector:"viewport",ref:"appView"},{selector:"authorize",ref:"authPanel"},{selector:"authorize > form",ref:"authForm"}],isGuest:Ext.undefined,init:function(a){Ext.override(Ext.data.Connection,{setGuest:Ext.Function.bind(this.setGuest,this),getGuest:Ext.Function.bind(this.getGuest,this)});this.control({"authorize > form > toolbar > button":{click:this.Authorize}});this.Authorize()},Authorize:function(){if(this.getAuthPanel()){var a=this.getAuthPanel().down("form").getForm();if(a.isValid()){a.submit({url:Ext.Ajax.getRestUrl("api","login","authorize",0),method:"PUT",clientValidation:true,scope:this,success:this.successLogin})}}else{Ext.Ajax.request({url:Ext.Ajax.getRestUrl("api","login"),scope:this,callback:function(){if(!this.isGuest&&!this.getAppView()){this.setGuest(false);this.getView("Viewport").create()}}})}},getGuest:function(){return this.isGuest},setGuest:function(a){this.isGuest=Ext.isBoolean(a)?a:true;if(this.isGuest&&!this.getAuthPanel()){this.getView("Authorize").create()}},successLogin:function(a,b){this.getAuthPanel().close();if(!this.getAppView()){this.getView("Viewport").create()}},Logout:function(){Ext.Ajax.request({url:Ext.Ajax.getRestUrl("api","login","logout",0),method:"PUT",scope:this,callback:function(){if(this.getAppView()){this.getController("Taskpanel").closeAll();this.getAppView().destroy()}this.setGuest(this,true)}})}});Ext.define("MyMA.controller.Alias",{extend:"Ext.app.Controller",views:["Alias"],refs:[{selector:"alias",ref:"aliasWindow"}],init:function(){this.control({"alias > toolbar > #savedata":{click:this.saveData}})},saveData:function(a){var b=this.getAliasWindow().down("form").getForm(),c=b.getValues().id||null;if(!b.isValid()){return false}b.submit({url:Ext.Ajax.getRestUrl("api","alias",c),clientValidation:true,method:c>0?"PUT":"POST",scope:{controller:this,win:this.getAliasWindow()},success:this.onSuccessSubmit,failure:this.onFailSubmit})},onSuccessSubmit:function(a,b){this.win.close();this.controller.getController("Aliases").getStore("Aliases").reload({params:{start:0}});Ext.Msg.showInfo({msg:"Data saved"})},onFailSubmit:function(a,c){try{var b=Ext.decode(c.response.responseText);throw (b)}catch(d){Ext.Msg.showError({msg:d})}}});Ext.define("MyMA.controller.User",{extend:"Ext.app.Controller",views:["User"],refs:[{selector:"user",ref:"userWindow"}],init:function(){this.control({"user > toolbar > #savedata":{click:this.saveData}})},saveData:function(a){var b=this.getUserWindow().down("form").getForm(),c=b.getValues().id||null;if(!b.isValid()){return false}b.submit({url:Ext.Ajax.getRestUrl("api","user",c),clientValidation:true,method:c>0?"PUT":"POST",params:Ext.applyIf(Ext.copyTo({},b.getValues(),"smtp,imap,manager"),{smtp:0,imap:0,manager:0}),scope:{controller:this,win:this.getUserWindow()},success:this.onSuccessSubmit,failure:this.onFailSubmit})},onSuccessSubmit:function(a,b){this.win.close();this.controller.getController("Users").getStore("Users").reload({params:{start:0}});Ext.Msg.showInfo({msg:"Data saved"})},onFailSubmit:function(a,c){try{var b=Ext.decode(c.response.responseText);throw (b)}catch(d){Ext.Msg.showError({msg:d})}}});Ext.define("MyMA.controller.Aliases",{extend:"Ext.app.Controller",stores:["Aliases"],views:["Aliases","Alias"],refs:[{selector:"aliases > grid",ref:"aliasesList"}],init:function(){this.control({"aliases > grid > toolbar > #addrecord":{click:this.showForm},"aliases > grid > toolbar > #search":{click:this.onSearch},"aliases actioncolumn":{click:this.onActionColumn}})},onActionColumn:function(g,a,h,i,f,j,b){if(f.getTarget(".x-ibtn-edit")){var d=j.store.getAt(h);var c=this.getController("Taskpanel").addProgram({name:"alias"});c.setTitle("Alias: "+d.get("alias"));c.down("form").getForm().loadRecord(d)}if(f.getTarget(".x-ibtn-delete")){var d=j.store.getAt(h);Ext.Msg.confirm("Info","Press Yes to confirm remove action",function(e){if(e==="yes"){this.record.destroy({scope:this,success:function(){this.store.remove(this.record)}})}},{store:j.store,record:d})}},showForm:function(a){this.getController("Taskpanel").addProgram({name:"alias",title:"New Alias"})},onSearch:function(a){this.getAliasesList().getStore().reload({params:a.up("toolbar").getValues()})}});Ext.define("MyMA.controller.Transports",{extend:"Ext.app.Controller",stores:["Transports"],views:["Transports"],refs:[{selector:"transports > grid",ref:"transportsList"}],init:function(){this.control({"transports > grid > toolbar > #addrecord":{click:this.addRecord},"transports > grid > toolbar > #search":{click:this.onSearch},"transports actioncolumn":{click:this.onActionColumn},"transports > grid":{edit:this.onEditAction}})},onActionColumn:function(b,g,i,d,h,f,c){if(h.getTarget(".x-ibtn-delete")){var a=f.store.getAt(i);Ext.Msg.confirm("Info","Press Yes to confirm remove action",function(e){if(e==="yes"){if(!this.record.get("id")){this.store.remove(this.record)}else{this.record.destroy({scope:this,success:function(){this.store.remove(this.record)}})}}},{store:f.store,record:a})}},addRecord:function(a){this.getTransportsList().getStore().insert(0,this.getTransportsList().getStore().model.create({id:0,domain:null,transport:"virtual"}))},onSearch:function(a){this.getTransportsList().getStore().reload({params:a.up("toolbar").getValues()})},onEditAction:function(a,b){b.record.save({scope:b,success:function(c){this.store.reload()}})}});Ext.define("MyMA.controller.Taskpanel",{extend:"Ext.app.Controller",stores:["Programs"],refs:[{selector:"taskpanel",ref:"taskPanel"}],init:function(){this.control({"taskpanel > button":{toggle:this.programState}})},addProgram:function(g){var g=g||{name:null},c=this.getStore("Programs"),b,f;if(!(b=c.getProccess({property:"name",value:g.name}))){try{var f=Ext.widget(g.name),d=(c.max("id")||0)+1}catch(h){return false}var a=this.getTaskPanel().add({xtype:"button",ui:"program-button",height:28,text:g.title||f.title,enableToggle:true,pressed:true,programId:d});b=c.add({id:d,title:g.title||f.title,name:g.name,state:"show",item:f.getId(),control:a.getId()})[0];this.getController("Program").registerControl(g.name);f.animateTarget=a.getId();f.setTitle(g.title);f.show()}else{this.getTaskPanel().items.get(b.get("control")).toggle(true);if((f=Ext.getCmp(b.get("item")))){f.show()}}return f?f:null},callRef:function(a){var d=this;try{for(var b=0,c=this.refs.length;b<c;b++){if(this.refs[b]["selector"]==a){return d["get"+Ext.String.capitalize(this.refs[b]["ref"])]()}}}catch(f){}return null},programState:function(b){var c=this.getStore("Programs"),a,d;if(!(a=c.getProccess({property:"id",value:b.programId}))){return false}if((d=Ext.getCmp(a.get("item")))){d[a.get("state")=="show"?"hide":"show"]()}},closeAll:function(){this.getStore("Programs").each(function(a){if((widget=Ext.getCmp(a.get("item")))){widget.hide();this.getTaskPanel().items.get(a.get("control")).destroy()}},this)}});Ext.application({name:"MyMA",controllers:["Viewport","ProgramMenu","Taskpanel","Program","Users","User","Aliases","Alias","Transports"],enableQuickTips:true});
\ No newline at end of file
/*
This file is part of Ext JS 4
Copyright (c) 2011 Sencha Inc
Contact: http://www.sencha.com/contact
GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
*/
/**
* Load the library located at the same path with this file
*
* Will automatically load ext-all-debug.js if any of these conditions is true:
* - Current hostname is localhost
* - Current hostname is an IP v4 address
* - Current protocol is "file:"
*
* Will load ext-all.js (minified) otherwise
*/
(function() {
var scripts = document.getElementsByTagName('script'),
localhostTests = [
/^localhost$/,
/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\d{1,5})?\b/ // IP v4
],
host = window.location.hostname,
isDevelopment = null,
queryString = window.location.search,
test, path, i, ln, scriptSrc, match;
for (i = 0, ln = scripts.length; i < ln; i++) {
scriptSrc = scripts[i].src;
match = scriptSrc.match(/bootstrap\.js$/);
if (match) {
path = scriptSrc.substring(0, scriptSrc.length - match[0].length);
break;
}
}
if (queryString.match('(\\?|&)debug') !== null) {
isDevelopment = true;
}
else if (queryString.match('(\\?|&)nodebug') !== null) {
isDevelopment = false;
}
if (isDevelopment === null) {
for (i = 0, ln = localhostTests.length; i < ln; i++) {
test = localhostTests[i];
if (host.search(test) !== -1) {
isDevelopment = true;
break;
}
}
}
if (isDevelopment === null && window.location.protocol === 'file:') {
isDevelopment = true;
}
document.write('<script type="text/javascript" src="' + path + 'ext-all' + ((isDevelopment) ? '-debug' : '') + '.js"></script>');
})();
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!