public $postAddLocations = false;
public $postAddRecurrences = false;
public $dateRange = "start_time >= now()";
+ public $postFirstAndLastTimes = false;
+ public $postCategories = true;
/**
* Constructor
'use' => 'lged'
),
- // Reference Target - Insert new record and for recall
- 'ref_dest' => array (
- 'field' => 'ref_dest',
- 'type' => 'integer',
- 'use' => 'ilged'
- ),
-
// Ref_name (member name - need to update this to be Reference Type aware)
'ref_dest' => array (
'field' => 'ref_dest',
'use' => 'a'
),
- // Member Name (need to update this to be Reference Type aware
- 'ref_name' => array(
+ // Reference Target ID
+ 'ref_dest_id' => array (
'field' => 'ref_dest',
- 'as' => 'ref_name',
- 'type' => 'pointer',
- 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
- 'p_field' => 'name',
- 'p_static' => true,
- 'use' => ''
+ 'as' => 'ref_dest_id',
+ 'type' => 'integer',
+ 'use' => 'ilged'
),
// Hide Address flag
{
// Get Member Category data for this entry
- $sql = "
- SELECT EC.event AS event_id, C.id, C.name, C.descr,
- COALESCE (
- (
- SELECT name
- FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "categories
- WHERE id = C.parent
- ), ''
- ) AS parent_name
- FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "categories AS C,
- ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "event_categories AS EC
- WHERE C.id = EC.category
- AND EC.event = ".$r['id']."
- ;";
- $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+ if ($this->postCategories) {
+ $sql = "
+ SELECT EC.event AS event_id, C.id, C.name, C.descr,
+ COALESCE (
+ (
+ SELECT name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "categories
+ WHERE id = C.parent
+ ), ''
+ ) AS parent_name
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "categories AS C,
+ ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "event_categories AS EC
+ WHERE C.id = EC.category
+ AND EC.event = ".$r['id']."
+ ;";
+ $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+ }
if ($this->postAddTimes) {
include_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataTimes.php';
}
+ // if List, Get, or Update, and if requested, get the first and last occurances for this event
+ if ($this->postFirstAndLastTimes && in_array($a, array('l', 'g', 'u')) ) {
+ $firstLast = $this->getFirstAndLastTimes($r['id']);
+ $r['firstDate'] = $firstLast['first'];
+ $r['lastDate'] = $firstLast['last'];
+ }
+
return $r;
}
$this->postAddTimes = false;
return $events;
}
+
+
+ /**
+ * Get first and last date/time for an event
+ *
+ * @param integer $id ID of event
+ *
+ * @return array ('first' => {datetime data}, 'last' => {datetime data})
+ */
+ public function getFirstAndLastTimes($id = false)
+ {
+
+ // Load the data class for Event Times
+ require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataTimes.php');
+ $Times = new GlmDataEventsTimes($this->wpdb, $this->config);
+
+ // Select the first and last entries by matching min and max start times
+ $first = $Times->getEntry(0, 'id', "T.event = $id ORDER BY T.start_time");
+ $last = $Times->getEntry(0, 'id', "T.event = $id ORDER BY T.start_time DESC");
+
+ $r = array('first' => date('m/d/Y', $first['start_time']['timestamp']), 'last' => date('m/d/Y', $last['start_time']['timestamp']));
+
+ return $r;
+
+ }
+
+ /**
+ * Get ID/Name list
+ *
+ * @param string $where
+ *
+ * @return array ID/Name pairs
+ */
+ public function getIdName($where = 'true')
+ {
+ $savedFields = $this->fields;
+ $savedCategories = $this->postCategories;
+
+ $this->postCategories = false;
+
+ $this->fields = array(
+ 'id' => $savedFields['id'],
+ 'name' => $savedFields['name']
+ );
+
+ $r = $this->getList($where);
+
+ $this->fields = $savedFields;
+ $this->postCategories = $savedCategories;
+
+ return $r;
+
+ }
+
}
?>