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.

print.inc 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/addressbook/print.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2015, The Roundcube Dev Team |
  8. | Copyright (C) 2011-2015, Kolab Systems AG |
  9. | |
  10. | Licensed under the GNU General Public License version 3 or |
  11. | any later version with exceptions for skins & plugins. |
  12. | See the README file for a full license statement. |
  13. | |
  14. | PURPOSE: |
  15. | Print contact details |
  16. | |
  17. +-----------------------------------------------------------------------+
  18. | Author: Thomas Bruederli <roundcube@gmail.com> |
  19. | Author: Aleksander Machniak <machniak@kolabsys.com> |
  20. +-----------------------------------------------------------------------+
  21. */
  22. // Get contact ID and source ID from request
  23. $cids = rcmail_get_cids();
  24. $source = key($cids);
  25. $cid = $cids ? array_shift($cids[$source]) : null;
  26. // Initialize addressbook source
  27. $CONTACTS = rcmail_contact_source($source, true);
  28. $SOURCE_ID = $source;
  29. // read contact record
  30. if ($cid && $CONTACTS) {
  31. $record = $CONTACTS->get_record($cid, true);
  32. }
  33. $OUTPUT->add_handlers(array(
  34. 'contacthead' => 'rcmail_contact_head',
  35. 'contactdetails' => 'rcmail_contact_details',
  36. 'contactphoto' => 'rcmail_contact_photo',
  37. ));
  38. $OUTPUT->send('contactprint');
  39. function rcmail_contact_head($attrib)
  40. {
  41. global $CONTACTS, $RCMAIL;
  42. // check if we have a valid result
  43. if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
  44. $RCMAIL->output->show_message('contactnotfound', 'error');
  45. return false;
  46. }
  47. $form = array(
  48. 'head' => array( // section 'head' is magic!
  49. 'name' => $RCMAIL->gettext('contactnameandorg'),
  50. 'content' => array(
  51. 'prefix' => array(),
  52. 'name' => array(),
  53. 'firstname' => array(),
  54. 'middlename' => array(),
  55. 'surname' => array(),
  56. 'suffix' => array(),
  57. ),
  58. ),
  59. );
  60. unset($attrib['name']);
  61. return rcmail_contact_form($form, $record, $attrib);
  62. }
  63. function rcmail_contact_details($attrib)
  64. {
  65. global $CONTACTS, $RCMAIL, $CONTACT_COLTYPES;
  66. // check if we have a valid result
  67. if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
  68. return false;
  69. }
  70. $i_size = $attrib['size'] ?: 40;
  71. $form = array(
  72. 'contact' => array(
  73. 'name' => $RCMAIL->gettext('properties'),
  74. 'content' => array(
  75. 'organization' => array(),
  76. 'department' => array(),
  77. 'jobtitle' => array(),
  78. 'email' => array(),
  79. 'phone' => array(),
  80. 'address' => array(),
  81. 'website' => array(),
  82. 'im' => array(),
  83. 'groups' => array(),
  84. ),
  85. ),
  86. 'personal' => array(
  87. 'name' => $RCMAIL->gettext('personalinfo'),
  88. 'content' => array(
  89. 'nickname' => array(),
  90. 'gender' => array(),
  91. 'maidenname' => array(),
  92. 'birthday' => array(),
  93. 'anniversary' => array(),
  94. 'manager' => array(),
  95. 'assistant' => array(),
  96. 'spouse' => array(),
  97. ),
  98. ),
  99. );
  100. if (isset($CONTACT_COLTYPES['notes'])) {
  101. $form['notes'] = array(
  102. 'name' => $RCMAIL->gettext('notes'),
  103. 'content' => array(
  104. 'notes' => array('type' => 'textarea', 'label' => false),
  105. ),
  106. );
  107. }
  108. if ($CONTACTS->groups) {
  109. $groups = $CONTACTS->get_record_groups($record['ID']);
  110. if (!empty($groups)) {
  111. $form['contact']['content']['groups'] = array(
  112. 'value' => rcube::Q(implode(', ', $groups)),
  113. 'label' => $RCMAIL->gettext('groups')
  114. );
  115. }
  116. }
  117. return rcmail_contact_form($form, $record);
  118. }