Esempio n. 1
0
 /**
  * Returns array of special entity data which is used, for example, in "Who has access" datagrid,
  * "oro_share_select" form type search result.
  *
  * @param object $object
  *
  * @return array
  */
 public function getEntityDetails($object)
 {
     $id = $label = $details = $image = $avatar = $classLabel = null;
     if ($object instanceof Organization) {
         $id = $object->getId();
         $label = $object->getName();
         $image = 'avatar-organization-small.png';
         $classLabel = $this->translator->trans('oro.organization.entity_label');
         $details = $classLabel;
     } elseif ($object instanceof BusinessUnit) {
         $id = $object->getId();
         $label = $object->getName();
         $image = 'avatar-business-unit-small.png';
         $classLabel = $this->translator->trans('oro.organization.businessunit.entity_label');
         $details = $classLabel . ' ' . $this->translator->trans('oro.security.datagrid.share_grid_row_details_from') . ' ' . $object->getOrganization()->getName();
     } elseif ($object instanceof User) {
         $id = $object->getId();
         $label = $object->getFirstName() . ' ' . $object->getLastName();
         $image = 'avatar-small.png';
         $classLabel = $this->translator->trans('oro.user.entity_label');
         $avatar = $object->getAvatar() ? $this->attachmentManager->getResizedImageUrl($object->getAvatar(), AttachmentManager::SMALL_IMAGE_WIDTH, AttachmentManager::SMALL_IMAGE_HEIGHT) : null;
         $details = $classLabel . ' ' . $this->translator->trans('oro.security.datagrid.share_grid_row_details_from') . ' ' . $object->getOwner()->getName();
     }
     return ['id' => $id, 'label' => $label, 'image' => $image, 'avatar' => $avatar, 'details' => $details, 'classLabel' => $classLabel];
 }
Esempio n. 2
0
 /**
  * Generate a link to an user image of a social platform.
  *
  * @param object  $socialProfiles Social profiles object.
  * @param integer $userId         User ID
  * @param string  $default        A link to default picture.
  * @param array   $options        Options that will be used to integration.
  *
  * @return string
  *
  * <code>
  *
  * $options = array(
  *      "avatar_size" => 50
  * );
  * $avatar  = JHtml::_("userideas.avatar", $socialProfiles, $userId, "media/com_userideas/images/no-profile.png", $options);
  *
  * </code>
  *
  */
 public static function avatar($socialProfiles, $userId, $default = null, $options = array())
 {
     $avatarSize = JArrayHelper::getValue($options, "avatar_size", 50);
     $link = !$socialProfiles ? null : $socialProfiles->getAvatar($userId, $avatarSize);
     // Set the link to default picture
     if (!$link and !empty($default)) {
         $link = $default;
     }
     return $link;
 }