Permalink
Browse files

+ add page inbox

  • Loading branch information...
Stive1987 committed May 13, 2018
1 parent 915cad8 commit 6ba5d81d88f482d779a301651cba38ad1bc14b05
@@ -89,6 +89,30 @@
(NULL, 'MEMBERS', 2);";
break;
case 'inbox':
$drop = 'DROP TABLE IF EXISTS `'.$_SESSION['prefix'].$table.'`';
$sql = "CREATE TABLE IF NOT EXISTS `".$_SESSION['prefix'].$table."` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`username` varchar(32) NOT NULL,
`usersend` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
break;
case 'inbox_msg':
$drop = 'DROP TABLE IF EXISTS `'.$_SESSION['prefix'].$table.'`';
$sql = "CREATE TABLE IF NOT EXISTS `".$_SESSION['prefix'].$table."` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_msg` int(11) NOT NULL,
`username` varchar(32) NOT NULL,
`date_msg` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`message` text NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
break;
case 'mails_blacklist':
$drop = 'DROP TABLE IF EXISTS `'.$_SESSION['prefix'].$table.'`';
$sql = "CREATE TABLE IF NOT EXISTS `".$_SESSION['prefix'].$table."` (
@@ -14,6 +14,8 @@ jQuery.noConflict();
'config',
'config_pages',
'groups',
'inbox',
'inbox_msg'
'mails_blacklist',
'page_blog',
'page_forum',
@@ -29,7 +31,7 @@ jQuery.noConflict();
);
var nbTables = tables.length;
$("#submit_bdd").click( function() { // à la soumission du formulaire
$("#submit_bdd").click( function() { // à la soumission du formulaire
var error = false;
$(tables).each(function(i, e) {
@@ -50,7 +52,7 @@ jQuery.noConflict();
if (error === false) {
if (i == nbTables) {
setTimeout(function() {
window.location.href = "?page=user";
window.location.href = "?page=user";
}, 2000);
}
}
@@ -65,4 +67,4 @@ jQuery.noConflict();
return false;
});
})(jQuery);
})(jQuery);
@@ -17,6 +17,9 @@ if (typeof jQuery === 'undefined') {
bel_cms_alert_box($(this), 'GET');
});
$('.dropdown-toggle').dropdown();
// Initialize popover component
$('[data-toggle="popover"]').popover()
// tooltip
$('[data-toggle="tooltip"]').tooltip();
// datepicker
@@ -72,6 +75,10 @@ if (typeof jQuery === 'undefined') {
_initTinymceFull();
}
emojify.run();
bel_cms_private_message();
})(jQuery);
function _initTinymceSimple () {
@@ -137,7 +144,7 @@ function bel_cms_alert_box (objet, type) {
if ($('#alrt_bel_cms').height()) {
$('#alrt_bel_cms').remove();
}
$('body').append('<div id="alrt_bel_cms">Loading...</div>');
$('body').append('<div id="alrt_bel_cms">Chargement...</div>');
$('#alrt_bel_cms').animate({ top: 0 }, 500);
/* start ajax */
$.ajax({
@@ -172,7 +179,7 @@ function bel_cms_alert_box (objet, type) {
alert('Error function ajax');
},
beforeSend:function() {
$('body').append('<div id="alrt_bel_cms">Loading...</div>');
$('body').append('<div id="alrt_bel_cms">Chargement...</div>');
$('#alrt_bel_cms').animate({ top: 0 }, 500);
},
complete: function() {
@@ -182,7 +189,43 @@ function bel_cms_alert_box (objet, type) {
}
});
}
function bel_cms_private_message () {
var currentLink = $(location).attr('pathname').replace('/', '').toLowerCase();
if (currentLink == 'blog' || currentLink == '' || currentLink == 'home' || currentLink == 'index.html') {
var link = "Inbox/countUnreadMessage?json";
$.getJSON(link, {
format: "json"
}).done(function(data) {
if (data >= 1) {
bel_cms_create_div_message();
$("#bel_cms_private_message").modal('show');
}
});
}
}
function bel_cms_create_div_message () {
var $body = $('body');
html = '<div class="modal fade" id="bel_cms_private_message" tabindex="-1" role="dialog" aria-hidden="true">';
html += '<div class="modal-dialog modal-dialog-centered" role="document">';
html += '<div class="modal-content">';
html += '<div class="modal-header">';
html += '<h5 class="modal-title">Message priver</h5>';
html += '<button type="button" class="close" data-dismiss="modal" aria-label="Close">';
html += '<span aria-hidden="true">&times;</span>';
html += '</button>';
html += '</div>';
html += '<div class="modal-body">';
html += '<p>Vous avez un message priver</p>';
html += '<p><a href="Inbox" title="Message priver">Lire le message</a></p>';
html += '</div>';
html += '<div class="modal-footer">';
html += '<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>';
html += '</div>';
html += '</div>';
html += '</div>';
html += '</div>';
$body.append(html);
}
/*###################################
# Function end Alert box
###################################*/
@@ -31,6 +31,8 @@
'TABLE_DOWNLOADS' => $DB_PREFIX.'downloads',
'TABLE_DOWNLOADS_CAT' => $DB_PREFIX.'downloads_cat',
'TABLE_GROUPS' => $DB_PREFIX.'groups',
'TABLE_INBOX' => $DB_PREFIX.'inbox',
'TABLE_INBOX_MSG' => $DB_PREFIX.'inbox_msg',
'TABLE_LINK_OUT' => $DB_PREFIX.'links_click',
'TABLE_MAIL_BLACKLIST' => $DB_PREFIX.'mails_blacklist',
'TABLE_PAGE' => $DB_PREFIX.'page',
@@ -98,6 +98,8 @@ function render($filename) {
require DIR_ASSET_TPL.'error'.DS.'404.php';
}
$this->page = ob_get_contents();
if (ob_get_length() != 0) {
@@ -0,0 +1,106 @@
<?php
/**
* Bel-CMS [Content management system]
* @version 0.0.2
* @link http://www.bel-cms.be
* @link http://www.stive.eu
* @license http://opensource.org/licenses/GPL-3.0 copyleft
* @copyright 2014-2016 Bel-CMS
* @author Stive - mail@stive.eu
*/
if (!defined('CHECK_INDEX')) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Direct access forbidden');
exit(ERROR_INDEX);
}
class Inbox extends Pages
{
#####################################
# Declaration variables
#####################################
var $models = array('ModelsInbox');
#####################################
# Start Class
#####################################
public function __construct ()
{
parent::__construct();
}
#####################################
# Get Index page for inbox
#####################################
public function index ()
{
$set['inbox'] = $this->ModelsInbox->getMessages();
$this->set($set);
$this->render('index');
}
#####################################
# Get message for inbox
#####################################
public function showMessage($id)
{
if (!is_numeric($id)) {
$this->error(INBOX, ERROR_NO_ID, 'danger');
} else {
$set = $this->ModelsInbox->showMessage($id);
if (array_key_exists('type', $set) && array_key_exists('text', $set)) {
$this->error(INBOX, $set['text'], $set['type']);
} else {
if (count($set) == 0) {
$this->error(INBOX, ERROR_NO_MESSAGE_EXIST, 'danger');
} else {
$set['inbox'] = $this->ModelsInbox->showMessage($id);
$this->set($set);
$this->render('show');
}
}
}
}
#####################################
# Get Users for new message
#####################################
public function getUsers ()
{
$search = $_GET['term'];
$this->json = array('username' => $this->ModelsInbox->getUsers($search));
}
#####################################
# Send
#####################################
public function send ()
{
if ($this->data['send'] == 'new') {
self::sendNewMessage();
} else if ($this->data['send'] == 'reponse') {
self::sendReponse();
}
}
#####################################
# Send new message
#####################################
private function sendNewMessage ()
{
$return = $this->ModelsInbox->sendNewMessage($this->data['username'], $this->data['message']);
$this->error(INBOX, $return['text'], $return['type']);
$this->redirect('Inbox', 2);
}
#####################################
# Send reponse message
#####################################
private function sendReponse ()
{
$return = $this->ModelsInbox->sendReponse($this->data['id'], $this->data['message']);
$this->error(INBOX, $return['text'], $return['type']);
$redirect = 'Inbox/ShowMessage/'.$return['id'];
$this->redirect($redirect, 2);
}
#####################################
# Get count message
#####################################
public function countUnreadMessage()
{
$this->json = $this->ModelsInbox->countUnreadMessage();
}
}
@@ -0,0 +1 @@
<!doctype html><html lang="fr"><head><meta charset="utf-8"><title>403 Direct access forbidden</title></head><body><h1>Direct access forbidden</h1><p>The requested URL is prohibited.</p></body></html>
@@ -0,0 +1,57 @@
#bel_cms_inbox_index_right {
border-left: 1px solid #dedfe0;
background: rgba(255, 255, 255, 1);
}
form#bel_cms_inbox_form_new {
}
form#bel_cms_inbox_form_new header,
#bel_cms_inbox_show header {
height: 50px;
padding: 0 15px;
border-bottom: 1px solid #dedfe0;
}
form#bel_cms_inbox_form_new header i {
display: block;
float: left;
font-size: 35px;
line-height: 50px;
}
#bel_cms_inbox_show header img {
display: block;
float: left;
width: 35px;
height: 35px;
}
form#bel_cms_inbox_form_new header span,
#bel_cms_inbox_show header span {
line-height: 50px;
font-weight: bold;
padding-left: 15px;
display: block;
float: left;
}
#bel_cms_inbox_form_new_body {
margin-top: 15px;
}
.bel_cms_inbox_show_msg {
background: rgba(0, 0, 0, .05);
margin-top: 15px;
padding: 15px;
}
.bel_cms_inbox_show_msg_other {
margin-left: 45px;
background: rgba(0, 0, 0, .07);
margin-top: 15px;
padding: 15px;
}
.bel_cms_inbox_show_msg_date {
display: block;
color: #686f7a;
font-size: 13px;
margin-bottom: 5px;
}
.bel_cms_inbox_show_msg,
.bel_cms_inbox_show_msg p {
text-align: justify;
}
Oops, something went wrong.

0 comments on commit 6ba5d81

Please sign in to comment.