本文整理汇总了PHP中Events::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::model方法的具体用法?PHP Events::model怎么用?PHP Events::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Events
的用法示例。
在下文中一共展示了Events::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAfterDelete
public function testAfterDelete()
{
$user = User::model()->findByPk('2');
if (X2_TEST_DEBUG_LEVEL > 1) {
/**/
print 'id of user to delete: ';
/**/
print $user->id;
}
// test calendar permissions deletion
$this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
$this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
// assert that group to user records exist for this user
$this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) > 0);
$this->assertTrue($user->delete());
X2_TEST_DEBUG_LEVEL > 1 && (print 'looking for groupToUser records with userId = ' . $user->id);
GroupToUser::model()->refresh();
// assert that group to user records were deleted
$this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) === 0);
// test profile deletion
$this->assertTrue(sizeof(Profile::model()->findAllByAttributes(array('username' => $user->username))) === 0);
// test social deletion
$this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('user' => $user->username))) === 0);
$this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('associationId' => $user->id))) === 0);
// test event deletion
$this->assertTrue(sizeof(Events::model()->findAll("user=:username OR (type='feed' AND associationId=" . $user->id . ")", array(':username' => $user->username))) === 0);
// test calendar permissions deletion
$this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
$this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
}
示例2: actionView
/**
* 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));
}
示例3: afterDelete
public function afterDelete()
{
parent::afterDelete();
if ($this->countByAttributes(['event_id' => $this->event_id]) == 0) {
Events::model()->deleteByPk($this->event_id);
}
}
示例4: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Events::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例5: getCalendarByRange
function getCalendarByRange($id)
{
try {
$event = Events::model()->findByPk($id);
} catch (Exception $e) {
}
return $event;
}
示例6: actionIndex
public function actionIndex()
{
if (Yii::app()->request->isAjaxRequest) {
header('Content-Type: application/json');
echo CJSON::encode(array('success' => true, 'msg' => ProjectMessages::model()->findByPk(Events::model()->findByPk(Yii::app()->request->getParam('id'))->event_id)->message));
Yii::app()->end();
}
$events = Events::model()->findAll(array('condition' => '', 'order' => 'timestamp DESC'));
$this->render('index', array('events' => $events));
}
示例7: actionGetEventByUser
public function actionGetEventByUser()
{
$request = Yii::app()->request;
try {
$user_id = StringHelper::filterString($request->getQuery('user_id'));
$limit = StringHelper::filterString($request->getQuery('limit'));
$offset = StringHelper::filterString($request->getQuery('offset'));
$data = Events::model()->getEventByUser($user_id, $limit, $offset);
ResponseHelper::JsonReturnSuccess($data, 'Success');
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
}
示例8: actionEventos
public function actionEventos()
{
$this->pageTitle = 'Eventos - ' . $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/facebook-eventos.png';
$categories = array();
$categoriesDb = EventCategories::model()->findAllByAttributes(array('status_category' => 1));
foreach ($categoriesDb as $key => $category) {
$events = Events::model()->findAllByAttributes(array('status_event' => 1, 'great_event' => 1, 'event_categories_id_category' => $category->id_category), array('order' => 't.id_event ASC', 'limit' => 3));
if ($events != null) {
$categories[] = array('events' => $events, 'category' => $category);
}
}
$this->render('eventos', array('categories' => $categories));
}
示例9: actionDelete
public function actionDelete()
{
$id = Yii::app()->request->getParam('id');
if (Yii::app()->request->isAjaxRequest) {
header('Content-Type: application/json');
if (Events::model()->deleteByPk($id)) {
echo CJSON::encode(array('success' => true));
} else {
echo CJSON::encode(array('error' => true));
}
Yii::app()->end();
}
$events = Events::model()->findAll(array('condition' => '', 'order' => 'timestamp DESC'));
$this->render('index', array('events' => $events));
}
示例10: actionEvent
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionEvent($id)
{
if (Yii::app()->request->isAjaxRequest) {
$event = Events::model()->findByAttributes(array('id_event' => $id, 'status_event' => 1));
if ($event != null) {
$days = array('Monday' => 'Lunes', 'Tuesday' => 'Martes', 'Wednesday' => 'Miercoles', 'Thursday' => 'Jueves', 'Friday' => 'Viernes', 'Saturday' => 'Sabado', 'Sunday' => 'Domingo');
$hour = new DateTime($event->hour_event);
$date = new DateTime($event->datesIdDate->date_date);
$event->hour_event = $hour->format('g:i A');
$event->datesIdDate->date_date = $days[$date->format('l')] . ' ' . intval($date->format('d'));
echo CJSON::encode(array("title" => MyMethods::myStrtoupper($event->title_event), "image" => Yii::app()->request->baseUrl . '/images/events/' . $event->image_event, "place" => MyMethods::myStrtoupper($event->placesIdPlace->name_place), "hour" => $event->datesIdDate->date_date . ' - ' . $event->hour_event, "description" => $event->description_event));
} else {
throw new CHttpException(404, 'The requested page does not exist.');
}
} else {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
示例11: run
public function run($args)
{
$companies = Company::model()->findAll('frozen=:p', array(':p' => '0'));
foreach ($companies as $company) {
Company::setActive($company);
Yii::app()->language = Company::getLanguage();
User::model()->refreshMetaData();
AuthAssignment::model()->refreshMetaData();
ProfileField::model()->refreshMetaData();
Profile::model()->refreshMetaData();
Zakaz::model()->refreshMetaData();
ZakazParts::model()->refreshMetaData();
Events::model()->refreshMetaData();
Templates::model()->refreshMetaData();
Emails::model()->refreshMetaData();
self::executor();
self::manager();
self::send_deffered_emails();
}
}
示例12: getEventByUser
public function getEventByUser($user_id, $limit, $offset)
{
$criteria = new CDbCriteria();
$criteria->condition = "created_by = {$user_id}";
$criteria->limit = $limit;
$criteria->offset = $offset;
$result = Events::model()->findAll($criteria);
$returnArr = array();
foreach ($result as $item) {
$itemArr['name'] = $item->name;
$itemArr['images'] = $item->images;
$itemArr['description'] = $item->description;
$itemArr['status'] = $item->status;
$itemArr['date'] = $item->date;
$itemArr['address'] = $item->address;
$itemArr['type'] = $item->type;
$returnArr[] = $itemArr;
}
return $returnArr;
}
示例13: removeCalendar
function removeCalendar($id)
{
$ret = array();
try {
$event = Events::model()->findByPk($id);
$event->delete();
if ($event->save() == false) {
$ret['IsSuccess'] = false;
$ret['Msg'] = $event->error();
} else {
$ret['IsSuccess'] = true;
$ret['Msg'] = 'Succefully';
}
} catch (Exception $e) {
$ret['IsSuccess'] = false;
$ret['Msg'] = $e->getMessage();
}
return $ret;
}
示例14: actionIndex
/**
* Вывод и добавление сообщений
*/
public function actionIndex($orderId)
{
$isGuest = Yii::app()->user->isGuest;
Yii::app()->session['project_id'] = $orderId;
if (Yii::app()->request->isAjaxRequest) {
if (Yii::app()->request->getPost('ProjectMessages')) {
$id = (int) $_POST['ProjectMessages']['id'];
if ($id > 0) {
$model = ProjectMessages::model()->findByPk($id);
} else {
$model = new ProjectMessages();
$model->sender = Yii::app()->user->id;
$model->moderated = 0;
$model->order = $orderId;
}
$post = $_POST['ProjectMessages']['message'];
$post = str_replace("\r\n", '<br>', $post);
$post = str_replace("\n", '<br>', $post);
$_POST['ProjectMessages']['message'] = $post;
$model->attributes = Yii::app()->request->getPost('ProjectMessages');
$model->date = date('Y-m-d H:i:s');
switch ($model->recipient) {
case 'manager':
$model->recipient = 1;
break;
case 'customer':
if (User::model()->isCustomer()) {
$model->recipient = Zakaz::model()->resetScope()->findByPk($orderId)->attributes['executor'];
$type_id = Emails::TYPE_20;
} else {
if (User::model()->isAuthor()) {
$model->recipient = Zakaz::model()->findByPk($orderId)->attributes['user_id'];
$type_id = Emails::TYPE_16;
}
}
$user = User::model()->findByPk($model->recipient);
$profile = Profile::model()->findAll("`user_id`='{$model->recipient}'");
$email = new Emails();
$rec = Templates::model()->findAll("`type_id`='{$type_id}'");
$title = $rec[0]->title;
$body = $rec[0]->text;
$email->name = $user->full_name;
if (strlen($email->name) < 2) {
$email->name = $user->username;
}
$email->num_order = $orderId;
$email->message = $post;
$email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
$email->sendTo($user->email, $body, $type_id);
break;
}
//print_r($model);
//echo '<br>$model->save()='.$model->save();
EventHelper::addMessage($orderId, $model->message);
}
$this->renderPartial('chat', array('orderId' => $orderId, 'isGuest' => $isGuest));
Yii::app()->end();
}
$order = Zakaz::model()->resetScope()->findByPk($orderId);
$parts = ZakazParts::model()->findAll(array('condition' => "`proj_id`='{$orderId}'"));
if ($isGuest) {
Yii::app()->theme = 'client';
// если гость прошёл по ссылке на неcуществующий
// проект, отправляем его на регистрацию
$url = 'http://' . $_SERVER['SERVER_NAME'] . '/';
if (!$order) {
$this->redirect($url);
}
$moderate_types = EventHelper::get_moderate_types_string();
$events = Events::model()->findAll(array('condition' => "`event_id`='{$orderId}' AND `type` in ({$moderate_types})", 'order' => 'timestamp DESC'), array(':event_id' => $orderId));
$moderated = count($events) == 0;
// если гость прошёл по ссылке на непромодерированный
// проект, отправляем его на регистрацию
if (!$moderated) {
$this->redirect(Yii::app()->createUrl('user/login'));
}
// Catalog::model()->tableName();
//$EmptyChat = UserModule::t('EmptyChat');
$this->render('index', array('orderId' => $orderId, 'order' => $order, 'executor' => Zakaz::getExecutor($orderId), 'moderated' => $moderated, 'isGuest' => $isGuest, 'parts' => $parts));
Yii::app()->end();
}
$moderate_types = EventHelper::get_moderate_types_string();
$events = Events::model()->findAll(array('condition' => "`event_id`='{$orderId}' AND `type` in ({$moderate_types})", 'order' => 'timestamp DESC'), array(':event_id' => $orderId));
$moderated = count($events) == 0;
$this->render('index', array('orderId' => $orderId, 'order' => $order, 'executor' => Zakaz::getExecutor($orderId), 'moderated' => $moderated, 'isGuest' => $isGuest, 'parts' => $parts));
}
示例15: actionModerationAnswer
/**
* Одобрение или нет заказа
* @param $answer
* @author Emericanec
*/
public function actionModerationAnswer($id, $event_id, $answer)
{
$model = Zakaz::model()->resetScope()->findByPk($id);
$event = Events::model()->findByPk($event_id);
if (!$model->is_active && $event) {
if ($answer == 1) {
$model->is_active = 1;
if ($model->save()) {
$event->delete();
// Заказчику проект принят
$type_id = Emails::TYPE_12;
$email = new Emails();
$order = Zakaz::model()->findByPk($id);
$user = User::model()->findByPk($order->user_id);
$email->from_id = 1;
$email->to_id = $user->id;
$rec = Templates::model()->findAll("`type_id`='{$type_id}'");
$campaign = Campaign::search_by_domain($_SERVER['SERVER_NAME']);
$email->campaign = $campaign->name;
$email->name = $user->full_name;
$email->num_order = $id;
$email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $id;
//$email->login= $user->username;
//$email->password= $soucePassword;
$email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id);
$this->redirect(Yii::app()->createUrl('project/zakaz/update', array('id' => $model->id)));
}
} else {
// если нет то просто удаляем
$model->delete();
$event->delete();
$this->redirect(Yii::app()->createUrl('project/event'));
}
} else {
$event->delete();
throw new CHttpException("Заказ не найден или его уже отмодерировали");
}
}