public function actionCreate() { $model = new Announcement(); if (isset($_POST['Announcement'])) { $model->attributes = $_POST['Announcement']; $model->create_time = time(); $model->update_time = time(); if ($model->save()) { $model->order_id = $model->id; $model->save(); $this->redirect(array('index')); } else { throw new CHttpException(404, Yii::t('yii', '创建失败')); } } else { throw new CHttpException(404, 'no post param'); } }
/** * Admin: Save new announcement. * @return \Illuminate\Http\RedirectResponse */ public function postCreate() { $data = Input::all(); $validator = Validator::make($data, array('probability' => 'required', 'series_id' => 'required', 'announcement_type' => 'required', 'name' => 'required', 'game' => 'required', 'coefficient' => 'required')); if ($validator->fails()) { Flash::error('Все поля формы обязательны'); return Redirect::to('admin/announcements')->withInput(); } $announcement = new Announcement($data); $expires = new Carbon(); $expires->addMinutes(10); $announcement->expires_at = $expires; $announcement->save(); // Send message to WebSocket server. $this->broadcast(array('stream' => $announcement->series_id, 'type' => 'message', 'text' => $announcement->getMessage(), 'ratio' => $announcement->probability, 'id' => $announcement->id)); Flash::success('Анонс сохранен.'); return Redirect::to('admin/announcements'); }
/** * 新增公告 */ public function actionCreate($courseId) { $announcement = new Announcement(); if (isset($_POST['Announcement'])) { $_POST['Announcement']['addTime'] = time(); $_POST['Announcement']['upTime'] = time(); $_POST['Announcement']['courseId'] = $courseId; $announcement->attributes = $_POST['Announcement']; if ($announcement->save()) { Yii::app()->user->setFlash('success', '添加成功!'); $this->sendNotice($courseId, array('announcementId' => $announcement->id), 'announcement_added'); $this->redirect(array('index', 'courseId' => $courseId)); } else { Yii::app()->user->setFlash('error', '添加失败!'); $this->redirect(array('index', 'courseId' => $courseId)); } } $this->layout = "/layouts/nonav_column1"; Yii::app()->clientScript->scriptMap['*.js'] = false; $this->renderPartial('create', array('model' => $announcement), false, true); }
$announcement->status = ARCHIVED; } //for parent ie content class $announcement->title = $_POST['title']; $announcement->body = $_POST['body']; $announcement->author_id = $_SESSION['user']['id']; $announcement->type = ANNOUNCEMENT; // for child ie announcement class $announcement->position = $_POST['position']; //for publishing time $announcement->announcement_time = time(); $announcement->is_active = 1; if ($aid) { $announcement->content_id = $aid; } $announcement->save(); if ($announcement->status == ARCHIVED) { $error_msg = "Announcement could not be made live, it is saved as Archieved"; } $error_msg .= "<br>Announcement has been made succesfully"; $form_data = NULL; if (!$aid) { //send notification only if announcement is created $params['aid'] = $res['aid']; auto_email_notification('announcement', $params); } header("location : {$base_url}/network_announcement.php"); } //if no error } // $_post
public function actionAnnouncement() { //print_r($_POST);exit; $announment = new Announcement(); $announment->uploadsourcetype = 61; $announment->uploadsourceid = $_POST['groupid']; $announment->announcement = $_POST['announcement']; $announment->createdby = Yii::app()->session['login']['id']; $announment->createddate = new CDbExpression('NOW()'); $announment->status = 1; if ($announment->save(false)) { $this->redirect(Yii::app()->createUrl('group/dashboard', array('groupid' => $_POST['groupid']))); } }
/** * Local Functions */ function addAnnouncement($arr = '') { if ($arr != '') { // If this is set to false don't write to database. $valid_write = true; if (isset($arr['title'])) { $title = $arr['title']; } else { $valid_write = false; } if (isset($arr['message'])) { $message = $arr['message']; } else { $valid_write = false; } if (isset($arr['create_date'])) { $create_date = $arr['create_date']; } else { $valid_write = false; } if (isset($arr['start_date'])) { $start_date = $arr['start_date']; } else { $start_date = date("Y-m-d H:i:s"); } if (isset($arr['end_date'])) { $end_date = $arr['end_date']; } else { $end_date = date("Y-m-d H:i:s"); } // Check that the start date is before the end date. if (isset($start_date) && isset($end_date)) { if ($start_date > $end_date) { echo "You cannot have a end date that is before the start date!"; return false; } } if ($valid_write) { // Let's write something to the database. $thisAnnouncement = new Announcement(); $thisAnnouncement->title = $title; $thisAnnouncement->message = $message; $thisAnnouncement->create_date = $create_date; $thisAnnouncement->start_date = $start_date; $thisAnnouncement->end_date = $end_date; $thisAnnouncement->save(); return true; } } return false; }
public function doAnnouncement($id) { global $club, $messageData, $messageSubject, $team, $sms, $user, $recipientMobile, $recipientEmail; $user = Auth::user(); // $club = $user->Clubs()->FirstOrFail(); // $team = Team::where("id", "=",$id)->where("club_id",'=',$club->id)->FirstOrFail(); $team = Team::find($id); $club = $team->club; $members = Member::where('team_id', '=', $team->id)->get(); $messageData = Input::get('message'); $messageSubject = Input::get('subject'); $sms = substr($messageData, 0, 140) . " {$club->name} - Do not reply"; $uuid = Uuid::generate(); //get list of recepients $recipientUser = array(); $recipientPlayer = array(); $recipientContact = array(); $recipientEmail = array(); $recipientMobile = array(); //do selection for children events if ($team->children->count() > 0) { foreach ($team->children as $e) { foreach ($e->members as $member) { //only members that accepted joined if ($member->accepted_user) { $user = User::find($member->accepted_user); $player = Player::find($member->player_id); $recipientUser[] = array('name' => $user->profile->firstname . " " . $user->profile->lastname, 'email' => $user->email, 'mobile' => $user->profile->mobile); foreach ($player->contacts as $contact) { $recipientContact[] = array('name' => $contact->firstname . " " . $contact->lastname, 'email' => $contact->email, 'mobile' => $contact->mobile); } //allow players with email and mobile if ($player->mobile && $player->email) { $recipientPlayer[] = array('name' => $player->firstname . " " . $player->lastname, 'email' => $player->email, 'mobile' => $player->mobile); } } } } } else { foreach ($members as $member) { //only members that accepted joined if ($member->accepted_user) { $user = User::find($member->accepted_user); $player = Player::find($member->player_id); $recipientUser[] = array('name' => $user->profile->firstname . " " . $user->profile->lastname, 'email' => $user->email, 'mobile' => $user->profile->mobile); foreach ($player->contacts as $contact) { $recipientContact[] = array('name' => $contact->firstname . " " . $contact->lastname, 'email' => $contact->email, 'mobile' => $contact->mobile); } //allow players with email and mobile if ($player->mobile && $player->email) { $recipientPlayer[] = array('name' => $player->firstname . " " . $player->lastname, 'email' => $player->email, 'mobile' => $player->mobile); } } } } //send default function function sendmessage($destination) { global $club, $messageData, $messageSubject, $team, $sms, $user, $recipientMobile, $recipientEmail; foreach ($destination as $recipient) { //send email notification of acceptance queue $data = array('club' => $club, 'messageOriginal' => $messageData, 'subject' => $messageSubject, 'team' => $team); Mail::later(3, 'emails.announcement.default', $data, function ($message) use($recipient, $club, $messageSubject) { $message->to($recipient['email'], $recipient['name'])->subject("{$messageSubject} | " . $club->name); }); $recipientEmail[] = array('name' => $recipient['name'], 'email' => $recipient['email']); if (Input::get('sms')) { $recipientMobile[] = array('name' => $recipient['name'], 'mobile' => $recipient['mobile']); //queue sms Queue::push(function ($job) use($recipient, $sms) { Twilio::message($recipient['mobile'], $sms); $job->delete(); }); } } } // send to user sendmessage($recipientUser); //send to player if (Input::get('players')) { sendmessage($recipientPlayer); } //send to contacts if (Input::get('family')) { sendmessage($recipientContact); } //save message to database $announcement = new Announcement(); $announcement->id = $uuid; $announcement->subject = $messageSubject; $announcement->message = $messageData; $announcement->sms = $sms; $announcement->to_email = serialize($recipientEmail); $announcement->to_sms = serialize($recipientMobile); $announcement->team_id = $team->id; $announcement->club_id = $club->id; $announcement->user_id = $user->id; $status = $announcement->save(); return array('success' => true, 'email' => $recipientEmail, 'mobile' => $recipientMobile); }
function post_announcement() { $this->data['subtitle'] = "Post New Announcement"; if ($this->input->post()) { if ($this->form_validation->run('announcement') == FALSE) { $this->content_view = "admin/announcement"; $this->data['error'] = true; } else { $this->content_view = "admin/announcement_success"; $attributes = array("title" => $this->input->post('title'), "text" => $this->input->post('text'), "user_id" => $this->session->userdata('user_id')); $new_announcement = new Announcement($attributes); $new_announcement->save(); } } else { $this->content_view = "admin/announcement"; } }