示例#1
0
文件: AJAX.php 项目: hguru/224Civi
 static function getImageProp()
 {
     $img = $_GET['img'];
     list($w, $h) = CRM_Badge_BAO_Badge::getImageProperties($img);
     echo json_encode(array('width' => $w, 'height' => $h));
     CRM_Utils_System::civiExit();
 }
示例#2
0
 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     CRM_Badge_BAO_Badge::buildBadges($params, $this);
 }
示例#3
0
 public static function getImageProp()
 {
     $img = $_GET['img'];
     list($w, $h) = CRM_Badge_BAO_Badge::getImageProperties($img);
     CRM_Utils_JSON::output(array('width' => $w, 'height' => $h));
 }
示例#4
0
 /**
  * Build badges parameters before actually creating badges.
  *
  * @param array $params
  *   Associated array of submitted values.
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildBadges(&$params, &$form)
 {
     // get name badge layout info
     $layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params);
     // split/get actual field names from token and individual contact image URLs
     $returnProperties = array();
     if (!empty($layoutInfo['data']['token'])) {
         foreach ($layoutInfo['data']['token'] as $index => $value) {
             $element = '';
             if ($value) {
                 $token = CRM_Utils_Token::getTokens($value);
                 if (key($token) == 'contact') {
                     $element = $token['contact'][0];
                 } elseif (key($token) == 'event') {
                     $element = $token['event'][0];
                     //FIX ME - we need to standardize event token names
                     if (substr($element, 0, 6) != 'event_') {
                         $element = 'event_' . $element;
                     }
                 } elseif (key($token) == 'participant') {
                     $element = $token['participant'][0];
                 }
                 // build returnproperties for query
                 $returnProperties[$element] = 1;
             }
             // add actual field name to row element
             $layoutInfo['data']['rowElements'][$index] = $element;
         }
     }
     // add additional required fields for query execution
     $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL');
     foreach ($additionalFields as $field) {
         $returnProperties[$field] = 1;
     }
     if ($form->_single) {
         $queryParams = NULL;
     } else {
         $queryParams = $form->get('queryParams');
     }
     $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT);
     list($select, $from, $where, $having) = $query->query();
     if (empty($where)) {
         $where = "WHERE {$form->_componentClause}";
     } else {
         $where .= " AND {$form->_componentClause}";
     }
     $sortOrder = NULL;
     if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
         $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
         if (!empty($sortOrder)) {
             $sortOrder = " ORDER BY {$sortOrder}";
         }
     }
     $queryString = "{$select} {$from} {$where} {$having} {$sortOrder}";
     $dao = CRM_Core_DAO::executeQuery($queryString);
     $rows = array();
     while ($dao->fetch()) {
         $query->convertToPseudoNames($dao);
         $rows[$dao->participant_id] = array();
         foreach ($returnProperties as $key => $dontCare) {
             $value = isset($dao->{$key}) ? $dao->{$key} : NULL;
             // Format custom fields
             if (strstr($key, 'custom_') && isset($value)) {
                 $value = CRM_Core_BAO_CustomField::getDisplayValue($value, substr($key, 7), $query->_options, $dao->contact_id);
             }
             $rows[$dao->participant_id][$key] = $value;
         }
     }
     $eventBadgeClass = new CRM_Badge_BAO_Badge();
     $eventBadgeClass->createLabels($rows, $layoutInfo);
 }
示例#5
0
 public function buildPreview(&$params)
 {
     // get a max participant id
     $participantID = CRM_Core_DAO::singleValueQuery('select max(id) from civicrm_participant');
     if (!$participantID) {
         CRM_Core_Session::setStatus(ts('Preview requires at least one event and one participant record.
    If you are just getting started, you can add a test participant record.'), ts('Preview Requirements'), 'alert');
         return;
     }
     $this->_single = TRUE;
     $this->_participantIds = array($participantID);
     $this->_componentClause = " civicrm_participant.id = {$participantID} ";
     CRM_Badge_BAO_Badge::buildBadges($params, $this);
 }