function get_no_of_active_vouchers($user = null) { if (!$user) { $user = elgg_get_logged_in_user_entity(); } $active = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'vouchers', 'container_guid' => $user->guid, 'limit' => 0, 'full_view' => false, 'metadata_name_value_pairs' => array(array('name' => 'valid_until', 'value' => time(), 'operand' => '>')))); $i = 0; foreach ($active as $act) { $voucher_howmany = get_voucher_howmany($act); if (trim($voucher_howmany) == '' || $voucher_howmany > 0) { $i++; } // empty howmany means that number is unlimited, so it's active } return $i; }
$message_to_buyer = elgg_echo('vouchers:messagetobuyer'); } } // retrieve date format from settings $dformat = trim(elgg_get_plugin_setting('default_dateformat', 'vouchers')); if (empty($dformat) || $dformat == '') { $dformat = 'F j, Y'; } if ($vouchers->valid_from) { $date_display_from = date($dformat, $vouchers->valid_from); } else { $date_display_from = false; } // set sold out icon $status = ''; $vouchers_howmany = get_voucher_howmany($vouchers); if (is_numeric($vouchers_howmany) && $vouchers_howmany == 0) { $status = '<img src="' . elgg_get_site_url() . 'mod/vouchers/graphics/soldout.png" width="100" height="76" alt="" class="soldout" />'; } $date_display_until = date($dformat, $vouchers->valid_until); if ($vouchers->valid_until > time()) { $vcode = ''; $print = false; if (elgg_is_logged_in()) { if ((!$vouchers->price || empty($vouchers->price)) && (!$vouchers->points || empty($vouchers->points))) { $buybuttton = getPrintButton($vouchers); $print = true; $vcode = '<div><strong>' . elgg_echo('vouchers:addvoucher:code') . '</strong>: ' . $vouchers->code . '</div>'; $gallerybutton = $buybuttton; } else { if ($isbuyer) {