mirror of
https://github.com/Mibew/java.git
synced 2024-11-15 09:24:12 +03:00
Add an ability to start chat with specified operator
This commit is contained in:
parent
b89e838625
commit
e01a75faea
@ -92,6 +92,14 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get operator code
|
||||
$operator_code = empty($_GET['operator_code'])
|
||||
? ''
|
||||
: $_GET['operator_code'];
|
||||
if (! preg_match("/^[A-z0-9_]+$/", $operator_code)) {
|
||||
$operator_code = false;
|
||||
}
|
||||
|
||||
// Get visitor info
|
||||
$visitor = visitor_from_request();
|
||||
$info = getgetparam('info');
|
||||
@ -132,8 +140,17 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
|
||||
$visitor_is_invited = false;
|
||||
}
|
||||
|
||||
// Get operator info
|
||||
$requested_operator = false;
|
||||
if ($operator_code) {
|
||||
$requested_operator = operator_by_code($operator_code);
|
||||
}
|
||||
|
||||
// Check if survey should be displayed
|
||||
if(Settings::get('enablepresurvey') == '1' && !$visitor_is_invited) {
|
||||
if(Settings::get('enablepresurvey') == '1'
|
||||
&& !$visitor_is_invited
|
||||
&& !$requested_operator
|
||||
) {
|
||||
// Display prechat survey
|
||||
$page = array_merge_recursive(
|
||||
setup_logo($group),
|
||||
@ -145,7 +162,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
|
||||
}
|
||||
|
||||
// Start chat thread
|
||||
$thread = chat_start_for_user($groupid, $visitor['id'], $visitor['name'], $referrer, $info);
|
||||
$thread = chat_start_for_user($groupid, $requested_operator, $visitor['id'], $visitor['name'], $referrer, $info);
|
||||
}
|
||||
$threadid = $thread->id;
|
||||
$token = $thread->lastToken;
|
||||
|
@ -128,6 +128,8 @@ $dbtables = array(
|
||||
"iperm" => "int DEFAULT 0", /* Do not grant all privileges by default */
|
||||
"dtmrestore" => "int NOT NULL DEFAULT 0",
|
||||
"vcrestoretoken" => "varchar(64)",
|
||||
// Use to start chat with specified operator
|
||||
"code" => "varchar(64) DEFAULT ''"
|
||||
),
|
||||
|
||||
"${mysqlprefix}chatoperatorstatistics" => array(
|
||||
@ -249,7 +251,7 @@ $dbtables_can_update = array(
|
||||
"${mysqlprefix}requestbuffer" => array("requestid", "requestkey", "request"),
|
||||
"${mysqlprefix}chatmessage" => array("agentId"),
|
||||
"${mysqlprefix}indexedchatmessage" => array(),
|
||||
"${mysqlprefix}chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "idisabled", "vcemail", "dtmrestore", "vcrestoretoken"),
|
||||
"${mysqlprefix}chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "idisabled", "vcemail", "dtmrestore", "vcrestoretoken", "code"),
|
||||
"${mysqlprefix}chatoperatorstatistics" => array("sentinvitations", "acceptedinvitations", "rejectedinvitations", "ignoredinvitations"),
|
||||
"${mysqlprefix}chatban" => array(),
|
||||
"${mysqlprefix}chatgroup" => array("vcemail", "iweight", "parent", "vctitle", "vcchattitle", "vclogo", "vchosturl"),
|
||||
|
@ -184,6 +184,10 @@ if ($act == "silentcreateall") {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcrestoretoken varchar(64)", $link);
|
||||
}
|
||||
|
||||
if (in_array("${mysqlprefix}chatoperator.code", $absent_columns)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD code varchar(64) DEFAULT ''", $link);
|
||||
}
|
||||
|
||||
if (in_array("${mysqlprefix}chatoperatorstatistics.sentinvitations", $absent_columns)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperatorstatistics ADD sentinvitations int NOT NULL DEFAULT 0", $link);
|
||||
}
|
||||
|
@ -625,12 +625,13 @@ function get_remote_host()
|
||||
*
|
||||
* @global string $current_locale Current locale code
|
||||
* @param int $group_id Id of group related to thread
|
||||
* @param array $requested_operator Array of requested operator info
|
||||
* @param string $visitor_id Id of the visitor
|
||||
* @param string $visitor_name Name of the visitor
|
||||
* @param string $referrer Page user came from
|
||||
* @param string $info User info
|
||||
*/
|
||||
function chat_start_for_user($group_id, $visitor_id, $visitor_name, $referrer, $info) {
|
||||
function chat_start_for_user($group_id, $requested_operator, $visitor_id, $visitor_name, $referrer, $info) {
|
||||
global $current_locale;
|
||||
|
||||
// Get user info
|
||||
@ -651,6 +652,14 @@ function chat_start_for_user($group_id, $visitor_id, $visitor_name, $referrer, $
|
||||
}
|
||||
}
|
||||
|
||||
// Get info about requested operator
|
||||
$requested_operator_online = false;
|
||||
if ($requested_operator) {
|
||||
$requested_operator_online = is_operator_online(
|
||||
$requested_operator['operatorid']
|
||||
);
|
||||
}
|
||||
|
||||
// Get thread object
|
||||
if ($is_invited) {
|
||||
// Get thread from invitation
|
||||
@ -663,6 +672,9 @@ function chat_start_for_user($group_id, $visitor_id, $visitor_name, $referrer, $
|
||||
// Create thread
|
||||
$thread = Thread::create();
|
||||
$thread->state = Thread::STATE_LOADING;
|
||||
if ($requested_operator && $requested_operator_online) {
|
||||
$thread->nextAgent = $requested_operator['operatorid'];
|
||||
}
|
||||
}
|
||||
|
||||
// Update thread fields
|
||||
@ -695,8 +707,17 @@ function chat_start_for_user($group_id, $visitor_id, $visitor_name, $referrer, $
|
||||
getstring2('chat.came.from',array($referrer))
|
||||
);
|
||||
}
|
||||
|
||||
$thread->postMessage(Thread::KIND_INFO, getstring('chat.wait'));
|
||||
if ($requested_operator && !$requested_operator_online) {
|
||||
$thread->postMessage(
|
||||
Thread::KIND_INFO,
|
||||
getstring2(
|
||||
'chat.requested_operator.offline',
|
||||
array(get_operator_name($requested_operator))
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$thread->postMessage(Thread::KIND_INFO, getstring('chat.wait'));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: May be move sending this message somewhere else?
|
||||
|
@ -479,6 +479,7 @@ class ThreadProcessor extends ClientSideProcessor {
|
||||
// Initialize dialog
|
||||
$thread = chat_start_for_user(
|
||||
$group_id,
|
||||
false,
|
||||
$visitor['id'],
|
||||
$visitor['name'],
|
||||
$referrer,
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity)
|
||||
function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity, $operator_code)
|
||||
{
|
||||
global $visitorcookie;
|
||||
$app_location = get_app_location($showhost, $forcesecure);
|
||||
@ -29,8 +29,23 @@ function generate_button($title, $locale, $style, $invitationstyle, $group, $inn
|
||||
|
||||
$modsecfix = $modsecurity ? ".replace('http://','').replace('https://','')" : "";
|
||||
$jslink = append_query("'" . $link, "url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)");
|
||||
$popup_options = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1";
|
||||
|
||||
// Generate operator code field
|
||||
if ($operator_code) {
|
||||
$form_on_submit = "if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 " .
|
||||
"&& window.event.preventDefault) window.event.preventDefault();" .
|
||||
"this.newWindow = window.open({$jslink} + '&operator_code=' + document.getElementById('mibewOperatorCodeField').value, 'webim', '{$popup_options}');" .
|
||||
"this.newWindow.focus();this.newWindow.opener=window;return false;";
|
||||
$temp = '<form action="" onsubmit="' . $form_on_submit . '" id="mibewOperatorCodeForm">' .
|
||||
'<input type="text" id="mibewOperatorCodeField" />' .
|
||||
'</form>';
|
||||
return "<!-- mibew operator code field -->" . $temp . "<!-- / mibew operator code field -->";
|
||||
}
|
||||
|
||||
// Generate button
|
||||
$temp = get_popup($link, "$jslink",
|
||||
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1");
|
||||
$inner, $title, "webim", $popup_options);
|
||||
if (Settings::get('enabletracking')) {
|
||||
$widget_data = array();
|
||||
|
||||
@ -55,7 +70,7 @@ function generate_button($title, $locale, $style, $invitationstyle, $group, $inn
|
||||
$widget_data['visitorCookieName'] = $visitorcookie;
|
||||
|
||||
// Build additional button code
|
||||
$temp = preg_replace('/^(<a )/', '\1id="mibewAgentButton" ', $temp) .
|
||||
$temp = preg_replace('/^(<a )/', '\1id="mibewAgentButton" ', $temp) .
|
||||
'<div id="mibewinvitation"></div>' .
|
||||
'<script type="text/javascript" src="' .
|
||||
$app_location . '/js/compiled/widget.js' .
|
||||
|
@ -96,6 +96,21 @@ function operator_by_id($id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load operator info by specified operators code
|
||||
* @param string $code Operators code
|
||||
* @return array|boolean Operators info array or boolean false if there is no
|
||||
* operator with specified code.
|
||||
*/
|
||||
function operator_by_code($code) {
|
||||
$db = Database::getInstance();
|
||||
return $db->query(
|
||||
"select * from {chatoperator} where code = ?",
|
||||
array($code),
|
||||
array('return_rows' => Database::RETURN_ONE_ROW)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of operators taking into account $options
|
||||
* @param array $options Associative array of options. It can contains following keys:
|
||||
@ -134,7 +149,7 @@ function get_operators_list($options)
|
||||
$orderby = "vclogin";
|
||||
}
|
||||
|
||||
$query = "select distinct {chatoperator}.operatorid, vclogin, vclocalename, vccommonname, istatus, idisabled, (:now - dtmlastvisited) as time " .
|
||||
$query = "select distinct {chatoperator}.operatorid, vclogin, vclocalename, vccommonname, code, istatus, idisabled, (:now - dtmlastvisited) as time " .
|
||||
"from {chatoperator}" .
|
||||
(
|
||||
empty($options['isolated_operator_id']) ? "" :
|
||||
@ -165,11 +180,10 @@ function get_operators_list($options)
|
||||
return $operators;
|
||||
}
|
||||
|
||||
function operator_get_all()
|
||||
{
|
||||
function operator_get_all() {
|
||||
$db = Database::getInstance();
|
||||
return $operators = $db->query(
|
||||
"select operatorid, vclogin, vclocalename, vccommonname, istatus, idisabled, " .
|
||||
"select operatorid, vclogin, vclocalename, vccommonname, istatus, code, idisabled, " .
|
||||
"(:now - dtmlastvisited) as time " .
|
||||
"from {chatoperator} order by vclogin",
|
||||
array(':now' => time()),
|
||||
@ -181,7 +195,7 @@ function get_operators_from_adjacent_groups($operator)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$query = "select distinct {chatoperator}.operatorid, vclogin, vclocalename,vccommonname, " .
|
||||
"istatus, idisabled, " .
|
||||
"istatus, idisabled, code, " .
|
||||
"(:now - dtmlastvisited) as time " .
|
||||
"from {chatoperator}, {chatgroupoperator} " .
|
||||
"where {chatoperator}.operatorid = {chatgroupoperator}.operatorid " .
|
||||
@ -224,8 +238,22 @@ function operator_is_disabled($operator)
|
||||
return $operator['idisabled'] == '1';
|
||||
}
|
||||
|
||||
function update_operator($operatorid, $login, $email, $password, $localename, $commonname)
|
||||
{
|
||||
/**
|
||||
* Update existing operator's info.
|
||||
*
|
||||
* If $password argument is empty operators password will not be changed.
|
||||
*
|
||||
* @param int $operatorid ID of operator to update
|
||||
* @param string $login Operator's login
|
||||
* @param string $email Operator's
|
||||
* @param string $password Operator's password
|
||||
* @param string $localename Operator's local name
|
||||
* @param string $commonname Operator's international name
|
||||
* @param string $avatar Operator's avatar
|
||||
* @param string $code Operator's code which use to start chat with specified
|
||||
* operator
|
||||
*/
|
||||
function update_operator($operatorid, $login, $email, $password, $localename, $commonname, $code) {
|
||||
$db = Database::getInstance();
|
||||
$values = array(
|
||||
':login' => $login,
|
||||
@ -233,7 +261,8 @@ function update_operator($operatorid, $login, $email, $password, $localename, $c
|
||||
':commonname' => $commonname,
|
||||
':email' => $email,
|
||||
':jabbername' => '',
|
||||
':operatorid' => $operatorid
|
||||
':operatorid' => $operatorid,
|
||||
':code' => $code
|
||||
);
|
||||
if ($password) {
|
||||
$values[':password'] = md5($password);
|
||||
@ -242,7 +271,7 @@ function update_operator($operatorid, $login, $email, $password, $localename, $c
|
||||
"update {chatoperator} set vclogin = :login, " .
|
||||
($password ? " vcpassword=:password, " : "") .
|
||||
"vclocalename = :localname, vccommonname = :commonname, " .
|
||||
"vcemail = :email, vcjabbername= :jabbername " .
|
||||
"vcemail = :email, code = :code, vcjabbername= :jabbername " .
|
||||
"where operatorid = :operatorid",
|
||||
$values
|
||||
|
||||
@ -267,23 +296,29 @@ function update_operator_avatar($operatorid, $avatar)
|
||||
* @param string $localename Operator's local name
|
||||
* @param string $commonname Operator's international name
|
||||
* @param string $avatar Operator's avatar
|
||||
* @param string $code Operator's code which use to start chat with specified
|
||||
* operator
|
||||
* @return array Operator's array
|
||||
*/
|
||||
function create_operator($login, $email, $password, $localename, $commonname, $avatar)
|
||||
{
|
||||
function create_operator($login, $email, $password, $localename, $commonname, $avatar, $code) {
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
"insert into {chatoperator} " .
|
||||
"(vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername) " .
|
||||
"values (?, ?, ?, ?, ?, ?, ?)",
|
||||
"INSERT INTO {chatoperator} (" .
|
||||
"vclogin, vcpassword, vclocalename, vccommonname, vcavatar, " .
|
||||
"vcemail, code, vcjabbername " .
|
||||
") VALUES (" .
|
||||
":login, :pass, :localename, :commonname, :avatar, " .
|
||||
":email, :code, :jabber".
|
||||
")",
|
||||
array(
|
||||
$login,
|
||||
md5($password),
|
||||
$localename,
|
||||
$commonname,
|
||||
$avatar,
|
||||
$email,
|
||||
''
|
||||
':login' => $login,
|
||||
':pass' => md5($password),
|
||||
':localename' => $localename,
|
||||
':commonname' => $commonname,
|
||||
':avatar' => $avatar,
|
||||
':email' => $email,
|
||||
':code' => $code,
|
||||
':jabber' => ''
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -63,6 +63,7 @@ chat.redirected.closewindow=Click to close the window
|
||||
chat.redirected.content=The visitor has been placed in the priorty queue of the operator {0}.
|
||||
chat.redirected.group.content=The visitor has been placed in a priorty queue of the group {0}.
|
||||
chat.redirected.title=The visitor has been redirected to another operator
|
||||
chat.requested_operator.offline=Thank you for contacting us. We are sorry, but requested operator <strong>{0}</strong> is offline. Another operator will be with you shortly.
|
||||
chat.status.operator.changed=Operator <strong>{0}</strong> changed operator <strong>{1}</strong>
|
||||
chat.status.operator.dead=Your operator has connection issues. We have moved you to a priorty position in the queue. Sorry for keeping you waiting.
|
||||
chat.status.operator.joined=Operator {0} joined the chat
|
||||
@ -138,6 +139,8 @@ error.no_password.visit_profile=Visit your <a href="{0}">Profile Page</a>.
|
||||
features.saved=Features activated
|
||||
form.field.address.description=Ex: 12.23.45.123 or todo.com
|
||||
form.field.address=Visitor's Address
|
||||
form.field.agent_code.description=Use to start chat with determined operator
|
||||
form.field.agent_code=Code
|
||||
form.field.agent_commonname.description=This name will be seen by your visitors.
|
||||
form.field.agent_commonname=International name (Latin)
|
||||
form.field.agent_name.description=This name will be seen by your visitors.
|
||||
@ -278,17 +281,20 @@ page.chat.old_browser.close=Close...
|
||||
page.chat.old_browser.list=<ul>\n<li>Internet Explorer 5.5+</li>\n<li>Firefox 1.0+</li>\n<li>Opera 8.0+</li>\n<li>Mozilla 1.4+</li>\n<li>Netscape 7.1+</li>\n<li>Safari 1.2+</li>\n</ul>\n<p>Also, we support some old browsers:</p>\n<ul>\n<li>Internet Explorer 5.0</li>\n<li>Opera 7.0</li>\n</ul>
|
||||
page.chat.old_browser.problem=<p>Your web browser is not fully supported. \nPlease, use one of the following web browsers:</p>
|
||||
page.chat.old_browser.title=Please use a more recent browser
|
||||
page.gen_button.button=button
|
||||
page.gen_button.choose_group=Code for group
|
||||
page.gen_button.choose_image=Choose image
|
||||
page.gen_button.choose_invitationstyle=Invitation style
|
||||
page.gen_button.choose_locale=Code for language
|
||||
page.gen_button.choose_style=Chat window style
|
||||
page.gen_button.choose_type=Generating code type
|
||||
page.gen_button.code.description=<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> it will work!
|
||||
page.gen_button.code=HTML code
|
||||
page.gen_button.default_group=-all operators-
|
||||
page.gen_button.include_site_name=Include host name into the code
|
||||
page.gen_button.intro=You can generate HTML code to place at your site here.
|
||||
page.gen_button.modsecurity=Compatibility with mod_security (modsecurity.org), turn on only if you have problems with it
|
||||
page.gen_button.operator_code=operator code field
|
||||
page.gen_button.sample=Example
|
||||
page.gen_button.secure_links=Use secure links (https)
|
||||
page.gen_button.title=Button HTML code generation
|
||||
@ -343,6 +349,7 @@ page_agent.create_new=You can create a new operator here.
|
||||
page_agent.error.duplicate_login=Please choose another login because an operator with that login is already registered in the system.
|
||||
page_agent.error.forbidden_create=You are not allowed to create operators.
|
||||
page_agent.error.wrong_login=Login should contain only latin characters, numbers and underscore symbol.
|
||||
page_agent.error.wrong_agent_code=Code should contain only latin characters, numbers and underscore symbol.
|
||||
page_agent.intro=Edit general operator settings.
|
||||
page_agent.tab.avatar=Photo
|
||||
page_agent.tab.groups=Groups
|
||||
|
@ -63,6 +63,7 @@ chat.redirected.closewindow=
|
||||
chat.redirected.content=Посетитель помещен в привелегированную очередь оператора {0}.
|
||||
chat.redirected.group.content=Посетитель помещен в привелегированную очередь группы {0}.
|
||||
chat.redirected.title=Посетитель переведен другому оператору
|
||||
chat.requested_operator.offline=Нам очень жаль, но запрошенный оператор <strong>{0}</strong> сейчас недоступен. Пожалуйста, подождите немного, к Вам присоединится другой оператор...
|
||||
chat.status.operator.changed=Оператор <strong>{0}</strong> сменил оператора <strong>{1}</strong>
|
||||
chat.status.operator.dead=У оператора возникли проблемы со связью, мы временно перевели Вас в приоритетную очередь. Приносим извинения за Ваше ожидание.
|
||||
chat.status.operator.joined=Оператор {0} включился в разговор
|
||||
@ -138,6 +139,8 @@ errors.wrong_field=
|
||||
features.saved=Набор сервисов изменен
|
||||
form.field.address.description=Например: 12.23.45.123 или relay.info.ru
|
||||
form.field.address=Адрес посетителя
|
||||
form.field.agent_code.description=Используется для начала диалога с определенным оператором
|
||||
form.field.agent_code=Код
|
||||
form.field.agent_commonname.description=Под этим именем Вас увидят ваши посетители из других стран.
|
||||
form.field.agent_commonname=Интернациональное имя (латиницей)
|
||||
form.field.agent_name.description=Под этим именем Вас увидят ваши посетители, по нему же к <br/>Вам будет обращаться система.
|
||||
@ -278,17 +281,20 @@ page.chat.old_browser.close=
|
||||
page.chat.old_browser.list=<ul>\n<li>Internet Explorer 5.5+</li>\n<li>Firefox 1.0+</li>\n<li>Opera 8.0+</li>\n<li>Mozilla 1.4+</li>\n<li>Netscape 7.1+</li>\n<li>Safari 1.2+</li>\n</ul>\n<p>Также поддерживаются некоторые старые браузеры:</p>\n<ul>\n<li>Internet Explorer 5.0</li>\n<li>Opera 7.0</li>\n</ul>
|
||||
page.chat.old_browser.problem=<p>К сожалению, для работы этой страницы необходим более новый браузер. Для лучшего просмотра используйте:</p>
|
||||
page.chat.old_browser.title=Используйте более новый browser
|
||||
page.gen_button.button=кнопка
|
||||
page.gen_button.choose_group=Для группы
|
||||
page.gen_button.choose_image=Выбор картинки
|
||||
page.gen_button.choose_invitationstyle=Стиль приглашения
|
||||
page.gen_button.choose_locale=Для какой локали создавать кнопку
|
||||
page.gen_button.choose_style=Стиль чат-окна
|
||||
page.gen_button.choose_type=Тип генерируемого кода
|
||||
page.gen_button.code.description=<strong>Внимание!</strong> При внесении<br/> каких-либо изменений<br/> в этот код работоспособность<br/> кнопки не гарантируется!
|
||||
page.gen_button.code=HTML-код
|
||||
page.gen_button.default_group=-все операторы-
|
||||
page.gen_button.include_site_name=Включать имя сайта в код
|
||||
page.gen_button.intro=На этой странице Вы можете получить HTML-код кнопки "Веб Мессенджера" для размещения на своем сайте.
|
||||
page.gen_button.modsecurity=Совместимость с mod_security (modsecurity.org), включите если окно с чатом открывается с http ошибкой
|
||||
page.gen_button.operator_code=поле для ввода кода оператора
|
||||
page.gen_button.sample=Пример
|
||||
page.gen_button.secure_links=Использовать защищенное соединение (https)
|
||||
page.gen_button.title=Получение HTML-кода кнопки
|
||||
@ -343,6 +349,7 @@ page_agent.create_new=
|
||||
page_agent.error.duplicate_login=Выберите другой логин, т.к. оператор с введенным логином уже зарегистрирован в системе.
|
||||
page_agent.error.forbidden_create=Вы не можете создавать операторов.
|
||||
page_agent.error.wrong_login=Логин должен состоять из латинских символов, цифр и знака подчеркивания.
|
||||
page_agent.error.wrong_agent_code=Код должен состоять из латинских символов, цифр и знака подчеркивания.
|
||||
page_agent.intro=На этой странице вы можете просмотреть детали оператора и отредактировать их.
|
||||
page_agent.tab.avatar=Фотография
|
||||
page_agent.tab.groups=Группы
|
||||
|
@ -52,6 +52,9 @@ $showhost = verifyparam("hostname", "/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure", "/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity", "/^on$/", "") == "on";
|
||||
|
||||
$code_type = verifyparam("codetype", "/^(button|operator_code)$/", "button");
|
||||
$operator_code = ($code_type == "operator_code");
|
||||
|
||||
$lang = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
if (!$lang || !in_array($lang, $image_locales))
|
||||
$lang = in_array($current_locale, $image_locales) ? $current_locale : $image_locales[0];
|
||||
@ -66,13 +69,18 @@ if ($groupid) {
|
||||
$message = get_image($imagehref, $size[0], $size[1]);
|
||||
|
||||
$page = array();
|
||||
$page['buttonCode'] = generate_button("", $lang, $style, $invitationstyle, $groupid, $message, $showhost, $forcesecure, $modsecurity);
|
||||
$page['buttonCode'] = generate_button("", $lang, $style, $invitationstyle, $groupid, $message, $showhost, $forcesecure, $modsecurity, $operator_code);
|
||||
$page['availableImages'] = array_keys($imageLocales);
|
||||
$page['availableLocales'] = $image_locales;
|
||||
$page['availableChatStyles'] = $stylelist;
|
||||
$page['availableInvitationStyles'] = $invitationstylelist;
|
||||
$page['groups'] = get_groups_list();
|
||||
|
||||
$page['availableCodeTypes'] = array(
|
||||
'button' => getlocal('page.gen_button.button'),
|
||||
'operator_code' => getlocal('page.gen_button.operator_code')
|
||||
);
|
||||
|
||||
$page['formgroup'] = $groupid;
|
||||
$page['formstyle'] = $style;
|
||||
$page['forminvitationstyle'] = $invitationstyle;
|
||||
@ -81,8 +89,10 @@ $page['formlang'] = $lang;
|
||||
$page['formhostname'] = $showhost;
|
||||
$page['formsecure'] = $forcesecure;
|
||||
$page['formmodsecurity'] = $modsecurity;
|
||||
$page['formcodetype'] = $code_type;
|
||||
|
||||
$page['enabletracking'] = Settings::get('enabletracking');
|
||||
$page['operator_code'] = $operator_code;
|
||||
|
||||
prepare_menu($operator);
|
||||
start_html_output();
|
||||
|
@ -38,6 +38,7 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
|
||||
$passwordConfirm = getparam('passwordConfirm');
|
||||
$localname = getparam('name');
|
||||
$commonname = getparam('commonname');
|
||||
$code = getparam('code');
|
||||
|
||||
if (!$localname)
|
||||
$errors[] = no_field("form.field.agent_name");
|
||||
@ -54,6 +55,10 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
|
||||
if ($email != '' && !is_valid_email($email))
|
||||
$errors[] = wrong_field("form.field.mail");
|
||||
|
||||
if ($code != '' && (! preg_match("/^[A-z0-9_]+$/", $code))) {
|
||||
$errors[] = getlocal("page_agent.error.wrong_agent_code");
|
||||
}
|
||||
|
||||
if (!$opId && !$password)
|
||||
$errors[] = no_field("form.field.password");
|
||||
|
||||
@ -73,11 +78,11 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
|
||||
|
||||
if (count($errors) == 0) {
|
||||
if (!$opId) {
|
||||
$newop = create_operator($login, $email, $password, $localname, $commonname, "");
|
||||
$newop = create_operator($login, $email, $password, $localname, $commonname, "", $code);
|
||||
header("Location: $webimroot/operator/avatar.php?op=" . $newop['operatorid']);
|
||||
exit;
|
||||
} else {
|
||||
update_operator($opId, $login, $email, $password, $localname, $commonname);
|
||||
update_operator($opId, $login, $email, $password, $localname, $commonname, $code);
|
||||
// update the session password
|
||||
if (!empty($password) && $opId == $operator['operatorid']) {
|
||||
$toDashboard = $operator['vcpassword'] == md5('') && $password != '';
|
||||
@ -95,6 +100,7 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
|
||||
$page['formname'] = topage($localname);
|
||||
$page['formemail'] = topage($email);
|
||||
$page['formcommonname'] = topage($commonname);
|
||||
$page['formcode'] = topage($code);
|
||||
$page['opid'] = topage($opId);
|
||||
}
|
||||
|
||||
@ -116,6 +122,7 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
|
||||
$page['formname'] = topage($op['vclocalename']);
|
||||
$page['formemail'] = topage($op['vcemail']);
|
||||
$page['formcommonname'] = topage($op['vccommonname']);
|
||||
$page['formcode'] = topage($op['code']);
|
||||
$page['opid'] = topage($op['operatorid']);
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,14 @@ require_once('inc_errors.php');
|
||||
<br clear="all"/>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="flabel"><?php echo getlocal('form.field.agent_code') ?></div>
|
||||
<div class="fvalue">
|
||||
<input type="text" name="code" size="40" value="<?php echo form_value('code') ?>" class="formauth"<?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
|
||||
</div>
|
||||
<div class="fdescr"> — <?php echo getlocal('form.field.agent_code.description') ?></div>
|
||||
<br clear="all"/>
|
||||
</div>
|
||||
<?php if($page['canmodify']) { ?>
|
||||
<div class="fbutton">
|
||||
<input type="image" name="save" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/>
|
||||
|
@ -41,19 +41,26 @@ require_once('inc_errors.php');
|
||||
</div>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_image") ?></div>
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_style") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="i" onchange="this.form.submit();"><?php foreach($page['availableImages'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("image") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
|
||||
<select name="style" onchange="this.form.submit();"><?php foreach($page['availableChatStyles'] as $k => $v) { echo "<option value=\"".$k."\"".($k == form_value("style") ? " selected=\"selected\"" : "").">".$v."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all"/>
|
||||
|
||||
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_style") ?></div>
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_type") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="style" onchange="this.form.submit();"><?php foreach($page['availableChatStyles'] as $k => $v) { echo "<option value=\"".$k."\"".($k == form_value("style") ? " selected=\"selected\"" : "").">".$v."</option>"; } ?></select>
|
||||
<select name="codetype" onchange="this.form.submit();"><?php foreach($page['availableCodeTypes'] as $k => $v) { echo "<option value=\"".$k."\"".($k == form_value("codetype") ? " selected=\"selected\"" : "").">".$v."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all"/>
|
||||
|
||||
<?php if(! $page['operator_code']) { ?>
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_image") ?></div>
|
||||
<div class="fvaluenodesc">
|
||||
<select name="i" onchange="this.form.submit();"><?php foreach($page['availableImages'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("image") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -66,6 +73,7 @@ require_once('inc_errors.php');
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br clear="all"/>
|
||||
<?php } ?>
|
||||
|
||||
<div class="fieldinrow">
|
||||
<div class="flabel"><?php echo getlocal("page.gen_button.choose_group") ?></div>
|
||||
|
Loading…
Reference in New Issue
Block a user