mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-01 05:44:41 +03:00
Remove functions definition from operator/group.php
This commit is contained in:
parent
c2336a753e
commit
f49b53f9d6
@ -30,6 +30,17 @@ function group_by_id($id)
|
||||
return $group;
|
||||
}
|
||||
|
||||
function group_by_name($name)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$group = $db->query(
|
||||
"select * from {chatgroup} where vclocalname = ?",
|
||||
array($name),
|
||||
array('return_rows' => Database::RETURN_ONE_ROW)
|
||||
);
|
||||
return $group;
|
||||
}
|
||||
|
||||
function get_group_name($group)
|
||||
{
|
||||
if (HOME_LOCALE == CURRENT_LOCALE || !isset($group['vccommonname']) || !$group['vccommonname'])
|
||||
@ -180,4 +191,104 @@ function get_group_description($group) {
|
||||
}
|
||||
}
|
||||
|
||||
function check_group_params($group, $extra_params = NULL)
|
||||
{
|
||||
$obligatory_params = array(
|
||||
'name',
|
||||
'description',
|
||||
'commonname',
|
||||
'commondescription',
|
||||
'email',
|
||||
'weight',
|
||||
'parent',
|
||||
'chattitle',
|
||||
'hosturl',
|
||||
'logo');
|
||||
$params = is_null($extra_params)?$obligatory_params:array_merge($obligatory_params,$extra_params);
|
||||
if(count(array_diff($params, array_keys($group))) != 0){
|
||||
die('Wrong parameters set!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates group
|
||||
*
|
||||
* @param array $group Operators' group.
|
||||
* The $group array must contains following keys:
|
||||
* name, description, commonname, commondescription,
|
||||
* email, weight, parent, title, chattitle, hosturl, logo
|
||||
* @return array Created group
|
||||
*/
|
||||
function create_group($group)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
check_group_params($group);
|
||||
$db->query(
|
||||
"insert into {chatgroup} (parent, vclocalname,vclocaldescription,vccommonname, " .
|
||||
"vccommondescription,vcemail,vctitle,vcchattitle,vchosturl,vclogo,iweight) " .
|
||||
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
array(
|
||||
($group['parent'] ? (int)$group['parent'] : NULL),
|
||||
$group['name'],
|
||||
$group['description'],
|
||||
$group['commonname'],
|
||||
$group['commondescription'],
|
||||
$group['email'],
|
||||
$group['title'],
|
||||
$group['chattitle'],
|
||||
$group['hosturl'],
|
||||
$group['logo'],
|
||||
$group['weight']
|
||||
)
|
||||
);
|
||||
$id = $db->insertedId();
|
||||
|
||||
$newdep = $db->query(
|
||||
"select * from {chatgroup} where groupid = ?",
|
||||
array($id),
|
||||
array('return_rows' => Database::RETURN_ONE_ROW)
|
||||
);
|
||||
return $newdep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates group info
|
||||
*
|
||||
* @param array $group Operators' group.
|
||||
* The $group array must contains following keys:
|
||||
* id, name, description, commonname, commondescription,
|
||||
* email, weight, parent, title, chattitle, hosturl, logo
|
||||
*/
|
||||
function update_group($group)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
check_group_params($group, array('id'));
|
||||
$db->query(
|
||||
"update {chatgroup} set parent = ?, vclocalname = ?, vclocaldescription = ?, " .
|
||||
"vccommonname = ?, vccommondescription = ?, vcemail = ?, vctitle = ?, " .
|
||||
"vcchattitle = ?, vchosturl = ?, vclogo = ?, iweight = ? where groupid = ?",
|
||||
array(
|
||||
($group['parent'] ? (int)$group['parent'] : NULL),
|
||||
$group['name'],
|
||||
$group['description'],
|
||||
$group['commonname'],
|
||||
$group['commondescription'],
|
||||
$group['email'],
|
||||
$group['title'],
|
||||
$group['chattitle'],
|
||||
$group['hosturl'],
|
||||
$group['logo'],
|
||||
$group['weight'],
|
||||
$group['id']
|
||||
)
|
||||
);
|
||||
|
||||
if ($group['parent']) {
|
||||
$db->query(
|
||||
"update {chatgroup} set parent = NULL where parent = ?",
|
||||
array($group['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
// Import namespaces and classes of the core
|
||||
use Mibew\Database;
|
||||
use Mibew\Style\PageStyle;
|
||||
|
||||
// Initialize libraries
|
||||
@ -34,117 +33,6 @@ $page = array(
|
||||
|
||||
$groupid = '';
|
||||
|
||||
function group_by_name($name)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$group = $db->query(
|
||||
"select * from {chatgroup} where vclocalname = ?",
|
||||
array($name),
|
||||
array('return_rows' => Database::RETURN_ONE_ROW)
|
||||
);
|
||||
return $group;
|
||||
}
|
||||
|
||||
function check_group_params($group, $extra_params = NULL)
|
||||
{
|
||||
$obligatory_params = array(
|
||||
'name',
|
||||
'description',
|
||||
'commonname',
|
||||
'commondescription',
|
||||
'email',
|
||||
'weight',
|
||||
'parent',
|
||||
'chattitle',
|
||||
'hosturl',
|
||||
'logo');
|
||||
$params = is_null($extra_params)?$obligatory_params:array_merge($obligatory_params,$extra_params);
|
||||
if(count(array_diff($params, array_keys($group))) != 0){
|
||||
die('Wrong parameters set!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates group
|
||||
*
|
||||
* @param array $group Operators' group.
|
||||
* The $group array must contains following keys:
|
||||
* name, description, commonname, commondescription,
|
||||
* email, weight, parent, title, chattitle, hosturl, logo
|
||||
* @return array Created group
|
||||
*/
|
||||
function create_group($group)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
check_group_params($group);
|
||||
$db->query(
|
||||
"insert into {chatgroup} (parent, vclocalname,vclocaldescription,vccommonname, " .
|
||||
"vccommondescription,vcemail,vctitle,vcchattitle,vchosturl,vclogo,iweight) " .
|
||||
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
array(
|
||||
($group['parent'] ? (int)$group['parent'] : NULL),
|
||||
$group['name'],
|
||||
$group['description'],
|
||||
$group['commonname'],
|
||||
$group['commondescription'],
|
||||
$group['email'],
|
||||
$group['title'],
|
||||
$group['chattitle'],
|
||||
$group['hosturl'],
|
||||
$group['logo'],
|
||||
$group['weight']
|
||||
)
|
||||
);
|
||||
$id = $db->insertedId();
|
||||
|
||||
$newdep = $db->query(
|
||||
"select * from {chatgroup} where groupid = ?",
|
||||
array($id),
|
||||
array('return_rows' => Database::RETURN_ONE_ROW)
|
||||
);
|
||||
return $newdep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates group info
|
||||
*
|
||||
* @param array $group Operators' group.
|
||||
* The $group array must contains following keys:
|
||||
* id, name, description, commonname, commondescription,
|
||||
* email, weight, parent, title, chattitle, hosturl, logo
|
||||
*/
|
||||
function update_group($group)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
check_group_params($group, array('id'));
|
||||
$db->query(
|
||||
"update {chatgroup} set parent = ?, vclocalname = ?, vclocaldescription = ?, " .
|
||||
"vccommonname = ?, vccommondescription = ?, vcemail = ?, vctitle = ?, " .
|
||||
"vcchattitle = ?, vchosturl = ?, vclogo = ?, iweight = ? where groupid = ?",
|
||||
array(
|
||||
($group['parent'] ? (int)$group['parent'] : NULL),
|
||||
$group['name'],
|
||||
$group['description'],
|
||||
$group['commonname'],
|
||||
$group['commondescription'],
|
||||
$group['email'],
|
||||
$group['title'],
|
||||
$group['chattitle'],
|
||||
$group['hosturl'],
|
||||
$group['logo'],
|
||||
$group['weight'],
|
||||
$group['id']
|
||||
)
|
||||
);
|
||||
|
||||
if ($group['parent']) {
|
||||
$db->query(
|
||||
"update {chatgroup} set parent = NULL where parent = ?",
|
||||
array($group['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['name'])) {
|
||||
$groupid = verifyparam("gid", "/^(\d{1,9})?$/", "");
|
||||
$name = getparam('name');
|
||||
|
Loading…
Reference in New Issue
Block a user