Пример #1
0
 /**
  * 'onFlush' event handling.
  * This method will be called when the 'flush' method of RLog is called
  * like: <pre>Rays::logger()->flush();</pre>
  * @param $event event object
  */
 public function onFlush($event)
 {
     $logs = $event->getParams();
     if (!empty($logs)) {
         foreach ($logs as $log) {
             $sysLog = new SystemLog(array('host' => Rays::app()->request()->getUserHostAddress(), 'path' => Rays::uri(), 'title' => $this->getHeaderTitle(), 'uri' => Rays::referrerUri(), 'timestamp' => date('Y-m-d H:i:s')));
             $sysLog->userId = Rays::isLogin() ? Rays::user()->id : 0;
             $sysLog->message = $log['message'];
             $level = null;
             switch ($log['level']) {
                 case RLog::LEVEL_ERROR:
                     $level = 2;
                     break;
                 case RLog::LEVEL_INFO:
                     $level = 0;
                     break;
                 case RLog::LEVEL_WARNING:
                     $level = 1;
                     break;
             }
             if ($level === null) {
                 continue;
             }
             $sysLog->severity = $level;
             $sysLog->type = $log['type'];
             $sysLog->save();
             unset($sysLog);
         }
     }
 }
Пример #2
0
 public function actionDelete($msgId)
 {
     $message = Message::get($msgId);
     if (Rays::isAjax() && $message != null) {
         if (Rays::user()->id != $message->receiverId) {
             echo "Sorry. You don't have the right to delete the message.";
             exit;
         }
         $message->delete();
         echo 'success';
         exit;
     }
     RAssert::not_null($message);
     $user = Rays::user();
     if ($message->receiverId == $user->id || $user->isAdmin()) {
         $message->delete();
     }
     $this->redirect(Rays::referrerUri());
 }
Пример #3
0
        <div class="panel panel-default user-login-register-panel">
            <div class="panel-heading"><b>Sign in</b></div>
            <div class="panel-body">
                <?php 
if (isset($validation_errors)) {
    RHtml::showValidationErrors($validation_errors);
}
$form = array();
if (isset($loginForm)) {
    $form = $loginForm;
}
echo RForm::openForm('user/login', array('id' => 'loginForm', 'class' => 'form-signin login-form'));
//echo RForm::label("User name",'username');
echo RForm::hidden('returnURL', Rays::referrerUri() ?: "");
echo RForm::input(array('id' => 'username', 'name' => 'username', 'class' => 'form-control', 'placeholder' => 'User name'), $form);
//echo RForm::label("Password",'password');
echo RForm::input(array('id' => 'password', 'name' => 'password', 'type' => 'password', 'class' => 'form-control', 'placeholder' => 'Password'), $form);
echo RForm::input(array('class' => 'btn btn-primary', 'type' => 'submit', 'value' => 'Login'));
echo RForm::endForm();
?>
            </div>
        </div>



Пример #4
0
 public function actionJoin($groupId)
 {
     //by songrenchu: need censorship by group creator
     $userId = Rays::user()->id;
     $userName = Rays::user()->name;
     $joinRequest = false;
     $text = '';
     $group = Group::get($groupId);
     if ($group !== null) {
         //join group sensor item
         $censor = new Censor();
         $censor = $censor->joinGroupApplication($userId, $group->id);
         $content = RHtml::linkAction('user', $userName, 'view', $userId) . " wants to join your group " . RHtml::linkAction('group', $group->name, 'detail', $group->id) . "<br/>" . RHtml::linkAction('group', 'Accept', 'accept', $censor->id, array('class' => 'btn btn-xs btn-success')) . "&nbsp;&nbsp;" . RHtml::linkAction('group', 'Decline', 'decline', $censor->id, array('class' => 'btn btn-xs btn-danger'));
         Message::sendMessage("group", $groupId, $group->creator, "Join group request", $content, '');
         $joinRequest = true;
         $text = 'Your join-group request has been send to the group manager!';
     } else {
         $text = 'Group does not exist!';
     }
     if (Rays::isAjax()) {
         echo json_encode(['result' => $joinRequest, 'text' => $text]);
         exit;
     } else {
         $this->flash($joinRequest ? "message" : "warning", $text);
         $this->redirect(Rays::referrerUri());
     }
 }
Пример #5
0
 public function actionDelete($topicId)
 {
     $topic = Topic::get($topicId);
     if ($topic === null) {
         $this->flash("message", "No such topic!");
     } else {
         $topic->delete();
         $this->flash("message", "Post " . $topic->title . " was deleted.");
     }
     if ($url = Rays::getParam("returnUrl", null)) {
         $this->redirect($url);
     } else {
         $this->redirect(Rays::referrerUri());
     }
 }