本文整理汇总了PHP中Group::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::current方法的具体用法?PHP Group::current怎么用?PHP Group::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
if (!Group::current('allow_assign')) {
throw new HTTP_Exception_403();
}
}
示例2: before
public function before()
{
if (!User::current()) {
$this->redirect('/login');
}
$url = str_replace('.', '_', URL::base() . $this->request->uri());
if (isset($_GET[$url])) {
unset($_GET[$url]);
}
if (isset($_GET[$url . '/'])) {
unset($_GET[$url . '/']);
}
if (Group::current('is_admin') || Group::current('show_all_jobs') && Group::current('allow_finance')) {
Pager::$counts[] = 2500;
}
if (Arr::get($_GET, 'limit') && in_array($_GET['limit'], Pager::$counts)) {
DB::update('users')->set(array('list_items' => intval($_GET['limit'])))->where('id', '=', User::current('id'))->execute();
die(json_encode(array('success' => 'true')));
}
if (Arr::get($_GET, 'dismiss')) {
DB::delete('notifications')->where('user_id', '=', User::current('id'))->and_where('id', '=', intval($_GET['dismiss']))->execute();
die(json_encode(array('success' => 'true')));
}
if (!Group::current('allow_assign')) {
Enums::$statuses[Enums::STATUS_UNALLOC] = 'Not active';
}
View::set_global('notifications', DB::select()->from('notifications')->where('user_id', '=', User::current('id'))->order_by('id', 'desc')->execute());
}
示例3: before
public function before()
{
parent::before();
if (!Group::current('allow_finance') || !Group::current('show_all_jobs')) {
throw new HTTP_Exception_403('Forbidden');
}
}
示例4: action_index
public function action_index()
{
$id = intval($this->request->param('id'));
$attachment = DB::select()->from('attachments')->where('id', '=', $id)->execute()->current();
if (!preg_match('/^image\\/.*$/i', $attachment['mime']) || $attachment['folder'] == 'Signatures') {
throw new HTTP_Exception_403('Forbidden');
}
$job = Database_Mongo::collection('jobs')->findOne(array('_id' => strval($attachment['job_id'])));
if (!$job) {
throw new HTTP_Exception_404('Not found');
}
if (!Group::current('show_all_jobs') && !in_array((int) User::current('company_id'), Arr::get($job, 'companies', array()), true) && !in_array((int) User::current('company_id'), Arr::get($job, 'ex', array()), true)) {
throw new HTTP_Exception_403('Forbidden');
}
if (!file_exists(DOCROOT . 'storage/' . $id)) {
throw new HTTP_Exception_404('Not found');
}
list(, $data) = explode(',', file_get_contents('php://input'), 2);
$src = imagecreatefromstring(file_get_contents(DOCROOT . 'storage/' . $id));
$image = imagecreatefromstring(base64_decode($data));
imagealphablending($src, true);
imagesavealpha($src, true);
imagecopyresampled($src, $image, 0, 0, 0, 0, imagesx($src), imagesy($src), imagesx($image), imagesy($image));
if ($attachment['mime'] == 'image/png') {
imagepng($src, DOCROOT . 'storage/' . $id, 9);
} else {
imagejpeg($src, DOCROOT . 'storage/' . $id, 90);
}
if (file_exists(DOCROOT . 'storage/' . $id . '.thumb')) {
unlink(DOCROOT . 'storage/' . $id . '.thumb');
}
imagedestroy($src);
imagedestroy($image);
die(json_encode(array('success' => true)));
}
示例5: before
public function before()
{
if (!Group::current('allow_reports')) {
throw new HTTP_Exception_403('Forbidden');
}
parent::before();
}
示例6: action_fda
public function action_fda()
{
$query = array();
if (!Group::current('allow_assign')) {
$query['$or'] = array(array('companies' => intval(User::current('company_id'))), array('ex' => intval(User::current('company_id'))));
} else {
if (Arr::get($_GET, 'company')) {
$company = is_array($_GET['company']) ? $_GET['company'] : explode(',', $_GET['company']);
$company = array_map('intval', $company);
if (count($company) == 1) {
$company = array_shift($company);
}
$query['$or'] = array(array('companies' => is_array($company) ? array('$in' => $company) : $company), array('ex' => is_array($company) ? array('$in' => $company) : $company));
}
if (Arr::get($_GET, 'region')) {
$query['region'] = strval($_GET['region']);
}
}
if (Arr::get($_GET, 'fsam')) {
$fsam = is_array($_GET['fsam']) ? array_map('strval', $_GET['fsam']) : explode(',', $_GET['fsam']);
$query['data.13'] = count($fsam) == 1 ? array_shift($fsam) : array('$in' => $fsam);
}
$list = Database_Mongo::collection('jobs')->distinct('data.14', $query ?: NULL);
sort($list);
die(json_encode($list));
}
示例7: action_index
public function action_index()
{
if (!Group::current('allow_assign')) {
throw new HTTP_Exception_403('Forbidden');
}
$ids = array_keys(Arr::get($_POST, 'job', array()));
if (!$ids) {
Messages::save('Please, select at least one job!');
} else {
$jobs = Database_Mongo::collection('jobs');
$result = $jobs->find(array('_id' => array('$in' => $ids)));
$count = 0;
foreach ($result as $job) {
if (Arr::get($job, 'status') == Enums::STATUS_ARCHIVE || Arr::get($job, 'status') == Enums::STATUS_COMPLETE || Arr::get($job, 'status') == Enums::STATUS_PENDING) {
if ($job['status'] == Enums::STATUS_PENDING) {
$submissions = Database_Mongo::collection('submissions')->find(array('job_key' => $job['_id'], 'active' => 1))->count();
if ($submissions) {
continue;
}
}
$update = array('$set' => array('last_update' => time()));
if (Arr::get($job, 'assigned')) {
$update['$set']['status'] = Enums::STATUS_ALLOC;
} else {
$update['$unset']['status'] = 1;
}
$jobs->update(array('_id' => $job['_id']), $update);
$count++;
}
}
Messages::save($count . ' jobs were succesfully reset to initial state', 'success');
}
$this->redirect('/search');
}
示例8: before
public function before()
{
parent::before();
if (!Group::current('is_admin')) {
throw new HTTP_Exception_403('Forbidden');
}
}
示例9: action_index
public function action_index()
{
if (!Group::current('allow_assign')) {
throw new HTTP_Exception_403('Forbidden');
}
$ids = array_keys(Arr::get($_POST, 'job', array()));
if (!$ids) {
Messages::save('Please, select at least one job!');
} else {
$jobs = Database_Mongo::collection('jobs');
$submissions = Database_Mongo::collection('submissions')->distinct('job_key', array('job_key' => array('$in' => $ids), 'active' => 1));
$ids = array_values(array_diff($ids, $submissions));
$result = Database_Mongo::collection('jobs')->find(array('_id' => array('$in' => $ids)));
print_r($result->explain());
$count = 0;
foreach ($result as $job) {
if (!in_array(Arr::get($job, 'status'), array(Enums::STATUS_ARCHIVE, Enums::STATUS_COMPLETE))) {
$jobs->update(array('_id' => $job['_id']), array('$set' => array('last_update' => time(), 'status' => Enums::STATUS_COMPLETE)));
$count++;
}
}
Messages::save($count . ' jobs were succesfully completed', 'success');
}
$this->redirect('/search');
}
示例10: before
public function before()
{
parent::before();
if (!Group::current('is_admin')) {
throw new HTTP_Exception_403('Forbidden');
}
ini_set('memory_limit', -1);
}
示例11: action_delete
public function action_delete()
{
if (!User::current('is_admin') && !Group::current('item_remove')) {
throw new HTTP_Exception_403('Forbidden');
}
$id = $this->request->param('id');
DB::delete('items')->where('id', '=', $id)->execute();
Messages::save('Item was successfully deleted!', 'info');
$this->redirect('/items');
}
示例12: action_index
public function action_index()
{
$items = DB::select(DB::expr('COUNT(*) as cnt'), DB::expr('COALESCE(`status`, "unattached") as status'))->from('unit_items')->join('tasks', 'left')->on('task_id', '=', 'tasks.id')->group_by('status');
if (!User::current('is_admin') && !Group::current('all_projects')) {
$items->where('company_id', '=', User::current('company_id'));
}
$items = $items->execute()->as_array('status', 'cnt');
$view = View::factory('Dashboard')->bind('items', $items);
$this->response->body($view);
}
示例13: get_results
private function get_results($all = false)
{
$archive = Database_Mongo::collection('archive');
$filters = array();
if (Arr::get($_GET, 'action')) {
if ($_GET['action'] == 2 && !Group::current('is_admin')) {
$show = array_keys(Columns::get_visible());
$filters['fields'] = array('$in' => $show);
}
$filters['update_type'] = intval($_GET['action']);
}
if (Arr::get($_GET, 'ticket')) {
$filters['job_key'] = $_GET['ticket'];
}
if (Arr::get($_GET, 'file')) {
$filters['filename'] = $_GET['file'];
}
if (Arr::get($_GET, 'start')) {
$start = strtotime($_GET['start']);
$filters['update_time']['$gt'] = $start;
}
if (isset($filters['end'])) {
$end = strtotime($_GET['end']);
$filters['update_time']['$lt'] = $end;
}
$filters = $filters ? array(array('$match' => $filters)) : array();
$filters[] = array('$sort' => array('update_time' => -1, 'job_key' => 1));
if (!$all) {
$count = Database_Mongo::collection('archive')->find(Arr::path($filters, '0.$match', array()))->count();
Pager::$count = $count;
$filters[] = array('$skip' => Pager::offset());
$filters[] = array('$limit' => Pager::limit());
}
$result = $archive->aggregateCursor($filters, array('allowDiskUse' => true));
$list = array();
$ids = array();
foreach ($result as $row) {
$list[] = $row;
$ids[$row['job_key']] = 1;
}
$result = Database_Mongo::collection('jobs')->find(array('_id' => array('$in' => array_keys($ids))));
$jobs = array();
foreach ($result as $job) {
$jobs[$job['_id']] = Arr::get($job, 'data');
}
$items = array();
foreach ($list as $row) {
$row['data'] = array_intersect_key($row['data'], Columns::get_visible());
foreach (Columns::get_static() as $static => $show) {
$row['static'][$static] = Arr::path($jobs, array($row['job_key'], $static));
}
$items[] = $row;
}
return $items;
}
示例14: action_index
public function action_index()
{
$id = $this->request->param('id');
$location = Arr::get($_GET, 'location', '');
$type = Arr::get($_GET, 'type', 'other');
$title = Arr::get($_GET, 'title', 'other');
$job = Database_Mongo::collection('jobs')->findOne(array('_id' => strval($id)));
if (!$job) {
throw new HTTP_Exception_404('Not found');
}
if (!Group::current('show_all_jobs') && !in_array((int) User::current('company_id'), Arr::get($job, 'companies', array()), true) && !in_array((int) User::current('company_id'), Arr::get($job, 'ex', array()), true)) {
throw new HTTP_Exception_403('Forbidden');
}
switch ($type) {
case 'photo-before':
$type = 'Photos';
$filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.before.%NUM%';
$title = '';
break;
case 'photo-after':
$type = 'Photos';
$filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.after.%NUM%';
$title = '';
break;
case 'jsa':
$type = 'JSA-forms';
$filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.JSA.%NUM%';
$title = '';
break;
case 'waiver':
$type = 'Waiver';
$filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.Waiver.%NUM%';
$title = '';
break;
case 'odtr':
$title = '';
$type = 'otdr-traces';
$filename = '';
break;
default:
$type = 'Other';
$filename = '';
break;
}
$number = DB::select('numbering')->from('attachments')->where('job_id', '=', $id)->and_where('folder', '=', $type)->order_by('numbering', 'desc')->limit(1)->execute()->get('numbering');
$data = array('filename' => $filename, 'mime' => '', 'uploaded' => 0, 'user_id' => User::current('id'), 'job_id' => $id, 'folder' => $type, 'fda_id' => Arr::path($job, 'data.14'), 'address' => trim(preg_replace('/-{2,}/', '-', preg_replace('/[^0-9a-z\\-]/i', '-', Arr::path($job, 'data.8'))), '-'), 'title' => $title, 'numbering' => intval($number) + 1);
$result = Arr::get(DB::insert('attachments', array_keys($data))->values(array_values($data))->execute(), 0);
if (file_exists(DOCROOT . 'storage/' . $result)) {
unlink(DOCROOT . 'storage/' . $result);
}
die(json_encode(array('success' => true, 'id' => $result)));
}
示例15: action_financial
public function action_financial()
{
if (!Group::current('is_admin') && !(Group::current('allow_finance') && Group::current('show_all_jobs'))) {
throw new HTTP_Exception_403('Forbidden');
}
$jobs = Database_Mongo::collection('jobs')->find();
foreach ($jobs as $job) {
set_time_limit(30);
Utils::calculate_financial($job);
}
header('Content-type: application/json');
die(json_encode(array('success' => true)));
}