Exemple #1
0
 /**
  * @param CRM_Core_Form $form
  */
 public static function preProcess(&$form)
 {
     //get multi client case configuration
     $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
     $form->_allowMultiClient = (bool) $xmlProcessorProcess->getAllowMultipleCaseClients();
     if ($form->_context == 'caseActivity') {
         $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form);
         $atype = CRM_Core_OptionGroup::getValue('activity_type', 'Change Case Start Date', 'name');
         $caseId = CRM_Utils_Array::first($form->_caseId);
         $form->assign('changeStartURL', CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$contactID}&caseid={$caseId}&atype={$atype}"));
         return;
     }
     $form->_context = CRM_Utils_Request::retrieve('context', 'String', $form);
     $form->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form);
     $form->assign('context', $form->_context);
     // check if the case type id passed in url is a valid one
     $caseTypeId = CRM_Utils_Request::retrieve('ctype', 'Positive', $form);
     $caseTypes = CRM_Case_PseudoConstant::caseType();
     $form->_caseTypeId = array_key_exists($caseTypeId, $caseTypes) ? $caseTypeId : NULL;
     // check if the case status id passed in url is a valid one
     $caseStatusId = CRM_Utils_Request::retrieve('case_status_id', 'Positive', $form);
     $caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $form->_caseStatusId = array_key_exists($caseStatusId, $caseStatus) ? $caseStatusId : NULL;
     // Add attachments
     CRM_Core_BAO_File::buildAttachment($form, 'civicrm_activity', $form->_activityId);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/case', 'reset=1'));
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->add('text', 'pcp_title', ts('Title'), NULL, TRUE);
     $this->add('textarea', 'pcp_intro_text', ts('Welcome'), NULL, TRUE);
     $this->add('text', 'goal_amount', ts('Your Goal'), NULL, TRUE);
     $this->addRule('goal_amount', ts('Goal Amount should be a numeric value'), 'money');
     $attributes = array();
     if ($this->_component == 'event') {
         if ($this->get('action') & CRM_Core_Action::ADD) {
             $attributes = array('value' => ts('Join Us'), 'onClick' => 'select();');
         }
         $this->add('text', 'donate_link_text', ts('Sign up Button'), $attributes);
     } else {
         if ($this->get('action') & CRM_Core_Action::ADD) {
             $attributes = array('value' => ts('Donate Now'), 'onClick' => 'select();');
         }
         $this->add('text', 'donate_link_text', ts('Donation Button'), $attributes);
     }
     $attrib = array('rows' => 8, 'cols' => 60);
     $this->add('textarea', 'page_text', ts('Your Message'), NULL, FALSE);
     $maxAttachments = 1;
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_pcp', $this->_pageId, $maxAttachments);
     $this->addElement('checkbox', 'is_thermometer', ts('Progress Bar'));
     $this->addElement('checkbox', 'is_honor_roll', ts('Honor Roll'), NULL);
     if ($this->_pageId) {
         $params = array('id' => $this->_pageId);
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
         $owner_notification_option = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id');
     } else {
         $owner_notification_option = CRM_PCP_BAO_PCP::getOwnerNotificationId($this->controller->get('component_page_id'), $this->_component ? $this->_component : 'contribute');
     }
     if ($owner_notification_option == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name')) {
         $this->assign('owner_notification_option', TRUE);
         $this->addElement('checkbox', 'is_notify', ts('Notify me via email when someone donates to my page'), NULL);
     }
     $this->addElement('checkbox', 'is_active', ts('Active'));
     if ($this->_context == 'dashboard') {
         CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/pcp', 'reset=1'));
     }
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_PCP_Form_Campaign', 'formRule'), $this);
 }
Exemple #3
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     require_once 'CRM/Core/OptionGroup.php';
     require_once 'CRM/Grant/BAO/Grant.php';
     $attributes = CRM_Core_DAO::getAttribute('CRM_Grant_DAO_Grant');
     $grantType = CRM_Core_OptionGroup::values('grant_type');
     $this->add('select', 'grant_type_id', ts('Grant Type'), array('' => ts('- select -')) + $grantType, true);
     $grantStatus = CRM_Core_OptionGroup::values('grant_status');
     $this->add('select', 'status_id', ts('Grant Status'), array('' => ts('- select -')) + $grantStatus, true);
     $this->addDate('application_received_date', ts('Application Received'), false, array('formatType' => 'custom'));
     $this->addDate('decision_date', ts('Grant Decision'), false, array('formatType' => 'custom'));
     $this->addDate('money_transfer_date', ts('Money Transferred'), false, array('formatType' => 'custom'));
     $this->addDate('grant_due_date', ts('Grant Report Due'), false, array('formatType' => 'custom'));
     $this->addElement('checkbox', 'grant_report_received', ts('Grant Report Received?'), null);
     $this->add('textarea', 'rationale', ts('Rationale'), $attributes['rationale']);
     $this->add('text', 'amount_total', ts('Amount Requested'), null, true);
     $this->addRule('amount_total', ts('Please enter a valid amount.'), 'money');
     $this->add('text', 'amount_granted', ts('Amount Granted'));
     $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
     $this->add('text', 'amount_requested', ts('Amount Requested<br />(original currency)'));
     $this->addRule('amount_requested', ts('Please enter a valid amount.'), 'money');
     $noteAttrib = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
     $this->add('textarea', 'note', ts('Notes'), $noteAttrib['note']);
     //build custom data
     CRM_Custom_Form_Customdata::buildQuickForm($this);
     // add attachments part
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_grant', $this->_id);
     // make this form an upload since we dont know if the custom data injected dynamically
     // is of type file etc $uploadNames = $this->get( 'uploadNames' );
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => array('onclick' => "return verify( );"), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     if ($this->_context == 'standalone') {
         require_once 'CRM/Contact/Form/NewContact.php';
         CRM_Contact_Form_NewContact::buildQuickForm($this);
         $this->addFormRule(array('CRM_Grant_Form_Grant', 'formRule'), $this);
     }
 }
 /**
  * Build the form object.
  *
  * @param CRM_Core_Form $form
  */
 public static function buildQuickForm(&$form)
 {
     $toArray = $ccArray = $bccArray = array();
     $suppressedEmails = 0;
     //here we are getting logged in user id as array but we need target contact id. CRM-5988
     $cid = $form->get('cid');
     if ($cid) {
         $form->_contactIds = explode(',', $cid);
     }
     if (count($form->_contactIds) > 1) {
         $form->_single = FALSE;
     }
     $emailAttributes = array('class' => 'huge');
     $to = $form->add('text', 'to', ts('To'), $emailAttributes, TRUE);
     $cc = $form->add('text', 'cc_id', ts('CC'), $emailAttributes);
     $bcc = $form->add('text', 'bcc_id', ts('BCC'), $emailAttributes);
     $setDefaults = TRUE;
     if (property_exists($form, '_context') && $form->_context == 'standalone') {
         $setDefaults = FALSE;
     }
     $elements = array('to', 'cc', 'bcc');
     $form->_allContactIds = $form->_toContactIds = $form->_contactIds;
     foreach ($elements as $element) {
         if (${$element}->getValue()) {
             $allEmails = explode(',', ${$element}->getValue());
             if ($element == 'to') {
                 $form->_toContactIds = $form->_contactIds = array();
             }
             foreach ($allEmails as $value) {
                 list($contactId, $email) = explode('::', $value);
                 if ($contactId) {
                     switch ($element) {
                         case 'to':
                             $form->_contactIds[] = $form->_toContactIds[] = $contactId;
                             $form->_toContactEmails[] = $email;
                             break;
                         case 'cc':
                             $form->_ccContactIds[] = $contactId;
                             break;
                         case 'bcc':
                             $form->_bccContactIds[] = $contactId;
                             break;
                     }
                     $form->_allContactIds[] = $contactId;
                 }
             }
             $setDefaults = TRUE;
         }
     }
     //get the group of contacts as per selected by user in case of Find Activities
     if (!empty($form->_activityHolderIds)) {
         $contact = $form->get('contacts');
         $form->_allContactIds = $form->_contactIds = $contact;
     }
     // check if we need to setdefaults and check for valid contact emails / communication preferences
     if (is_array($form->_allContactIds) && $setDefaults) {
         $returnProperties = array('sort_name' => 1, 'email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1, 'display_name' => 1, 'preferred_mail_format' => 1);
         // get the details for all selected contacts ( to, cc and bcc contacts )
         list($form->_contactDetails) = CRM_Utils_Token::getTokenDetails($form->_allContactIds, $returnProperties, FALSE, FALSE);
         // make a copy of all contact details
         $form->_allContactDetails = $form->_contactDetails;
         // perform all validations
         foreach ($form->_allContactIds as $key => $contactId) {
             $value = $form->_contactDetails[$contactId];
             if ($value['do_not_email'] || empty($value['email']) || !empty($value['is_deceased']) || $value['on_hold']) {
                 $suppressedEmails++;
                 // unset contact details for contacts that we won't be sending email. This is prevent extra computation
                 // during token evaluation etc.
                 unset($form->_contactDetails[$contactId]);
             } else {
                 $email = $value['email'];
                 // build array's which are used to setdefaults
                 if (in_array($contactId, $form->_toContactIds)) {
                     $form->_toContactDetails[$contactId] = $form->_contactDetails[$contactId];
                     // If a particular address has been specified as the default, use that instead of contact's primary email
                     if (!empty($form->_toEmail) && $form->_toEmail['contact_id'] == $contactId) {
                         $email = $form->_toEmail['email'];
                     }
                     $toArray[] = array('text' => '"' . $value['sort_name'] . '" <' . $email . '>', 'id' => "{$contactId}::{$email}");
                 } elseif (in_array($contactId, $form->_ccContactIds)) {
                     $ccArray[] = array('text' => '"' . $value['sort_name'] . '" <' . $email . '>', 'id' => "{$contactId}::{$email}");
                 } elseif (in_array($contactId, $form->_bccContactIds)) {
                     $bccArray[] = array('text' => '"' . $value['sort_name'] . '" <' . $email . '>', 'id' => "{$contactId}::{$email}");
                 }
             }
         }
         if (empty($toArray)) {
             CRM_Core_Error::statusBounce(ts('Selected contact(s) do not have a valid email address, or communication preferences specify DO NOT EMAIL, or they are deceased or Primary email address is On Hold.'));
         }
     }
     $form->assign('toContact', json_encode($toArray));
     $form->assign('ccContact', json_encode($ccArray));
     $form->assign('bccContact', json_encode($bccArray));
     $form->assign('suppressedEmails', $suppressedEmails);
     $form->assign('totalSelectedContacts', count($form->_contactIds));
     $form->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', TRUE);
     $form->add('select', 'fromEmailAddress', ts('From'), $form->_fromEmails, TRUE, array('class' => 'crm-select2 huge'));
     CRM_Mailing_BAO_Mailing::commonCompose($form);
     // add attachments
     CRM_Core_BAO_File::buildAttachment($form, NULL);
     if ($form->_single) {
         // also fix the user context stack
         if ($form->_caseId) {
             $ccid = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $form->_caseId, 'contact_id', 'case_id');
             $url = CRM_Utils_System::url('civicrm/contact/view/case', "&reset=1&action=view&cid={$ccid}&id={$form->_caseId}");
         } elseif ($form->_context) {
             $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
         } else {
             $url = CRM_Utils_System::url('civicrm/contact/view', "&show=1&action=browse&cid={$form->_contactIds[0]}&selectedChild=activity");
         }
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
         $form->addDefaultButtons(ts('Send Email'), 'upload', 'cancel');
     } else {
         $form->addDefaultButtons(ts('Send Email'), 'upload');
     }
     $fields = array('followup_assignee_contact_id' => array('type' => 'entityRef', 'label' => ts('Assigned to'), 'attributes' => array('multiple' => TRUE, 'create' => TRUE, 'api' => array('params' => array('is_deceased' => 0)))), 'followup_activity_type_id' => array('type' => 'select', 'label' => ts('Followup Activity'), 'attributes' => array('' => '- ' . ts('select activity') . ' -') + CRM_Core_PseudoConstant::ActivityType(FALSE), 'extra' => array('class' => 'crm-select2')), 'followup_activity_subject' => array('type' => 'text', 'label' => ts('Subject'), 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject')));
     //add followup date
     $form->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
     foreach ($fields as $field => $values) {
         if (!empty($fields[$field])) {
             $attribute = CRM_Utils_Array::value('attributes', $values);
             $required = !empty($values['required']);
             if ($values['type'] == 'select' && empty($attribute)) {
                 $form->addSelect($field, array('entity' => 'activity'), $required);
             } elseif ($values['type'] == 'entityRef') {
                 $form->addEntityRef($field, $values['label'], $attribute, $required);
             } else {
                 $form->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
             }
         }
     }
     $form->addFormRule(array('CRM_Contact_Form_Task_EmailCommon', 'formRule'), $form);
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js', 0, 'html-header');
 }
Exemple #5
0
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 static function buildQuickForm(&$form)
 {
     $toArray = $ccArray = $bccArray = array();
     $suppressedEmails = 0;
     $to = $form->add('text', 'to', ts('To'), '', true);
     $cc = $form->add('text', 'cc_id', ts('CC'));
     $bcc = $form->add('text', 'bcc_id', ts('BCC'));
     $elements = array('cc', 'bcc');
     foreach ($elements as $element) {
         if (${$element}->getValue()) {
             preg_match_all('!"(.*?)"\\s+<\\s*(.*?)\\s*>!', ${$element}->getValue(), $matches);
             $elementValues = array();
             for ($i = 0; $i < count($matches[0]); $i++) {
                 $name = '"' . $matches[1][$i] . '" &lt;' . $matches[2][$i] . '&gt;';
                 $elementValues[] = array('name' => $name, 'id' => $matches[0][$i]);
             }
             $var = "{$element}Contact";
             $form->assign($var, json_encode($elementValues));
         }
     }
     // when form is submitted recompute contactIds
     $allToEmails = array();
     if ($to->getValue()) {
         $allToEmails = explode(',', $to->getValue());
         $form->_contactIds = array();
         foreach ($allToEmails as $value) {
             list($contactId, $email) = explode('::', $value);
             $form->_contactIds[] = $contactId;
             $form->_toContactEmails[] = $email;
         }
     }
     if (is_array($form->_contactIds)) {
         $returnProperties = array('sort_name' => 1, 'email' => 1, 'do_not_email' => 1, 'on_hold' => 1, 'display_name' => 1, 'preferred_mail_format' => 1);
         require_once 'CRM/Mailing/BAO/Mailing.php';
         list($form->_contactDetails) = CRM_Mailing_BAO_Mailing::getDetails($form->_contactIds, $returnProperties, false, false);
         // make a copy of all contact details
         $form->_allContactDetails = $form->_contactDetails;
         foreach ($form->_contactIds as $key => $contactId) {
             $value = $form->_contactDetails[$contactId];
             if ($value['do_not_email'] || empty($value['email']) || $value['is_deceased'] || $value['on_hold']) {
                 $suppressedEmails++;
                 // unset contact details for contacts that we won't be sending email. This is prevent extra computation
                 // during token evaluation etc.
                 unset($form->_contactDetails[$contactId]);
             } else {
                 if (empty($form->_toContactEmails)) {
                     $email = $value['email'];
                 } else {
                     $email = $form->_toContactEmails[$key];
                 }
                 $toArray[] = array('name' => '"' . $value['sort_name'] . '" &lt;' . $email . '&gt;', 'id' => "{$contactId}::{$email}");
             }
         }
         if (empty($toArray)) {
             CRM_Core_Error::statusBounce(ts('Selected contact(s) do not have a valid email address, or communication preferences specify DO NOT EMAIL, or they are deceased or Primary email address is On Hold).'));
         }
     }
     $form->assign('toContact', json_encode($toArray));
     $form->assign('suppressedEmails', $suppressedEmails);
     $form->assign('noEmails', $form->_noEmails);
     $session =& CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
     if (!$fromEmail) {
         CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
     }
     if (!trim($fromDisplayName)) {
         $fromDisplayName = $fromEmail;
     }
     $form->assign('totalSelectedContacts', count($form->_contactIds));
     $from = "{$fromDisplayName} <{$fromEmail}>";
     $form->_fromEmails = array('0' => $from) + CRM_Core_PseudoConstant::fromEmailAddress();
     $form->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', true);
     $selectEmails = $form->_fromEmails;
     foreach (array_keys($selectEmails) as $k) {
         $selectEmails[$k] = htmlspecialchars($selectEmails[$k]);
     }
     $form->add('select', 'fromEmailAddress', ts('From'), $selectEmails, true);
     require_once "CRM/Mailing/BAO/Mailing.php";
     CRM_Mailing_BAO_Mailing::commonCompose($form);
     // add attachments
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($form, null);
     if ($form->_single) {
         // also fix the user context stack
         if ($form->_caseId) {
             $ccid = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $form->_caseId, 'contact_id', 'case_id');
             $url = CRM_Utils_System::url('civicrm/contact/view/case', "&reset=1&action=view&cid={$ccid}&id={$form->_caseId}");
         } else {
             if ($form->_context) {
                 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
             } else {
                 $url = CRM_Utils_System::url('civicrm/contact/view', "&show=1&action=browse&cid={$form->_contactIds[0]}&selectedChild=activity");
             }
         }
         $session->replaceUserContext($url);
         $form->addDefaultButtons(ts('Send Email'), 'upload', 'cancel');
     } else {
         $form->addDefaultButtons(ts('Send Email'), 'upload');
     }
     $form->addFormRule(array('CRM_Contact_Form_Task_EmailCommon', 'formRule'), $form);
 }
Exemple #6
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     $this->add('text', 'title', ts('Title'), null, true);
     $this->add('textarea', 'intro_text', ts('Welcome'), null, true);
     $this->add('text', 'goal_amount', ts('Your Goal'), null, true);
     $this->addRule('goal_amount', ts('Goal Amount should be a numeric value'), 'money');
     $attributes = array();
     if ($this->get('action') & CRM_Core_Action::ADD) {
         $attributes = array('value' => ts('Donate Now'), 'onClick' => 'select();');
     }
     $this->add('text', 'donate_link_text', ts('Donation Button'), $attributes);
     $attrib = array('rows' => 8, 'cols' => 60);
     //        $this->addWysiwyg( 'page_text', ts('Your Message'), $attrib );
     $this->add('textarea', 'page_text', ts('Your Message'), null, false);
     $maxAttachments = 1;
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_pcp', $this->_pageId, $maxAttachments);
     $this->addElement('checkbox', 'is_thermometer', ts('Progress Bar'));
     $this->addElement('checkbox', 'is_honor_roll', ts('Honor Roll'), null);
     $this->addElement('checkbox', 'is_active', ts('Active'));
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_Contribute_Form_PCP_Campaign', 'formRule'), $this);
 }
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Grant_DAO_Grant');
     $this->addSelect('grant_type_id', array('onChange' => "CRM.buildCustomData( 'Grant', this.value );"), TRUE);
     //need to assign custom data type and subtype to the template
     $this->assign('customDataType', 'Grant');
     $this->assign('customDataSubType', $this->_grantType);
     $this->assign('entityID', $this->_id);
     $this->addSelect('status_id', array(), TRUE);
     $this->addDate('application_received_date', ts('Application Received'), FALSE, array('formatType' => 'custom'));
     $this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom'));
     $this->addDate('money_transfer_date', ts('Money Transferred'), FALSE, array('formatType' => 'custom'));
     $this->addDate('grant_due_date', ts('Grant Report Due'), FALSE, array('formatType' => 'custom'));
     $this->addElement('checkbox', 'grant_report_received', ts('Grant Report Received?'), NULL);
     $this->add('textarea', 'rationale', ts('Rationale'), $attributes['rationale']);
     $this->add('text', 'amount_total', ts('Amount Requested'), NULL, TRUE);
     $this->addRule('amount_total', ts('Please enter a valid amount.'), 'money');
     $this->add('text', 'amount_granted', ts('Amount Granted'));
     $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money');
     $this->add('text', 'amount_requested', ts('Amount Requested<br />(original currency)'));
     $this->addRule('amount_requested', ts('Please enter a valid amount.'), 'money');
     $noteAttrib = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note');
     $this->add('textarea', 'note', ts('Notes'), $noteAttrib['note']);
     // add attachments part
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_grant', $this->_id);
     // make this form an upload since we dont know if the custom data injected dynamically
     // is of type file etc $uploadNames = $this->get( 'uploadNames' );
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => array('onclick' => "return verify( );"), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     if ($this->_context == 'standalone') {
         $this->addEntityRef('contact_id', ts('Applicant'), array('create' => TRUE), TRUE);
     }
 }
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 static function buildQuickForm(&$form)
 {
     $toArray = $ccArray = $bccArray = array();
     $suppressedEmails = 0;
     //here we are getting logged in user id as array but we need target contact id. CRM-5988
     $cid = $form->get('cid');
     if ($cid) {
         $form->_contactIds = array($cid);
     }
     $to = $form->add('text', 'to', ts('To'), '', TRUE);
     $cc = $form->add('text', 'cc_id', ts('CC'));
     $bcc = $form->add('text', 'bcc_id', ts('BCC'));
     $elements = array('cc', 'bcc');
     foreach ($elements as $element) {
         if (${$element}->getValue()) {
             preg_match_all('!"(.*?)"\\s+<\\s*(.*?)\\s*>!', ${$element}->getValue(), $matches);
             $elementValues = array();
             for ($i = 0; $i < count($matches[0]); $i++) {
                 $name = '"' . $matches[1][$i] . '" &lt;' . $matches[2][$i] . '&gt;';
                 $elementValues[] = array('name' => $name, 'id' => $matches[0][$i]);
             }
             $var = "{$element}Contact";
             $form->assign($var, json_encode($elementValues));
         }
     }
     $toSetDefault = TRUE;
     if (property_exists($form, '_context') && $form->_context == 'standalone') {
         $toSetDefault = FALSE;
     }
     // when form is submitted recompute contactIds
     $allToEmails = array();
     if ($to->getValue()) {
         $allToEmails = explode(',', $to->getValue());
         $form->_contactIds = array();
         foreach ($allToEmails as $value) {
             list($contactId, $email) = explode('::', $value);
             if ($contactId) {
                 $form->_contactIds[] = $contactId;
                 $form->_toContactEmails[] = $email;
             }
         }
         $toSetDefault = TRUE;
     }
     //get the group of contacts as per selected by user in case of Find Activities
     if (!empty($form->_activityHolderIds)) {
         $contact = $form->get('contacts');
         $form->_contactIds = $contact;
     }
     if (is_array($form->_contactIds) && $toSetDefault) {
         $returnProperties = array('sort_name' => 1, 'email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1, 'display_name' => 1, 'preferred_mail_format' => 1);
         list($form->_contactDetails) = CRM_Utils_Token::getTokenDetails($form->_contactIds, $returnProperties, FALSE, FALSE);
         // make a copy of all contact details
         $form->_allContactDetails = $form->_contactDetails;
         foreach ($form->_contactIds as $key => $contactId) {
             $value = $form->_contactDetails[$contactId];
             if ($value['do_not_email'] || empty($value['email']) || CRM_Utils_Array::value('is_deceased', $value) || $value['on_hold']) {
                 $suppressedEmails++;
                 // unset contact details for contacts that we won't be sending email. This is prevent extra computation
                 // during token evaluation etc.
                 unset($form->_contactDetails[$contactId]);
             } else {
                 if (empty($form->_toContactEmails)) {
                     $email = $value['email'];
                 } else {
                     $email = $form->_toContactEmails[$key];
                 }
                 $toArray[] = array('name' => '"' . $value['sort_name'] . '" &lt;' . $email . '&gt;', 'id' => "{$contactId}::{$email}");
             }
         }
         if (empty($toArray)) {
             CRM_Core_Error::statusBounce(ts('Selected contact(s) do not have a valid email address, or communication preferences specify DO NOT EMAIL, or they are deceased or Primary email address is On Hold.'));
         }
     }
     $form->assign('toContact', json_encode($toArray));
     $form->assign('suppressedEmails', $suppressedEmails);
     $form->assign('totalSelectedContacts', count($form->_contactIds));
     $form->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', TRUE);
     $form->add('select', 'fromEmailAddress', ts('From'), $form->_fromEmails, TRUE);
     CRM_Mailing_BAO_Mailing::commonCompose($form);
     // add attachments
     CRM_Core_BAO_File::buildAttachment($form, NULL);
     if ($form->_single) {
         // also fix the user context stack
         if ($form->_caseId) {
             $ccid = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $form->_caseId, 'contact_id', 'case_id');
             $url = CRM_Utils_System::url('civicrm/contact/view/case', "&reset=1&action=view&cid={$ccid}&id={$form->_caseId}");
         } elseif ($form->_context) {
             $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
         } else {
             $url = CRM_Utils_System::url('civicrm/contact/view', "&show=1&action=browse&cid={$form->_contactIds[0]}&selectedChild=activity");
         }
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
         $form->addDefaultButtons(ts('Send Email'), 'upload', 'cancel');
     } else {
         $form->addDefaultButtons(ts('Send Email'), 'upload');
     }
     $form->addFormRule(array('CRM_Contact_Form_Task_EmailCommon', 'formRule'), $form);
 }
Exemple #9
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', false);
     if ($this->_cdType) {
         $this->assign('cdType', true);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
     $this->assign('atypefile', false);
     if ($this->_atypefile) {
         $this->assign('atypefile', true);
     }
     $this->_addAssigneeContact = CRM_Utils_Array::value('assignee_contact', $_GET);
     $this->assign('addAssigneeContact', false);
     if ($this->_addAssigneeContact) {
         $this->assign('addAssigneeContact', true);
     }
     $this->_addTargetContact = CRM_Utils_Array::value('target_contact', $_GET);
     $this->assign('addTargetContact', false);
     if ($this->_addTargetContact) {
         $this->assign('addTargetContact', true);
     }
     $session =& CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     // this is used for setting jQuery tabs
     if (!$this->_context) {
         $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     }
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('delete activities')) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
         }
     }
     if ($this->_context != 'search') {
         // if we're not adding new one, there must be an id to
         // an activity we're trying to work on.
         if ($this->_action != CRM_Core_Action::ADD) {
             $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
         }
     }
     $this->_currentlyViewedContactId = $this->get('contactId');
     if (!$this->_currentlyViewedContactId) {
         $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     }
     $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
     $this->assign('atype', $this->_activityTypeId);
     if (!$this->_activityTypeId && $this->_activityId) {
         $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
     }
     //Assigning Activity type name
     if ($this->_activityTypeId) {
         require_once 'CRM/Core/OptionGroup.php';
         $activityTName = CRM_Core_OptionGroup::values('activity_type', false, false, false, 'AND v.value = ' . $this->_activityTypeId, 'name');
         if ($activityTName[$this->_activityTypeId]) {
             $this->assign('activityTName', $activityTName[$this->_activityTypeId]);
         }
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
         $this->_single = true;
         $this->assign('urlPath', 'civicrm/activity');
     } else {
         //set the appropriate action
         $advanced = null;
         $builder = null;
         $session =& CRM_Core_Session::singleton();
         $advanced = $session->get('isAdvanced');
         $builder = $session->get('isSearchBuilder');
         $searchType = "basic";
         if ($advanced == 1) {
             $this->_action = CRM_Core_Action::ADVANCED;
             $searchType = "advanced";
         } else {
             if ($advanced == 2 && ($builder = 1)) {
                 $this->_action = CRM_Core_Action::PROFILE;
                 $searchType = "builder";
             } else {
                 if ($advanced == 3) {
                     $searchType = "custom";
                 }
             }
         }
         parent::preProcess();
         $this->_single = false;
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Activity_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $this->assign('action', $this->_action);
     if ($this->_action & CRM_Core_Action::VIEW) {
         // get the tree of custom fields
         $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree("Activity", $this, $this->_activityId, 0, $this->_activityTypeId);
     }
     if ($this->_activityTypeId) {
         //set activity type name and description to template
         require_once 'CRM/Core/BAO/OptionValue.php';
         list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId);
         $this->assign('activityTypeName', $this->_activityTypeName);
         $this->assign('activityTypeDescription', $activityTypeDescription);
     }
     $url = null;
     // set user context
     if (in_array($this->_context, array('standalone', 'home', 'search'))) {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     } else {
         if ($this->_context != 'caseActivity') {
             $url = CRM_Utils_System::url('civicrm/contact/view', "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity");
         }
     }
     if ($url) {
         $session->pushUserContext($url);
     }
     // hack to retrieve activity type id from post variables
     if (!$this->_activityTypeId) {
         $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         // we need to set it in the session for the below code to work
         // CRM-3014
         //need to assign custom data subtype to the template
         $this->set('type', 'Activity');
         $this->set('subType', $this->_activityTypeId);
         $this->set('entityId', $this->_activityId);
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // add attachments part
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_activity', $this->_activityId);
     // figure out the file name for activity type, if any
     if ($this->_activityTypeId && ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir))) {
         require_once "CRM/{$this->_crmDir}/Form/Activity/{$this->_activityTypeFile}.php";
         $this->assign('activityTypeFile', $this->_activityTypeFile);
         $this->assign('crmDir', $this->_crmDir);
     }
     $this->setFields();
     if ($this->_activityTypeFile) {
         eval("CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );");
     }
 }
Exemple #10
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     $this->add('text', 'subject', ts('Subject:'), array('size' => 20));
     $this->add('textarea', 'note', ts('Note:'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note', 'note'), TRUE);
     $this->add('select', 'privacy', ts('Privacy:'), CRM_Core_OptionGroup::values('note_privacy'));
     $this->add('hidden', 'parent_id');
     // add attachments part
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_note', $this->_id, NULL, TRUE);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
function wordmailmerge_civicrm_buildForm($formName, &$form)
{
    require_once 'CRM/Core/DAO/MessageTemplate.php';
    require_once 'CRM/Core/BAO/File.php';
    require_once 'CRM/Core/DAO.php';
    if ($formName == 'CRM_Admin_Form_MessageTemplates') {
        $action = $form->getVar('_action');
        $template = CRM_Core_Smarty::singleton();
        $form->assign('action', $action);
        $templatePath = realpath(dirname(__FILE__) . "/templates");
        $config = CRM_Core_Config::singleton();
        if ($action == CRM_Core_Action::UPDATE) {
            $msgTemplateId = $form->getVar('_defaultValues')['id'];
            $sql = "SELECT * FROM veda_civicrm_wordmailmerge WHERE msg_template_id = %1";
            $params = array(1 => array($msgTemplateId, 'Integer'));
            $dao = CRM_Core_DAO::executeQuery($sql, $params);
            while ($dao->fetch()) {
                $fileId = $dao->file_id;
            }
            if (!empty($fileId)) {
                $mysql = "SELECT * FROM civicrm_file WHERE id = %1";
                $params = array(1 => array($fileId, 'Integer'));
                $dao = CRM_Core_DAO::executeQuery($mysql, $params);
                while ($dao->fetch()) {
                    $default['fileID'] = $dao->id;
                    $default['mime_type'] = $dao->mime_type;
                    $default['fileName'] = $dao->uri;
                    $default['cleanName'] = CRM_Utils_File::cleanFileName($dao->uri);
                    $default['fullPath'] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
                    $default['url'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$dao->id}&eid={$msgTemplateId}");
                    $default['href'] = "<a href=\"{$default['url']}\">{$default['cleanName']}</a>";
                    $default['tag'] = CRM_Core_BAO_EntityTag::getTag($dao->id, 'civicrm_file');
                    $default['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs('civicrm_msg_template', $msgTemplateId, $dao->id);
                }
                $defaults[$dao->id] = $default;
                $form->assign('defaults', $defaults);
            }
        }
        CRM_Core_BAO_File::buildAttachment($form, 'civicrm_msg_template', '', 1);
        $session = CRM_Core_Session::singleton();
        $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'reset=1'));
        CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/CRM/Wordmailmerge/testfield.tpl"));
    }
}
Exemple #12
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     require_once 'CRM/Core/PseudoConstant.php';
     $formEmailAddress = CRM_Core_PseudoConstant::fromEmailAddress('from_email_address');
     if (empty($formEmailAddress)) {
         //redirect user to enter from email address.
         $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'group=from_email_address&action=add&reset=1');
         $status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
         $session->setStatus($status);
     } else {
         foreach ($formEmailAddress as $key => $email) {
             $formEmailAddress[$key] = htmlspecialchars($formEmailAddress[$key]);
         }
     }
     $this->add('select', 'from_email_address', ts('From Email Address'), array('' => '- select -') + $formEmailAddress, true);
     $this->add('text', 'subject', ts('Mailing Subject'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'subject'), true);
     $attributes = array('onclick' => "showHideUpload();");
     $options = array(ts('Upload Content'), ts('Compose On-screen'));
     $this->addRadio('upload_type', ts('I want to'), $options, $attributes, "&nbsp;&nbsp;");
     require_once 'CRM/Mailing/BAO/Mailing.php';
     CRM_Mailing_BAO_Mailing::commonCompose($this);
     $this->addElement('file', 'textFile', ts('Upload TEXT Message'), 'size=30 maxlength=60');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
     $this->addRule('textFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     $this->addElement('file', 'htmlFile', ts('Upload HTML Message'), 'size=30 maxlength=60');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('htmlFile', ts('File size should be less than %1 MByte(s)', array(1 => 1)), 'maxfilesize', 1024 * 1024);
     $this->addRule('htmlFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     //fix upload files when context is search. CRM-3711
     $ssID = $this->get('ssID');
     if ($this->_searchBasedMailing && $ssID) {
         $this->set('uploadNames', array('textFile', 'htmlFile'));
     }
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_mailing', $this->_mailingID);
     require_once 'CRM/Mailing/PseudoConstant.php';
     $this->add('select', 'header_id', ts('Mailing Header'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header'));
     $this->add('select', 'footer_id', ts('Mailing Footer'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer'));
     $this->addFormRule(array('CRM_Mailing_Form_Upload', 'formRule'), $this);
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'upload', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save & Continue Later'), 'subName' => 'save'), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->_searchBasedMailing && $ssID) {
         $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'upload', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     }
     $this->addButtons($buttons);
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', false);
     if ($this->_cdType) {
         $this->assign('cdType', true);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
     $this->assign('atypefile', false);
     if ($this->_atypefile) {
         $this->assign('atypefile', true);
     }
     $this->_addAssigneeContact = CRM_Utils_Array::value('assignee_contact', $_GET);
     $this->assign('addAssigneeContact', false);
     if ($this->_addAssigneeContact) {
         $this->assign('addAssigneeContact', true);
     }
     $this->_addTargetContact = CRM_Utils_Array::value('target_contact', $_GET);
     $this->assign('addTargetContact', false);
     if ($this->_addTargetContact) {
         $this->assign('addTargetContact', true);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     //give the context.
     if (!$this->_context) {
         $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
         require_once 'CRM/Contact/Form/Search.php';
         if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
             $this->_context = 'search';
         }
         $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     }
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('delete activities')) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
         }
     }
     //CRM-6957
     //when we come from contact search, activity id never comes.
     //so don't try to get from object, it might gives you wrong one.
     // if we're not adding new one, there must be an id to
     // an activity we're trying to work on.
     if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
         $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     $this->_currentlyViewedContactId = $this->get('contactId');
     if (!$this->_currentlyViewedContactId) {
         $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     }
     $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
     $this->assign('atype', $this->_activityTypeId);
     //check for required permissions, CRM-6264
     require_once 'CRM/Case/BAO/Case.php';
     if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if (!$this->_activityTypeId && $this->_activityId) {
         $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
     }
     //Assigning Activity type name
     if ($this->_activityTypeId) {
         require_once 'CRM/Core/OptionGroup.php';
         $activityTName = CRM_Core_OptionGroup::values('activity_type', false, false, false, 'AND v.value = ' . $this->_activityTypeId, 'name');
         if ($activityTName[$this->_activityTypeId]) {
             $this->assign('activityTName', $activityTName[$this->_activityTypeId]);
         }
     }
     // Assign pageTitle to be "Activity - "+ activity name
     $pageTitle = 'Activity - ' . CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
     $this->assign('pageTitle', $pageTitle);
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
         $this->_single = true;
         $this->assign('urlPath', 'civicrm/activity');
     } else {
         //set the appropriate action
         $url = CRM_Utils_System::currentPath();
         $seachPath = array_pop(explode('/', $url));
         $searchType = 'basic';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($seachPath) {
             case 'basic':
                 $searchType = $seachPath;
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'advanced':
                 $searchType = $seachPath;
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $searchType = $seachPath;
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'custom':
                 $this->_action = CRM_Core_Action::COPY;
                 $searchType = $seachPath;
                 break;
         }
         parent::preProcess();
         $this->_single = false;
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Activity_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $this->assign('action', $this->_action);
     if ($this->_action & CRM_Core_Action::VIEW) {
         // get the tree of custom fields
         $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Activity', $this, $this->_activityId, 0, $this->_activityTypeId);
     }
     if ($this->_activityTypeId) {
         //set activity type name and description to template
         require_once 'CRM/Core/BAO/OptionValue.php';
         list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId);
         $this->assign('activityTypeName', $this->_activityTypeName);
         $this->assign('activityTypeDescription', $activityTypeDescription);
     }
     // set user context
     $urlParams = $urlString = null;
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     //validate the qfKey
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
         $qfKey = null;
     }
     if ($this->_context == 'fulltext') {
         $keyName = '&qfKey';
         $urlParams = 'force=1';
         $urlString = 'civicrm/contact/search/custom';
         if ($this->_action == CRM_Core_Action::UPDATE) {
             $keyName = '&key';
             $urlParams .= '&context=fulltext&action=view';
             $urlString = 'civicrm/contact/view/activity';
         }
         if ($qfKey) {
             $urlParams .= "{$keyName}={$qfKey}";
         }
         $this->assign('searchKey', $qfKey);
     } else {
         if (in_array($this->_context, array('standalone', 'home'))) {
             $urlParams = 'reset=1';
             $urlString = 'civicrm/dashboard';
         } else {
             if ($this->_context == 'search') {
                 $urlParams = 'force=1';
                 if ($qfKey) {
                     $urlParams .= "&qfKey={$qfKey}";
                 }
                 if ($this->_compContext == 'advanced') {
                     $urlString = 'civicrm/contact/search/advanced';
                 }
                 $this->assign('searchKey', $qfKey);
             } else {
                 if ($this->_context != 'caseActivity') {
                     $urlParams = "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity";
                     $urlString = 'civicrm/contact/view';
                 }
             }
         }
     }
     if ($urlString) {
         $session->pushUserContext(CRM_Utils_System::url($urlString, $urlParams));
     }
     // hack to retrieve activity type id from post variables
     if (!$this->_activityTypeId) {
         $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         // we need to set it in the session for the below code to work
         // CRM-3014
         //need to assign custom data subtype to the template
         $this->set('type', 'Activity');
         $this->set('subType', $this->_activityTypeId);
         $this->set('entityId', $this->_activityId);
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // add attachments part
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_activity', $this->_activityId);
     // figure out the file name for activity type, if any
     if ($this->_activityTypeId && ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir))) {
         require_once "CRM/{$this->_crmDir}/Form/Activity/{$this->_activityTypeFile}.php";
         $this->assign('activityTypeFile', $this->_activityTypeFile);
         $this->assign('crmDir', $this->_crmDir);
     }
     $this->setFields();
     if ($this->_activityTypeFile) {
         eval("CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );");
     }
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     $config = CRM_Core_Config::singleton();
     $options = array();
     $tempVar = FALSE;
     // this seems so hacky, not sure what we are doing here and why. Need to investigate and fix
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$this->controller->_key}");
     $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
     if (empty($fromEmailAddress)) {
         //redirect user to enter from email address.
         $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'action=add&reset=1');
         $status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
         $session->setStatus($status, ts('Notice'));
     } else {
         foreach ($fromEmailAddress as $key => $email) {
             $fromEmailAddress[$key] = htmlspecialchars($fromEmailAddress[$key]);
         }
     }
     $this->add('select', 'from_email_address', ts('From Email Address'), array('' => '- select -') + $fromEmailAddress, TRUE);
     //Added code to add custom field as Reply-To on form when it is enabled from Mailer settings
     if ((int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo') && empty($options['override_verp'])) {
         $this->add('select', 'reply_to_address', ts('Reply-To'), array('' => '- select -') + $fromEmailAddress);
     } elseif (!empty($options['override_verp'])) {
         $trackReplies = TRUE;
         $this->assign('trackReplies', $trackReplies);
     }
     $this->add('text', 'subject', ts('Mailing Subject'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'subject'), TRUE);
     $attributes = array('onclick' => "showHideUpload();");
     $options = array(ts('Upload Content'), ts('Compose On-screen'));
     $this->addRadio('upload_type', ts('I want to'), $options, $attributes, "&nbsp;&nbsp;");
     CRM_Mailing_BAO_Mailing::commonCompose($this);
     $this->addElement('file', 'textFile', ts('Upload TEXT Message'), 'size=30 maxlength=60');
     $this->addUploadElement('textFile');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
     $this->addRule('textFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     $this->addElement('file', 'htmlFile', ts('Upload HTML Message'), 'size=30 maxlength=60');
     $this->addUploadElement('htmlFile');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('htmlFile', ts('File size should be less than %1 MByte(s)', array(1 => 1)), 'maxfilesize', 1024 * 1024);
     $this->addRule('htmlFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     //fix upload files when context is search. CRM-3711
     $ssID = $this->get('ssID');
     if ($this->_searchBasedMailing && $ssID) {
         $this->set('uploadNames', array('textFile', 'htmlFile'));
     }
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_mailing', $this->_mailingID);
     $this->add('select', 'header_id', ts('Mailing Header'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header'));
     $this->add('select', 'footer_id', ts('Mailing Footer'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer'));
     $this->addFormRule(array('CRM_Mailing_Form_Upload', 'formRule'), $this);
     $buttons = array(array('type' => 'back', 'name' => ts('Previous')), array('type' => 'upload', 'name' => ts('Next'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save & Continue Later'), 'subName' => 'save'), array('type' => 'cancel', 'name' => ts('Cancel')));
     $this->addButtons($buttons);
 }
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $this->add('text', 'pcp_title', ts('Title'), NULL, TRUE);
     $this->add('textarea', 'pcp_intro_text', ts('Welcome'), NULL, TRUE);
     $this->add('text', 'goal_amount', ts('Your Goal'), NULL, TRUE);
     $this->addRule('goal_amount', ts('Goal Amount should be a numeric value'), 'money');
     $attributes = array();
     if ($this->_component == 'event') {
         if ($this->get('action') & CRM_Core_Action::ADD) {
             $attributes = array('value' => ts('Join Us'), 'onClick' => 'select();');
         }
         $this->add('text', 'donate_link_text', ts('Sign up Button'), $attributes);
     } else {
         if ($this->get('action') & CRM_Core_Action::ADD) {
             $attributes = array('value' => ts('Donate Now'), 'onClick' => 'select();');
         }
         $this->add('text', 'donate_link_text', ts('Donation Button'), $attributes);
     }
     $attrib = array('rows' => 8, 'cols' => 60);
     $this->add('textarea', 'page_text', ts('Your Message'), null, false);
     $maxAttachments = 1;
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_pcp', $this->_pageId, $maxAttachments);
     //MV: added the custom fields in PCP form
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     //end
     $this->addElement('checkbox', 'is_thermometer', ts('Progress Bar'));
     $this->addElement('checkbox', 'is_honor_roll', ts('Honor Roll'), NULL);
     $this->addElement('checkbox', 'is_active', ts('Active'));
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_PCP_Form_Campaign', 'formRule'), $this);
 }
 /**
  * Build the form object.
  */
 public function preProcess()
 {
     CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
     $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
     $this->assign('atypefile', FALSE);
     if ($this->_atypefile) {
         $this->assign('atypefile', TRUE);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     $this->_currentlyViewedContactId = $this->get('contactId');
     if (!$this->_currentlyViewedContactId) {
         $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     }
     $this->assign('contactId', $this->_currentlyViewedContactId);
     // Give the context.
     if (!isset($this->_context)) {
         $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
         if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
             $this->_context = 'search';
         } elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) {
             $this->_context = 'activity';
         }
         $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     }
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('delete activities')) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
     }
     // CRM-6957
     // When we come from contact search, activity id never comes.
     // So don't try to get from object, it might gives you wrong one.
     // if we're not adding new one, there must be an id to
     // an activity we're trying to work on.
     if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
         $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
     $this->assign('atype', $this->_activityTypeId);
     $this->assign('activityId', $this->_activityId);
     // Check for required permissions, CRM-6264.
     if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) {
         $this->assign('permission', 'edit');
     }
     if (!$this->_activityTypeId && $this->_activityId) {
         $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
     }
     // Assigning Activity type name.
     if ($this->_activityTypeId) {
         $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
         if ($activityTName[$this->_activityTypeId]) {
             $this->_activityTypeName = $activityTName[$this->_activityTypeId];
             $this->assign('activityTName', $activityTName[$this->_activityTypeId]);
         }
     }
     // Set title.
     if (isset($activityTName)) {
         $activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
         $this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
         if ($this->_currentlyViewedContactId) {
             $displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
             // Check if this is default domain contact CRM-10482.
             if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) {
                 $displayName .= ' (' . ts('default organization') . ')';
             }
             CRM_Utils_System::setTitle($displayName . ' - ' . $activityName);
         } else {
             CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName)));
         }
     }
     // Check the mode when this form is called either single or as
     // search task action.
     if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/activity');
     } else {
         // Set the appropriate action.
         $url = CRM_Utils_System::currentPath();
         $urlArray = explode('/', $url);
         $searchPath = array_pop($urlArray);
         $searchType = 'basic';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($searchPath) {
             case 'basic':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'advanced':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'custom':
                 $this->_action = CRM_Core_Action::COPY;
                 $searchType = $searchPath;
                 break;
         }
         parent::preProcess();
         $this->_single = FALSE;
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Activity_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $this->assign('action', $this->_action);
     if ($this->_action & CRM_Core_Action::VIEW) {
         // Get the tree of custom fields.
         $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Activity', $this, $this->_activityId, 0, $this->_activityTypeId);
     }
     if ($this->_activityTypeId) {
         // Set activity type name and description to template.
         list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId);
         $this->assign('activityTypeName', $this->_activityTypeName);
         $this->assign('activityTypeDescription', $activityTypeDescription);
     }
     // set user context
     $urlParams = $urlString = NULL;
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     if (!$qfKey) {
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     }
     // Validate the qfKey.
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
         $qfKey = NULL;
     }
     if ($this->_context == 'fulltext') {
         $keyName = '&qfKey';
         $urlParams = 'force=1';
         $urlString = 'civicrm/contact/search/custom';
         if ($this->_action == CRM_Core_Action::UPDATE) {
             $keyName = '&key';
             $urlParams .= '&context=fulltext&action=view';
             $urlString = 'civicrm/contact/view/activity';
         }
         if ($qfKey) {
             $urlParams .= "{$keyName}={$qfKey}";
         }
         $this->assign('searchKey', $qfKey);
     } elseif (in_array($this->_context, array('standalone', 'home', 'dashlet', 'dashletFullscreen'))) {
         $urlParams = 'reset=1';
         $urlString = 'civicrm/dashboard';
     } elseif ($this->_context == 'search') {
         $urlParams = 'force=1';
         if ($qfKey) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $path = CRM_Utils_System::currentPath();
         if ($this->_compContext == 'advanced') {
             $urlString = 'civicrm/contact/search/advanced';
         } elseif ($path == 'civicrm/group/search' || $path == 'civicrm/contact/search' || $path == 'civicrm/contact/search/advanced' || $path == 'civicrm/contact/search/custom' || $path == 'civicrm/group/search') {
             $urlString = $path;
         } else {
             $urlString = 'civicrm/activity/search';
         }
         $this->assign('searchKey', $qfKey);
     } elseif ($this->_context != 'caseActivity') {
         $urlParams = "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity";
         $urlString = 'civicrm/contact/view';
     }
     if ($urlString) {
         $session->pushUserContext(CRM_Utils_System::url($urlString, $urlParams));
     }
     // hack to retrieve activity type id from post variables
     if (!$this->_activityTypeId) {
         $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         // We need to set it in the session for the code below to work.
         // CRM-3014
         // Need to assign custom data subtype to the template.
         $this->set('type', 'Activity');
         $this->set('subType', $this->_activityTypeId);
         $this->set('entityId', $this->_activityId);
         CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity', $this->_activityId);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // add attachments part
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_activity', $this->_activityId, NULL, TRUE);
     // figure out the file name for activity type, if any
     if ($this->_activityTypeId && ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir))) {
         $this->assign('activityTypeFile', $this->_activityTypeFile);
         $this->assign('crmDir', $this->_crmDir);
     }
     $this->setFields();
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $className::preProcess($this);
     }
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
         $this->_values = array();
         if (isset($this->_activityId) && $this->_activityId) {
             $params = array('id' => $this->_activityId);
             CRM_Activity_BAO_Activity::retrieve($params, $this->_values);
         }
         $this->set('values', $this->_values);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
     }
 }
Exemple #17
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     $this->applyFilter('__ALL__', 'trim');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Auction_DAO_Item');
     $this->add('text', 'title', ts('Item Label'), $attributes['title'], true);
     $this->addWysiwyg('description', ts('Complete Description'), $attributes['description']);
     $auctionTypes = CRM_Core_OptionGroup::values('auction_item_type');
     $this->add('select', 'auction_item_type_id', ts('Item Type'), array('' => ts('- select -')) + $auctionTypes);
     $this->add('text', 'url', ts('Item URL'), array_merge($attributes['description'], array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false")));
     $this->_checkboxes = array('is_active' => ts('Is Active?'), 'is_group' => ts('Does this item have other items associated with it?'));
     foreach ($this->_checkboxes as $name => $title) {
         $this->addElement('checkbox', $name, $title);
     }
     $this->_numbers = array('quantity' => ts('Number of units available'), 'retail_value' => ts('Retail value of item'), 'min_bid_value' => ts('Minimum bid accepted'), 'min_bid_increment' => ts('Minimum bid increment'), 'buy_now_value' => ts('Buy it now value'));
     foreach ($this->_numbers as $name => $title) {
         $this->addElement('text', $name, $title, $attributes[$name]);
         if ($name == 'quantity') {
             $this->addRule($name, ts('%1 should be a postive number', array(1 => $title)), 'positiveInteger');
         } else {
             $this->addRule($name, ts('%1 should be a valid money value', array(1 => $title)), 'money');
         }
     }
     $maxAttachments = 1;
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_pcp', $this->_pageId, $maxAttachments);
     if ($this->_action & CRM_Core_Action::VIEW) {
         $buttons = array(array('type' => 'upload', 'name' => ts('Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true));
         $this->freeze();
     } else {
         if ($this->_action & CRM_Core_Action::DELETE) {
             $this->freeze();
             $buttons = array(array('type' => 'upload', 'name' => ts('Delete'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
         } else {
             $buttons = array(array('type' => 'upload', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true));
             $session =& CRM_Core_Session::singleton();
             if ($session->get('userID')) {
                 $buttons[] = array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new');
             }
             $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
         }
     }
     $this->addButtons($buttons);
     $this->addFormRule(array('CRM_Auction_Form_Item', 'formRule'), $this);
 }