actions['chopt'] = 'doChangeOption';
}
function _doListBind(&$DB_List)
{
$DB_List->ipp = 20;
$DB_List->def_order_by = 'id DESC';
$DB_List->urlVarNames = array('ipp', 'query');
$DB_List->insertColLast('Name', array(
'title'=>'Full Name',
'tpl'=>DB_LIST_CELL_TEXT,
'width'=>250,
'params'=>array('name'),
'order_by'=>'name'
));
$DB_List->insertColLast('login', array(
'title'=>'User Name',
'tpl'=>DB_LIST_CELL_TEXT,
'width'=>150,
'params'=>array('login'),
'order_by'=>'login'
));
$DB_List->insertColLast('options', array('title' => 'Options',
'width' => '150',
'tpl' => DB_LIST_CELL_EDIT_DEL,
'edit_link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?&action=edit&id=',
'del_link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=del&id=',
'params' => array('id', 'login'),
)
);
return true;
}
function _bindFormFields($form)
{
$form->addElement('text', 'firstname', 'First Name', array('style' => 'width:300px;'));
$form->addElement('text', 'lastname', 'Last Name', array('style' => 'width:300px;'));
$form->addElement('text', 'u_login', 'Site User Name', array('value'=>$this->DBObj->getData('login'),'style' => 'width:300px;'));
$form->addRuleRequired(array('firstname', 'lastname', 'u_login'));
$password = array();
$password[] =& Form::createElement('password', 'u_password', null, array('size' => 30, 'autocomplete' => 'off', 'style' => 'width:300px;'));
$password[] =& Form::createElement('static', 'password_static', '', '');
$form->addGroup($password, 'password', 'Site Password', null, false);
$re_password = array();
$re_password[] =& Form::createElement('password', 'u_re_password', null, array('size' => 30, 'autocomplete' => 'off', 'style' => 'width:300px;'));
$re_password[] =& Form::createElement('static', 're_password_static', '', '');
$form->addGroup($re_password, 're_password', 'Confirm Password', null, false);
$form->addElement('text', 'email', 'E-Mail', array('value'=>$this->DBObj->getData('email')));
$form->addRuleRequired(array('email'));
$form->addRule('email', 'Email is incorect', 'email', null, 'client');
$form->addRule('email', 'Email is incorect', 'email');
$form->addFormRule(array(&$this, 'validForm'));
$form->setConstants(array('u_password' => '', 'u_re_password' => '' ));
return $form;
}
function validForm($fields){
$error_bool = false;
$error = array();
if (!$this->DBObj->isLoginUnique($fields['u_login'])){
$error_bool = true;
$error = array_merge($error, array('u_login' => 'The Site User Name must be unique'));
}
if (!$this->DBObj->isEmailUnique($fields['email'])){
$error_bool = true;
$error = array_merge($error, array('email' => 'The Email must be unique'));
}
if ($fields['u_password'] != $fields['u_re_password']) {
$error_bool = true;
$error = array_merge($error, array('password' => 'Password and Confirm password entries do not match'));
}
if ($error_bool == false) {
return true;
} else {
return $error;
}
}
function _getNewForm()
{
$form = parent::_getNewForm();
$form->addGroupRule('password', array(
'u_password' => array(
array('Password is required', 'required'),
array('Password is required', 'required', null, 'client'),
),
));
$form->addGroupRule('re_password', array(
'u_re_password' => array(
array('Confirm password is required', 'required'),
array('Confirm password is required', 'required', null, 'client'),
),
));
$data = array();
$form->setDefaults($data);
return $form;
}
function _getEditForm()
{
$this->DBObj->initFromDB();
$form = parent::_getEditForm();
$this->DBObj->_data['password_static'] = '
Leave blank to use current';
$this->DBObj->_data['re_password_static'] = '
Leave blank to use current';
$form->setDefaults($this->DBObj->_data);
return $form;
}
function addLink()
{
$addLink = array(
'tpl' => 'center_link_one.tpl',
'link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=new',
'title' => 'Add new '.$this->DBObj->itemName, );
$this->Doc->addContent($addLink);
}
function getFilterForm()
{
$form = $this->_getBaseForm('get');
$form->tpl = BASE_PATH.'/tpl/User/filter.tpl';
$form->setRendType(FORM_RENDERER_ARRAY_SMARTY);
$form->addElement('text', 'query','', array('style'=>'width: 145px;'));
$form->addElement('submit', 'submit', 'Search', array( 'class' => 'btn') );
$form->addElement('button', 'cancel', 'Cancel', array( 'class' => 'btn' , 'onclick' => "document.location.href='".Constant::get('BASE_URL').'/'.CURR_PAGE."'" ));
return $form;
}
function doList()
{
$this->_saveBackUrl();
parent::doList();
}
function doNew()
{
$form = $this->_getNewForm();
$form->exec();
}
function doEdit()
{
$this->DBObj->initFromDB();
$form = $this->_getEditForm();
$form->exec();
}
function doChangeOption(){
$this->DBObj->changeOption(@$_REQUEST['opt']);
$this->doBack();
}
}
?>