XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
BannerclientAdminEditForm.class.php
1<?php
6
7if (!defined('XOOPS_ROOT_PATH')) {
8 exit();
9}
10
11require_once XOOPS_ROOT_PATH . '/core/XCube_ActionForm.class.php';
12require_once XOOPS_MODULE_PATH . '/legacy/class/Legacy_Validator.class.php';
13
15{
16 public function getTokenName()
17 {
18 return 'module.legacyRender.BannerclientAdminEditForm.TOKEN' . $this->get('cid');
19 }
20
21 public function prepare()
22 {
23 //
24 // Set form properties
25 //
26 $this->mFormProperties['cid'] =new XCube_IntProperty('cid');
27 $this->mFormProperties['name'] =new XCube_StringProperty('name');
28 $this->mFormProperties['contact'] =new XCube_StringProperty('contact');
29 $this->mFormProperties['email'] =new XCube_StringProperty('email');
30 $this->mFormProperties['login'] =new XCube_StringProperty('login');
31 $this->mFormProperties['passwd'] =new XCube_StringProperty('passwd');
32 $this->mFormProperties['extrainfo'] =new XCube_TextProperty('extrainfo');
33
34 //
35 // Set field properties
36 //
37 $this->mFieldProperties['cid'] =new XCube_FieldProperty($this);
38 $this->mFieldProperties['cid']->setDependsByArray(['required']);
39 $this->mFieldProperties['cid']->addMessage('required', _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_CID);
40
41 $this->mFieldProperties['name'] =new XCube_FieldProperty($this);
42 $this->mFieldProperties['name']->setDependsByArray(['required', 'maxlength']);
43 $this->mFieldProperties['name']->addMessage('required', _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_NAME, '60');
44 $this->mFieldProperties['name']->addMessage('maxlength', _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_NAME, '60');
45 $this->mFieldProperties['name']->addVar('maxlength', '60');
46
47 $this->mFieldProperties['contact'] =new XCube_FieldProperty($this);
48 $this->mFieldProperties['contact']->setDependsByArray(['maxlength']);
49 $this->mFieldProperties['contact']->addMessage('maxlength', _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_CONTACT, '60');
50 $this->mFieldProperties['contact']->addVar('maxlength', '60');
51
52 $this->mFieldProperties['email'] =new XCube_FieldProperty($this);
53 $this->mFieldProperties['email']->setDependsByArray(['maxlength', 'email']);
54 $this->mFieldProperties['email']->addMessage('email', _AD_LEGACYRENDER_ERROR_EMAIL, _AD_LEGACYRENDER_LANG_EMAIL, '60');
55 $this->mFieldProperties['email']->addMessage('maxlength', _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_EMAIL, '60');
56 $this->mFieldProperties['email']->addVar('maxlength', '60');
57
58 $this->mFieldProperties['login'] =new XCube_FieldProperty($this);
59 $this->mFieldProperties['login']->setDependsByArray(['maxlength']);
60 $this->mFieldProperties['login']->addMessage('maxlength', _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_LOGIN, '10');
61 $this->mFieldProperties['login']->addVar('maxlength', '10');
62
63 $this->mFieldProperties['passwd'] =new XCube_FieldProperty($this);
64 $this->mFieldProperties['passwd']->setDependsByArray(['maxlength']);
65 $this->mFieldProperties['passwd']->addMessage('maxlength', _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_PASSWD, '10');
66 $this->mFieldProperties['passwd']->addVar('maxlength', '10');
67 }
68
69 public function validateLogin()
70 {
71 if (strlen($this->get('login')) > 0) {
72 $handler =& xoops_getmodulehandler('bannerclient', 'legacyRender');
73 $criteria =new CriteriaCompo();
74 $criteria->add(new Criteria('login', $this->get('login')));
75 $criteria->add(new Criteria('cid', $this->get('cid'), '<>'));
76
77 if ($handler->getCount($criteria) > 0) {
78 $this->addErrorMessage(_AD_LEGACYRENDER_ERROR_LOGIN_REPETITION);
79 }
80 }
81 }
82
83 public function validatePasswd()
84 {
85 if (strlen($this->get('login')) > 0 && 0 == strlen($this->get('passwd'))) {
86 $this->addErrorMessage(XCube_Utils::formatString(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_PASSWD));
87 }
88 }
89
90 public function load(&$obj)
91 {
92 $this->set('cid', $obj->get('cid'));
93 $this->set('name', $obj->get('name'));
94 $this->set('contact', $obj->get('contact'));
95 $this->set('email', $obj->get('email'));
96 $this->set('login', $obj->get('login'));
97 $this->set('passwd', $obj->get('passwd'));
98 $this->set('extrainfo', $obj->get('extrainfo'));
99 }
100
101 public function update(&$obj)
102 {
103 $obj->set('cid', $this->get('cid'));
104 $obj->set('name', $this->get('name'));
105 $obj->set('contact', $this->get('contact'));
106 $obj->set('email', $this->get('email'));
107 $obj->set('login', $this->get('login'));
108 $obj->set('passwd', $this->get('passwd'));
109 $obj->set('extrainfo', $this->get('extrainfo'));
110 }
111}
update(&$obj)
[Abstract] Updates an object with properties values.
getTokenName()
Gets the token name of this actionform's token.
prepare()
[Abstract] Set up form properties and field properties.
load(&$obj)
[Abstract] Initializes properties' values from an object.
addErrorMessage( $message)
Adds a message to the form's error message buffer.
[Abstract] Used for validating member property values of XCube_ActionForm.
Represents int property.
Represents string property.
Represents string property which allows CR and LF.
static formatString()
[Static] Formats string with special care for international.