本文整理汇总了PHP中Notice::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::save方法的具体用法?PHP Notice::save怎么用?PHP Notice::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* 新增数据
*
*/
public function actionCreate()
{
$model = new Notice();
if (isset($_POST['Notice'])) {
$model->attributes = $_POST['Notice'];
//标题样式
$title_style = $this->_request->getPost('style');
if ($title_style['bold'] != 'Y') {
unset($title_style['bold']);
}
if ($title_style['underline'] != 'Y') {
unset($title_style['underline']);
}
if (!$title_style['color']) {
unset($title_style['color']);
}
if ($title_style) {
$model->title_style = serialize($title_style);
} else {
$model->title_style = '';
}
//摘要
$model->introduce = trim($_POST['Notice']['introduce']) ? $_POST['Notice']['introduce'] : Helper::truncate_utf8_string(preg_replace('/\\s+/', ' ', $_POST['Notice']['content']), 200);
$model->create_time = time();
$model->update_time = $model->create_time;
if ($model->save()) {
$this->message('success', Yii::t('admin', 'Add Success'), $this->createUrl('index'));
}
}
$this->render('create', array('model' => $model));
}
示例2: approve
function approve($id)
{
if ($_POST) {
$notice = new Notice($id);
$_POST['approve_id'] = $this->session->userdata('id');
$notice->approve_date = date("Y-m-d H:i:s");
$notice->from_array($_POST);
$notice->save();
echo approve_comment($notice);
}
}
示例3: publishNotice
public function publishNotice()
{
$title = Input::get("title");
$content = Input::get("content");
if (!$title || !$content) {
return Response::json(array("errCode" => 1, "errMsg" => "[参数错误]请填写要发布公告的标题和内容"));
}
$notice = new Notice();
$notice->title = $title;
$notice->content = $content;
if (!$notice->save()) {
return Response::json(array("errCode" => 1, "errMsg" => "[数据库错误]发布失败"));
}
return Response::json(array("errCode" => 0));
}
示例4: actionSetStatus
public function actionSetStatus($id, $status)
{
$course = Course::model()->findByPk($id);
$oldState = $course->status;
$course->status = $status;
$result = $course->save();
if ($result && ($oldState == "apply" && $status == Course::STATUS_OK)) {
$notice = new Notice();
$notice->type = 'course_publish';
$notice->setData(array('courseId' => $id));
$notice->userId = $course->userId;
$notice->save();
}
if ($result) {
Yii::app()->user->setFlash('success', '操作成功');
}
$this->redirect(array('index'));
}
示例5: actionSetStatus
/**
* set status
* @param integer $id
* @param integer $status
*/
public function actionSetStatus($id, $status)
{
$group = Group::model()->findByPk($id);
$oldState = $group->status;
$group->status = $status;
$result = $group->save();
if ($result && ($oldState == "apply" && $status == "ok")) {
$notice = new Notice();
$notice->type = 'group_publish';
$notice->setData(array('groupId' => $id));
$notice->userId = $group->userId;
$notice->save();
}
if ($result) {
Yii::app()->user->setFlash('success', '操作成功');
}
$this->redirect(array('index'));
}
示例6: sendNotice
/**
* 发送Notice
*/
private function sendNotice($courseId, $announcementId, $entityType = 'announcement_added')
{
$courseMember = new CourseMember();
$members = $courseMember->findAllByAttributes(array('courseId' => $courseId));
foreach ($members as $k => $v) {
$entity = new Entity();
$eData['type'] = 'announcement';
$entity->attributes = $eData;
$entity->save();
$notice = new Notice();
$nData['userId'] = $v->userId;
$nData['type'] = $entityType;
$nData['addTime'] = time();
$nData['data'] = serialize(Announcement::model()->findByPk($announcementId)->id);
$notice->attributes = $nData;
$notice->save();
}
}
示例7: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->info('Search Delivery Items Life Time');
// 六十天提醒
//
$N_Time = date("Y-m-d", time());
$L_Time = date("Y-m-d", time() + 60 * 3600 * 24);
// 获取满足条件的货品
//
$Items = DeliveryItems::where('life_date', '>', $N_Time)->where('life_date', '<', $L_Time)->orderBy('delivery_id', 'desc')->get();
// 初始化
//
$branch_ids = array();
$delivery_ids = array();
foreach ($Items as $Item) {
// 条件过滤
//
if (!in_array($Item->delivery_id, $delivery_ids) && in_array($Item->branch_id, $branch_ids)) {
continue;
} else {
if (!in_array($Item->delivery_id, $delivery_ids)) {
$delivery_ids[] = $Item->delivery_id;
}
if (!in_array($Item->branch_id, $branch_ids)) {
$branch_ids[] = $Item->branch_id;
}
$branch = Branch::find($Item->branch_id);
$delivery = Delivery::find($Item->delivery_id);
if ($branch && $delivery) {
$notice = new Notice();
$notice->user_id = $branch->user_id;
$notice->type = '5';
$notice->content = '客户(' . $branch->name . ')的出货单(' . $delivery->bn . ')中商品(' . $Item->good_name . ')' . date("Y-m-d", strtotime($Item->life_date)) . ' 过期!';
$notice->data = json_encode(array('branch_id' => $Item->branch_id, 'delivery_id' => $Item->delivery_id));
$notice->read = '0';
$notice->timeline = date("Y-m-d H:i:s", time());
$notice->save();
$this->info($notice->content);
}
}
}
$this->info('Done!');
}
示例8: createNotice
static function createNotice($type, $targetUserID, $content = '', $appID, $reviewID)
{
$targetUser = User::model()->findByPk($targetUserID);
if ($targetUser && $targetUser->Status != -1) {
$notice = new Notice();
$notice->type = $type;
$notice->targetUserid = $targetUserID;
if (!empty($content)) {
$content = mb_substr($content, 0, 128, 'utf-8');
}
$notice->msg = $content;
$notice->createTime = date('Y-m-d H:i:s');
$notice->appId = $appID;
$notice->reviewId = $reviewID;
if (!$notice->save()) {
throw new CDbException($notice->getErrors());
}
return $notice->ID;
}
return false;
}
示例9: actionShareResultNotice
public function actionShareResultNotice()
{
$appID = Yii::app()->request->getParam('appID');
$app = AppInfoList::model()->findByPk($appID);
if (!$app instanceof AppInfoList) {
echo new ReturnInfo(RET_ERROR, 'app id error');
Yii::app()->end();
}
$user = User::model()->findByPk($app->CommitUserId);
if (!$user instanceof User || $user->Status != 0) {
echo new ReturnInfo(RET_ERROR, 'user id or user status error');
Yii::app()->end();
}
$message = '';
if ($app->Status == 0) {
$message = '您分享的<a href="/produce/index/' . $appID . '">App《' . htmlspecialchars($app->AppName) . '》</a>已经通过审核';
} else {
if ($app->Status == 2) {
$message = '您分享的App(<a href="' . rawurlencode($app->AppUrl) . '" target="_blank">' . htmlspecialchars($app->AppUrl) . '</a>),没有通过审核';
} else {
echo new ReturnInfo(RET_ERROR, 'app status error');
Yii::app()->end();
}
}
$notice = new Notice();
$notice->type = 0;
$notice->targetUserid = $app->CommitUserId;
$notice->msg = $message;
$notice->createTime = date('Y-m-d H:i:s');
$notice->appId = $appID;
if ($notice->save()) {
echo new ReturnInfo(RET_SUC, true);
} else {
echo new ReturnInfo(RET_ERROR, $notice->getErrors());
}
}
示例10: create_notice
public function create_notice()
{
if (Auth::check()) {
$data["inside_url"] = Config::get('app.inside_url');
$data["user"] = Session::get('user');
$data["actions"] = Session::get('actions');
if (in_array('side_nuevo_comunicado', $data["actions"])) {
$current_ay = AcademicYear::getCurrentAcademicYear();
if (!$current_ay) {
return View::make('notices/academic_year_error', $data);
}
// Validate the info, create rules for the inputs
$attributes = array('title' => 'Título del Comunicado', 'description' => 'Contenido del Comunicado');
$messages = array();
$rules = array('title' => 'required|min:2|max:50', 'description' => 'required|max:500');
// Run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules, $messages, $attributes);
// If the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::to('notices/new_notice')->withErrors($validator)->withInput(Input::all());
} else {
$level_id = Input::get('level_id');
// se crea el comunicado
$notice = new Notice();
$notice->title = Input::get('title');
$notice->description = Input::get('description');
if ($data["user"]->teacher) {
$notice->teacher_id = $data["user"]->teacher->id;
} elseif (AdministrativeStaff::where('user_id', '=', $data["user"]->id)->first()) {
$notice->administrative_staff_id = AdministrativeStaff::where('user_id', '=', $data["user"]->id)->first()->id;
}
if ($level_id != '0') {
$notice->level_id = $level_id;
}
$notice->academic_year_id = $current_ay->id;
$notice->save();
Session::flash('message', 'Se creó correctamente el Comunicado.');
// Llamo a la función para registrar el log de auditoria
$log_description = "Se creó el Comunicado con id: {{$notice->id}}";
Helpers::registerLog(3, $log_description);
return Redirect::to('notices/view_notices');
}
} else {
// Llamo a la función para registrar el log de auditoria
$log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
Helpers::registerLog(10, $log_description);
Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
return Redirect::to('/dashboard');
}
} else {
return View::make('error/error');
}
}
示例11: create_notices
/**
* 插入随机数据
*/
protected function create_notices($total = 50)
{
echo 'Creating notices...';
for ($i = 0; $i < 50; ++$i) {
$notice = new Notice();
$notice->title = $this->get_random(self::$RANDOM_ALPHA, 32, 32);
$notice->content = $this->get_random(self::$RANDOM_ALPHA_NUM, 50, 100);
$notice->created_at = $this->get_random_datetime();
$notice->save();
}
echo 'Done' . PHP_EOL;
}
示例12: Notify
/**
* Эта адова хуйня отправляет оповещение пользователю. Кто-то в будущем должен задуматься о её разумности.
* @param int $typ тип оповещения, Notice::*
* @param mixed $param1 зависит от типа оповещения, обычно - Book
* @param mixed $param2 зависит от типа, обычно - User, если null - то текущий юзер
* @param mixed $param3 зависит от типа
* @return bool
*/
public function Notify($typ, $param1, $param2 = null, $param3 = null)
{
if ($this->isDeleted) {
return true;
}
$Notice = new Notice();
$Notice->typ = $typ;
$Notice->user_id = $this->id;
$msg = "";
switch ($typ) {
case Notice::INVITE:
case Notice::JOIN_REQUEST:
if ($param2 === null) {
$param2 = Yii::app()->user;
}
$msg = "{$param1->id}\n{$param1->fullTitle}\n{$param2->id}\n{$param2->login}";
break;
case Notice::JOIN_ACCEPTED:
case Notice::JOIN_DENIED:
case Notice::EXPELLED:
case Notice::BANNED:
case Notice::UNBANNED:
case Notice::CROWNED:
case Notice::DEPOSED:
$msg = "{$param1->id}\n{$param1->fullTitle}";
break;
case Notice::CHAPTER_ADDED:
$msg = "{$param1->id}\n{$param1->fullTitle}\n{$param2->id}\n{$param2->title}";
break;
case Notice::CHAPTER_STATUS:
$msg = "{$param1->id}\n{$param1->fullTitle}\n{$param2->id}\n{$param2->title}\n{$param3}";
break;
default:
$msg = $param1;
}
$Notice->msg = $msg;
if (!$Notice->save()) {
return false;
}
// Уведомление по мылу, если надо
if ($this->ini_get(self::INI_MAIL_NOTICES)) {
$subj = array(Notice::INVITE => "Приглашение в группу перевода", Notice::JOIN_REQUEST => "Заявка на вступление в группу перевода", Notice::JOIN_ACCEPTED => "Заявка принята", Notice::JOIN_DENIED => "Заявка отклонена", Notice::EXPELLED => "Исключение из группы", Notice::BANNED => "Бан", Notice::UNBANNED => "Бан снят", Notice::CROWNED => "Назначение модератором", Notice::DEPOSED => "Лишение модераторских полномочий", Notice::CHAPTER_ADDED => "Новая глава в переводе, за которым вы следите", Notice::CHAPTER_STATUS => "Изменился статус перевода, за которым вы следите");
$msg = new YiiMailMessage($subj[$Notice->typ]);
$msg->view = "notice";
$msg->setFrom(array(Yii::app()->params["systemEmail"] => "Оповещение"));
$msg->addTo($this->email);
$msg->setBody(array("Notice" => $Notice, "user" => $this), "text/html");
Yii::app()->mail->send($msg);
}
return true;
}
示例13: actionComment
public function actionComment()
{
$comment = new LessonComment();
if (isset($_POST['LessonComment'])) {
$comment->attributes = $_POST['LessonComment'];
$comment->userId = Yii::app()->user->id;
$comment->addTime = time();
if ($comment->save()) {
$comment = LessonComment::model()->findByPk($comment->getPrimaryKey());
if ($comment->referid) {
$notice = new Notice();
$notice->type = 'lesson_recomment';
$notice->setData(array('commentId' => $comment->commentId));
$notice->userId = $comment->refer->userId;
$result = $notice->save();
}
$commentDataProvider = new CArrayDataProvider($comment->lesson->comments, array('keyField' => 'commentId', 'pagination' => array('pageSize' => 20)));
$feed = new Feed();
$feed->type = 'lesson_comment';
$feed->setData(array('commentId' => $comment->getPrimaryKey()));
$feed->save();
$feed->dispatch(array('user' => array('userId' => $comment->userId), 'course' => array('courseId' => $comment->lesson->courseId)));
$this->renderPartial('_comment', array('commentDataProvider' => $commentDataProvider));
}
}
// $this->redirect(array('view','id'=>$comment->lessonid));
}
示例14: actionApplyPublish
public function actionApplyPublish($courseId)
{
$course = $this->loadModel($courseId);
if ($course->userId == Yii::app()->user->id) {
$course->status = "applying";
if ($course->save()) {
//通知#1用户
$notice = new Notice();
$notice->userId = 1;
$notice->type = "apply_publish_course";
$notice->setData(array('courseId' => $courseId));
$notice->save();
echo true;
}
}
}
示例15: postAdd
public function postAdd()
{
$validator = Validator::make(Input::all(), Notice::$rules);
if ($validator->passes()) {
if (Input::get("user") == 0) {
$notice = new Notice();
$notice->notice_id = Input::get("noticeId");
$notice->body = Input::get("body");
if ($notice->save()) {
return Redirect::back()->with("event", "<p class='alert alert-success'><span class='glyphicon glyphicon-ok'></span> Notice created. You can add another.</p>");
}
return Redirect::back()->with("event", "<p class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> Error occured. Please try after sometime</p>");
} else {
$notice = new Notice();
$notice->notice_id = Input::get("noticeId");
$notice->body = Input::get("body");
if ($notice->save()) {
return View::make("Dashboard.Notices.BrowseUser")->with("notice", Input::get("noticeId"))->with("users", User::all());
}
return Redirect::back()->with("event", "<p class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> Error occured. Please try after sometime</p>");
}
}
return Redirect::back()->withErrors($validator)->withInput();
}