<?
/**
* Bitrix Framework
* @package bitrix
* @subpackage main
* @copyright 2001-2013 Bitrix
*/
/**
* Bitrix vars
* @global CUser $USER
* @global CMain $APPLICATION
* @global CDatabase $DB
* @global CUserTypeManager $USER_FIELD_MANAGER
* @global string $by
* @global string $order
*/
require_once(dirname(__FILE__)."/../include/prolog_admin_before.php");
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/prolog.php");
define("HELP_FILE", "users/user_admin.php");
$entity_id = "USER";
if(!($USER->CanDoOperation('view_subordinate_users') || $USER->CanDoOperation('view_all_users') || $USER->CanDoOperation('edit_all_users') || $USER->CanDoOperation('edit_subordinate_users')))
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
$arUserSubordinateGroups = array();
$uid = $USER->GetID();
$handle_subord = (
($USER->CanDoOperation('edit_subordinate_users') && !$USER->CanDoOperation('edit_all_users'))
|| ($USER->CanDoOperation('view_subordinate_users') && !$USER->CanDoOperation('view_all_users'))
);
if($handle_subord)
{
$arUserGroups = CUser::GetUserGroup($uid);
for ($j = 0, $len = count($arUserGroups); $j < $len; $j++)
{
$arSubordinateGroups = CGroup::GetSubordinateGroups($arUserGroups[$j]);
$arUserSubordinateGroups = array_merge ($arUserSubordinateGroups, $arSubordinateGroups);
}
$arUserSubordinateGroups = array_unique($arUserSubordinateGroups);
}
IncludeModuleLangFile(__FILE__);
//authorize as user
if($_REQUEST["action"] == "authorize" && check_bitrix_sessid() && $USER->CanDoOperation('edit_php'))
{
$USER->Logout();
$USER->Authorize(intval($_REQUEST["ID"]));
LocalRedirect("user_admin.php?lang=".LANGUAGE_ID);
}
$sTableID = "tbl_user";
$oSort = new CAdminSorting($sTableID, "TIMESTAMP_X", "desc");
$lAdmin = new CAdminList($sTableID, $oSort);
$bIntranetEdition = IsModuleInstalled("intranet");//(defined("INTRANET_EDITION") && INTRANET_EDITION == "Y");
$arFilterFields = Array(
"find",
"find_type",
"find_id",
"find_timestamp_1",
"find_timestamp_2",
"find_last_login_1",
"find_last_login_2",
"find_active",
"find_login",
"find_name",
"find_email",
"find_keywords",
"find_group_id"
);
if ($bIntranetEdition)
$arFilterFields[] = "find_intranet_users";
$USER_FIELD_MANAGER->AdminListAddFilterFields($entity_id, $arFilterFields);
$lAdmin->InitFilter($arFilterFields);
$arFilter = Array();
if(CheckFilter($arFilterFields))
{
$arFilter = Array(
"ID" => $find_id,
"TIMESTAMP_1" => $find_timestamp_1,
"TIMESTAMP_2" => $find_timestamp_2,
"LAST_LOGIN_1" => $find_last_login_1,
"LAST_LOGIN_2" => $find_last_login_2,
"ACTIVE" => $find_active,
"LOGIN" => ($find!='' && $find_type == "login"? $find: $find_login),
"NAME" => ($find!='' && $find_type == "name"? $find: $find_name),
"EMAIL" => ($find!='' && $find_type == "email"? $find: $find_email),
"KEYWORDS" => $find_keywords,
"GROUPS_ID" => $find_group_id
);
$USER_FIELD_MANAGER->AdminListAddFilter($entity_id, $arFilter);
}
$arHeaders = array(
array("id"=>"LOGIN", "content"=>GetMessage("LOGIN"), "sort"=>"login", "default"=>true),
...
array("id"=>"EXTERNAL_AUTH_ID", "content"=>GetMessage("EXTERNAL_AUTH_ID")),
);
$rsRatings = CRatings::GetList(array('ID' => 'ASC'), array('ACTIVE' => 'Y', 'ENTITY_ID' => 'USER'));
while ($arRatingsTmp = $rsRatings->GetNext())
$arHeaders[] = array("id"=>"RATING_".$arRatingsTmp['ID'], "content"=>htmlspecialcharsbx($arRatingsTmp['NAME']), "sort"=>"RATING_".$arRatingsTmp['ID']);
$USER_FIELD_MANAGER->AdminListAddHeaders($entity_id, $arHeaders);
$lAdmin->AddHeaders($arHeaders);
$rsData = CUser::GetList($by, $order, $arFilter, array(
"SELECT" => $lAdmin->GetVisibleHeaderColumns(),
"NAV_PARAMS"=> array("nPageSize"=>CAdminResult::GetNavSize($sTableID)),
));
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("PAGES")));
while($arRes = $rsData->NavNext(true, "f_"))
{
$row =& $lAdmin->AddRow($f_ID, $arRes);
$USER_FIELD_MANAGER->AddUserFields($entity_id, $arRes, $row);
$row->AddViewField("ID", "<a href='user_edit.php?lang=".LANGUAGE_ID."&ID=".$f_ID."' title='".GetMessage("MAIN_EDIT_TITLE")."'>".$f_ID."</a>");
$own_edit = ($USER->CanDoOperation('edit_own_profile') && ($USER->GetParam("USER_ID") == $f_ID));
$edit = ($USER->CanDoOperation('edit_subordinate_users') || $USER->CanDoOperation('edit_all_users'));
$can_edit = (IntVal($f_ID)>1 && ($own_edit || $edit));
if($f_ID == 1 || $own_edit || !$can_edit)
$row->AddCheckField("ACTIVE", false);
else
$row->AddCheckField("ACTIVE");
if ($can_edit && $edit)
{
$row->AddField("LOGIN", "<a href='user_edit.php?lang=".LANGUAGE_ID."&ID=".$f_ID."' title='".GetMessage("MAIN_EDIT_TITLE")."'>".$f_LOGIN."</a>", true);
$row->AddInputField("TITLE");
$row->AddInputField("NAME");
$row->AddInputField("LAST_NAME");
$row->AddInputField("SECOND_NAME");
...
$row->AddInputField("XML_ID");
}
else
{
$row->AddViewField("LOGIN", "<a href='user_edit.php?lang=".LANGUAGE_ID."&ID=".$f_ID."' title='".GetMessage("MAIN_EDIT_TITLE")."'>".$f_LOGIN."</a>");
$row->AddViewField("EMAIL", TxtToHtml($arRes["EMAIL"]));
$row->AddViewField("PERSONAL_WWW", TxtToHtml($arRes["PERSONAL_WWW"]));
$row->AddViewField("WORK_WWW", TxtToHtml($arRes["WORK_WWW"]));
}
$arActions = Array();
$arActions[] = array("ICON"=>$can_edit ? "edit" : "view", "TEXT"=>GetMessage($can_edit ? "MAIN_ADMIN_MENU_EDIT" : "MAIN_ADMIN_MENU_VIEW"), "LINK"=> "user_edit.php?lang=".LANGUAGE_ID."&ID=".$f_ID, "DEFAULT"=>true);
if($can_edit && $edit)
{
$arActions[] = array("ICON"=>"copy", "TEXT"=>GetMessage("MAIN_ADMIN_ADD_COPY"), "LINK"=>"user_edit.php?lang=".LANGUAGE_ID."©_ID=".$f_ID);
if (!$own_edit)
$arActions[] = array("ICON"=>"delete", "TEXT"=>GetMessage("MAIN_ADMIN_MENU_DELETE"), "ACTION"=>"if(confirm('".GetMessage('CONFIRM_DEL_USER')."')) ".$lAdmin->ActionDoGroup($f_ID, "delete"));
}
if($USER->CanDoOperation('edit_php'))
{
$arActions[] = array("SEPARATOR"=>true);
$arActions[] = array("ICON"=>"", "TEXT"=>GetMessage("MAIN_ADMIN_AUTH"), "TITLE"=>GetMessage("MAIN_ADMIN_AUTH_TITLE"), "LINK"=>"user_admin.php?lang=".LANGUAGE_ID."&ID=".$f_ID."&action=authorize&".bitrix_sessid_get());
}
$row->AddActions($arActions);
}
$aContext = Array();
...
$lAdmin->AddAdminContextMenu($aContext);
$lAdmin->CheckListMode();
$APPLICATION->SetTitle(GetMessage("TITLE"));
require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php");
?>
</form>
<?
$lAdmin->DisplayList();
require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin.php");
?>