예제 #1
0
 public function postEdit($id)
 {
     $notices = Notice::getNotice($id);
     $notices->noticeContent = Request::input('noticeContent');
     $notices->save();
     print_r($notices);
     return redirect("/home");
 }
예제 #2
0
 public function actionNotifications()
 {
     $myId = Yii::$app->getUser()->id;
     Notice::updateAll(['updated_at' => time(), 'status' => 1], ['status' => 0, 'target_id' => $myId]);
     $query = Notice::find()->where(['target_id' => $myId]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count('id')]);
     $notices = $query->orderBy(['id' => SORT_DESC])->offset($pages->offset)->with(['source', 'topic'])->limit($pages->limit)->asArray()->all();
     return $this->render('notifications', ['notices' => $notices, 'pages' => $pages]);
 }
예제 #3
0
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert === true) {
         (new History(['user_id' => $this->user_id, 'action' => History::ACTION_ADD_COMMENT, 'action_time' => $this->created_at, 'target' => $this->id]))->save(false);
         Siteinfo::updateCounterInfo('addComment');
         UserInfo::updateCounterInfo('addComment', $this->user_id);
         Topic::afterCommentInsert($this->topic_id, $this->user_id);
         Notice::afterCommentInsert($this);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
 /**
  * server 运行状态
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @api {get} /status 查询运行状态
  * @apiName PostRegister
  * @apiGroup Status
  */
 public function index(Request $request)
 {
     $currentPage = 1;
     if ($request->has('page')) {
         $currentPage = $request->input('page');
         Paginator::currentPageResolver(function () use($currentPage) {
             return $currentPage;
         });
     }
     $per_page = $request->has('per_page') ? $request->input('per_page') : 20;
     $result = Notice::orderBy('id', 'DESC')->paginate($per_page)->toArray();
     return view('status', ['notice' => $result['data'], 'current_page' => $currentPage, 'last_page' => $result['last_page']]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Notice::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
예제 #6
0
 public function actionIndex()
 {
     $notice = null;
     $order_in = 0;
     $order_finish = 0;
     $order_pend = 0;
     if (!empty($this->user)) {
         $notice = Notice::find()->where('rids like :rids', [':rids' => '%,' . $this->user->rid . ',%'])->orderBy('create_time desc')->one();
         $order_in = CommodityOrder::find()->where('op_statu = :op_statu', [':op_statu' => CommodityOrder::$_OP_IN])->count();
         $order_finish = CommodityOrder::find()->where('op_statu = :op_statu', [':op_statu' => CommodityOrder::$_OP_FINISH])->count();
         $order_pend = CommodityOrder::find()->where('statu = :statu', [':statu' => CommodityOrder::$_AUDIT_PEND])->count();
     }
     return $this->render('index', ['notice' => $notice, 'order_in' => $order_in, 'order_finish' => $order_finish, 'order_pend' => $order_pend]);
 }
 public function search($input)
 {
     $query = Notice::query();
     $columns = Schema::getColumnListing('notices');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
예제 #8
0
 public function test()
 {
     $users = User::all();
     $ids = [];
     $notice;
     if (Input::get('type') === 0) {
         foreach ($users as $u) {
             if ($u->hxid && $u->gender == 0) {
                 $ids[] = $u->hxid;
                 $notice = Notice::create(array('userId' => $u->_id, 'title' => Input::get('title') ? Input::get('title') : '', 'content' => Input::get('msg') ? Input::get('msg') : '', 'wishId' => '', 'noticeUrl' => Input::get('url') ? Input::get('url') : '', 'type' => 0));
             }
         }
     } elseif (Input::get('type') === 1) {
         foreach ($users as $u) {
             if ($u->hxid && $u->gender == 1) {
                 $ids[] = $u->hxid;
                 $notice = Notice::create(array('userId' => $u->_id, 'title' => Input::get('title') ? Input::get('title') : '', 'content' => Input::get('msg') ? Input::get('msg') : '', 'wishId' => '', 'noticeUrl' => Input::get('url') ? Input::get('url') : '', 'type' => 0));
             }
         }
     } else {
         foreach ($users as $u) {
             if ($u->hxid) {
                 $ids[] = $u->hxid;
                 $notice = Notice::create(array('userId' => $u->_id, 'title' => Input::get('title') ? Input::get('title') : '', 'content' => Input::get('msg') ? Input::get('msg') : '', 'wishId' => '', 'noticeUrl' => Input::get('url') ? Input::get('url') : '', 'type' => 0));
             }
         }
     }
     $token = $this->getHxToken();
     $uri = "https://a1.easemob.com/tongjo/wishes/messages";
     $data = array('target_type' => 'users', 'target' => $ids, 'msg' => array('type' => 'txt', 'msg' => Input::get('msg') ? Input::get('msg') : '你的心愿被摘取啦!'), 'ext' => $notice->toArray());
     $header = array();
     array_push($header, 'Accept:application/json');
     array_push($header, 'Content-Type:application/json');
     array_push($header, 'Authorization: Bearer ' . $token);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $uri);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     $return = curl_exec($ch);
     curl_close($ch);
     print_r($return);
 }
예제 #9
0
 public function index()
 {
     $this->auth();
     $user = User::find(Session::get('uid'));
     foreach ($user->notices as $vv) {
         $vv->wish = Wish::find($vv->wishId);
         unset($vv->wishId);
         if (!$vv->wish) {
             continue;
         }
         $v = $vv->wish;
         $creator = User::find($v->creatorId);
         $creator->school;
         unset($creator->schoolId);
         $v->creatorUser = $creator;
         $picker = User::find($v->pickerId);
         if ($picker) {
             $picker->school;
             unset($picker->schoolId);
             $v->pickerUser = $picker;
         }
     }
     return $this->output(array('total' => Notice::where('userId', '=', $user->id)->count(), 'notices' => $user->notices));
 }
예제 #10
0
 /**
  * @param Request $request
  * @return Response
  *
  * @api {get} /yzh/notice/investment 投资结果通知
  * @apiName GetNoticeInvestment
  * @apiGroup Notice
  *
  * @apiParam {String} UserId 用户ID
  * @apiParam {String} ProductName 理财产品名称
  * @apiParam {String} Amount 投资金额
  * @apiParam {String} DateTime 投资时间
  * @apiParam {String} Ref 消息流水号
  *
  * @apiSuccessExample Success-Response:
  * success
  */
 public function noticeInvestment(Request $request)
 {
     $input = $request->all();
     Logger::AuthorizationInfo('@YzhController noticeInvestment, start', $input);
     if (empty($input['sign'])) {
         Logger::AuthorizationError('@YzhController noticeInvestment, no sign');
         return response('no sign');
     }
     // sign
     if (!HMAC::compare($input, $this->getKey(), $input['sign'])) {
         Logger::AuthorizationError('@YzhController noticeInvestment, sign error');
         return response('sign error');
     }
     // duplicate
     $row = Notice::where('ref', $input['Ref'])->first();
     if ($row) {
         Logger::AuthorizationInfo('@YzhController noticeInvestment, duplicate, return success');
         return response('success');
     }
     // data 记录通知数据,跟据业务再做处理
     $notice = new Notice();
     $notice->ref = $input['Ref'];
     $notice->type = Notice::T_INVEST;
     $notice->uid = $input['UserId'];
     $notice->result = json_encode($input);
     $notice->save();
     // response
     Logger::AuthorizationInfo('@YzhController noticeInvestment, received, return success');
     return response('success');
 }
예제 #11
0
 public static function afterFollow($favorite)
 {
     $types = [Favorite::TYPE_TOPIC => self::TYPE_FOLLOW_TOPIC, Favorite::TYPE_USER => self::TYPE_FOLLOW_USER];
     $notice = new Notice(['type' => $types[$favorite->type], 'source_id' => $favorite->source_id]);
     if ($favorite->type == Favorite::TYPE_TOPIC) {
         $notice->topic_id = $favorite->target_id;
         $notice->target_id = $favorite->topic->user_id;
         if ($notice->source_id == $notice->target_id) {
             return true;
         }
     } else {
         $notice->target_id = $favorite->target_id;
     }
     return $notice->save(false);
 }
예제 #12
0
 public function actionDelete($id)
 {
     Notice::findOne($id)->delete();
     $this->redirect('/notice/index');
 }
예제 #13
0
 public function update(Request $request)
 {
     $user = $this->auth();
     $wish = Wish::find(Input::get("_id"));
     if (!$wish) {
         return $this->outputError('心愿不存在', 2);
     }
     if ($wish->creatorId != $user->_id) {
         return $this->outputError('只有创建者可以修改心愿', 3);
     }
     $wish->update(Input::get());
     if ($request->has('isPicked')) {
         if ($request->input('isPicked') == 0) {
             $wish->pickerId = "";
             $wish->isPicked = 0;
             $wish->save();
         }
     }
     $v = $wish;
     $creator = User::find($v->creatorId);
     $creator->school;
     unset($creator->schoolId);
     $v->creatorUser = $creator;
     $picker = User::find($v->pickerId);
     if ($picker) {
         $picker->school;
         unset($picker->schoolId);
         $v->pickerUser = $picker;
     }
     if (Input::get('isCompleted') == 1) {
         $notice = Notice::create(array('userId' => $wish->pickerId, 'title' => 'wishes', 'wishId' => $wish->_id, 'noticeUrl' => '', 'content' => '你摘的心愿被完成啦!', 'type' => 2));
         $token = $this->getHxToken();
         $uri = "https://a1.easemob.com/tongjo/wishes/messages";
         $data = array('target_type' => 'users', 'target' => [$wish->picker->hxid], 'msg' => array('type' => 'txt', 'msg' => '你摘的心愿被完成啦!'), 'ext' => $notice->toArray());
         $header = array();
         array_push($header, 'Accept:application/json');
         array_push($header, 'Content-Type:application/json');
         array_push($header, 'Authorization: Bearer ' . $token);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $uri);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
         $return = curl_exec($ch);
         curl_close($ch);
     }
     return $this->output($v);
 }
예제 #14
0
 /**
  * Finds the Notice model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Notice the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Notice::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #15
0
파일: User.php 프로젝트: 0ps/simpleforum
 public function getNotices()
 {
     return $this->hasMany(Notice::className(), ['target_id' => 'id'])->where(['status' => 0])->orderBy(['updated_at' => SORT_DESC]);
 }
예제 #16
0
파일: User.php 프로젝트: aoopvn/EduSec4.0.0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNotices()
 {
     return $this->hasMany(Notice::className(), ['updated_by' => 'user_id']);
 }
예제 #17
0
        <p class="lead">Sistem Informasi PT. Global Lestari Motorindo</p>

        <!--<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>-->
    </div>

        <p><?php 
//echo __DIR__
?>
</p>

    <div class="body-content">
        <?php 
if (Yii::$app->user->isGuest) {
    echo '';
} else {
    $model = \app\models\Notice::find()->orderBy(['id' => SORT_DESC])->one();
    echo '<div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
    echo '<strong>INFO : </strong>';
    echo nl2br($model->content);
    echo '<br/><br/><p style="font-size:12px;">Posted : ' . $model->date . '</p>';
    echo '</div>';
}
?>

       <!-- <div class="row">
            <div class="col-lg-4">
                <h2>Heading</h2>

                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
                    dolore magna liqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
예제 #18
0
파일: Topic.php 프로젝트: 0ps/simpleforum
 public function afterDelete()
 {
     (new History(['user_id' => $this->user_id, 'action' => History::ACTION_DELETE_TOPIC, 'target' => $this->id]))->save(false);
     TopicContent::deleteAll(['topic_id' => $this->id]);
     Node::updateCounterInfo('deleteTopic', $this->node_id);
     UserInfo::updateCounterInfo('deleteTopic', $this->user_id);
     $count = Comment::afterTopicDelete($this->id);
     Siteinfo::updateCountersInfo(['topics' => -1, 'comments' => -$count]);
     Favorite::afterTopicDelete($this->id);
     Notice::afterTopicDelete($this->id);
     return parent::afterDelete();
 }
예제 #19
0
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert === true) {
         if ($this->type === self::TYPE_NODE) {
             $action = 'followNode';
             Node::updateCounterInfo($action, $this->target_id);
         } else {
             if ($this->type === self::TYPE_TOPIC) {
                 $action = 'followTopic';
                 Topic::updateCounterInfo($action, $this->target_id);
                 Notice::afterFollow($this);
             } else {
                 if ($this->type === self::TYPE_USER) {
                     $action = 'followUser';
                     UserInfo::updateCounterInfo('followed', $this->target_id);
                     Notice::afterFollow($this);
                 }
             }
         }
         UserInfo::updateCounterInfo($action, Yii::$app->getUser()->getId());
     }
     return parent::afterSave($insert, $changedAttributes);
 }