copyright and version fixes
[civicrm-core.git] / CRM / Contact / Form / Task / PDF.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 *
34 */
35
36 /**
37 * This class provides the functionality to create PDF letter for a group of
38 * contacts or a single contact.
39 */
40 class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task {
41
42 /**
43 * all the existing templates in the system
44 *
45 * @var array
46 */
47 public $_templates = NULL;
48
49 public $_single = NULL;
50
51 public $_cid = NULL;
52
53 public $_activityId = NULL;
54
55 /**
56 * build all the data structures needed to build the form
57 *
58 * @return void
59 * @access public
60 */
61 function preProcess() {
62
63 $this->skipOnHold = $this->skipDeceased = FALSE;
64 CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
65
66 // store case id if present
67 $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE);
68
69 // retrieve contact ID if this is 'single' mode
70 $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
71
72 if ($cid) {
73 // this is true in non-search context / single mode
74 // in search context 'id' is the default profile id for search display
75 // CRM-11227
76 $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
77 }
78
79 if ($cid) {
80 CRM_Contact_Form_Task_PDFLetterCommon::preProcessSingle($this, $cid);
81 $this->_single = TRUE;
82 $this->_cid = $cid;
83 }
84 else {
85 parent::preProcess();
86 }
87 $this->assign('single', $this->_single);
88 }
89
90 function setDefaultValues() {
91 $defaults = array();
92 if (isset($this->_activityId)) {
93 $params = array('id' => $this->_activityId);
94 CRM_Activity_BAO_Activity::retrieve($params, $defaults);
95 $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults);
96 }
97 $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
98 return $defaults;
99 }
100
101 /**
102 * Build the form
103 *
104 * @access public
105 *
106 * @return void
107 */
108 public function buildQuickForm() {
109 //enable form element
110 $this->assign('suppressForm', FALSE);
111 CRM_Contact_Form_Task_PDFLetterCommon::buildQuickForm($this);
112 }
113
114 /**
115 * process the form after the input has been submitted and validated
116 *
117 * @access public
118 *
119 * @return void
120 */
121 public function postProcess() {
122 CRM_Contact_Form_Task_PDFLetterCommon::postProcess($this);
123 }
124 }
125