Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/formatting.php on line 4768

EVENTOS
- $event['start'] );
}
/**
* _limit_result_set function
*
* Slice given number of events from list, with exception when all
* events from last day shall be included.
*
* @param array $events List of events to slice
* @param int $limit Number of events to slice-off
* @param bool $last_day Set to true to include all events from last day ignoring {$limit}
*
* @return array Sliced events list
*/
protected function _limit_result_set(
array $events,
$limit,
$last_day
) {
$limited_events = array();
$start_day_previous = 0;
foreach ( $events as $event ) {
$start_day = date(
'Y-m-d',
$event['start']
);
--$limit; // $limit = $limit - 1;
if ( $limit < 0 ) {
if ( true === $last_day ) {
if ( $start_day != $start_day_previous ) {
break;
}
} else {
break;
}
}
$limited_events[] = $event;
$start_day_previous = $start_day;
}
return $limited_events;
}
/**
* _get_post_status_sql function
*
* Returns SQL snippet for properly matching event posts, as well as array
* of arguments to pass to $this_dbi->prepare, in function argument
* references.
* Nothing is returned by the function.
*
* @return array An array containing post_status_where: the sql string,
* args: the arguments for prepare()
*/
protected function _get_post_status_sql() {
$args = array();
// Query the correct post status
if (
current_user_can( 'administrator' ) ||
current_user_can( 'editor' ) ||
current_user_can( 'read_private_ai1ec_events' )
) {
// User has privilege of seeing all published and private
$post_status_where = 'AND post_status IN ( %s, %s ) ';
$args[] = 'publish';
$args[] = 'private';
} elseif ( is_user_logged_in() ) {
// User has privilege of seeing all published and only their own
// private posts.
// Get user ID
$user_id = 0;
if ( is_callable( 'wp_get_current_user' ) ) {
$user = wp_get_current_user();
$user_id = (int)$user->ID;
unset( $user );
}
// include post_status = published
// OR
// post_status = private AND post_author = userID
$post_status_where =
'AND ( ' .
'post_status = %s ' .
'OR ( post_status = %s AND post_author = %d ) ' .
') ';
$args[] = 'publish';
$args[] = 'private';
$args[] = $user_id;
} else {
// User can only see published posts.
$post_status_where = 'AND post_status = %s ';
$args[] = 'publish';
}
return array(
'post_status_where' => $post_status_where,
'args' => $args
);
}
/**
* Take filter and return SQL options.
*
* Takes an array of filtering options and turns it into JOIN and WHERE
* statements for running an SQL query limited to the specified options.
*
* @param array $filter Array of filters for the events returned:
* ['cat_ids'] => list of category IDs
* ['tag_ids'] => list of tag IDs
* ['post_ids'] => list of event post IDs
* ['auth_ids'] => list of event author IDs
* ['instance_ids'] => list of event instance IDs
*
* @return array The modified filter array to having:
* ['filter_join'] the Join statements for the SQL
* ['filter_where'] the Where statements for the SQL
*/
protected function _get_filter_sql( $filter ) {
$filter_join = $filter_where = array();
foreach ( $filter as $filter_type => $filter_ids ) {
$filter_object = null;
try {
if ( empty( $filter_ids ) ) {
$filter_ids = array();
}
$filter_object = $this->_registry->get(
'model.filter.' . $filter_type,
$filter_ids
);
if ( ! ( $filter_object instanceof Ai1ec_Filter_Interface ) ) {
throw new Ai1ec_Bootstrap_Exception(
'Filter \'' . get_class( $filter_object ) .
'\' is not instance of Ai1ec_Filter_Interface'
);
}
} catch ( Ai1ec_Bootstrap_Exception $exception ) {
continue;
}
$filter_join[] = $filter_object->get_join();
$filter_where[] = $filter_object->get_where();
}
$filter_join = array_filter( $filter_join );
$filter_where = array_filter( $filter_where );
$filter_join = join( ' ', $filter_join );
if ( count( $filter_where ) > 0 ) {
$operator = $this->get_distinct_types_operator();
$filter_where = $operator . '( ' .
implode( ' ) ' . $operator . ' ( ', $filter_where ) .
' ) ';
} else {
$filter_where = '';
}
return $filter + compact( 'filter_where', 'filter_join' );
}
/**
* Get operator for joining distinct filters in WHERE.
*
* @return string SQL operator.
*/
public function get_distinct_types_operator() {
static $operators = array( 'AND' => 1, 'OR' => 2 );
$default = 'AND';
$where_operator = strtoupper( trim( (string)apply_filters(
'ai1ec_filter_distinct_types_logic',
$default
) ) );
if ( ! isset( $operators[$where_operator] ) ) {
$where_operator = $default;
}
return $where_operator;
}
}