本文整理汇总了PHP中Notice::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::model方法的具体用法?PHP Notice::model怎么用?PHP Notice::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::model方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPostNoticeReturn
/**
* 提交消息信息
*/
public function actionPostNoticeReturn()
{
if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['noticeId']) || !isset($_REQUEST['status'])) {
$this->_return('MSG_ERR_LESS_PARAM');
}
$user_id = trim(Yii::app()->request->getParam('userId'));
$token = trim(Yii::app()->request->getParam('token'));
$noticeId = trim(Yii::app()->request->getParam('noticeId'));
$status = trim(Yii::app()->request->getParam('status'));
if (!ctype_digit($user_id) || $user_id < 1) {
$this->_return('MSG_ERR_NO_USER');
}
if (!ctype_digit($noticeId) || $noticeId < 1 || !Notice::model()->isExistNoticeId($noticeId, $user_id)) {
$this->_return('MSG_ERR_FAIL_NOTICE');
}
if (!ctype_digit($status) || !in_array($status, array(1, 2, 3, 4))) {
$this->_return('MSG_ERR_FAIL_NOTICE_STATUS');
}
// 验证token
if (Token::model()->verifyToken($user_id, $token)) {
$data = Notice::model()->postNoticeReturn($noticeId, $status);
$this->_return('MSG_SUCCESS', $data);
} else {
$this->_return('MSG_ERR_TOKEN');
}
}
示例2: actionNotices
public function actionNotices()
{
$ajax = false;
if (isset($_POST["rm"])) {
$id = (int) $_POST["rm"];
$n = Yii::app()->db->createCommand("DELETE FROM notices WHERE user_id = :user_id AND id = :id")->execute(array(":user_id" => Yii::app()->user->id, ":id" => $id));
$ajax = true;
}
$crit = new CDbCriteria();
if ($_GET["new"] == 1) {
$crit->addCondition("not seen");
}
$notices_dp = new CActiveDataProvider(Notice::model()->user(Yii::app()->user->id, false), array("criteria" => $crit, "pagination" => array("pageSize" => 20)));
$new_ids = array();
foreach ($notices_dp->data as $notice) {
if (!$notice->seen) {
$new_ids[] = $notice->id;
}
}
$this->side_view = array("notices_side" => array("new_ids" => $new_ids));
$p = array("notices_dp" => $notices_dp);
if ($ajax) {
$p["ajax"] = true;
$this->renderPartial("notices", $p);
} else {
$this->render("notices", $p);
}
// Отмечаем показанные, как прочитанные
if (count($new_ids) > 0) {
Yii::app()->db->createCommand("UPDATE notices SET seen = true WHERE user_id = :user_id AND id IN('" . join("','", $new_ids) . "')")->execute(array(":user_id" => Yii::app()->user->id));
}
}
示例3: actionIndex
public function actionIndex()
{
$noticeModel = Notice::model();
$msg = $noticeModel->findAll(array('condition' => 'targetUserid =:targetUserid AND readFlag = 1', 'order' => 'createTime', 'params' => array(':targetUserid' => $this->apiUser->ID)));
echo new ReturnInfo(RET_SUC, array('data' => $msg));
$noticeModel->updateAll(array('readFlag' => '0'), 'targetUserid = :targetUserid', array(':targetUserid' => $this->apiUser->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 $id the ID of the model to be loaded
* @return Notice the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Notice::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例5: actionIndex
public function actionIndex()
{
$noticeModel = Notice::model();
$targetUserid = Yii::app()->user->id;
$msgs = $noticeModel->findAll(array('condition' => 'targetUserid =:targetUserid AND readFlag = 1', 'order' => 'createTime', 'params' => array(':targetUserid' => $targetUserid)));
$noticeInfo = array();
foreach ($msgs as $msg) {
if ($msg->type == 0) {
$noticeInfo[] = array('type' => $msg->type, 'msg' => $msg->msg, 'createTime' => $msg->createTime);
} else {
$appInfo = AppInfoList::model()->find(array('select' => 'Id, AppName', 'condition' => 'Id = :appId', 'params' => array(':appId' => $msg->appId)));
$authorId = $msg->reviews->AuthorId;
$noticeInfo[] = array('type' => $msg->type, 'msg' => $msg->reviews->Content, 'createTime' => $msg->createTime, 'appName' => $appInfo->AppName, 'appID' => $appInfo->Id, 'authorName' => htmlspecialchars(CommonFunc::getRedis('user_' . $authorId, 'userName')), 'authorID' => $authorId);
}
}
$noticeModel->updateAll(array('readFlag' => '0'), 'targetUserid = :targetUserid', array(':targetUserid' => $targetUserid));
$this->render('msg', array('msg' => $noticeInfo));
}
示例6: actionBatch
/**
* 批量操作
*
*/
public function actionBatch()
{
if ($this->method() == 'GET') {
$command = trim($_GET['command']);
$ids = intval($_GET['id']);
} elseif ($this->method() == 'POST') {
$command = trim($_POST['command']);
$ids = $_POST['id'];
} else {
$this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
}
empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
switch ($command) {
case 'delete':
//删除
foreach ((array) $ids as $id) {
$postModel = Notice::model()->findByPk($id);
if ($postModel) {
$postModel->delete();
}
}
break;
case 'show':
//显示
foreach ((array) $ids as $id) {
$postModel = Notice::model()->findByPk($id);
if ($postModel) {
$postModel->status = 'Y';
$postModel->save();
}
}
break;
case 'hidden':
//隐藏
foreach ((array) $ids as $id) {
$postModel = Notice::model()->findByPk($id);
if ($postModel) {
$postModel->status = 'N';
$postModel->save();
}
}
break;
default:
throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
}
$this->message('success', Yii::t('admin', 'Batch Operate Success'));
}
示例7: postExtraLesson
/**
* 教师提交补课信息
* @param $user_id
* @param $departmentId
* @param $courseId
* @param $classroomId
* @param $extraTime
* @param $studentJson
* @param $extraReason
* @return array|bool
*/
public function postExtraLesson($user_id, $departmentId, $courseId, $classroomId, $extraTime, $studentJson, $extraReason)
{
$data = array();
$nowTime = date('Y-m-d H:i:s');
try {
$con_user = Yii::app()->cnhutong;
// 补课表添加数据
$result1 = $con_user->createCommand()->insert('com_extra', array('member_id' => $user_id, 'extra_time' => $extraTime, 'department_id' => $departmentId, 'course_id' => $courseId, 'classroom_id' => $classroomId, 'create_time' => $nowTime, 'update_time' => $nowTime, 'flag' => 1, 'status' => 1, 'type' => 2, 'reason' => $extraReason));
// 获取补课表id
$extraId = Yii::app()->cnhutong->getLastInsertID();
$studentNameArr = array();
// 补课详情表添加数据
foreach ($studentJson as $row) {
$result2 = $con_user->createCommand()->insert('com_extra_detail', array('extra_id' => $extraId, 'member_id' => $row['studentId'], 'status' => 0, 'create_time' => $nowTime, 'update_time' => $nowTime, 'create_user_id' => 0, 'update_user_id' => 0));
if (Common::model()->getNameById($row['studentId'])) {
$studentNameArr[] = Common::model()->getNameById($row['studentId']);
}
}
// 推送相关补课消息给相应老师
// 申请人名称
$userName = Common::model()->getNameById($user_id);
// 学员名称
$studentNames = implode(' ', $studentNameArr);
// 加课时间 $extraTime
// 课程
$courseName = Common::model()->getCourseById($courseId);
// 校区
$departmentName = Common::model()->getDepartmentById($departmentId);
// 老师
$teacherName = Common::model()->getNameById($user_id);
// 教室
$classroomName = Common::model()->getClassroomById($classroomId);
// 理由 备注 $extraReason
$msg_content = " 申请人: {$userName} &8424 学员: {$studentNames} &8424 时间: {$extraTime} &8424 课程: {$courseName} &8424 老师: {$teacherName} &8424 教室: {$departmentName}/{$classroomName} &8424 备注: {$extraReason} ";
$msg_title = '老师补课申请';
$alert_content = $teacherName . " 提交了 " . $extraTime . " 的补课申请";
// 添加老师补课消息
Notice::model()->insertNotice($user_id, $user_id, 1, null, $extraId, 3, $msg_title, $msg_content, $nowTime, 1, 0);
$push = Push::model()->pushMsg(11, $user_id, '3', $msg_title, $alert_content);
if ($push) {
return true;
} else {
return false;
}
} catch (Exception $e) {
error_log($e);
return false;
}
}
示例8: run
public function run($id)
{
$this->controller->_seoTitle = '公告通知详情 - ' . $this->controller->_setting['site_name'];
$model = Notice::model()->findByAttributes(array('id' => $id, 'status' => 'Y'));
$this->controller->render('notice_view', array('model' => $model));
}
示例9: postSign
/**
* 提交任务签到接口:
* 教师在App中提交学员课时签到信息
* @param $user_id
* @param $lessonJson
* @return bool|int
*/
public function postSign($user_id, $lessonJson)
{
$nowTime = date('Y-m-d H:m:i');
try {
$con_task = Yii::app()->cnhutong;
$table_name = 'ht_lesson_student';
// 按照课时ID进行签到,ht_lesson_student: status_id = 1(老师签到),step = 0 正常, step = 1 补课, step = 2 缺勤, step = 6 请假
foreach ($lessonJson as $row) {
// 需要对$lessonJson里面的数值做判断 if... step = 0 增加一条消息记录,jPush推送学员用户; step = 2|6 增加一条补课机会记录
$result = $con_task->createCommand()->update($table_name, array('status_id' => 1, 'step' => $row['step']), 'id = :id', array(':id' => $row['lessonStudentId']));
if ($row['step'] == 2 || $row['step'] == 6) {
// 判断 step = 2|6 添加补课机会记录
self::insertExtraChance($row['lessonStudentId'], $row['step']);
} elseif ($row['step'] == 0) {
// step = 0 增加一条消息记录,jPush推送学员用户发送销课通知
$acceptIdArr = self::getAcceptIdByLessonStudentId($row['lessonStudentId']);
// $acceptArr = array(); 则表示为该学员未绑定任何user_id 只记录消息,不推送
if ($acceptIdArr && $acceptIdArr[0]['user_id']) {
foreach ($acceptIdArr as $acceptId) {
$lessonDetail = Common::model()->getLessonDetailById($row['lessonStudentId']);
// 推送相关补课消息给相应老师
// 学员名称
$studentName = $lessonDetail['studentName'];
// 时间
$dateTime = $lessonDetail['date'] . ' ' . $lessonDetail['time'];
// 课程
$courseName = $lessonDetail['course'];
// 课时
$lesson_cnt_charged = $lessonDetail['lesson_cnt_charged'];
// 校区
$departmentName = $lessonDetail['department'];
// 老师
$teacherName = Common::model()->getNameById($user_id);
// 教室
$classroomName = $lessonDetail['classroom'];
// 学员
$studentId = $lessonDetail['studentId'];
// 理由 备注 $extraReason
$msg_content = " 学员: {$studentName} &8424 时间: {$dateTime} &8424 课程: {$courseName} &8424 课时: {$lesson_cnt_charged} &8424 老师: {$teacherName} &8424 教室: {$departmentName}/{$classroomName} ";
$msg_title = '销课通知';
$alert_content = $studentName . " 完成了 " . $courseName;
$push = Push::model()->pushMsg(10, $acceptId['user_id'], '1', $msg_title, $alert_content);
// if ($push) {
// return true;
// } else {
// return false;
// }
}
// 添加老师销课消息
Notice::model()->insertNotice($user_id, $studentId, 1, null, null, 1, $msg_title, $msg_content, $nowTime, 1, 0);
} else {
// 记录消息,不推送
$lessonDetail = Common::model()->getLessonDetailById($row['lessonStudentId']);
// 推送相关补课消息给相应老师
// 学员名称
$studentName = $lessonDetail['studentName'];
// 时间
$dateTime = $lessonDetail['date'] . ' ' . $lessonDetail['time'];
// 课程
$courseName = $lessonDetail['course'];
// 课时
$lesson_cnt_charged = $lessonDetail['lesson_cnt_charged'];
// 校区
$departmentName = $lessonDetail['department'];
// 老师
$teacherName = Common::model()->getNameById($user_id);
// 教室
$classroomName = $lessonDetail['classroom'];
// 学员
$studentId = $lessonDetail['studentId'];
// 理由 备注 $extraReason
$msg_content = " 学员: {$studentName} &8424 时间: {$dateTime} &8424 课程: {$courseName} &8424 课时: {$lesson_cnt_charged} &8424 老师: {$teacherName} &8424 教室: {$departmentName}/{$classroomName} ";
$msg_title = '销课通知';
// 添加老师销课消息
Notice::model()->insertNotice($user_id, $studentId, 1, null, null, 1, $msg_title, $msg_content, $nowTime, 1, 0);
}
} else {
return false;
}
// return true; // 不加会返回null
}
} catch (Exception $e) {
error_log($e);
return false;
}
}
示例10: lessonStudentLeave
/**
* 提交课时请假信息
* @param $memberId
* @param $courseId
* @param $lessonStudentId
* @param $dateTime
* @param $reason
* @return bool
*/
public function lessonStudentLeave($memberId, $courseId, $lessonStudentId, $dateTime, $reason)
{
$nowTime = date('Y-m-d H:i:s');
try {
$con_user = Yii::app()->cnhutong;
$table_name = 'com_leave';
// 请假表记录请假详情
$data = $con_user->createCommand()->insert($table_name, array('member_id' => $memberId, 'course_id' => $courseId, 'lesson_student_id' => $lessonStudentId, 'leave_time' => $dateTime, 'create_time' => $nowTime, 'update_time' => $nowTime, 'flag' => 2, 'status' => 1, 'reason' => $reason));
$leaveId = Yii::app()->cnhutong->getLastInsertID();
// 学员请假直接修改课表课时状态
$dataLeave = $con_user->createCommand()->update('ht_lesson_student', array('step' => 6), 'id = :lessonStudentId', array(':lessonStudentId' => $lessonStudentId));
// 根据课时id获得学员id (ht_lesson_student),再根据学员id获得绑定的user_id(com_user_member)
$lessonDetail = Common::model()->getLessonDetailById($lessonStudentId);
// 推送相关请假消息给相应老师
// 学员名称
$studentName = $lessonDetail['studentName'];
// 时间
$dateTime = $lessonDetail['date'] . ' ' . $lessonDetail['time'];
// 课程
$courseName = $lessonDetail['course'];
// 课时
$lesson_cnt_charged = $lessonDetail['lesson_cnt_charged'];
// 校区
$departmentName = $lessonDetail['department'];
// 老师
$teacherId = $lessonDetail['teacherId'];
// 教室
$classroomName = $lessonDetail['classroom'];
// 理由 备注 $extraReason
$msg_content = " 学员: {$studentName} &8424 时间: {$dateTime} &8424 课程: {$courseName} &8424 课时: {$lesson_cnt_charged} &8424 教室: {$departmentName}/{$classroomName} &8424 备注: {$reason} ";
$msg_title = '学员请假通知';
$alert_content = $dateTime . " 的 " . $courseName . " 有一位学员请假";
// 添加学员请假消息
// 教师
Notice::model()->insertNotice($memberId, $teacherId, 2, $leaveId, null, 2, $msg_title, $msg_content, $nowTime, 1, 0);
// 学生
Notice::model()->insertNotice($memberId, $memberId, 2, $leaveId, null, 2, $msg_title, $msg_content, $nowTime, 1, 0);
$push = Push::model()->pushMsg(11, $teacherId, '2', $msg_title, $alert_content);
// if ($push) {
// return true;
// } else {
// return false;
// }
} catch (Exception $e) {
error_log($e);
return false;
}
}