diff --git a/htdocs/add_oclass_form.php b/htdocs/add_oclass_form.php index 9330ce1..ce1fa22 100644 --- a/htdocs/add_oclass_form.php +++ b/htdocs/add_oclass_form.php @@ -107,6 +107,9 @@ if (count($ldap['attrs']['need']) > 0) { $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=objectclass', $app['server']->getIndex(),rawurlencode($request['dn'])); + if (get_request('meth','REQUEST') == 'ajax') + $href .= '&meth=ajax'; + header(sprintf('Location: %s',$href)); die(); } diff --git a/htdocs/add_value_form.php b/htdocs/add_value_form.php index 2100f6a..f4c070e 100644 --- a/htdocs/add_value_form.php +++ b/htdocs/add_value_form.php @@ -32,7 +32,7 @@ if ($request['attribute']->isReadOnly()) */ # Render the form -if (get_request('meth','REQUEST') != 'ajax') { +if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST') != 'ajax') { # Render the form. $request['page']->drawTitle(sprintf('%s %s %s %s',_('Add new'),$request['attr'],_('value to'),get_rdn($request['dn']))); $request['page']->drawSubTitle(); @@ -113,7 +113,9 @@ if (get_request('meth','REQUEST') != 'ajax') { echo ''; echo '
'; - printf('',_('Add new ObjectClass')); + printf('', + _('Add new ObjectClass'), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'entry_form\'),\'%s\');"',_('Updating Object')) : '')); echo ''; echo ''; echo ''; diff --git a/htdocs/create_confirm.php b/htdocs/create_confirm.php index cfff1f9..7f23f75 100644 --- a/htdocs/create_confirm.php +++ b/htdocs/create_confirm.php @@ -60,7 +60,7 @@ if (count($request['template']->getLDAPadd(true))) { echo ''; echo "\n\n"; - echo '
'; + echo ''; echo '
'; echo ''; printf('',$app['server']->getIndex()); @@ -111,19 +111,32 @@ if (count($request['template']->getLDAPadd(true))) { echo '
'; echo '
'; - printf('',_('Commit')); - printf('',_('Cancel')); + + printf('', + _('Commit'), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'create_form\'),\'%s\');"',_('Updating Object')) : '')); + + printf('', + _('Cancel'), + (isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&server_id=%s&container=%s\',\'%s\');"',$app['server']->getIndex(),$request['template']->getContainer(),_('Retrieving DN')) : '')); + echo '
'; echo ''; echo '
'; } else { - echo '
'; - echo _('You made no changes'); - $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', + $href = sprintf('cmd=template_engine&server_id=%s&dn=%s', $app['server']->getIndex(),rawurlencode($request['dn'])); - printf(' %s.',htmlspecialchars($href),_('Go back')); + echo '
'; + echo _('You made no changes'); + + if (isAjaxEnabled()) + printf(' %s.', + htmlspecialchars($href),htmlspecialchars($href),_('Retrieving DN'),_('Go back')); + else + printf(' %s.',htmlspecialchars($href),_('Go back')); + echo '
'; } ?> diff --git a/htdocs/delete_form.php b/htdocs/delete_form.php index ecffa9b..5056d88 100644 --- a/htdocs/delete_form.php +++ b/htdocs/delete_form.php @@ -67,11 +67,14 @@ if (count($request['children'])) { echo ''; echo ''; - echo '
'; + echo ''; echo ''; printf('',$app['server']->getIndex()); printf('',htmlspecialchars($request['dn'])); - printf('',sprintf(_('Delete all %s objects'),count($request['search']))); + //@todo need to refresh the tree after a delete + printf('', + sprintf(_('Delete all %s objects'),count($request['search'])), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'delete_form\'),\'%s\');"',_('Deleting Object(s)')) : '')); echo '
'; echo ''; @@ -80,7 +83,9 @@ if (count($request['children'])) { echo ''; printf('',$app['server']->getIndex()); printf('',htmlspecialchars($request['dn'])); - printf('',_('Cancel')); + printf('', + _('Cancel'), + (isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&server_id=%s&dn=%s\',\'%s\');"',$app['server']->getIndex(),htmlspecialchars($request['dn']),_('Retrieving DN')) : '')); echo ''; echo ''; echo ''; @@ -114,11 +119,14 @@ if (count($request['children'])) { echo ''; echo ''; - echo '
'; + echo ''; echo ''; printf('',$app['server']->getIndex()); printf('',htmlspecialchars($request['dn'])); - printf('',_('Delete')); + //@todo need to refresh the tree after a delete + printf('', + _('Delete'), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'delete_form\'),\'%s\');"',_('Deleting Object(s)')) : '')); echo '
'; echo ''; @@ -128,7 +136,9 @@ if (count($request['children'])) { echo ''; printf('',$app['server']->getIndex()); printf('',htmlspecialchars($request['dn'])); - printf('',_('Cancel')); + printf('', + _('Cancel'), + (isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&server_id=%s&dn=%s\',\'%s\');"',$app['server']->getIndex(),htmlspecialchars($request['dn']),_('Retrieving DN')) : '')); echo ''; echo ''; diff --git a/htdocs/js/ajax_functions.js b/htdocs/js/ajax_functions.js index ab88a8b..680d157 100644 --- a/htdocs/js/ajax_functions.js +++ b/htdocs/js/ajax_functions.js @@ -10,9 +10,27 @@ var http_request = null; var http_request_success_callback = ''; var http_request_error_callback = ''; -function ajDISPLAY(div,urlParameters,display) { +function ajSUBMIT(div,obj,display) { var pageDiv = getDiv(div); + window.scrollTo(0,95); + + if (pageDiv) + includeHTML(pageDiv,'
'+display+'...'); + else + return true; + + makeHttpRequest('cmd.php',getParameters(obj.parentNode)+'meth=ajax','POST','alertAJ','cancelAJ',div); + + return false; +} + +function ajDISPLAY(div,urlParameters,display,ns) { + var pageDiv = getDiv(div); + + if (! ns) + window.scrollTo(0,95); + if (pageDiv) includeHTML(pageDiv,'
'+display+'...'); else @@ -190,3 +208,46 @@ function makeHttpRequest(url,parameters,meth,successCallbackFunctionName,errorCa if (meth == 'GET') parameters = null; http_request.send(parameters); } + +function getParameters(obj) { + var elements = ['input','select','textarea']; + var getstr = ''; + + for (var j in elements) { + for (i=0; igetLDAPmodify() as $attr => $junk) $redirect_url .= sprintf('&modified_attrs[]=%s',$attr); + if (get_request('meth','REQUEST') == 'ajax') + $redirect_url .= '&meth=ajax'; + header("Location: $redirect_url"); die(); } diff --git a/htdocs/update_confirm.php b/htdocs/update_confirm.php index 8358cc1..6c956a8 100644 --- a/htdocs/update_confirm.php +++ b/htdocs/update_confirm.php @@ -38,7 +38,7 @@ if (count($request['template']->getLDAPmodify(true))) { echo '
'; echo "\n\n"; - echo '
'; + echo ''; echo '
'; echo ''; printf('',$app['server']->getIndex()); @@ -187,14 +187,20 @@ if (count($request['template']->getLDAPmodify(true))) { echo '
'; echo '
'; - printf('',_('Commit')); - printf('',_('Cancel')); + printf('', + _('Commit'), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'update_form\'),\'%s\');"',_('Updating Object')) : '')); + + printf('', + _('Cancel'), + (isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&dn=%s\',\'%s\');"',htmlspecialchars($request['dn']),_('Retrieving DN')) : '')); + echo '
'; echo ''; echo '
'; if (count($request['template']->getForceDeleteAttrs()) > 0) { - echo ''; + echo '
'; printf('',_('The deletion of objectClass(es)')); printf('',implode(', ',$request['template']->getAttribute('objectclass')->getRemovedValues())); echo ''; @@ -212,12 +218,18 @@ if (count($request['template']->getLDAPmodify(true))) { } } else { - echo '
'; - echo _('You made no changes'); - $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', + $href = sprintf('cmd=template_engine&server_id=%s&dn=%s', $app['server']->getIndex(),rawurlencode($request['dn'])); - printf(' %s.',htmlspecialchars($href),_('Go back')); + echo '
'; + echo _('You made no changes'); + + if (isAjaxEnabled()) + printf(' %s.', + htmlspecialchars($href),htmlspecialchars($href),_('Retrieving DN'),_('Go back')); + else + printf(' %s.',htmlspecialchars($href),_('Go back')); + echo '
'; } diff --git a/lib/Template.php b/lib/Template.php index a2835a7..8b5ed4d 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -343,7 +343,7 @@ class Template extends xmlTemplate { continue; # If _REQUEST['skip_array'] with this attr set, we'll ignore this new_value - if (isset($_REQUEST['skip_array'][$attr])) + if (isset($_REQUEST['skip_array'][$attr]) && $_REQUEST['skip_array'][$attr] == 'on') continue; # Prune out entries with a blank value. diff --git a/lib/TemplateRender.php b/lib/TemplateRender.php index e300037..ce2d625 100644 --- a/lib/TemplateRender.php +++ b/lib/TemplateRender.php @@ -1408,7 +1408,10 @@ class TemplateRender extends PageRender { if (DEBUGTMP) printf('%s
',__METHOD__); if (! $this->template->isReadOnly()) - printf('
',_('Update Object')); + printf('', + _('Update Object'), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'entry_form\'),\'%s\');"',_('Updating DN')) : ''), + _('Update Object')); } /** STEP FORM METHODS **/ @@ -1504,7 +1507,9 @@ class TemplateRender extends PageRender { if ($page < $this->pagelast) printf('',_('Proceed >>')); else - printf('',_('Create Object')); + printf('', + _('Create Object'), + (isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'entry_form\'),\'%s\');"',_('Creating Object')) : '')); echo ''; } @@ -2012,7 +2017,7 @@ function fillRec(id,value) { $this->getServerID(),rawurlencode($this->template->getDN()),rawurlencode($attribute->getName(false)))); if (isAjaxEnabled()) - return sprintf('(%s)', + return sprintf('(%s)', $href_parm,_('Add an additional value to attribute'),$attribute->getName(false),$attribute->getName(), $href_parm,_('Add Value to Attribute'),_('add value')); else @@ -2020,6 +2025,24 @@ function fillRec(id,value) { $href_parm,_('Add an additional value to attribute'),$attribute->getName(false),_('add value')); } + protected function getAddValueMenuItemObjectClassAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('%s
',__METHOD__); + + $href_parm = htmlspecialchars(sprintf('cmd=add_value_form&server_id=%s&dn=%s&attr=%s', + $this->getServerID(),rawurlencode($this->template->getDN()),rawurlencode($attribute->getName(false)))); + + if (isAjaxEnabled()) + return sprintf('(%s)', + $href_parm,_('Add an additional value to attribute'),$attribute->getName(false), + $href_parm,_('Add Value to Attribute'),_('add value')); + else + return sprintf('(%s)', + $href_parm,_('Add an additional value to attribute'),$attribute->getName(false),_('add value')); + } + protected function getModifyMemberMenuItemAttribute($attribute) { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); diff --git a/lib/page.php b/lib/page.php index aedccc7..803eabe 100644 --- a/lib/page.php +++ b/lib/page.php @@ -107,8 +107,11 @@ class page { printf(''); if (isset($_SESSION[APPCONFIG])) - printf('%s (%s) - %s', - $this->_app['title'],app_version(),$_SESSION[APPCONFIG]->getValue('appearance','page_title')); + printf('%s (%s) - %s%s', + $this->_app['title'], + app_version(), + (get_request('dn','REQUEST') ? htmlspecialchars(get_request('dn','REQUEST')).' ' : ''), + $_SESSION[APPCONFIG]->getValue('appearance','page_title')); else printf('%s - %s',$this->_app['title'],app_version());
%s:%s