Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
util.php
1<?php
3
8class Util
9{
16 public static function generateUserUniqueId($prefix = '')
17 {
18 global $USER;
19 $gid = ($prefix ? $prefix . '_' : '') . randString(25) . '_' . $USER->getId() . randString(8);
20 return $gid;
21 }
22
23
32 public static function getAvatarSrc($avatarId, $width = 21, $height = 21)
33 {
34 static $cache = array();
35
36 if(empty($avatarId))
37 {
38 return null;
39 }
40
41 $avatarId = (int) $avatarId;
42 $key = $avatarId . " $width $height";
43
44 if (!isset($cache[$key]))
45 {
46 $src = false;
47 if ($avatarId > 0)
48 {
49
50 $imageFile = \CFile::getFileArray($avatarId);
51 if ($imageFile !== false)
52 {
53
54 $fileTmp = \CFile::resizeImageGet(
55 $imageFile,
56 array("width" => $width, "height" => $height),
57 BX_RESIZE_IMAGE_EXACT,
58 false
59 );
60 $src = $fileTmp["src"];
61 }
62
63 $cache[$key] = $src;
64 }
65 }
66
67 return $cache[$key];
68 }
69}
static getAvatarSrc($avatarId, $width=21, $height=21)
Definition util.php:32
static generateUserUniqueId($prefix='')
Definition util.php:16