M
M
microf2017-10-07 21:11:24
1C-Bitrix
microf, 2017-10-07 21:11:24

How to display your field in the list of users?

Good afternoon. I already asked my question, but, apparently, I either formulated it poorly or was too general. There is a field in which the user's points are stored - they are summed up to get the total amount. They come out like this

CModule::IncludeModule("iblock");
$arSelect = Array("ID", "PROPERTY_BAL");				 
$arFilter = Array("IBLOCK_ID"=>9, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y","PROPERTY_USER"=>$USER->GetID());
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
while($ob = $res->GetNextElement())
{
 $arFields = $ob->GetFields();
  $bonus += $arFields["PROPERTY_BAL_VALUE"];
}
$rsUser = CUser::GetByID($USER->GetID());
$arUser = $rsUser->Fetch();
echo $bonus

I made a separate module where I want to display the sum of points in the list of users for each user. I
59d9164911db6586090269.png
copied the standard user_admin from main into the module file, which displays a list of users as usual
code user_admin
<?
/**
 * 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."&COPY_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");
?>


How can I insert my code into my module code so that the number of bonuses of the user is displayed next to the line?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question