本文整理汇总了PHP中Event::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::find方法的具体用法?PHP Event::find怎么用?PHP Event::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest($command, $date = NULL)
{
$events = Event::find($command, $date);
if (empty($events)) {
throw new Exception("Nothing found");
}
$formattedEvents = Event::format($events);
render('event', array('events' => $formattedEvents));
}
示例2: destroy
public function destroy($id)
{
// delete
$event = Event::find($id);
$event->delete();
// redirect
Session::flash('message', 'Successfully deleted the event!');
return Redirect::to('events');
}
示例3: index
function index() {
$recent_events = Event::find()->where(array('created_at >= NOW() - INTERVAL 1 WEEK'))->order('created_at DESC')->all();
$find_news = News::find()
->order(array('weight ASC', 'updated_at DESC'))
->limit(5);
$this->render(array(
'recent_events' => $recent_events,
'news' => $find_news->all(),
));
}
示例4: create
function create()
{
$types = Event::getTypes();
RoutingEngine::getSmarty()->assign("event_types", $types);
if (isset($_GET["eid"])) {
$eid = $_GET["eid"];
$event = Event::find($eid);
if ($event->uid == User::$current_user->uid) {
RoutingEngine::getSmarty()->assign("event", $event);
}
}
}
示例5: show
function show($params) {
$char = Character::find()->where(array('guid' => $params['guid']))->realm($params['rid'])->first();
$events = Event::find()->where(array('target_class' => 'Character', 'target_dbid' => $params['rid'], 'target_id' => $params['guid']));
$cheats = CheatLogEntry::find()->realm($params['rid'])->where(array('guid' => $params['guid']));
if ($char->guid == $params['guid']) {
$this->render(array(
'character' => $char,
'events_count' => $events->count(),
'cheats_count' => $cheats->count()
));
} else {
$this->render_error('404');
}
}
示例6: sync_dbid
function sync_dbid(){
Event::$per_page = null;
$events = Event::find()->all();
foreach($events as $event){
$target = unserialize($event->target_obj);
if($target->realm != null && $target->realm->id != $event->target_dbid){
$event->target_dbid = $target->realm->id;
echo "missing dbid in event " . $event->id . " - actual: " . $event->target_dbid . " correct: " . $target->realm->id;
if($event->save())
echo " - currected <br>\n";
else
echo " - can't correct <br>\n";
}
}
}
示例7: test_belongs_to_returns_null_when_no_record
public function test_belongs_to_returns_null_when_no_record()
{
$event = Event::find(6);
$this->assert_null($event->venue);
}
示例8: cancelEventAction
/**
* Allows a user to cancel an event
*
*/
public function cancelEventAction()
{
$get = Zend_Registry::get('getFilter');
if (!isset($get->eventId)) {
throw new Ot_Exception_Input('msg-error-eventIdNotSet');
}
$workshop = new Workshop();
$event = new Event();
$location = new Location();
$thisEvent = $event->find($get->eventId);
if (is_null($thisEvent)) {
throw new Ot_Exception_Data('msg-error-noEvent');
}
$i = new Event_Instructor();
$where = $i->getAdapter()->quoteInto('eventId = ?', $get->eventId);
$results = $i->fetchAll($where);
$currentInstructors = array();
foreach ($results as $r) {
$currentInstructors[] = $r->accountId;
}
if (!$this->_helper->hasAccess('view-all-instructor-pages') && !in_array(Zend_Auth::getInstance()->getIdentity()->accountId, $currentInstructors)) {
throw new Ot_Exception_Access('msg-error-noWorkshopAccess');
}
$thisEvent = $thisEvent->toArray();
$thisEvent['startTime'] = strftime('%l:%M %p', strtotime($thisEvent['startTime']));
$thisEvent['endTime'] = strftime('%l:%M %p', strtotime($thisEvent['endTime']));
$thisEvent['location'] = $location->find($thisEvent['locationId'])->toArray();
$thisEvent['workshop'] = $workshop->find($thisEvent['workshopId'])->toArray();
$this->view->event = $thisEvent;
$form = Ot_Form_Template::delete('eventDelete', 'workshop-schedule-cancelEvent:cancel');
if ($this->_request->isPost() && $form->isValid($_POST)) {
$dba = $event->getAdapter();
$dba->beginTransaction();
$where = $dba->quoteInto('eventId = ?', $get->eventId);
$data = array('status' => 'canceled');
try {
$result = $event->update($data, $where);
} catch (Exception $e) {
$dba->rollback();
throw $e;
}
$attendee = new Event_Attendee();
try {
$attendee->update($data, $where);
} catch (Exception $e) {
$dba->rollback();
throw $e;
}
$dba->commit();
$this->_helper->flashMessenger->addMessage('msg-info-eventCanceled');
$date = explode('-', $thisEvent['date']);
$this->_helper->redirector->gotoUrl('/workshop/schedule?startYear=' . $date[0] . '&startMonth=' . (int) $date[1]);
}
$this->_helper->pageTitle('workshop-schedule-cancelEvent:title');
$this->view->form = $form;
}
示例9: v152
public function v152()
{
// Regenerate cache
Cache::clear(false);
// Timezone
$this->Setting->setOption('timezone', 'Europe/Paris');
// Update events registration end date
App::uses('Event', 'Model');
$EventModel = new Event();
$params = array();
$params['recursive'] = -1;
$params['fields'] = array('id', 'time_start', 'time_inscription');
$params['conditions']['time_inscription'] = null;
if ($events = $EventModel->find('all', $params)) {
foreach ($events as $event) {
$EventModel->query("UPDATE " . $EventModel->tablePrefix . "events SET time_inscription='" . $event['Event']['time_start'] . "' WHERE id = " . $event['Event']['id']);
}
}
}
示例10: test_eager_loading_clones_related_objects
public function test_eager_loading_clones_related_objects()
{
$events = Event::find(array(2, 3), array('include' => array('venue')));
$venue = $events[0]->venue;
$venue->name = "new name";
$this->assert_equals($venue->id, $events[1]->venue->id);
$this->assert_not_equals($venue->name, $events[1]->venue->name);
$this->assert_not_equals(spl_object_hash($venue), spl_object_hash($events[1]->venue));
}
示例11: award
public function award()
{
if ($this->post) {
$achievement = $this->load_achievement($this->PostData('achievement_id'));
$user_temp = $this->PostData('users');
if (!is_array($user_temp)) {
$user_temp = explode(',', $user_temp);
}
$error_on = array();
$success = 0;
foreach ($user_temp as $name_temp) {
$user_id = mysql_real_escape_string($name_temp);
$user = User::find_by_id($user_id);
if ($user) {
if ($achievement->award($user, $this->PostData("category_id"))) {
$success++;
} else {
$error_on[] = $name;
}
} else {
$error_on[] = $name;
}
}
if (count($user_temp) == 1) {
if ($success == 1) {
Site::InstantFlash("notice", "{$user->nickname} has been awarded {$achievement->name}");
} else {
Site::InstantFlash("error", "Unable to award achievement");
}
} else {
if ($success == 0) {
Site::InstantFlash("error", "Unable to award achievements to any of the users listed");
} elseif (count($error_on) > 0) {
Site::InstantFlash("error", "Awarded achievement to {$success} user" . ($success != 1 ? "s" : "") . ", failed to award to " . implode(", ", $error_on));
} else {
Site::InstantFlash("notice", "Awarded achievements to all users listed.");
}
}
}
$filters = array();
$pageQuery = '';
if ($this->GetData('query')) {
$pageQuery = $this->GetData('query');
$query = mysql_real_escape_string($this->GetData('query'));
$filters[] = "users.nickname LIKE '%{$query}%'";
}
$filter = implode('AND', $filters);
$achievement_id = null;
if ($this->GetData('achievement_id')) {
$achievement_id = $this->GetData('achievement_id');
}
$page = 1;
if ($this->GetData('page')) {
$page = $this->GetData('page');
}
$users = User::paginate($filter, 'users.nickname ASC', $page, 50);
$achievements = Achievement::find_all("", "achievements.created_at ASC");
$achlist = array();
foreach ($achievements as $ach) {
$achlist[$ach->id] = "{$ach->id}. {$ach->name}";
}
// Yay - Magic Numbers!
$category_id = 11;
$categories = array();
$all_categories = array();
$all_categories = AchievementCategory::find_all();
foreach ($all_categories as $category) {
$event = Event::find("achievement_category_id={$category->id}");
if (!$event || $event->check_user(Site::CurrentUser()) && $event->display_achievements) {
$categories[$category->id] = $category->category_name;
if ($category->default_category) {
$category_id = $category->id;
}
}
}
if ($this->GetData('category_id')) {
$category_id = $this->GetData('category_id');
}
$this->assign("achievements", $achlist);
$this->assign("categories", $categories);
$this->assign("category_id", $category_id);
$this->assign("achievement_id", $achievement_id);
$this->assign("users", $users);
$this->assign('pagequery', $pageQuery);
$this->title = "Award Achievement";
$this->render("achievement/award.tpl");
}
示例12:
$row = Group::find($id);
$row->delete();
} else {
// Set error.
$error = "CantDeleteGroup";
$message = "The group could not be deleted since they are persons that belong to them";
$statusCode = 422;
}
}
// Event.
if ($type == "event") {
// Verify if the event is used by assistances.
$count = Assistance::count(array('conditions' => 'event_id = ' . $id));
if ($count <= 0) {
// Delete event.
$row = Event::find($id);
$row->delete();
} else {
// Set error.
$error = "CantDeleteEvent";
$message = "The event could not be deleted since some assistance lists are linked to him";
$statusCode = 422;
}
}
// Person.
if ($type == "person") {
// Verify if the person is used by assistances.
$count = Assistance::count(array('conditions' => 'person_id = ' . $id));
if ($count <= 0) {
// Delete person.
$row = Person::find($id);
示例13: isset
<?php
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 20;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'updated_at desc';
if (isset($event) && is_numeric($event) && Event::find($event)->user_id == $res->membre->id) {
$res->events = array(Event::find($event));
} else {
$res->events = $res->membre->id == $res->user->id ? $res->membre->getEvents(true, $args) : $res->membre->getEvents(false, $args);
$res->total = $res->membre->id == $res->user->id ? $res->membre->getEvents(true)->count : $res->membre->getEvents(false)->count;
}
$res->useTemplate();
示例14: cancelAction
/**
* Allows a user to cancel their reservation for an event.
*
*/
public function cancelAction()
{
$get = Zend_Registry::get('getFilter');
if (!isset($get->eventId)) {
throw new Ot_Exception_Input('msg-error-eventIdNotSet');
}
$event = new Event();
$location = new Location();
$workshop = new Workshop();
$instructor = new Event_Instructor();
$attendee = new Event_Attendee();
$thisEvent = $event->find($get->eventId);
if (is_null($thisEvent)) {
throw new Ot_Exception_Data('msg-error-noEvent');
}
$this->view->event = $thisEvent->toArray();
$status = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $thisEvent->eventId);
if ($status != 'waitlist' && $status != 'attending') {
throw new Ot_Exception_Data('msg-error-notAttending');
}
$this->view->status = $status;
$this->view->reservationCancelable = $event->isReservationCancelable($thisEvent->eventId);
$thisLocation = $location->find($thisEvent->locationId);
if (is_null($thisLocation)) {
throw new Ot_Exception_Data('msg-error-noLocation');
}
$this->view->location = $thisLocation->toArray();
$thisWorkshop = $workshop->find($thisEvent->workshopId);
if (is_null($thisWorkshop)) {
throw new Ot_Exception_Data('msg-error-noWorkshop');
}
$this->view->workshop = $thisWorkshop->toArray();
$instructors = $instructor->getInstructorsForEvent($thisEvent->eventId);
$inst = array();
foreach ($instructors as $i) {
$inst[] = $i['firstName'] . ' ' . $i['lastName'];
}
$this->view->instructors = $inst;
$events = $event->getEvents($thisWorkshop->workshopId, null, null, time(), null, 'open')->toArray();
$newEvents = array();
foreach ($events as $e) {
if ($e['eventId'] != $thisEvent->eventId) {
$e['status'] = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $e['eventId']);
$e['workshop'] = $thisWorkshop->toArray();
$newEvents[] = $e;
}
}
$this->view->events = $newEvents;
$form = Ot_Form_Template::delete('cancelReservation', 'workshop-signup-cancel:cancel', 'workshop-signup-cancel:keep');
if ($this->_request->isPost() && $form->isValid($_POST)) {
$instructorNames = array();
$instructorEmails = array();
foreach ($instructors as $i) {
$instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
$instructorEmails[] = $i['emailAddress'];
}
$attendee->cancelReservation(Zend_Auth::getInstance()->getIdentity()->accountId, $thisEvent->eventId);
$startDt = strtotime($thisEvent->date . ' ' . $thisEvent->startTime);
$endDt = strtotime($thisEvent->date . ' ' . $thisEvent->endTime);
$data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $thisEvent->minSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails), 'studentEmail' => Zend_Auth::getInstance()->getIdentity()->emailAddress, 'studentName' => Zend_Auth::getInstance()->getIdentity()->firstName . ' ' . Zend_Auth::getInstance()->getIdentity()->lastName, 'studentUsername' => Zend_Auth::getInstance()->getIdentity()->username);
$this->_helper->flashMessenger->addMessage($this->view->translate('msg-info-canceled', $thisWorkshop->title));
$trigger = new Ot_Trigger();
$trigger->setVariables($data);
$trigger->dispatch('Event_Cancel_Reservation');
$account = new Ot_Account();
if ($status != 'waitlist') {
$waiting = $attendee->getAttendeesForEvent($thisEvent->eventId, 'waitlist');
if (count($waiting) != 0) {
$newAccount = $account->find($waiting[0]['accountId']);
if (!is_null($newAccount)) {
$attendee->makeReservation($newAccount->accountId, $thisEvent->eventId);
$data['studentEmail'] = $newAccount->emailAddress;
$data['studentName'] = $newAccount->firstName . ' ' . $newAccount->lastName;
$data['studentUsername'] = $newAccount->username;
$trigger = new Ot_Trigger();
$trigger->setVariables($data);
$trigger->dispatch('Event_Waitlist_To_Attending');
}
}
}
$this->_redirect('/');
}
$this->view->form = $form;
$this->view->layout()->setLayout('twocolumn');
$this->view->layout()->rightContent = $this->view->render('signup/right.phtml');
}
示例15: afterSave
public function afterSave($created, $options)
{
// Mark the user as absent in all his games
// Get characters, so we can also have the game list
App::uses('Character', 'Model');
$Character = new Character();
$params = array();
$params['recursive'] = -1;
$params['fields'] = array('Character.id', 'Character.game_id', 'Character.level', 'Character.default_role_id');
$params['group'] = 'game_id';
$params['conditions']['user_id'] = $this->data['Availability']['user_id'];
$params['conditions']['main'] = 1;
if ($characters = $Character->find('all', $params)) {
App::uses('Event', 'Model');
$Event = new Event();
$Event->Behaviors->detach('Commentable');
App::uses('EventsCharacter', 'Model');
$EventsCharacter = new EventsCharacter();
foreach ($characters as $character) {
// Get events for this period
$params = array();
$params['recursive'] = -1;
$params['fields'] = array('Event.id');
$params['conditions']['game_id'] = $character['Character']['game_id'];
$params['conditions']['character_level <='] = $character['Character']['level'];
$params['conditions']['time_start >='] = $this->data['Availability']['start'] . ' 00:00:00';
$params['conditions']['time_start <='] = $this->data['Availability']['end'] . ' 23:59:59';
if ($events = $Event->find('all', $params)) {
foreach ($events as $event) {
// If already registered to this event, update it
$paramsEventsCharacter = array();
$paramsEventsCharacter['recursive'] = -1;
$paramsEventsCharacter['fields'] = array('id');
$paramsEventsCharacter['conditions']['event_id'] = $event['Event']['id'];
$paramsEventsCharacter['conditions']['user_id'] = $this->data['Availability']['user_id'];
if ($eventCharacter = $EventsCharacter->find('first', $paramsEventsCharacter)) {
$eventCharacter['EventsCharacter']['status'] = 0;
$EventsCharacter->save($eventCharacter['EventsCharacter']);
} else {
$toSave = array();
$toSave['event_id'] = $event['Event']['id'];
$toSave['user_id'] = $this->data['Availability']['user_id'];
$toSave['character_id'] = $character['Character']['id'];
$toSave['raids_role_id'] = $character['Character']['default_role_id'];
$toSave['comment'] = $this->data['Availability']['comment'];
$toSave['status'] = 0;
$EventsCharacter->__add($toSave);
}
}
}
}
}
return true;
}