2012-01-26 20:00:30 +04:00
|
|
|
<?php
|
|
|
|
/*
|
2013-03-13 01:03:50 +04:00
|
|
|
* Copyright 2005-2013 the original author or authors.
|
2012-01-26 20:00:30 +04:00
|
|
|
*
|
2013-03-13 01:03:50 +04:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2012-01-26 20:00:30 +04:00
|
|
|
*
|
2013-03-13 01:03:50 +04:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-01-26 20:00:30 +04:00
|
|
|
*
|
2013-03-13 01:03:50 +04:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2012-01-26 20:00:30 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
function load_canned_messages($locale, $groupid)
|
|
|
|
{
|
|
|
|
global $mysqlprefix;
|
|
|
|
$link = connect();
|
2012-01-29 01:52:44 +04:00
|
|
|
$query = "select id, vctitle, vcvalue from ${mysqlprefix}chatresponses " .
|
2012-01-26 20:00:30 +04:00
|
|
|
"where locale = '" . $locale . "' AND (" .
|
|
|
|
($groupid
|
|
|
|
? "groupid = $groupid"
|
|
|
|
: "groupid is NULL OR groupid = 0") .
|
|
|
|
") order by vcvalue";
|
|
|
|
$result = select_multi_assoc($query, $link);
|
|
|
|
close_connection($link);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_canned_message($key)
|
|
|
|
{
|
|
|
|
global $mysqlprefix;
|
|
|
|
$link = connect();
|
2012-01-29 01:52:44 +04:00
|
|
|
$result = select_one_row("select vctitle, vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
|
2012-01-26 20:00:30 +04:00
|
|
|
close_connection($link);
|
2012-01-29 01:52:44 +04:00
|
|
|
return $result ? $result : null;
|
2012-01-26 20:00:30 +04:00
|
|
|
}
|
|
|
|
|
2012-01-29 01:52:44 +04:00
|
|
|
function save_canned_message($key, $title, $message)
|
2012-01-26 20:00:30 +04:00
|
|
|
{
|
|
|
|
global $mysqlprefix;
|
|
|
|
$link = connect();
|
2012-01-29 01:52:44 +04:00
|
|
|
perform_query("update ${mysqlprefix}chatresponses set vcvalue = '" . db_escape_string($message, $link) . "', " .
|
|
|
|
"vctitle = '" . db_escape_string($title, $link) . "' " .
|
|
|
|
"where id = $key", $link);
|
2012-01-26 20:00:30 +04:00
|
|
|
close_connection($link);
|
|
|
|
}
|
|
|
|
|
2012-01-29 01:52:44 +04:00
|
|
|
function add_canned_message($locale, $groupid, $title, $message)
|
2012-01-26 20:00:30 +04:00
|
|
|
{
|
|
|
|
global $mysqlprefix;
|
|
|
|
$link = connect();
|
2012-01-29 01:52:44 +04:00
|
|
|
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vctitle,vcvalue) values ('$locale'," .
|
|
|
|
($groupid ? "$groupid, " : "null, ") .
|
|
|
|
"'" . db_escape_string($title, $link) . "', " .
|
|
|
|
"'" . db_escape_string($message, $link) . "')", $link);
|
2012-01-26 20:00:30 +04:00
|
|
|
close_connection($link);
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|