예제 #1
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     // Initiate CiviCRM
     require_once JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php';
     require_once 'CRM/Core/Config.php';
     $config =& CRM_Core_Config::singleton();
     require_once 'api/v2/Event.php';
     $params = array('is_active' => 1, 'return.title' => 1, 'return.id' => 1, 'return.end_date' => 1, 'return.start_date' => 1);
     $events = civicrm_event_search($params);
     $currentdate = date("Y-m-d H:i:s");
     $options = array();
     $options[] = JHTML::_('select.option', '', JText::_('- Select Event -'));
     foreach ($events as $event) {
         if ($event['start_date'] > $currentdate || $event['end_date'] < $currentdate) {
             $options[] = JHTML::_('select.option', $event['id'], $event['event_title']);
         }
     }
     return JHTML::_('select.genericlist', $options, 'params[id]', null, 'value', 'text', $value);
 }
예제 #2
0
파일: Event.php 프로젝트: bhirsch/voipdev
/**
 * Get an Event.
 * 
 * This api is used to retrieve all data for an existing Event.
 * Required parameters : id of event
 * 
 * @param  array $params  an associative array of title/value property values of civicrm_event
 * 
 * @return  If successful array of event data; otherwise object of CRM_Core_Error.
 * @access public
 */
function civicrm_event_get(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Input parameters is not an array.');
    }
    if (empty($params)) {
        return civicrm_create_error('Params cannot be empty.');
    }
    $event =& civicrm_event_search($params);
    if (count($event) != 1 && !CRM_Utils_Array::value('returnFirst', $params)) {
        return civicrm_create_error(ts('%1 events matching input params', array(1 => count($event))));
    }
    if (civicrm_error($event)) {
        return $event;
    }
    $event = array_values($event);
    $event[0]['is_error'] = 0;
    return $event[0];
}
예제 #3
0
 /**
  *  Test civicrm_event_search with empty params
  */
 function testSearchEmptyParams()
 {
     $params = array();
     $result =& civicrm_event_search($params);
     $this->markTestIncomplete();
 }
예제 #4
0
 /**
  *  Test civicrm_event_search. Success expected.
  *  return.offset and return.max_results test (CRM-5266)
  */
 function testSearchWithOffsetAndMaxResults()
 {
     $maxEvents = 5;
     $events = array();
     while ($maxEvents > 0) {
         $params = array('title' => 'Test Event' . $maxEvents, 'event_type_id' => 2, 'start_date' => 20081021);
         $events[$maxEvents] = civicrm_event_create($params);
         $maxEvents--;
     }
     $params = array('event_type_id' => 2, 'return.id' => 1, 'return.title' => 1, 'return.offset' => 2, 'return.max_results' => 2);
     $result =& civicrm_event_search($params);
     $this->assertEquals(count($result), 2, 'In line ' . __LINE__);
 }