<?PHP
// Pushok's SEMA (Small Enterprise Management Application)
//
// Copyright (C) 2004 Pushok Software http://www.pushok.com
//
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
/*
subscription: contain necessary instruments for adding or removing user's rules.
*/
$nIdContact = 0;
if ( isset($_GET['idcontact']) && $_GET['idcontact']>0 )
$nIdContact = $_GET['idcontact'];
else
web_RedirectRelative("sema.php");
class web_Contact extends web_Layout
{
function Info()
{
global $nIdContact;
$_oIn = array();
$arObjects = array();
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_OBJECT_REGISTER", $_oIn, $arObjects);
$this->tableStart();
$arHeader = array(
array('value'=>_LW('Object'), 'colspan'=>0, 'align'=>'left'),
array('value'=>_LW('Mask'), 'colspan'=>0, 'align'=>'left'),
array('value'=>_LW('Action'), 'colspan'=>0, 'align'=>'left'),
);
$this->tableHeader($arHeader);
$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$nIdContact, 'type'=>ID_SEMA_CONTACT, 'mask'=>'5');
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut=array());
$bHasMask = false;
if ( isset($_oOut['result']) && $_oOut['result'] )
$bHasMask = true;
$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_RULE_GET_DEFAULT", $oIn = array('idcontact_current'=>$_SESSION['iduser'], 'idcontact'=>$nIdContact, 'bid'=>1, 'eid'=>1000), $arRules);
if ( count($arRules['rules']) )
{
foreach ( $arRules['rules'] as $nId => $sMask )
{
$this->tableRow();
$this->tableCol($arObjects[$nId]);
$this->tableCol($sMask);
if ( $bHasMask )
$this->tableCol("<A href=\"?action=remove&idform=GT_CONTACT_RULE&id=$nId&idcontact=$nIdContact\">"._LW("Remove")."</A>");
else
$this->tableCol("");
}
}
if ( $bHasMask )
{
echo "<FORM method=\"POST\">\n";
$this->tableRow();
echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_CONTACT_RULE_CREATE\"></INPUT>\n";
echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
echo "<INPUT type=\"hidden\" name=\"idcontact\" value=\"$nIdContact\"></INPUT>\n";
// predefined objects column
$this->tableCol($this->singleInputItem(false, "select", "idobject", "", $arObjects));
$this->tableCol($this->singleInputItem(false, "accessrights", "mask", ""));
$this->tableCol($this->singleInputItem(_LW("Add"), "submit"));
}
$this->tableEnd();
echo "<BR><CENTER>";
echo _LW("Default right are the rights for creation of global object, or accessing the objects where user is creator.");
echo "</CENTER>";
}
}
$oPage = new web_Contact;
$oPage->m_windowHeader = _LW("Contact's default rules");
$oPage->WebStack("contact_addition_info.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());
$_SESSION['active_page'] = web_GetPageGetParams();
if ( !isset($_SESSION['iduser']) )
web_RedirectRelative("sema.php");
$oPage->m_menuFLvl = "Contacts";
$oPage->RenderPage();
?>