Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion issabel-pbx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Issabel PBX Module
Name: issabel-pbx
Version: 5.0.0
Release: 5
Release: 6
License: GPL
Group: Applications/System
Source0: issabel-%{modname}-%{version}.tar.gz
Expand Down Expand Up @@ -311,3 +311,6 @@ fi
/etc/cron.daily/asterisk_cleanup

%changelog
* Tue Jun 30 2026 Trixocom <[email protected]> - 5.0.0-6
- monitoring: filter recordings by a group of extensions per user (acl_user.monitorexten)

14 changes: 10 additions & 4 deletions modules/monitoring/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ function _moduleContent(&$smarty, $module_name)
$pDBACL = new paloDB($arrConf['issabel_dsn']['acl']);
$pACL = new paloACL($pDBACL);
$user = isset($_SESSION['issabel_user'])?$_SESSION['issabel_user']:"";
$extension = $pACL->getUserExtension($user);
if ($extension == '') $extension = NULL;
$ownext = $pACL->getUserExtension($user);
if ($ownext == '') $ownext = NULL;

// Sólo el administrador puede consultar con $extension == NULL
if (is_null($extension)) {
// Lista de extensiones que el usuario puede monitorear. Si tiene definida
// la columna acl_user.monitorexten se usa esa lista; si no, su propia
// extensión (comportamiento clásico). $extension es SIEMPRE un arreglo.
$extension = $pACL->getUserMonitorExtensions($user);
if (count($extension) == 0 && !is_null($ownext)) $extension = array($ownext);

// Sólo reportany (administrador) puede consultar sin ninguna extensión asociada
if (count($extension) == 0) {
if (hasModulePrivilege($user, $module_name, 'reportany'))
$smarty->assign("mb_message", "<b>"._tr("no_extension")."</b>");
else{
Expand Down
46 changes: 32 additions & 14 deletions modules/monitoring/libs/paloSantoMonitoring.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,27 @@ function _construirWhereMonitoring_notempty($x) { return ($x != ''); }
}
}

// Extensión de fuente o destino, copiada de paloSantoCDR.class.php
// Extensión(es) de fuente o destino, copiada de paloSantoCDR.class.php.
// Acepta un valor escalar (comportamiento clásico) o un arreglo de
// extensiones (filtro por grupo de extensiones).
if (isset($param['extension'])) {
$condSQL[] = <<<SQL_COND_EXTENSION
$extens = is_array($param['extension'])
? $param['extension'] : array($param['extension']);
$extens = array_values(array_filter(array_map('trim', $extens),
'_construirWhereMonitoring_notempty'));
if (count($extens) > 0) {
$ph = implode(',', array_fill(0, count($extens), '?'));
$condSQL[] = <<<SQL_COND_EXTENSION
(
src = ?
OR dst = ?
OR SUBSTRING_INDEX(SUBSTRING_INDEX(channel,'-',1),'/',-1) = ?
OR SUBSTRING_INDEX(SUBSTRING_INDEX(dstchannel,'-',1),'/',-1) = ?
src IN ($ph)
OR dst IN ($ph)
OR SUBSTRING_INDEX(SUBSTRING_INDEX(channel,'-',1),'/',-1) IN ($ph)
OR SUBSTRING_INDEX(SUBSTRING_INDEX(dstchannel,'-',1),'/',-1) IN ($ph)
)
SQL_COND_EXTENSION;
array_push($paramSQL, $param['extension'], $param['extension'],
$param['extension'], $param['extension']);
for ($i = 0; $i < 4; $i++)
foreach ($extens as $e) $paramSQL[] = $e;
}
}

foreach (array('src', 'dst') as $sCampo) if (isset($param[$sCampo])) {
Expand Down Expand Up @@ -323,17 +332,26 @@ private function _rutaAbsolutaGrabacion($file)

function recordBelongsToUser($uniqueid, $extension)
{
// $extension puede ser un escalar (clásico) o un arreglo de extensiones.
$extens = is_array($extension) ? $extension : array($extension);
$tmp = array();
foreach ($extens as $e) { $e = trim($e); if ($e !== '') $tmp[] = $e; }
$extens = $tmp;
if (count($extens) == 0) return FALSE;
$ph = implode(',', array_fill(0, count($extens), '?'));
$sql = <<<RECORD_BELONGS_TO_EXTENSION
SELECT COUNT(*) FROM cdr
WHERE uniqueid = ? AND (
src = ?
OR dst = ?
OR SUBSTRING_INDEX(SUBSTRING_INDEX(channel,'-',1),'/',-1) = ?
OR SUBSTRING_INDEX(SUBSTRING_INDEX(dstchannel,'-',1),'/',-1) = ?
src IN ($ph)
OR dst IN ($ph)
OR SUBSTRING_INDEX(SUBSTRING_INDEX(channel,'-',1),'/',-1) IN ($ph)
OR SUBSTRING_INDEX(SUBSTRING_INDEX(dstchannel,'-',1),'/',-1) IN ($ph)
)
RECORD_BELONGS_TO_EXTENSION;
$result = $this->_DB->getFirstRowQuery($sql, FALSE,
array($uniqueid, $extension, $extension, $extension, $extension));
$params = array($uniqueid);
for ($i = 0; $i < 4; $i++)
foreach ($extens as $e) $params[] = $e;
$result = $this->_DB->getFirstRowQuery($sql, FALSE, $params);
if (!is_array($result)) {
$this->errMsg = $this->_DB->errMsg;
return FALSE;
Expand Down
24 changes: 24 additions & 0 deletions modules/userlist/plugins/extension/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ function addFormElements($privileged)
"VALIDATION_TYPE" => "text",
"VALIDATION_EXTRA_PARAM" => ""
),
"monitorexten" => array(
"LABEL" => _tr("Monitor extensions"),
"REQUIRED" => "no",
"INPUT_TYPE" => "TEXT",
"INPUT_EXTRA_PARAM" => '',
"VALIDATION_TYPE" => "text",
"VALIDATION_EXTRA_PARAM" => ""
),
);
} else {
return array(
Expand All @@ -76,6 +84,15 @@ function addFormElements($privileged)
"VALIDATION_EXTRA_PARAM" => "",
'EDITABLE' => 'no',
),
"monitorexten" => array(
"LABEL" => _tr("Monitor extensions"),
"REQUIRED" => "no",
"INPUT_TYPE" => "TEXT",
"INPUT_EXTRA_PARAM" => '',
"VALIDATION_TYPE" => "text",
"VALIDATION_EXTRA_PARAM" => "",
'EDITABLE' => 'no',
),
);
}
}
Expand All @@ -85,6 +102,9 @@ function loadFormEditValues($username, $id_user)
if (!isset($_POST['extension'])) {
$_POST['extension'] = $this->_pACL->getUserExtension($username);
}
if (!isset($_POST['monitorexten'])) {
$_POST['monitorexten'] = implode(',', $this->_pACL->getUserMonitorExtensions($username));
}
}

function fetchForm($smarty, $oForm, $local_templates_dir, $pvars)
Expand All @@ -97,6 +117,10 @@ function runPostCreateUser($smarty, $username, $id_user)
{
$r = $this->_pACL->setUserExtension($username,
(trim($_POST['extension']) == '') ? NULL : trim($_POST['extension']));
if ($r && isset($_POST['monitorexten'])) {
$r = $this->_pACL->setUserMonitorExtensions($username,
(trim($_POST['monitorexten']) == '') ? NULL : trim($_POST['monitorexten']));
}
if (!$r) {
$smarty->assign(array(
'mb_title' => 'ERROR',
Expand Down
1 change: 1 addition & 0 deletions modules/userlist/plugins/extension/lang/es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ $arrLangModule = array(
"No extension associated" => "La extensión no ha sido asociada",
"no extension" => "sin extensión",
"PBX Profile" => "Perfil PBX",
"Monitor extensions" => "Extensiones a monitorear",
);
?>
5 changes: 5 additions & 0 deletions modules/userlist/plugins/extension/tpl/new_extension.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
<td width="30%">{$extension.INPUT}</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="20%">{$monitorexten.LABEL}:</td>
<td width="30%">{$monitorexten.INPUT}</td>
<td colspan="2">{$monitorexten.LABEL_HELP}</td>
</tr>
</table>
</fieldset>