* admin: refactor the register page.
This commit is contained in:
+47
-47
@@ -115,39 +115,42 @@ class admin extends control
|
||||
{
|
||||
$response = $this->admin->registerByAPI();
|
||||
$response = json_decode($response);
|
||||
if($response->result == 'success')
|
||||
if($response->result == 'fail')
|
||||
{
|
||||
$user = $response->data;
|
||||
$data['community'] = $user->account;
|
||||
$data['ztPrivateKey'] = $user->private;
|
||||
$message = '';
|
||||
if(is_string($response->message))
|
||||
{
|
||||
$message = $response->message;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($response->message as $item) $message .= is_array($item) ? join('\n', $item) . '\n' : $item . '\n';
|
||||
}
|
||||
$message = str_replace(array('<strong>', '</strong>'), '', $message);
|
||||
|
||||
$this->loadModel('setting');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=community');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=ztPrivateKey');
|
||||
$this->setting->setItems('system.common.global', $data);
|
||||
|
||||
echo js::alert($this->lang->admin->registerNotice->success);
|
||||
if($from == 'admin') return print(js::locate(inlink('index'), 'parent'));
|
||||
if($from == 'mail') return print(js::locate($this->createLink('mail', 'ztcloud'), 'parent'));
|
||||
return $this->send(array('result' => 'fail', 'message' => $message));
|
||||
}
|
||||
|
||||
$alertMessage = '';
|
||||
if(is_string($response->message))
|
||||
{
|
||||
$alertMessage = $response->message;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($response->message as $item) $alertMessage .= is_array($item) ? join('\n', $item) . '\n' : $item . '\n';
|
||||
}
|
||||
$alertMessage = str_replace(array('<strong>', '</strong>'), '', $alertMessage);
|
||||
return print(js::alert($alertMessage));
|
||||
$user = $response->data;
|
||||
$data['community'] = $user->account;
|
||||
$data['ztPrivateKey'] = $user->private;
|
||||
|
||||
$this->loadModel('setting');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=community');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=ztPrivateKey');
|
||||
$this->setting->setItems('system.common.global', $data);
|
||||
|
||||
$locate = true;
|
||||
if($from == 'admin') $locate = inlink('index');
|
||||
if($from == 'mail') $locate = $this->createLink('mail', 'ztcloud');
|
||||
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->admin->registerNotice->success, 'load' => $locate));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->admin->registerNotice->caption;
|
||||
$this->view->register = $this->admin->getRegisterInfo();
|
||||
$this->view->sn = $this->config->global->sn;
|
||||
$this->view->from = $from;
|
||||
$this->view->title = $this->lang->admin->registerNotice->caption;
|
||||
$this->view->register = $this->admin->getRegisterInfo();
|
||||
$this->view->sn = $this->config->global->sn;
|
||||
$this->view->from = $from;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -164,30 +167,27 @@ class admin extends control
|
||||
{
|
||||
$response = $this->admin->bindByAPI();
|
||||
$response = json_decode($response);
|
||||
if($response->result == 'success')
|
||||
{
|
||||
$user = $response->data;
|
||||
$data['community'] = $user->account;
|
||||
$data['ztPrivateKey'] = $user->private;
|
||||
|
||||
$this->loadModel('setting');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=community');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=ztPrivateKey');
|
||||
$this->setting->setItems('system.common.global', $data);
|
||||
if($response->result == 'fail') return $this->send($response);
|
||||
|
||||
echo js::alert($this->lang->admin->bind->success);
|
||||
if($from == 'admin') return print(js::locate(inlink('index'), 'parent'));
|
||||
if($from == 'mail') return print(js::locate($this->createLink('mail', 'ztcloud'), 'parent'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if($response->result == 'fail') return print(js::alert($response->message));
|
||||
}
|
||||
$user = $response->data;
|
||||
$data['community'] = $user->account;
|
||||
$data['ztPrivateKey'] = $user->private;
|
||||
|
||||
$this->loadModel('setting')->deleteItems('owner=system&module=common§ion=global&key=community');
|
||||
$this->setting->deleteItems('owner=system&module=common§ion=global&key=ztPrivateKey');
|
||||
$this->setting->setItems('system.common.global', $data);
|
||||
|
||||
$locate = true;
|
||||
if($from == 'admin') $locate = inlink('index');
|
||||
if($from == 'mail') $locate = $this->createLink('mail', 'ztcloud');
|
||||
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->admin->bind->success, 'load' => $locate));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->admin->bind->caption;
|
||||
$this->view->sn = $this->config->global->sn;
|
||||
$this->view->from = $from;
|
||||
$this->view->title = $this->lang->admin->bind->caption;
|
||||
$this->view->sn = $this->config->global->sn;
|
||||
$this->view->from = $from;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
function sendCaptcha(event, type)
|
||||
{
|
||||
const $target = $(event.target);
|
||||
const url = $target.data('url');
|
||||
const data = [];
|
||||
|
||||
data[type] = $target.closest('.input-group').find('input').val();
|
||||
|
||||
$.post(url, data, function(response)
|
||||
{
|
||||
if(response.result == 'success')
|
||||
{
|
||||
zui.Messager.show({content: response.message, type: 'success', time: 1500});
|
||||
}
|
||||
else
|
||||
{
|
||||
zui.Modal.alert(response.message);
|
||||
}
|
||||
}, 'json')
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The register view file of admin module of ZenTaoPMS.
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Gang Liu <liugang@easycorp.ltd>
|
||||
* @package admin
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
$canBind = hasPriv('admin', 'bind');
|
||||
|
||||
$account = zget($config->global, 'community', '');
|
||||
if($account == 'na') $account = '';
|
||||
|
||||
$buildCaptchRow = function($type) : wg
|
||||
{
|
||||
global $lang;
|
||||
return formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
setClass('w-1/2'),
|
||||
set::label($lang->user->$type),
|
||||
set::required(true),
|
||||
inputGroup
|
||||
(
|
||||
input
|
||||
(
|
||||
set::name($type)
|
||||
),
|
||||
span
|
||||
(
|
||||
setClass('input-group-btn'),
|
||||
button
|
||||
(
|
||||
on::click("sendCaptcha(event, '{$type}')"),
|
||||
setClass('btn'),
|
||||
set(array('data-url' => inlink('ajaxSendCode', "type={$type}"))),
|
||||
$lang->admin->getCaptcha
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
setClass('w-1/2'),
|
||||
set::label($lang->admin->captcha),
|
||||
set::name("{$type}Code"),
|
||||
set::required(true)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
$buildHidden = function($sn, $siteName): array
|
||||
{
|
||||
$items[] = input
|
||||
(
|
||||
set::type('hidden'),
|
||||
set::name('sn'),
|
||||
set::value($sn)
|
||||
);
|
||||
$items[] = input
|
||||
(
|
||||
set::type('hidden'),
|
||||
set::name($siteName),
|
||||
set::value(common::getSysURL())
|
||||
);
|
||||
return $items;
|
||||
};
|
||||
|
||||
div
|
||||
(
|
||||
setClass('flex'),
|
||||
col
|
||||
(
|
||||
setClass($canBind ? 'pr-2 w-1/2' : 'w-full'),
|
||||
formPanel
|
||||
(
|
||||
setClass('w-full'),
|
||||
set::actions(array('submit')),
|
||||
set::title($lang->admin->registerNotice->common),
|
||||
set::submitBtnText($lang->admin->registerNotice->submit),
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->user->account),
|
||||
set::name('account'),
|
||||
set::placeholder($lang->admin->registerNotice->lblAccount),
|
||||
set::required(true)
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->user->realname),
|
||||
set::name('realname'),
|
||||
set::required(true)
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->user->company),
|
||||
set::name('company'),
|
||||
set::value($register->company),
|
||||
set::required(true)
|
||||
),
|
||||
empty($config->isINT) ? $buildCaptchRow('mobile') : null,
|
||||
$buildCaptchRow('email'),
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->user->password),
|
||||
set::control('password'),
|
||||
set::name('password1'),
|
||||
set::placeholder($lang->admin->registerNotice->lblPasswd),
|
||||
set::required(true)
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->user->password2),
|
||||
set::control('password'),
|
||||
set::name('password2'),
|
||||
set::required(true)
|
||||
),
|
||||
$buildHidden($sn, 'bindSite')
|
||||
)
|
||||
),
|
||||
$canBind ? col
|
||||
(
|
||||
setClass('pl-2 w-1/2'),
|
||||
formPanel
|
||||
(
|
||||
setClass('w-full'),
|
||||
set::actions(array('submit')),
|
||||
set::title($lang->admin->registerNotice->bind),
|
||||
set::url(inlink('bind', "from={$from}")),
|
||||
formGroup
|
||||
(
|
||||
setClass('w-1/2'),
|
||||
set::label($lang->user->account),
|
||||
set::name('account'),
|
||||
set::value($account)
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
setClass('w-1/2'),
|
||||
set::label($lang->user->password),
|
||||
set::control('password'),
|
||||
set::name('password')
|
||||
),
|
||||
$buildHidden($sn, 'site')
|
||||
)
|
||||
) : null
|
||||
);
|
||||
|
||||
render();
|
||||
Reference in New Issue
Block a user