public function getDataToShow() { $event = \CCalendarEvent::getById($this->entityId); if (empty($event)) { return array(); } $members = array(); if ($event['IS_MEETING']) { if (is_array($event['~ATTENDEES'])) { foreach ($event['~ATTENDEES'] as $user) { $members[] = array("NAME" => $user['DISPLAY_NAME'], "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $user['USER_ID'])), 'AVATAR_SRC' => $user['AVATAR'], "IS_EXTRANET" => "N"); } } } else { $by = "id"; $order = "asc"; $userRow = \CUser::getList($by, $order, array("ID_EQUAL_EXACT" => $event['CREATED_BY'], "ACTIVE" => "Y"), array("SELECT" => array('ID', 'NAME', 'LAST_NAME', 'LOGIN', 'PERSONAL_PHOTO')))->fetch(); if ($userRow) { $name = trim($userRow['NAME'] . ' ' . $userRow['LAST_NAME']); if ($name == '') { $name = trim($userRow['LOGIN']); } $members[] = array("NAME" => $name, "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $event['CREATED_BY'])), 'AVATAR_SRC' => Ui\Avatar::getPerson($userRow['PERSONAL_PHOTO']), "IS_EXTRANET" => "N"); } } return array('TITLE' => Loc::getMessage('DISK_UF_CAL_EVENT_CONNECTOR_TITLE') . ": " . $event['NAME'], 'DETAIL_URL' => null, 'DESCRIPTION' => Ui\Text::killTags($event['DESCRIPTION']), 'MEMBERS' => $members); }
/** * Get image (avatar) of entity. * Can be shown with entityTitle in different lists. * @param int $width Image width. * @param int $height Image height. * @return string */ public function getEntityImageSrc($width, $height) { $group = $this->getGroup(); $photo = (int) $group['IMAGE_ID']; $key = $photo . " {$width} {$height}"; if (!isset($this->photoCache[$key])) { $this->photoCache[$key] = Avatar::getGroup($photo, $width, $height); } return $this->photoCache[$key]; }
protected function getMembers($members) { $result = array(); foreach ($members as $memberId) { $rs = \CUser::getList($by = "ID", $order = "ASC", array("ID" => $memberId), array("FIELDS" => array("ID", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL", "PERSONAL_PHOTO"))); if ($ar = $rs->fetch()) { $result[] = array("NAME" => \CUser::formatName('#NAME# #LAST_NAME#', $ar, true, false), "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $memberId)), 'AVATAR_SRC' => Ui\Avatar::getPerson($ar['PERSONAL_PHOTO']), "IS_EXTRANET" => "N"); } } return $result; }
protected function getDestinations() { if ($this->taskPostData === null) { return array(); } $members = array(); if (!empty($this->taskPostData['RESPONSIBLE_ID'])) { $members[] = array("NAME" => \CUser::formatName('#NAME# #LAST_NAME#', array('NAME' => $this->taskPostData['RESPONSIBLE_NAME'], 'LAST_NAME' => $this->taskPostData['RESPONSIBLE_LAST_NAME'], 'SECOND_NAME' => $this->taskPostData['RESPONSIBLE_SECOND_NAME'], 'ID' => $this->taskPostData['RESPONSIBLE_ID'], 'LOGIN' => $this->taskPostData['RESPONSIBLE_LOGIN']), true, false), "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $this->taskPostData['RESPONSIBLE_ID'])), 'AVATAR_SRC' => Ui\Avatar::getPerson($this->taskPostData['RESPONSIBLE_PHOTO']), "IS_EXTRANET" => "N"); } if (!empty($this->taskPostData['CREATED_BY'])) { $members[] = array("NAME" => \CUser::formatName('#NAME# #LAST_NAME#', array('NAME' => $this->taskPostData['CREATED_BY_NAME'], 'LAST_NAME' => $this->taskPostData['CREATED_BY_LAST_NAME'], 'SECOND_NAME' => $this->taskPostData['CREATED_BY_SECOND_NAME'], 'ID' => $this->taskPostData['CREATED_BY'], 'LOGIN' => $this->taskPostData['CREATED_BY_LOGIN']), true, false), "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $this->taskPostData['CREATED_BY'])), 'AVATAR_SRC' => Ui\Avatar::getPerson($this->taskPostData['CREATED_BY_PHOTO']), "IS_EXTRANET" => "N"); } return $members; }
protected function getDestinations() { $isExtranetInstalled = Loader::includeModule("extranet"); $members = array(); if ($this->blogPostData["HAS_SOCNET_ALL"] != "Y") { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $perm = \CBlogPost::getSocnetPermsName($this->entityId); foreach ($perm as $type => $v) { foreach ($v as $vv) { if ($type == "SG") { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if ($socNetGroup = \CSocNetGroup::getByID($vv["ENTITY_ID"])) { $name = $socNetGroup["~NAME"]; $link = \CComponentEngine::makePathFromTemplate($this->getPathToGroup(), array("group_id" => $vv["ENTITY_ID"])); $groupSiteID = false; /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $queryGroupSite = \CSocNetGroup::getSite($vv["ENTITY_ID"]); while ($groupSite = $queryGroupSite->fetch()) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if (!$isExtranetInstalled || $groupSite["LID"] != \CExtranet::getExtranetSiteID()) { $groupSiteID = $groupSite["LID"]; break; } } if ($groupSiteID) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $tmp = \CSocNetLogTools::processPath(array("GROUP_URL" => $link), $this->getUser()->getId(), $groupSiteID); // user_id is not important parameter $link = strlen($tmp["URLS"]["GROUP_URL"]) > 0 ? $tmp["URLS"]["GROUP_URL"] : $link; } $isExtranet = is_array($GLOBALS["arExtranetGroupID"]) && in_array($vv["ENTITY_ID"], $GLOBALS["arExtranetGroupID"]); $members[] = array("NAME" => $name, "LINK" => $link, 'AVATAR_SRC' => Ui\Avatar::getGroup($socNetGroup['IMAGE_ID']), "IS_EXTRANET" => $isExtranet ? "Y" : "N"); } } elseif ($type == "U") { if (in_array("US" . $vv["ENTITY_ID"], $vv["ENTITY"])) { array_unshift($members, array("NAME" => Loc::getMessage('DISK_UF_BLOG_POST_CONNECTOR_MEMBERS_ALL'), "LINK" => null, 'AVATAR_SRC' => Ui\Avatar::getDefaultGroup(), "IS_EXTRANET" => "N")); } else { $name = \CUser::formatName('#NAME# #LAST_NAME#', array("NAME" => $vv["~U_NAME"], "LAST_NAME" => $vv["~U_LAST_NAME"], "SECOND_NAME" => $vv["~U_SECOND_NAME"], "LOGIN" => $vv["~U_LOGIN"], "NAME_LIST_FORMATTED" => ""), false); $isExtranet = is_array($GLOBALS["arExtranetUserID"]) && in_array($vv["ENTITY_ID"], $GLOBALS["arExtranetUserID"]); $members[] = array("NAME" => $name, "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $vv["ENTITY_ID"])), 'AVATAR_SRC' => Ui\Avatar::getPerson($vv['U_PERSONAL_PHOTO']), "IS_EXTRANET" => $isExtranet ? "Y" : "N"); } } elseif ($type == "DR") { $members[] = array("NAME" => $vv["EL_NAME"], "LINK" => null, 'AVATAR_SRC' => Ui\Avatar::getDefaultGroup(), "IS_EXTRANET" => "N"); } } } } else { $members[] = array("NAME" => Loc::getMessage('DISK_UF_BLOG_POST_CONNECTOR_MEMBERS_ALL'), "LINK" => null, 'AVATAR_SRC' => Ui\Avatar::getDefaultGroup(), "IS_EXTRANET" => "N"); } return $members; }
/** * Get image (avatar) of entity. * Can be shown with entityTitle in different lists. * @param int $width Image width. * @param int $height Image height. * @return string */ public function getEntityImageSrc($width, $height) { return Avatar::getDefaultGroup(); }
public function getAvatarSrc($width = 21, $height = 21) { return Ui\Avatar::getPerson($this->personalPhoto, $width, $height); }
/** * Returns list users who have sharing on this object. * @return array * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\LoaderException */ public function getMembersOfSharing() { $sharings = $this->getRealObject()->getSharingsAsReal(); $members = array(); $membersToSharing = array(); foreach ($sharings as $sharing) { if ($sharing->isToDepartmentChild()) { continue; } list($type, $id) = Sharing::parseEntityValue($sharing->getToEntity()); $members[$type][] = $id; $membersToSharing[$type . '|' . $id] = $sharing; } unset($sharing); $enabledSocialnetwork = Loader::includeModule('socialnetwork'); $entityList = array(); foreach (SharingTable::getListOfTypeValues() as $type) { if (empty($members[$type])) { continue; } if ($type == SharingTable::TYPE_TO_USER) { $query = \Bitrix\Main\UserTable::getList(array('select' => array('ID', 'PERSONAL_PHOTO', 'NAME', 'LOGIN', 'LAST_NAME', 'SECOND_NAME'), 'filter' => array('ID' => array_values($members[$type])))); while ($userRow = $query->fetch()) { /** @var Sharing $sharing */ $sharing = $membersToSharing[$type . '|' . $userRow['ID']]; $entityList[] = array('entityId' => Sharing::CODE_USER . $userRow['ID'], 'name' => \CUser::formatName('#NAME# #LAST_NAME#', array("NAME" => $userRow['NAME'], "LAST_NAME" => $userRow['LAST_NAME'], "SECOND_NAME" => $userRow['SECOND_NAME'], "LOGIN" => $userRow['LOGIN']), false), 'right' => $sharing->getTaskName(), 'avatar' => Avatar::getPerson($userRow['PERSONAL_PHOTO']), 'type' => 'users'); } } elseif ($type == SharingTable::TYPE_TO_GROUP && $enabledSocialnetwork) { $query = \CSocNetGroup::getList(array(), array('ID' => array_values($members[$type])), false, false, array('ID', 'IMAGE_ID', 'NAME')); while ($query && ($groupRow = $query->fetch())) { /** @var Sharing $sharing */ $sharing = $membersToSharing[$type . '|' . $groupRow['ID']]; $entityList[] = array('entityId' => Sharing::CODE_SOCNET_GROUP . $groupRow['ID'], 'name' => $groupRow['NAME'], 'right' => $sharing->getTaskName(), 'avatar' => Avatar::getGroup($groupRow['IMAGE_ID']), 'type' => 'groups'); } } elseif ($type == SharingTable::TYPE_TO_DEPARTMENT && $enabledSocialnetwork) { // intranet structure $structure = \CSocNetLogDestination::getStucture(); foreach (array_values($members[$type]) as $departmentId) { if (empty($structure['department']['DR' . $departmentId])) { continue; } /** @var Sharing $sharing */ $sharing = $membersToSharing[$type . '|' . $departmentId]; $entityList[] = array('entityId' => Sharing::CODE_DEPARTMENT . $departmentId, 'name' => $structure['department']['DR' . $departmentId]['name'], 'right' => $sharing->getTaskName(), 'avatar' => Avatar::getDefaultGroup(), 'type' => 'department'); } unset($departmentId); } } unset($type); return $entityList; }