您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // misc user functions
  2. wn.user_info = function(uid) {
  3. var def = {
  4. 'fullname':uid,
  5. 'image': 'lib/images/ui/avatar.png'
  6. }
  7. if(!wn.boot.user_info) return def
  8. if(!wn.boot.user_info[uid]) return def
  9. if(!wn.boot.user_info[uid].fullname)
  10. wn.boot.user_info[uid].fullname = uid;
  11. if(!wn.boot.user_info[uid].image)
  12. wn.boot.user_info[uid].image = def.image;
  13. return wn.boot.user_info[uid];
  14. }
  15. wn.avatar = function(user, large, title) {
  16. var image = wn.user_info(user).image;
  17. var to_size = large ? 72 : 30;
  18. if(!title) title = wn.user_info(user).fullname;
  19. return repl('<span class="avatar" title="%(title)s" style="width: %(len)s; \
  20. height: %(len)s; border-radius: %(len)s; overflow: hidden;">\
  21. <img src="%(image)s"></span>', {
  22. image: image,
  23. len: to_size + "px",
  24. title: title
  25. });
  26. }
  27. wn.provide('wn.user');
  28. $.extend(wn.user, {
  29. name: (wn.boot ? wn.boot.profile.name : 'Guest'),
  30. has_role: function(rl) {
  31. if(typeof rl=='string')
  32. rl = [rl];
  33. for(var i in rl) {
  34. if((wn.boot ? wn.boot.profile.roles : ['Guest']).indexOf(rl[i])!=-1)
  35. return true;
  36. }
  37. },
  38. is_report_manager: function() {
  39. return wn.user.has_role(['Administrator', 'System Manager', 'Report Manager']);
  40. }
  41. })
  42. // wn.session_alive is true if user shows mouse movement in 30 seconds
  43. wn.session_alive = true;
  44. $(document).bind('mousemove', function() {
  45. wn.session_alive = true;
  46. if(wn.session_alive_timeout)
  47. clearTimeout(wn.session_alive_timeout);
  48. wn.session_alive_timeout = setTimeout('wn.session_alive=false;', 30000);
  49. })