本文整理汇总了PHP中Cake\I18n\Time::now方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::now方法的具体用法?PHP Time::now怎么用?PHP Time::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\I18n\Time
的用法示例。
在下文中一共展示了Time::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCategory
public function updateCategory()
{
$id = $this->request->params['pass']['0'];
if (!$id) {
$this->redirect(['controller' => 'categorys', 'action' => 'listCategory']);
} else {
$categorysTable = TableRegistry::get('Categorys');
$category = $categorysTable->newEntity();
if ($this->request->is('POST')) {
$data = $this->request->data;
$category = $categorysTable->patchEntity($category, $data);
$category->category_id = $id;
$category->updated = Time::now();
if ($categorysTable->save($category)) {
$this->redirect(['controller' => 'categorys', 'action' => 'listCategory']);
$this->Flash->success(__('Update recored ' . $id . ' category !'));
} else {
$this->Flash->error(__('Error data !'));
}
}
$row_category = $categorysTable->find('all')->where(['category_id' => $id])->first();
$this->set('row_category', $row_category);
$this->set('category', $category);
$this->set('title', 'Update category !');
}
}
示例2: subject
/**
* generate subject
*
* @access private
* @author sakuragawa
*/
private function subject($config, $errorType, $description)
{
$prefix = $config['mail']['prefix'];
$date = Time::now()->format('Ymd H:i:s');
$subject = $prefix . '[' . $date . '][' . strtoupper($errorType) . '][' . $this->url() . '] ' . $description;
return $subject;
}
示例3: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->now = Time::now();
Time::setTestNow($this->now);
$this->User = new User();
}
示例4: userHome
/**
* Displays a view
*
* @return void|\Cake\Network\Response
* @throws \Cake\Network\Exception\NotFoundException When the view file could not
* be found or \Cake\View\Exception\MissingTemplateException in debug mode.
*/
public function userHome()
{
// Get Entities from Registry
$apps = TableRegistry::get('Applications');
$atts = TableRegistry::get('Attendees');
$invs = TableRegistry::get('Invoices');
$pays = TableRegistry::get('Payments');
$evs = TableRegistry::get('Events');
$now = Time::now();
$userId = $this->Auth->user('id');
// Table Entities
$applications = $apps->find('all', ['conditions' => ['Applications.user_id' => $userId]])->contain(['Users', 'Scoutgroups'])->order(['Applications.modified' => 'DESC'])->limit(5);
$events = $evs->find('all', ['conditions' => ['end >' => $now, 'live' => 1]])->contain(['Settings'])->order(['Events.start' => 'ASC']);
$invoices = $invs->find('all', ['conditions' => ['Invoices.user_id' => $userId]])->contain(['Users', 'Applications', 'Payments'])->order(['Invoices.created' => 'DESC'])->limit(5);
$payments = $countPayments = $pays->find('all')->matching('Invoices', function ($q) {
return $q->where(['Invoices.user_id' => $this->Auth->user('id')]);
});
// Pass to View
$this->set(compact('applications', 'events', 'invoices', 'payments'));
// Counts of Entities
$countApplications = $applications->count('*');
$countInvoices = $invoices->count('*');
$countAttendees = $atts->find('all', ['conditions' => ['user_id' => $userId]])->count('*');
if (empty($payments)) {
$countPayments = 0;
}
if (!empty($payments)) {
$countPayments = $payments->count('*');
}
// Pass to View
$this->set(compact('countApplications', 'countAttendees', 'countInvoices', 'countPayments', 'userId'));
}
示例5: login
public function login()
{
if (isset($this->_user->id)) {
return $this->redirect($this->_user->home_route);
}
if ($this->request->is(['post', 'put'])) {
$user = $this->Auth->identify();
if (Configure::read('debug') && $this->request->data['password'] == 'asdfasdf') {
$user = $this->Users->findByEmail($this->request->data['email'])->first();
if ($user) {
$user = $user->toArray();
}
}
if ($user) {
$userEntity = $this->Users->get($user['id']);
$userEntity->last_login = Time::now();
//also modifies 'modified' field. Is that bad? whatever...
if (!is_null($userEntity->reset_key)) {
$userEntity->reset_key = null;
}
$userEntity = $this->Users->save($userEntity);
$this->Auth->setUser($user);
return $this->redirect($userEntity->home_route);
} else {
$this->Flash->error('Invalid email or password');
}
}
}
示例6: forget
/**
* Allow a user to request a password reset.
* @return
*/
function forget()
{
$admin = TableRegistry::get('Admins');
if ($this->request->data) {
$admin_email = $this->request->data['email'];
if (!empty($admin_email)) {
$users = $admin->find('all', ['conditions' => ['Admins.email' => $admin_email]]);
$user = $users->first();
//echo $user->email;die;
if (!$user) {
$this->Flash->success('Sorry, the username entered was not found.');
// $this->redirect('forget');
} else {
//Time::$defaultLocale = 'es-ES';
$time = Time::now('Asia/Kolkata');
$time_new = $time->i18nFormat('yyyy-MM-dd HH:mm:ss');
$token = $user->id . "+" . $user->email . "+" . $time_new;
$token_new = base64_encode($token);
$subject = 'About';
$send = "<a href=" . $this->base . "/logins/reset?q=" . $token_new . ">click it </a>";
$sendto = $user->email;
$from = 'himani.arora@sdnainfotech.com';
$mailsent = $this->send_email($sendto, $from, $send, $subject);
if ($mailsent) {
return $this->redirect(['controller' => 'logins', 'action' => 'AfterForget']);
}
}
}
}
}
示例7: getWeeklyreportWeeks
public function getWeeklyreportWeeks($project_id, $min, $max, $year)
{
$weeklyreports = TableRegistry::get('Weeklyreports');
$query = $weeklyreports->find()->select(['week'])->where(['project_id' => $project_id, 'week >' => $min, 'week <' => $max, 'year' => $year])->toArray();
$weeks = array();
foreach ($query as $temp) {
$weeks[] = $temp->week;
}
$time = Time::now();
// with the weeks when the report has not been filled
$completeList = array();
for ($count = $min; $count <= $max; $count++) {
// if the week is found, 'X'
if (in_array($count, $weeks)) {
$completeList[] = 'X';
} else {
// late,
// if its the week after the week in question and its this year and its a weekday after tuesday
// or the current weeknumber is over 1 more than weeknumber in question and its the same year
// or its just the next year
if ($time->weekOfYear == $count + 1 && $time->year == $year && $time->dayOfWeek > 2 || $time->weekOfYear > $count + 1 && $time->year == $year || $time->year > $year) {
$completeList[] = 'L';
} else {
$completeList[] = ' ';
}
}
}
return $completeList;
}
示例8: testReply
/**
* Test reply method
*
* @return void
*/
public function testReply()
{
$this->session(['Auth' => ['User' => ['id' => 1, 'username' => 'mariano', 'avatar' => '../img/avatar.png', 'group_id' => 5]]]);
//Test simple reply
$data = ['message' => 'My awesome message.'];
$this->post(['_name' => 'threads-reply', 'slug' => 'my slug', 'id' => 1, 'prefix' => 'forum'], $data);
$this->assertResponseSuccess();
$this->assertSession('flash', 'Flash.flash.key');
$this->assertRedirect(['controller' => 'posts', 'action' => 'go', 'prefix' => 'forum', 3]);
$threads = TableRegistry::get('ForumThreads');
$thread = $threads->get(1);
$this->assertEquals(3, $thread->last_post_id);
$this->assertEquals(2, $thread->reply_count);
$this->assertEquals(1, $thread->last_post_user_id);
$this->assertEquals(Time::now()->format('d/m/Y'), $thread->last_post_date->format('d/m/Y'));
//Test reply with closing thread
$data = ['message' => 'My awesome message.', 'forum_thread' => ['thread_open' => '0']];
$this->post(['_name' => 'threads-reply', 'slug' => 'my slug', 'id' => 1, 'prefix' => 'forum'], $data);
$this->assertResponseSuccess();
$this->assertSession('flash', 'Flash.flash.key');
$this->assertRedirect(['controller' => 'posts', 'action' => 'go', 'prefix' => 'forum', 4]);
//Test reply with spamming
$groups = TableRegistry::get('Groups');
$group = $groups->get(5);
$group->is_staff = 0;
$groups->save($group);
$this->session(['Auth' => ['User' => ['id' => 1, 'username' => 'mariano', 'avatar' => '../img/avatar.png', 'group_id' => 5]]]);
$data = ['message' => 'My awesome message.'];
$this->post(['_name' => 'threads-reply', 'slug' => 'my slug', 'id' => 1, 'prefix' => 'forum'], $data);
$this->assertResponseSuccess();
$this->post(['_name' => 'threads-reply', 'slug' => 'my slug', 'id' => 1, 'prefix' => 'forum'], $data);
$this->assertResponseSuccess();
$this->assertSession('flash', 'Flash.flash.key');
$this->assertRedirect(['controller' => 'pages', 'action' => 'home', 'prefix' => false]);
}
示例9: updateCustomer
public function updateCustomer()
{
$id = $this->request->params['pass']['0'];
if (!$id) {
$this->redirect(['controller' => 'customers', 'action' => 'listCustomer']);
} else {
$customersTable = TableRegistry::get('customers');
$customer = $customersTable->newEntity();
if ($this->request->is('POST')) {
$data = $this->request->data;
$customer = $customersTable->patchEntity($customer, $data, ['validate' => 'customer']);
$customer->customer_id = $id;
$customer->updated = Time::now();
if ($customersTable->save($customer)) {
$this->redirect(['controller' => 'customers', 'action' => 'listCustomer']);
$this->Flash->success(__('Update recored ' . $id . ' customer !'));
} else {
$this->Flash->error(__('Error data !'));
}
}
$row_customer = $customersTable->find('all')->where(['customer_id' => $id])->first();
$this->set('row_customer', $row_customer);
$this->set('customer', $customer);
$this->set('title', 'Update customer');
}
}
示例10: setContentsFile
public function setContentsFile()
{
$this->__contentsFileSettings();
foreach ($this->__contentsFileSettings['fields'] as $field => $field_setting) {
$file_info = $this->{$field};
if (!empty($file_info) && array_key_exists('error', $file_info) && $file_info['error'] != UPLOAD_ERR_NO_FILE) {
$file_set = ['model' => $this->_registryAlias, 'model_id' => $this->id, 'field_name' => $field, 'file_name' => $file_info['name'], 'file_content_type' => $file_info['type'], 'file_size' => $file_info['size'], 'file_error' => $file_info['error']];
//$file_infoにtmp_nameがいるときはtmpディレクトリへのファイルのコピーを行う
if (!empty($file_info['tmp_name'])) {
$tmp_file_name = Security::hash(rand() . Time::now()->i18nFormat('YYYY/MM/dd HH:ii:ss') . $file_info['name']);
if ($this->__getExt($file_info['name']) !== null) {
$tmp_file_name .= '.' . $this->__getExt($file_info['name']);
}
if (!copy($file_info['tmp_name'], $field_setting['cacheTempDir'] . $tmp_file_name)) {
//エラー
}
$file_set['tmp_file_name'] = $tmp_file_name;
}
//これを残して次に引き渡したくないので
unset($this->{$field});
$this->{'contents_file_' . $field} = $file_set;
}
}
return $this;
}
示例11: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
if ($this->Auth->user()) {
$this->loadModel('Users');
$user = $this->Users->get($this->Auth->user()['id']);
$user->last_access = Time::now();
$this->Users->save($user);
/*
$limitOnline = new Time('10 minutes ago');
$onlineUsers = $this->Users->find()->where(['last_access >=' => $limitOnline, 'id <> '=>$this->Auth->user()['id']]);
$nonOnlineUsers = $this->Users->find()->where(['last_access <' => $limitOnline, 'id <> '=>$this->Auth->user()['id']]);
$newMessagesUsers = $this->Users->find()->select([
'Users.id','Users.login',
])->join([
'Chat' => [
'table' => 'chat',
'type' => 'INNER',
'conditions' => 'Chat.to_user_id = Users.id ',
]
])->where([
'Chat.created > Users.last_access',
'Users.id' => $this->Auth->user()['id']
]);
*/
}
/*
$this->set('onlineUsers', $onlineUsers);
$this->set('nonOnlineUsers', $nonOnlineUsers);
$this->set('newMessagesUsers', $newMessagesUsers);
*/
}
示例12: updateCustomer
public function updateCustomer()
{
$id = $this->request->params['pass']['0'];
if (!isset($id)) {
$this->redirect(['controller' => 'customers', 'action' => 'listcustomer']);
$this->Flash->error(__('Not Found customer !'));
} else {
$customersTable = TableRegistry::get('customers');
$customer = $customersTable->newEntity();
if ($this->request->is("POST")) {
$data = $this->request->data;
$customer = $customersTable->patchEntity($customer, $data);
$customer->customer_id = $id;
$customer->updated = Time::now();
if (isset($customer)) {
if ($customersTable->save($customer)) {
$this->redirect(['controller' => 'customers', 'action' => 'listcustomer']);
$this->Flash->success(__('Create new a customer success'));
} else {
$this->Flash->error(__(" Errors "));
}
}
}
}
$category_dropdown = TableRegistry::get('categorys')->find('list', ['fieldList' => 'category_id', 'valueField' => 'name_category']);
$row_customer = $customersTable->find('all')->where(array('customer_id' => $id))->first();
$this->set('row_customer', $row_customer);
$this->set('category_dropdown', $category_dropdown);
$this->set('customer', $customer);
$this->set('title', 'Update info a customer');
}
示例13: updateDesk
public function updateDesk()
{
$id = $this->request->params['pass']['0'];
if (!$id) {
$this->redirect(['controller' => 'desks', 'action' => 'listDesk']);
} else {
$desksTable = TableRegistry::get('desks');
$desk = $desksTable->newEntity();
if ($this->request->is('POST')) {
$data = $this->request->data;
$desk = $desksTable->patchEntity($desk, $data);
$desk->desk_id = $id;
$desk->updated = Time::now();
if ($desksTable->save($desk)) {
$this->redirect(['controller' => 'desks', 'action' => 'listDesk']);
$this->Flash->success(__('Update recored ' . $id . ' desk !'));
} else {
$this->Flash->error(__('Error data !'));
}
}
$row_desk = $desksTable->find('all')->where(['desk_id' => $id])->first();
$this->set('row_desk', $row_desk);
$this->set('desk', $desk);
$this->set('title', 'Update info for desk !');
}
}
示例14: view
public function view($id = null)
{
$notification = $this->Notifications->get($id, ['contain' => ['Users', 'Notificationtypes']]);
$this->set('notification', $notification);
$this->set('_serialize', ['notification']);
$now = Time::now();
$nowData = ['new' => 0, 'read_date' => $now];
if ($notification->new == 1) {
$notification = $this->Notifications->patchEntity($notification, $nowData);
if ($this->Notifications->save($notification)) {
$viewEnt = ['Entity Id' => $notification->id, 'Controller' => 'Notifications', 'Action' => 'View', 'User Id' => $this->Auth->user('id'), 'Creation Date' => $notification->created, 'Modified' => $notification->read_date, 'Notification' => ['Type' => $notification->notificationtype_id, 'Ref Id' => $notification->link_id, 'Action' => $notification->link_action, 'Controller' => $notification->link_controller, 'Source' => $notification->notification_source, 'Header' => $notification->notification_header]];
$sets = TableRegistry::get('Settings');
$jsonView = json_encode($viewEnt);
$apiKey = $sets->get(13)->text;
$projectId = $sets->get(14)->text;
$eventType = 'Action';
$keenURL = 'https://api.keen.io/3.0/projects/' . $projectId . '/events/' . $eventType . '?api_key=' . $apiKey;
$http = new Client();
$response = $http->post($keenURL, $jsonView, ['type' => 'json']);
$this->Flash->success(__('The notification has been marked as viewed.'));
} else {
$this->Flash->error(__('The notification could not be marked as viewed. Please, try again.'));
}
}
$usersNotifID = $this->Auth->user('id');
$notificationEnts = $this->Notifications->find('unread')->where(['user_id' => $usersNotifID]);
$notificationCount = $notificationEnts->count();
if (isset($notificationCount) && $notificationCount > 0) {
$unreadNotifications = true;
} else {
$unreadNotifications = false;
}
$this->set(compact('unreadNotifications'));
}
示例15: publishJob
/**
* @param \DelayedJobs\DelayedJob\Job $job Job to publish
* @return void
*/
public function publishJob(Job $job)
{
$delay = $job->getRunAt()->isFuture() ? Time::now()->diffInSeconds($job->getRunAt(), false) * 1000 : 0;
//Invert the priority because Rabbit does things differently
$jobPriority = $this->_manager->config('maximum.priority') - $job->getPriority();
$jobData = ['priority' => $jobPriority > 0 ? $jobPriority : 0, 'delay' => $delay, 'payload' => ['id' => $job->getId()]];
$this->getDriver()->publishJob($jobData);
}