本文整理汇总了PHP中Events类的典型用法代码示例。如果您正苦于以下问题:PHP Events类的具体用法?PHP Events怎么用?PHP Events使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Events类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bindToShutdown
/**
*
*/
protected function bindToShutdown()
{
if (!$this->shutdownBound) {
$this->shutdownBound = true;
$this->Events->bindEvent('shutdown', $this, 'handleShutdown');
}
}
示例2: run
public function run($id)
{
$formModel = new EventCommentPublisherFormModel();
$profile = Yii::app()->params->profile;
$model = $this->controller->lookUpModel($id, 'Events');
$this->controller->dataUrl = Yii::app()->request->url;
if ($model->checkPermissions('view')) {
if (isset($_POST['EventCommentPublisherFormModel'])) {
$formModel->setAttributes($_POST['EventCommentPublisherFormModel']);
if (isset($_FILES['EventCommentPublisherFormModel'])) {
$model->photo = CUploadedFile::getInstance($model, 'photo');
}
if ($formModel->validate()) {
$event = new Events();
$event->setAttributes(array('visibility' => X2PermissionsBehavior::VISIBILITY_PUBLIC, 'user' => $profile->username, 'type' => 'structured-feed', 'associationType' => 'Events', 'associationId' => $id, 'text' => $formModel->text, 'photo' => $formModel->photo), false);
if ($event->save()) {
$formModel->text = '';
if (!isset($_FILES['EventCommentPublisherFormModel'])) {
} else {
Yii::app()->end();
}
} else {
throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
}
}
}
$dataProvider = new CActiveDataProvider('Events', array('criteria' => array('order' => 'timestamp ASC', 'condition' => "type in ('comment', 'structured-feed') AND \n associationType='Events' AND associationId={$id}"), 'pagination' => array('pageSize' => 30)));
$this->controller->render($this->pathAliasBase . 'views.mobile.viewEvent', array('model' => $model, 'dataProvider' => $dataProvider, 'formModel' => $formModel));
} else {
$this->controller->denied();
}
}
示例3: main
function main()
{
$events = new Events();
$person = (new Facebook())->person(S()->id());
$events->signUp($_GET['event_id'], S()->id(), $person['name'], $person['link']);
R('/');
}
示例4: getInstance
/**
* Allow one instance only!
*
* @return Events instance
*/
public static function getInstance()
{
static $instance = false;
if (!$instance) {
$instance = new Events();
$instance->initializeListeners();
}
return $instance;
}
示例5: listAction
/**
* Render data for view on list action
*/
public function listAction()
{
if ($this->_getParam('day', false)) {
$this->view->day = $this->_getParam('day');
$events = new Events();
$this->view->events = $events->getEventsDate($this->_getParam('day'));
} else {
throw new Pas_Exception_Param($this->_missingParameter);
}
}
示例6: testFire
/**
* @todo Implement testFire().
*/
public function testFire()
{
$observer = new EventsTestObserver();
$this->object->extend('fire', $observer, 'invoke', null);
$this->object->fire('dontfire', array('a' => 1, 'b' => 2));
$this->assertEquals(0, $observer->invoked);
$this->object->fire('fire', array('a' => 18, 'b' => 81));
$this->assertEquals(1, $observer->invoked);
$this->assertEquals(81, $observer->lastArgs['b']);
}
示例7: calendar_cron
function calendar_cron()
{
require 'includes/classes/events.class.php';
require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php';
//Iterate through each member's preference
$sql = "SELECT * FROM %scalendar_notification WHERE 1=1";
$rows_notify = queryDB($sql, array(TABLE_PREFIX));
$event_obj = new Events();
foreach ($rows_notify as $row) {
//Send email only when preference is 1
if ($row['status'] == 1) {
$all_events = array();
$mail = new ATutorMailer();
//Get personal events
$personal_events = $event_obj->get_personal_events($row['memberid']);
foreach ($personal_events as $event) {
$all_events[] = $event;
}
//Get course events
$sql_q = "SELECT course_id FROM %scourse_enrollment WHERE member_id = %d";
$rows_enrolled = queryDB($sql_q, array(TABLE_PREFIX, TABLE_PREFIX));
foreach ($rows_enrolled as $row_q) {
$course_events = $event_obj->get_atutor_events($row['memberid'], $row_q['course_id']);
foreach ($course_events as $event) {
$all_events[] = $event;
}
}
//Iterate through each event and keep only those events which will start tomorrow
$email_msg = _AT('calendar_noti_mail_1') . "\n";
$index = 1;
foreach ($all_events as $id => $event) {
if (strtotime(substr($event['start'], 0, 10)) == strtotime('tomorrow')) {
$email_msg .= _AT('calendar_noti_mail_2') . " #" . $index . " \n";
$email_msg .= _AT('calendar_noti_mail_3') . ": " . substr($event['start'], 0, 10) . " \n";
$email_msg .= _AT('calendar_noti_mail_4') . ": " . substr($event['end'], 0, 10) . " \n";
$email_msg .= _AT('calendar_noti_mail_5') . ": " . $event['title'] . " \n\n";
$index++;
}
}
//Send email using ATutor mailer
$mail->From = $_config['contact_email'];
$mail->FromName = $_config['site_name'];
$mail->AddAddress($_config['contact_email']);
$mail->Subject = $stripslashes(_AT('calendar_noti_title'));
$mail->Body = $email_msg;
$sql_email = "SELECT email FROM %smembers WHERE member_id = %d";
$row_email = queryDB($sql_email, array(TABLE_PREFIX, $row['memberid']), TRUE);
$mail->AddBCC($row_email['email']);
$mail->Send();
unset($mail);
//For testing
// echo "<br/>".$email_msg."<br/>".$row_email['mail'];
}
}
}
示例8: testEvent
public function testEvent()
{
Client::relateIQ(GlobalVar::KEY, GlobalVar::SECRET);
$event = new Events([]);
$event->subject("Support Ticket #12345: How do I create an event?");
$event->body("Just called Tim and walked him through how to create an event with the new API.\n He'll reach out to support@relateiq.com with any questions he might have.\n Resolving.\n - James");
$participantIds = [["type" => "email", "value" => "james.mcsales@relateiq.com"], ["type" => "email", "value" => "tim.archer@avocado.com"], ["type" => "phone", "value" => "8001235555"]];
$event->participantIds($participantIds);
$res = $event->update();
$this->assertInstanceOf('Events', $res);
}
示例9: testFire
/**
* @todo Implement testFire().
*/
public function testFire()
{
$observer = new EventsTestObserver();
$this->object->addListener('fire', array($observer, 'invoke'));
$event = new GenericEvent('dontfire', array('a' => 1, 'b' => 2));
$this->object->dispatch('dontfire');
$this->assertEquals(0, $observer->invoked);
$event = new GenericEvent('fire', array('a' => 18, 'b' => 81));
$this->object->dispatch('fire', $event);
$this->assertEquals(1, $observer->invoked);
$this->assertEquals('81', $observer->event['b']);
}
示例10: actionIndex
public function actionIndex()
{
$event = new Events();
$event->attributes = $_GET;
if (!isset($_GET['content_id'])) {
$content = Content::model()->findByAttributes(array('slug' => Cii::get($_GET, 'uri', NULL)));
if ($content !== NULL) {
$event->content_id = $content->id;
}
}
if ($event->save()) {
Yii::app()->end();
}
return $this->returnError(400, NULL, $event->getErrors());
}
示例11: addEvent
static function addEvent($inputs)
{
$event = new Events();
$event->name = $inputs['eventName'];
$event->event_description = $inputs['eventDescription'];
$event->event_date = date("Y-m-d", strtotime($inputs['eventDate']));
$event->area = $inputs['eventLocation'];
$event->type = $inputs['eventType'];
$event->state = $inputs['state'];
$event->city = $inputs['city'];
$event->created_by = Session::get('userId');
$event->created_at = date("Y-m-d H:i:s");
$event->save();
return $event;
}
示例12: testIteratorReturnsWrappedEvents
/** @dataProvider provideIterators */
public function testIteratorReturnsWrappedEvents($startKey, $expected)
{
$this->events->set('2009', '1');
$this->events->set('2009', '2');
$this->events->set('2009 12', '3');
$this->events->set('2010', '4');
$this->events->set('2011 12', '5');
$this->events->set('2011 12 20', '6');
$this->events->set('2013 7 7 7 7', '7');
$iterator = $this->events->iterate($startKey);
assertThat(iterator_to_array($iterator), identicalTo($expected));
}
示例13: on_start
public function on_start()
{
Loader::helper('ms_route', 'multisite');
if (!User::isLoggedIn()) {
Events::extend('on_before_render', 'MsRouter', 'render', 'packages/' . $this->pkgHandle . '/models/ms_router.php');
}
}
示例14: getEvent
public function getEvent($id)
{
if (Session::has('in') && !strcmp(Session::get('in'), 'gautepJ9')) {
return View::make('events.eventDisplay')->with('entries', Events::find($id));
}
return Redirect::to('admin/login')->with('isErr', true)->with('msg', 'You need to login first.');
}
示例15: group
/**
* Shows the permissions for a specific user group.
*
* @param int $group_id The id of the group to show permissions for.
*/
public function group($group_id)
{
$this->load->library('form_validation');
if ($_POST) {
$modules = $this->input->post('modules');
$roles = $this->input->post('module_roles');
// Save the permissions.
if ($this->permission_m->save($group_id, $modules, $roles)) {
// Fire an event. Permissions have been saved.
Events::trigger('permissions_saved', array($group_id, $modules, $roles));
}
$this->session->set_flashdata('success', lang('permissions:message_group_saved_success'));
$this->input->post('btnAction') === 'save_exit' ? redirect('admin/permissions') : redirect('admin/permissions/group/' . $group_id);
}
// Get the group data
$group = $this->group_m->get($group_id);
// If the group data could not be retrieved
if (!$group) {
// Set a message to notify the user.
$this->session->set_flashdata('error', lang('permissions:message_no_group_id_provided'));
// Send him to the main index to select a proper group.
redirect('admin/permissions');
}
// See if this is the admin group
$group_is_admin = (bool) ($this->config->item('admin_group', 'ion_auth') == $group->name);
// Get the groups permission rules (no need if this is the admin group)
$edit_permissions = $group_is_admin ? array() : $this->permission_m->get_group($group_id);
// Get all the possible permission rules from the installed modules
$permission_modules = $this->module_m->get_all(array('is_backend' => true, 'installed' => true));
foreach ($permission_modules as &$permission_module) {
$permission_module['roles'] = $this->module_m->roles($permission_module['slug']);
}
$this->template->append_js('module::group.js')->set('edit_permissions', $edit_permissions)->set('group_is_admin', $group_is_admin)->set('permission_modules', $permission_modules)->set('group', $group)->build('admin/group');
}