本文整理汇总了PHP中Sentry::group_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::group_exists方法的具体用法?PHP Sentry::group_exists怎么用?PHP Sentry::group_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::group_exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_search_items
public function get_search_items($group_id = false)
{
// Override group_id if its a search
$group_id = \Input::get('user_group', $group_id);
if ($group_id && \Sentry::group_exists((int) $group_id)) {
// Get only group users
\View::set_global('group', \Sentry::group((int) $group_id));
$items = \Sentry::group((int) $group_id)->users();
} else {
$items = \Sentry::user()->all('admin');
}
// Reset to empty array if there are no result found by query
if (is_null($items)) {
$items = array();
}
// Get user objects
if (!empty($items)) {
foreach ($items as $key => $item) {
$items[$key] = \Sentry::user((int) $item['id']);
}
// Get search filters
foreach (\Input::get() as $key => $value) {
if (!empty($value) || $value == '0') {
switch ($key) {
case 'title':
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
$full_name = $item->get('metadata.first_name') . ' ' . $item->get('metadata.last_name');
if (stripos($full_name, $value) === false) {
unset($items[$number]);
}
}
break;
case 'email':
foreach ($items as $number => $item) {
if (stripos($item->email, $value) === false) {
unset($items[$number]);
}
}
break;
case 'country':
if ($value && $value !== 'false') {
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
if (stripos($item->get('metadata.country'), $value) === false) {
unset($items[$number]);
}
}
}
break;
case 'postcode_from':
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
if ($item->get('metadata.postcode') < $value) {
unset($items[$number]);
}
}
break;
case 'postcode_to':
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
if ($item->get('metadata.postcode') > $value) {
unset($items[$number]);
}
}
break;
}
}
}
}
// Reset to empty array if there are no result found by query
if (is_null($items)) {
$items = array();
}
// Initiate pagination
$pagination = \Hybrid\Pagination::make(array('total_items' => count($items), 'per_page' => \Input::get('per_page', 10), 'uri_segment' => null));
// Remove unwanted items, and show only required ones
$items = array_slice($items, $pagination->offset, $pagination->per_page);
return array('items' => $items, 'pagination' => $pagination);
}
示例2: get_search_customers
public function get_search_customers($group_id = false)
{
// Override group_id if its a search
$group_id = \Input::get('user_group', $group_id);
$activated = \Input::get('activated', false);
if (\Input::get()) {
if ($group_id && \Sentry::group_exists((int) $group_id)) {
// Get only group users
\View::set_global('group', \Sentry::group((int) $group_id));
$items = \Sentry::group((int) $group_id)->users();
} else {
// Get all users and remove admin users from array
$items = \Sentry::user()->all('front');
}
}
// Reset to empty array if there are no result found by query
if (empty($items)) {
$items = array();
}
// Get user objects
if (!empty($items)) {
foreach ($items as $key => $item) {
$items[$key] = \Sentry::user((int) $item['id']);
}
// Get search filters
foreach (\Input::get() as $key => $value) {
if (!empty($value) || $value == '0') {
switch ($key) {
case 'title':
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
$full_name = $item->get('metadata.first_name') . ' ' . $item->get('metadata.last_name');
$customer_id = $item->get('metadata.user_id');
if (stripos($full_name, $value) === false && stripos($customer_id, $value) === false) {
unset($items[$number]);
}
}
break;
case 'email':
foreach ($items as $number => $item) {
if (stripos($item->email, $value) === false) {
unset($items[$number]);
}
}
break;
case 'country':
if ($value && $value !== 'false') {
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
if (stripos($item->get('metadata.country'), $value) === false) {
unset($items[$number]);
}
}
}
break;
case 'postcode_from':
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
if ($item->get('metadata.postcode') < $value) {
unset($items[$number]);
}
}
break;
case 'postcode_to':
foreach ($items as $number => $item) {
if (empty($item['metadata'])) {
unset($items[$number]);
continue;
}
if ($item->get('metadata.postcode') > $value) {
unset($items[$number]);
}
}
break;
case 'activated':
if ($value !== 'false') {
foreach ($items as $number => $item) {
if ($item->activated != $value) {
unset($items[$number]);
}
}
}
break;
}
}
}
}
// Reset to empty array if there are no result found by query
if (empty($items)) {
$items = array();
}
//.........这里部分代码省略.........