/** * */ protected function bindToShutdown() { if (!$this->shutdownBound) { $this->shutdownBound = true; $this->Events->bindEvent('shutdown', $this, 'handleShutdown'); } }
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(); } }
function main() { $events = new Events(); $person = (new Facebook())->person(S()->id()); $events->signUp($_GET['event_id'], S()->id(), $person['name'], $person['link']); R('/'); }
/** * Allow one instance only! * * @return Events instance */ public static function getInstance() { static $instance = false; if (!$instance) { $instance = new Events(); $instance->initializeListeners(); } return $instance; }
/** * 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); } }
/** * @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']); }
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']; } } }
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" => "*****@*****.**"], ["type" => "email", "value" => "*****@*****.**"], ["type" => "phone", "value" => "8001235555"]]; $event->participantIds($participantIds); $res = $event->update(); $this->assertInstanceOf('Events', $res); }
/** * @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']); }
public function dispatch() { $action = $this->_request->get('action', ''); foreach ($this->_routing as $values) { if ($values['act'] == $action) { return call_user_func(array($this, $values['action'] . 'Action')); } } if (!$this->eventManager->processNotify('FrontController.dispatch', $this, $action)) { return; } throw new Exception('Запрашиваемая страница не найдена', 404); }
public function testStopPropagation() { $handler = \Closure::bind(function () { $this->buffer = 'closure'; throw new StopPropagation(); }, $this, get_class($this)); $handler2 = \Closure::bind(function () { $this->buffer = 'closure2'; }, $this, get_class($this)); $this->events->on('name', $handler); $this->events->on('name', $handler2); $this->events->emit('name'); self::assertEquals('closure', $this->buffer); }
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()); }
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; }
/** @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)); }
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'); } }
/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['eventreader'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } // Set the item from the auto_item parameter if (!isset($_GET['events']) && \Config::get('useAutoItem') && isset($_GET['auto_item'])) { \Input::setGet('events', \Input::get('auto_item')); } // Do not index or cache the page if no event has been specified if (!\Input::get('events')) { /** @var \PageModel $objPage */ global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; return ''; } $this->cal_calendar = $this->sortOutProtected(deserialize($this->cal_calendar)); // Do not index or cache the page if there are no calendars if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) { /** @var \PageModel $objPage */ global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; return ''; } return parent::generate(); }
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.'); }
/** * 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'); }
/** * Vytvori entity, nebo vrati tuto existujici. * @param array * @return IEntity * @see IRepository::hydrateEntity() */ public function create($data) { if ($this->conventional === NULL) { $this->conventional = $this->repository->getMapper()->getConventional(); // speedup $this->primaryKey = $this->conventional->getPrimaryKey(); } if (!isset($data[$this->primaryKey])) { throw new BadReturnException("Data, that is returned from storage, doesn't contain id."); } $id = $data[$this->primaryKey]; if (!isset($this->entities[$id]) or !$this->entities[$id]) { $data = (array) $this->conventional->formatStorageToEntity($data); $entityName = $this->repository->getEntityClassName($data); $this->checkEntityClassName($entityName); $entity = unserialize("O:" . strlen($entityName) . ":\"{$entityName}\":0:{}"); if (!$entity instanceof IEntity) { throw new InvalidEntityException('Unserialize error'); } $args = array('data' => $data); $this->events->fireEvent(Events::HYDRATE_BEFORE, $entity, $args); $id = $entity->id; $this->entities[$id] = $entity; $this->events->fireEvent(Events::HYDRATE_AFTER, $entity, $args); } return $this->entities[$id]; }
public static function build($statistic, $page = 1) { if ($statistic['type'] === 'all') { $bestPodiums = array(); $eventIds = array_keys(Events::getNormalEvents()); $temp = $statistic; $temp['type'] = 'single'; foreach ($eventIds as $eventId) { $temp['eventId'] = $eventId; $bestPodiums[$eventId] = self::build($temp); } return self::makeStatisticsData($statistic, array('statistic' => $bestPodiums, 'select' => Events::getNormalEvents(), 'selectHandler' => 'Yii::t("event", "$name")', 'selectKey' => 'event')); } $eventId = $statistic['eventId']; $type = self::getType($eventId); $command = Yii::app()->wcaDb->createCommand(); $command->select(array('r.competitionId', 'r.eventId', 'r.roundId', self::getSelectSum($eventId, $type), 'c.cellName', 'c.cityName', 'c.year', 'c.month', 'c.day'))->from('Results r')->leftJoin('Competitions c', 'r.competitionId=c.id')->where('r.eventId=:eventId', array(':eventId' => $eventId))->andWhere('r.roundId IN ("c", "f")')->andWhere('r.pos IN (1,2,3)')->andWhere('c.countryId="China"')->andWhere("r.{$type} > 0"); $cmd = clone $command; $command->group('r.competitionId')->order('sum ASC')->having('count(DISTINCT pos)<=3 AND count(pos)>=3')->limit(self::$limit)->offset(($page - 1) * self::$limit); $columns = array(array('header' => 'Yii::t("common", "Competition")', 'value' => 'CHtml::link(ActiveRecord::getModelAttributeValue($data, "name"), $data["url"])', 'type' => 'raw'), array('header' => 'Yii::t("Competition", "Date")', 'value' => '$data["date"]', 'type' => 'raw'), array('header' => 'Yii::t("statistics", "Sum")', 'value' => 'CHtml::tag("b", array(), $data["formatedSum"])', 'type' => 'raw'), array('header' => 'Yii::t("common", "Average")', 'value' => '$data["formatedAverage"]', 'type' => 'raw'), array('header' => 'Yii::t("statistics", "First")', 'value' => self::makePosValue('first'), 'type' => 'raw'), array('header' => '', 'value' => self::makePosResultValue('first')), array('header' => 'Yii::t("statistics", "Second")', 'value' => self::makePosValue('second'), 'type' => 'raw'), array('header' => '', 'value' => self::makePosResultValue('second')), array('header' => 'Yii::t("statistics", "Third")', 'value' => self::makePosValue('third'), 'type' => 'raw'), array('header' => '', 'value' => self::makePosResultValue('third'))); $rows = array(); foreach ($command->queryAll() as $row) { $row = self::getCompetition($row); self::setPodiumsResults($row, $type); $row['formatedSum'] = self::formatSum($row); $row['formatedAverage'] = self::formatAverage($row); $row['date'] = sprintf("%d-%02d-%02d", $row['year'], $row['month'], $row['day']); $rows[] = $row; } $statistic['count'] = $cmd->select('count(DISTINCT r.competitionId) AS count')->queryScalar(); $statistic['rank'] = ($page - 1) * self::$limit; $statistic['rankKey'] = 'sum'; return self::makeStatisticsData($statistic, $columns, $rows); }
public function index() { $this->load->parser(); $validation_rules = array(array('field' => 'email_test_form_captcha', 'label' => 'Captcha', 'rules' => 'nohtml|trim|callback__captcha')); $success = false; $messages = array(); $this->form_validation->set_rules($validation_rules); if ($this->form_validation->run()) { $custom_text = $this->input->post('custom_text'); $custom_html = trim($custom_text) != '' ? $this->parser->parse_string($custom_text, null, true, array('textile' => array('restricted_mode' => true))) : ''; $success = (bool) Events::trigger('email_test', array('custom_text' => $custom_html)); if ($success) { $messages[] = $this->lang->line('mailer_your_message_has_been_sent'); } else { if ($this->registry->get('email_debugger') != '') { $messages[] = $this->lang->line('mailer_error') . '<br /><br />' . $this->registry->get('email_debugger'); } else { $messages[] = $this->lang->line('mailer_error'); } } } else { $messages = validation_errors_array(); } extract(Modules::run('email/test/get_message')); $has_logo = file_exists(DEFAULTFCPATH . 'apple-touch-icon-precomposed.png'); $body = $this->parser->parse_string($body, array('has_logo' => $has_logo, 'logo_src' => default_base_url('apple-touch-icon-precomposed.png')), true, 'mustache'); $this->captcha->clear(); $this->template->set(compact('success', 'messages', 'subject', 'body'))->enable_parser_body('i18n')->build('email_test'); }
public function afterDelete() { parent::afterDelete(); if ($this->countByAttributes(['event_id' => $this->event_id]) == 0) { Events::model()->deleteByPk($this->event_id); } }
/** * Função para definir uso de cache na Query * * @access public * @return \MySQLTableCached */ public function Cache($iTimeout = 3600) { Storage::Set("cachedb.timeout", $iTimeout); Events::Set("BeforeQuery", function ($sSQL, $fCallback) { if (Storage::Get("cachedb.enabled", false)) { $mCache = @CacheDB::Get(sha1($sSQL)); if ($mCache !== false && !is_null($mCache)) { if ($fCallback) { $fCallback(json_decode($mCache, true), null); } return true; } else { return false; } } else { return false; } }); Events::Set("AfterQuery", function ($sSQL, $aResult) { if (Storage::Get("cachedb.enabled", false)) { @CacheDB::Set(sha1($sSQL), json_encode($aResult), Storage::Get("cachedb.timeout", 3600)); } }); return $this; }
public function init() { $self = $this; Events::add_listener('ws.response', function ($resp) use($self) { $self->dump($resp); }); }
/** * @see TransactionManagerInterface::unbindConnection */ public function unbindConnection(DatabaseInterface $connection) { $this->Events->unbindEvent('TransactionManager.rollback', $connection, 'rollback'); $this->Events->unbindEvent('TransactionManager.commit', $connection, 'commit'); $this->Events->unbindEvent('TransactionManager.begin', $connection, 'beginTransaction'); return $this; }
/** * Loads the library's dependencies and configuration. * * @return void */ public static function initialize() { // get all installed extensions if (empty(self::$extensions)) { self::$CI =& get_instance(); self::$extensions = self::$CI->extension->getInstalledExtensions(); } // Merge events from indivdual modules. foreach (Modules::list_modules() as $module) { // Skip if module is not installed if (!isset(self::$extensions[$module])) { continue; } $path = ROOTPATH . EXTPATH . "{$module}/config/"; if (is_file($path . 'events.php')) { $module_events = Modules::load_file('events', $path, 'config'); if (is_array($module_events)) { self::$events = array_merge_recursive(self::$events, $module_events); } } } if (self::$events === FALSE) { self::$events = array(); } }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $category = explode('_', $id); $category = $this->loadModel($category[0]); $events = array(); $dates = Dates::model()->findAllByAttributes(array('status_date' => 1), array('order' => 't.date_date ASC')); foreach ($dates as $key => $date) { $eventsDate = Events::model()->findAllByAttributes(array('dates_id_date' => $date->id_date, 'status_event' => 1, 'great_event' => 1, 'event_categories_id_category' => $category->id_category), array('order' => 't.hour_event ASC')); $events = array_merge($events, $eventsDate); } if (isset($_GET['event'])) { $event = Events::model()->findByAttributes(array('status_event' => 1, 'great_event' => 1, 'event_categories_id_category' => $category->id_category, 'id_event' => $_GET['event'])); if ($event == null) { throw new CHttpException(404, 'The requested page does not exist.'); } } else { if (isset($events[0])) { $event = $events[0]; $this->pageTitle = 'Eventos ' . $category->name_category . ' - ' . $this->pageTitle; $this->pageDescription = 'Los esperamos sin falta en nuestros eventos religiosos, teatro, danza, noches de música, cabalgata, carrozas y comparsas, deportes extremos y actividades para toda la familia.'; $this->tagImage = '/images/events/' . $event->image_event; } else { $event = null; } } $this->render('view', array('category' => $category, 'events' => $events, 'event' => $event)); }
/** * 전체 메인 페이지입니다 */ public function index() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_main_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $where = array('brd_search' => 1); $board_id = $this->Board_model->get_board_list($where); $board_list = array(); if ($board_id && is_array($board_id)) { foreach ($board_id as $key => $val) { $board_list[] = $this->board->item_all(element('brd_id', $val)); } } $view['view']['board_list'] = $board_list; $view['view']['canonical'] = site_url(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $page_title = $this->cbconfig->item('site_meta_title_main'); $meta_description = $this->cbconfig->item('site_meta_description_main'); $meta_keywords = $this->cbconfig->item('site_meta_keywords_main'); $meta_author = $this->cbconfig->item('site_meta_author_main'); $page_name = $this->cbconfig->item('site_page_name_main'); $layoutconfig = array('path' => 'main', 'layout' => 'layout', 'skin' => 'main', 'layout_dir' => $this->cbconfig->item('layout_main'), 'mobile_layout_dir' => $this->cbconfig->item('mobile_layout_main'), 'use_sidebar' => $this->cbconfig->item('sidebar_main'), 'use_mobile_sidebar' => $this->cbconfig->item('mobile_sidebar_main'), 'skin_dir' => $this->cbconfig->item('skin_main'), 'mobile_skin_dir' => $this->cbconfig->item('mobile_skin_main'), 'page_title' => $page_title, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords, 'meta_author' => $meta_author, 'page_name' => $page_name); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
/** * Do not show the module if no calendar has been selected * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['calendar'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } $this->cal_calendar = $this->sortOutProtected(deserialize($this->cal_calendar, true)); // Return if there are no calendars if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) { return ''; } $this->strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request')); $this->strLink = $this->strUrl; if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) { /** @var \PageModel $objTarget */ $this->strLink = $objTarget->getFrontendUrl(); } return parent::generate(); }
/** * Выполняет обработку запроса * * @param WS_Environment $env * * @return mixed */ public function run(WS_Environment $env) { $config = Config::all(); $env->assign_if(array('config' => $config)); Events::call('ws.config', $config); return $this->application->run($env); }