Commit 842943e2 authored by Ad Schellevis's avatar Ad Schellevis

(captiveportal, new) add (login) templates to model

parent 98a0662d
......@@ -64,4 +64,22 @@ class CaptivePortal extends BaseModel
}
return false;
}
/**
* find ttemplate by name or return a new object
* @param $name template name
* @return mixed
*/
public function getTemplateByName($name)
{
foreach ($this->templates->template->__items as $template) {
if ((string)$template->name === $name) {
return $template;
}
}
$newItem = $this->templates->template->Add();
$newItem->name = $name;
$newItem->fileid = uniqid();
return $newItem;
}
}
......@@ -74,5 +74,24 @@
</description>
</zone>
</zones>
<templates>
<template type="ArrayField">
<fileid type="TextField">
<Required>Y</Required>
<mask>/[0-9a-zA-Z\-]{1,255}/u</mask>
<ValidationMessage>Fileid should be an internally generated unique number</ValidationMessage>
</fileid>
<name type="TextField">
<Required>Y</Required>
<mask>/^([\t\n\v\f\r 0-9a-zA-Z.,_\x{00A0}-\x{FFFF}]){1,255}$/u</mask>
<ValidationMessage>Template name should be a string between 1 and 255 characters</ValidationMessage>
</name>
<content type="TextField">
<Required>Y</Required>
<mask>/[0-9a-zA-Z\+\=\/]{20,}/u</mask>
<ValidationMessage>File content should be in (base64 encoded) zip format</ValidationMessage>
</content>
</template>
</templates>
</items>
</model>
Markdown is supported
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