Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.94 KB | None | 0 0
  1. /*
  2. DESCRIPTION Present a user from our user database with a picture in a nice format, a bit like a business card.
  3. USEDFROM Wiki
  4. CREATER Henning C. Nielsen
  5. CREATED 20110524
  6. */
  7. alter proc spDlt_UserCard
  8.     @attributes varchar(max)
  9. as
  10. begin
  11.     -- SET NOCOUNT ON added to prevent extra result sets from
  12.     -- interfering with SELECT statements.
  13.     set nocount on;
  14.  
  15.     -- Find the user id.
  16.     declare @userID as int
  17.    
  18.     if isnumeric(@attributes) = 1
  19.         set @userID = cast(@attributes as int)
  20.     else
  21.         set @userID = (select u.UserID from vwUser u where lower(u.Username) = lower(ltrim(rtrim(@attributes))))
  22.        
  23.     if not exists (select 1 from vwUser where UserID = @userID)
  24.         raiserror('User was not found', 1, 1)  
  25.  
  26.     -- Select the stylesheets used to represent active projects.
  27.     select '<style type="text/css">'
  28.             + ' div.usercard { float:right; font-size: 10pt; background-color: #EBF6FD; padding: 10px; width: 375px }'
  29.             + ' div.usercard div.name { font-weight: bold; }'
  30.             + ' div.usercard div.title { margin-bottom: 10px; white-space: nowrap; }'
  31.             + ' div.usercard img { float: right; }'
  32.          + '</style>'
  33.  
  34.     -- Select the HTML
  35.     select '<div class="usercard"><img src="' + dbo.fnGravatar(u.Email, 110, default) + '" class="gravatar" />'        
  36.             + '<div class="info">'
  37.              + '<div class="name">'
  38.                  + u.Name + '<br />'
  39.              + '</div>'
  40.              + '<div class="title">'
  41.                  + (select isnull(t.InfoString, '') from UserInfo t where t.InfoTypeID = 27 and t.UserID = @userID) + '<br />'
  42.    --            + '</div>'            
  43.             --   + 'Mail: <a href="mailto:' + u.Email + '">' + u.Email + '</a><br />'
  44.             --   + 'Phone: ' + (select isnull(p.InfoString, '') from UserInfo p where p.InfoTypeID = 1 and p.UserID = @userID) + '<br />'
  45.             --   + 'Mobile: ' + (select isnull(m.InfoString, '') from UserInfo m where m.InfoTypeID = 3 and m.UserID = @userID)
  46.             --+ '</div>'
  47.            + '</div>' -- , u.Name
  48.     from vwUser u
  49.     left join tbUserData d on d.UserID = u.UserID
  50.     where u.UserID = @userID
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement