Merge pull request #928 from dawnbreak/docu
Some documentation, fix chatroom service class lookup.
This commit is contained in:
commit
f823e2e2ed
@ -586,13 +586,26 @@ function service_class_allows($uid,$property,$usage = false) {
|
|||||||
else {
|
else {
|
||||||
if(! array_key_exists($property,$arr))
|
if(! array_key_exists($property,$arr))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return (((intval($usage)) < intval($arr[$property])) ? true : false);
|
return (((intval($usage)) < intval($arr[$property])) ? true : false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// like service_class_allows but queries by account rather than channel
|
/**
|
||||||
|
* @brief Checks service class restrictions by account_id.
|
||||||
|
*
|
||||||
|
* Like service_class_allows() but queries by account rather than channel.
|
||||||
|
*
|
||||||
|
* @see service_class_allows()
|
||||||
|
*
|
||||||
|
* @param int $aid account_id
|
||||||
|
* @param string $property
|
||||||
|
* @param int|boolean $usage, default false
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
* @todo Can't we use here internally account_service_class_fetch() to reduce duplicate code?
|
||||||
|
*/
|
||||||
function account_service_class_allows($aid, $property, $usage = false) {
|
function account_service_class_allows($aid, $property, $usage = false) {
|
||||||
$a = get_app();
|
|
||||||
$r = q("select account_service_class as service_class from account where account_id = %d limit 1",
|
$r = q("select account_service_class as service_class from account where account_id = %d limit 1",
|
||||||
intval($aid)
|
intval($aid)
|
||||||
);
|
);
|
||||||
@ -612,11 +625,23 @@ function account_service_class_allows($aid,$property,$usage = false) {
|
|||||||
else {
|
else {
|
||||||
if(! array_key_exists($property, $arr))
|
if(! array_key_exists($property, $arr))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return (((intval($usage)) < intval($arr[$property])) ? true : false);
|
return (((intval($usage)) < intval($arr[$property])) ? true : false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetches a service class for a channel_id and property.
|
||||||
|
*
|
||||||
|
* This method not just checks if a service class is allowed like service_class_allows(),
|
||||||
|
* but also returns the service class value.
|
||||||
|
* If no service class is available it returns false and everything should be
|
||||||
|
* allowed.
|
||||||
|
*
|
||||||
|
* @param int $uid channel_id
|
||||||
|
* @param string $property
|
||||||
|
* @return boolean|int
|
||||||
|
*/
|
||||||
function service_class_fetch($uid, $property) {
|
function service_class_fetch($uid, $property) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
if($uid == local_channel()) {
|
if($uid == local_channel()) {
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
<?php /** @file */
|
<?php
|
||||||
|
/**
|
||||||
|
* @file include/chat.php
|
||||||
|
* @brief Chat related functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a chatroom.
|
||||||
|
*
|
||||||
|
* @param array $channel
|
||||||
|
* @param array $arr
|
||||||
|
* @return An associative array containing:
|
||||||
|
* - success: A boolean
|
||||||
|
* - message: (optional) A string
|
||||||
|
*/
|
||||||
function chatroom_create($channel, $arr) {
|
function chatroom_create($channel, $arr) {
|
||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
@ -24,7 +37,7 @@ function chatroom_create($channel,$arr) {
|
|||||||
intval($channel['channel_account_id'])
|
intval($channel['channel_account_id'])
|
||||||
);
|
);
|
||||||
if($r)
|
if($r)
|
||||||
$limit = service_class_fetch($channel_id,'chatrooms');
|
$limit = service_class_fetch($channel['channel_id'], 'chatrooms');
|
||||||
|
|
||||||
if(($r) && ($limit !== false) && ($r[0]['total'] >= $limit)) {
|
if(($r) && ($limit !== false) && ($r[0]['total'] >= $limit)) {
|
||||||
$ret['message'] = upgrade_message();
|
$ret['message'] = upgrade_message();
|
||||||
@ -60,6 +73,7 @@ function chatroom_create($channel,$arr) {
|
|||||||
function chatroom_destroy($channel,$arr) {
|
function chatroom_destroy($channel,$arr) {
|
||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
|
|
||||||
if(intval($arr['cr_id']))
|
if(intval($arr['cr_id']))
|
||||||
$sql_extra = " and cr_id = " . intval($arr['cr_id']) . " ";
|
$sql_extra = " and cr_id = " . intval($arr['cr_id']) . " ";
|
||||||
elseif(trim($arr['cr_name']))
|
elseif(trim($arr['cr_name']))
|
||||||
@ -88,6 +102,7 @@ function chatroom_destroy($channel,$arr) {
|
|||||||
intval($r[0]['cr_id'])
|
intval($r[0]['cr_id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user