diff --git a/workflow/engine/controllers/newSiteProxy.php b/workflow/engine/controllers/newSiteProxy.php new file mode 100644 index 000000000..0f0b18d3f --- /dev/null +++ b/workflow/engine/controllers/newSiteProxy.php @@ -0,0 +1,65 @@ + + */ +class newSiteProxy extends HttpProxyController +{ + + function testingNW($params){ + if(isset($_POST['NW_TITLE'])){ + $action = (isset($_POST['action']))?trim($_POST['action']):'test'; + + G::LoadClass('Installer'); + G::LoadClass('json'); + $name = trim($_POST['NW_TITLE']); + $inst = new Installer(); + $isset = $inst->isset_site($name); + $new = ((!$isset))?true:false; + $user = (isset($_POST['NW_USERNAME']))?trim($_POST['NW_USERNAME']):'admin'; + $pass = (isset($_POST['NW_PASSWORD']))?$_POST['NW_PASSWORD']:'admin'; + $pass1 = (isset($_POST['NW_PASSWORD2']))?$_POST['NW_PASSWORD2']:'admin'; + + $ao_db_drop = (isset($_POST['AO_DB_DROP']))?true:false; + + $ao_db_wf = (isset($_POST['AO_DB_WF']))?$_POST['AO_DB_WF']:false; + $ao_db_rb = (isset($_POST['AO_DB_RB']))?$_POST['AO_DB_RB']:false; + $ao_db_rp = (isset($_POST['AO_DB_RP']))?$_POST['AO_DB_RP']:false; + + $result = $inst->create_site(Array( + 'isset'=>true, + 'name' =>$name, + 'admin'=>Array('username'=>$user,'password'=>$pass), + 'advanced'=>Array( + 'ao_db_drop'=>$ao_db_drop, + 'ao_db_wf'=>$ao_db_wf, + 'ao_db_rb'=>$ao_db_rb, + 'ao_db_rp'=>$ao_db_rp + ) + ),($action==='create')?true:false); + $result['result']['admin']['password']=($pass===$pass1)?true:false; + $result['result']['action']=$action; + $json = new Services_JSON(); + //G::pr($result['result']['database']);G::pr($action); + $dbWf=$result['result']['database']['ao']['ao_db_wf']['status']; + $dbRb=$result['result']['database']['ao']['ao_db_rb']['status']; + $dbRp=$result['result']['database']['ao']['ao_db_rp']['status']; + $wsAction =($action!='')?1:0; + if($dbWf && $dbRb && $dbRp && $action){ + $this->success = true; + //echo $json->encode($result); + }else{//the site does not available + $this->error = true; + } + }else{ + $this->error = true; + } + } + + function creatingNW($params){ + G::pr($_POST); + G::pr("krlossss"); + } + +} //End newSiteProxy diff --git a/workflow/engine/methods/install/newSite.php b/workflow/engine/methods/install/newSite.php index 399eb375f..228d43bef 100644 --- a/workflow/engine/methods/install/newSite.php +++ b/workflow/engine/methods/install/newSite.php @@ -23,7 +23,6 @@ * */ - if(isset($_POST['form']['NW_TITLE'])) { $action = (isset($_POST['form']['ACTION']))?trim($_POST['form']['ACTION']):'test'; @@ -84,13 +83,24 @@ else break; } $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/newSite', '', '', 'newSite'); + /*$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/newSite', '', '', 'newSite'); if( isset($_GET['type']) ) G::RenderPage( "publishBlank", "blank"); else - G::RenderPage( "publish" ); - + G::RenderPage( "publish" );*/ + G::LoadClass('configuration'); + $c = new Configurations(); + $configPage = $c->getConfiguration('usersList', 'pageSize','',$_SESSION['USER_LOGGED']); + $Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20; + + $oHeadPublisher =& headPublisher::getSingleton(); + $oHeadPublisher->addExtJsScript('setup/newSite', false); //adding a javascript file .js + $oHeadPublisher->addContent('setup/newSite'); //adding a html file .html. +// $oHeadPublisher->assign('CONFIG', $Config); +// $oHeadPublisher->assign('FORMATS',$c->getFormats()); + + G::RenderPage('publish', 'extJs'); } ?> diff --git a/workflow/engine/templates/setup/newSite.html b/workflow/engine/templates/setup/newSite.html new file mode 100644 index 000000000..f9f75b5ef --- /dev/null +++ b/workflow/engine/templates/setup/newSite.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/workflow/engine/templates/setup/newSite.js b/workflow/engine/templates/setup/newSite.js new file mode 100644 index 000000000..6d572a8e8 --- /dev/null +++ b/workflow/engine/templates/setup/newSite.js @@ -0,0 +1,222 @@ +/* + * @author krlos P.C + * Jan 15th, 2011 + */ + +Ext.onReady(function(){ + + var fieldNameWS=new Ext.form.TextField({ + id: 'NW_TITLE', + fieldLabel: _('ID_NAME'), + xtype:'textfield', + value:'sample', + width: 200, + autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '13'}, + allowBlank: false, + listeners: { + 'render': function(c) { + c.getEl().on('keyup', function() { + namews=formNewSite.getForm().findField('NW_TITLE').getValue(); + formNewSite.getForm().findField('AO_DB_WF').setValue('ws_'+namews); + formNewSite.getForm().findField('AO_DB_RB').setValue('rb_'+namews); + formNewSite.getForm().findField('AO_DB_RP').setValue('rp_'+namews); + }, c); + } + } + }); + nameWS = new Ext.form.FieldSet({ + title: 'New Workspace', + items: [ + fieldNameWS + ] + }); + dbOptionsWS = new Ext.form.FieldSet({ + title: 'Database Options', + items: [ + { + id: 'AO_DB_WF', + fieldLabel: 'Workflow Database', + xtype:'textfield', + value:'ws_sample', + width: 200, + autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '13'}, + allowBlank: false + }, + { + id: 'AO_DB_RB', + fieldLabel: 'Rbac Database', + xtype:'textfield', + value:'rb_sample', + width: 200, + autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '13'}, + allowBlank: false + }, + { + id: 'AO_DB_RP', + fieldLabel: 'Report Database', + xtype:'textfield', + value:'rp_sample', + width: 200, + autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '13'}, + allowBlank: false + }, + { + xtype: 'checkbox', + fieldLabel: 'Drop database if exists', + name: 'AO_DB_DROP', + id: 'id-active' + } + ] + }); + + wspaceAdmWS = new Ext.form.FieldSet({ + title: 'Workspace Administrator', + items: [ + { + id: 'NW_USERNAME', + fieldLabel: 'Username', + xtype:'textfield', + value:'admin', + width: 200, + allowBlank: false + }, + { + id: 'NW_PASSWORD', + fieldLabel: 'Password (admin)(Max. length 20):', + xtype:'textfield', + inputType:'password', + value:'admin', + width: 200, + allowBlank: false + }, + { + id: 'NW_PASSWORD2', + fieldLabel: 'Re-type Password', + xtype:'textfield', + inputType:'password', + value:'admin', + width: 200, + allowBlank: false + } + ] + }); + + + formNewSite = new Ext.FormPanel({ + id:'formNewSite', + labelWidth: 250, + labelAlign:'right', + autoScroll: true, + fileUpload: true, + width:800, + bodyStyle:'padding:10px', + waitMsgTarget : true, + frame: true, + defaults: { + anchor: '100%', + allowBlank: false, + resizable: true, + msgTarget: 'side', + align:'center' + }, + items:[ + nameWS, + dbOptionsWS, + wspaceAdmWS + ], + buttons: [ + { + text: 'reset', + handler: resetfields + + }, + { + text: 'Test', + handler: TestSite + } + ] + + }); + + formNewSite.render(document.body); + + }); + function resetfields(){ + formNewSite.getForm().reset(); + } + function TestSite(){ + formNewSite.getForm().submit({ + url: '../newSiteProxy/testingNW', + params: { + action : 'test' + }, + waitMsg : 'new site testing...', + timeout : 3600, + success: function(f,a){ + nwTitle =formNewSite.getForm().findField('NW_TITLE').getValue(); + aoDbWf =formNewSite.getForm().findField('AO_DB_WF').getValue(); + aoDbRb =formNewSite.getForm().findField('AO_DB_RB').getValue(); + aoDbRp =formNewSite.getForm().findField('AO_DB_RP').getValue(); + nwUsername =formNewSite.getForm().findField('NW_USERNAME').getValue(); + nwPassword =formNewSite.getForm().findField('NW_PASSWORD').getValue(); + nwPassword2=formNewSite.getForm().findField('NW_PASSWORD2').getValue(); + aoDbDrop=formNewSite.getForm().findField('AO_DB_DROP').getValue(); + //Ext.getCmp('NW_TITLE').disable()=true; + //Ext.getCmp('NW_TITLE').readOnly = true; + createNW(nwTitle, aoDbWf, aoDbRb, aoDbRp, nwUsername, nwPassword, nwPassword2); + }, + failure: function(f,a){ + if (a.failureType === Ext.form.Action.CONNECT_FAILURE){ + Ext.Msg.alert('Failure', 'Server reported:'+a.response.status+' '+a.response.statusText); + } + if (a.failureType === Ext.form.Action.SERVER_INVALID){ + Ext.Msg.alert('Warning', _('NEW_SITE_NOT_AVAILABLE')); + } + } + }); + } + + function createNW(nwTitle, aoDbWf, aoDbRb, aoDbRp, nwUsername, nwPassword, nwPassword2){ + PMExt.confirm(_('ID_CONFIRM'), _('NEW_SITE_CONFIRM_TO_CREATE'), function(){ + var loadMask = new Ext.LoadMask(document.body, {msg:'site creating..'}); + loadMask.show(); + Ext.Ajax.request({ + url: '../newSiteProxy/testingNW', + params: { + action : 'create', + NW_TITLE : nwTitle, + AO_DB_WF : aoDbWf, + AO_DB_RB : aoDbRb, + AO_DB_RP : aoDbRp, + NW_USERNAME : nwUsername, + NW_PASSWORD : nwPassword, + NW_PASSWORD2 : nwPassword2, + AO_DB_DROP : aoDbDrop + }, + method: 'POST', + success: function ( result, request ) { + loadMask.hide(); + var data = Ext.util.JSON.decode(result.responseText); + if( data.success ) { + PMExt.confirm(_('ID_CONFIRM'), _('NEW_SITE_SUCCESS') +" "+nwTitle+"
"+ _('NEW_SITE_SUCCESS_CONFIRM')+"
"+ _('NEW_SITE_SUCCESS_CONFIRMNOTE'), function(){ + nwTitle =formNewSite.getForm().findField('NW_TITLE').getValue(); + parent.parent.window.location="/sys"+nwTitle+"/en/green/login/login"; + }); + } else { + PMExt.error(_('ID_ERROR'), data.msg); + } + }, + failure: function ( result, request) { + Ext.MessageBox.alert('Failed', result.responseText); + } + }); + }); + } + + + + + + + +