Verified Commit 3288a277 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(public-forms) Added object creation to public forms

issue #5838
parent b37fc6d8
No related merge requests found
Showing with 28 additions and 13 deletions
+28 -13
...@@ -23,9 +23,11 @@ ...@@ -23,9 +23,11 @@
{$template_dialog} {$template_dialog}
</div> </div>
</div> </div>
{if !$done}
<div id="window-footer" class="plugbottom"> <div id="window-footer" class="plugbottom">
<input type="submit" name="form_submit" value="{msgPool type=okButton}"/> <input type="submit" id="form_submit" name="form_submit" value="{msgPool type=okButton}"/>
</div> </div>
{/if}
</form> </form>
</div> </div>
</div> </div>
......
...@@ -22,6 +22,7 @@ class publicFormPage extends standAlonePage ...@@ -22,6 +22,7 @@ class publicFormPage extends standAlonePage
{ {
protected $form; protected $form;
protected $template; protected $template;
protected $done;
function readLdapConfig() function readLdapConfig()
{ {
...@@ -36,6 +37,10 @@ class publicFormPage extends standAlonePage ...@@ -36,6 +37,10 @@ class publicFormPage extends standAlonePage
return; return;
} }
if ($this->done) {
return;
}
if (!isset($this->form) && isset($_GET['form'])) { if (!isset($this->form) && isset($_GET['form'])) {
/* Search for the form object */ /* Search for the form object */
$forms = objects::ls('publicForm', array('dn' => 'raw', 'cn' => 1, 'fdPublicFormTitle' => 1, 'fdPublicFormText' => 1, 'fdPublicFormTemplateType' => 1, 'fdPublicFormTemplateDN' => 1), NULL, '(cn='.ldap_escape_f($_GET['form']).')'); $forms = objects::ls('publicForm', array('dn' => 'raw', 'cn' => 1, 'fdPublicFormTitle' => 1, 'fdPublicFormText' => 1, 'fdPublicFormTemplateType' => 1, 'fdPublicFormTemplateDN' => 1), NULL, '(cn='.ldap_escape_f($_GET['form']).')');
...@@ -52,13 +57,15 @@ class publicFormPage extends standAlonePage ...@@ -52,13 +57,15 @@ class publicFormPage extends standAlonePage
$this->template->save_object(); $this->template->save_object();
//~ $success = TRUE; if (isset($_POST['form_submit'])) {
//~ /* Do we need to show error messages? */ $tabobject = $this->template->apply();
//~ if (count($this->message) != 0) { $errors = $tabobject->save();
//~ /* Show error message and continue editing */ if (empty($errors)) {
//~ msg_dialog::displayChecks($this->message); $this->done = TRUE;
//~ $success = FALSE; } else {
//~ } msg_dialog::displayChecks($errors);
}
}
} }
...@@ -74,14 +81,20 @@ class publicFormPage extends standAlonePage ...@@ -74,14 +81,20 @@ class publicFormPage extends standAlonePage
$this->assignSmartyVars(); $this->assignSmartyVars();
$templateOutput = $this->template->execute(); if ($this->done) {
if ($this->template->dialogOpened()) { $smarty->assign('template_dialog', _('Object created successfully'));
//~ TODO
return $templateOutput;
} else { } else {
$smarty->assign('template_dialog', $templateOutput); $templateOutput = $this->template->execute();
if ($this->template->dialogOpened()) {
//~ TODO
return $templateOutput;
} else {
$smarty->assign('template_dialog', $templateOutput);
}
} }
$smarty->assign('done', $this->done);
$smarty->assign('form', $this->form); $smarty->assign('form', $this->form);
$smarty->append('css_files', get_template_path('login.css')); $smarty->append('css_files', get_template_path('login.css'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment