コード例 #1
0
ファイル: PCP.php プロジェクト: kidaa30/yes
 /**
  * Add PCP form elements to a form.
  *
  * @param int $pcpId
  * @param CRM_Core_Page $page
  * @param null $elements
  */
 public static function buildPcp($pcpId, &$page, &$elements = NULL)
 {
     $prms = array('id' => $pcpId);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
     if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) {
         if ($pcpInfo['page_type'] == 'event') {
             $pcp_supporter_text = ts('This event registration is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event');
             if (!empty($text)) {
                 $pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!";
             }
         } else {
             $pcp_supporter_text = ts('This contribution is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute');
             if (!empty($text)) {
                 $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!";
             }
         }
         $page->assign('pcpSupporterText', $pcp_supporter_text);
     }
     $page->assign('pcp', TRUE);
     // build honor roll fields for registration form if supporter has honor roll enabled for their PCP
     if ($pcpInfo['is_honor_roll']) {
         $page->assign('is_honor_roll', TRUE);
         $page->add('checkbox', 'pcp_display_in_roll', ts('Show my support in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
         $extraOption = array('onclick' => "return pcpAnonymous( );");
         $elements = array();
         $elements[] =& $page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption);
         $page->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
         $page->_defaults['pcp_is_anonymous'] = 0;
         $page->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $page->add('textarea', "pcp_personal_note", ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     } else {
         $page->assign('is_honor_roll', FALSE);
     }
 }