You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.7 KiB

15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
  1. <?php
  2. /**
  3. * @file Profile.php
  4. * This file is part of MOVIM.
  5. *
  6. * @brief The Profile widget
  7. *
  8. * @author Timothée Jaussoin <edhelas_at_gmail_dot_com>
  9. *
  10. * @version 1.0
  11. * @date 20 October 2010
  12. *
  13. * Copyright (C)2010 MOVIM project
  14. *
  15. * See COPYING for licensing information.
  16. */
  17. class Profile extends Widget
  18. {
  19. function WidgetLoad()
  20. {
  21. $this->addcss('profile.css');
  22. $this->addjs('profile.js');
  23. $this->registerEvent('vcardreceived', 'onVcardReceived');
  24. }
  25. function onVcardReceived($vcard)
  26. {
  27. $html = $this->prepareVcard($vcard);
  28. MovimRPC::call('movim_fill', 'avatar', MovimRPC::cdata($html));
  29. }
  30. function prepareVcard($vcard) {
  31. $html = '<img alt="' . t("Your avatar") . '" style="width: 60px;" src="data:'.
  32. $vcard['vCardPhotoType'] . ';base64,' . $vcard['vCardPhotoBinVal'] . '" />'
  33. .'<div id="infos">'.$vcard['vCardNickname'].'<br />'.$vcard['vCardFN'].'</div>';
  34. return $html;
  35. }
  36. function ajaxRefreshVcard($jid = false)
  37. {
  38. $user = new User();
  39. $xmpp = XMPPConnect::getInstance($user->getLogin());
  40. $xmpp->getVCard($jid); // We send the vCard request
  41. }
  42. function ajaxPresence($presence)
  43. {
  44. $user = new User();
  45. $xmpp = XMPPConnect::getInstance($user->getLogin());
  46. $xmpp->setStatus(false, $presence);
  47. }
  48. function build()
  49. {
  50. ?>
  51. <div id="profile">
  52. <div class="config_button" onclick="<?php $this->callAjax('ajaxRefreshVcard', "'".$_GET['f']."'");?>"></div>
  53. <div id="avatar">
  54. <?php
  55. if(isset($_GET['f']))
  56. echo $this->prepareVcard(movim_cache('vcard'.$_GET['f']));
  57. else {
  58. $user = new User();
  59. echo $this->prepareVcard(movim_cache('vcard'));
  60. }
  61. ?>
  62. </div>
  63. </div>
  64. <?php
  65. }
  66. }
  67. ?>