Re: [nouveau] Module mylove version 3 | Titre du sujet : Re: [nouveau] Module mylove version 3 par eparcyl92 sur 03/06/2007 21:14:24
Voila patron
<?php
// ------------------------------------------------------------------------- //
// XOOPS - Module MP Manager //
// <http://www.xoops.org/> ... nbsp; //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------- //
// Votre nouveau systeme de messagerie priver //
// //
// "MP" //
// //
// http://lexode.info/mods &n ... nbsp; //
// //
// //
//---------------------------------------------------------------------------//
$xoopsOption['pagetype'] = "pmsg";
include("mainfile.php");
$mydirname = "mpmanager" ;
require_once ("modules/mpmanager/include/functions.php");
include_once XOOPS_ROOT_PATH."/include/xoopscodes.php";
include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
include_once XOOPS_ROOT_PATH."/modules/mpmanager/class/formselectuser.php";
include XOOPS_ROOT_PATH."/modules/mpmanager/include/get_perms.php" ;
$module_handler =& xoops_gethandler('module');
$xoopsModule =& $module_handler->getByDirname("mpmanager");
$xoopsModuleConfig =& $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid'));
$myts = & MyTextSanitizer :: getInstance(); // MyTextSanitizer object
if( file_exists(XOOPS_ROOT_PATH."/modules/mpmanager/language/".$xoopsConfig['language']."/main.php") ) {
include(XOOPS_ROOT_PATH."/modules/mpmanager/language/".$xoopsConfig['language']."/main.php");
} else {
include(XOOPS_ROOT_PATH."/modules/mpmanager/language/english/main.php");
}
global $xoopsUser;
if (empty($xoopsUser)) {
redirect_header("user.php",1,_PM_REGISTERNOW);
} else {
if ( isset($_POST) ) {
foreach ( $_POST as $k => $v ) {
$$k = $v;
}
}
$mp_alert = mp_getTotal();
if (isset($HTTP_POST_VARS['op'])) {
$op = intval($HTTP_POST_VARS['op']);
} else {
@$op = $HTTP_GET_VARS['op'];
}
if (isset($_POST['post_messages'])) {
$op = 'envoimp';
}
xoops_header();
echo '<script type="text/JavaScript"><!--
var h=600;
var w=700;
window.resizeTo(w, h);
// -->
</script>';
echo '<script type="text/javascript">
function auto_close(delai)
{ setTimeout("self.close();",delai); }
</script>';
switch( $op )
{
//Boite de reception
case "envoimp":
global $xoopsDB, $xoopsUser, $xoopsConfig, $_FILES;
$msg_time = time();
$from_userid = $xoopsUser->getVar('uid');
$sendt = _MP_THEREARESENDT;
if ($xoopsModuleConfig['wysiwyg'] == "xoopseditor") {
$subject = $myts->htmlSpecialChars($subject);
$message = $myts->htmlSpecialChars($message);
} else {
$subject = $myts->htmlSpecialChars($subject);
$message = $myts -> AddSlashes($message);
}
if (empty($_POST['to_userid']) && empty($_POST['to_groupe'])) {
redirect_header("javascript:history.go(-1)",1, _PM_USERNOEXIST);
exit;
}
if (empty($subject)) {
$subject = _MP_NOSUBJECT;
}
if (isset($_POST['to_userid'])) {
//option utilisateur
$sq3 = "SELECT * FROM ".$xoopsDB->prefix("priv_msgsopt")." WHERE userid = ".$from_userid;
$result3=$xoopsDB->queryF($sq3);
$myopt=$xoopsDB->fetchArray($result3);
//
//upload
if ($_FILES['fileup']['name'] != "") {
include_once XOOPS_ROOT_PATH . "/class/uploader.php";
$allowed_mimetypes = $xoopsModuleConfig['mimetypes'];
$maxfilesize = $xoopsModuleConfig['mimemax'];
$uploaddir = XOOPS_ROOT_PATH . "/modules/".$xoopsModule->dirname()."/upload/";
$uploader = new XoopsMediaUploader($uploaddir, $allowed_mimetypes, $maxfilesize, null, null);
$uploader->setPrefix('mp') ;
if ($uploader->fetchMedia($HTTP_POST_VARS['xoops_upload_file'][0])) {
if (!$uploader->upload()) {
$errors = $uploader->getErrors();
redirect_header("javascript:history.go(-1)",1, $errors);
} else {
$upfile = $uploader->getSavedFileName();
}} else {
$errors = $uploader->getErrors();
redirect_header("javascript:history.go(-1)",1, $errors);
}}
//
$sq2 = "INSERT INTO ".$xoopsDB->prefix("priv_msgs")."(msg_image,subject,from_userid,to_userid,msg_time,msg_text,read_msg,reply_msg,anim_msg,cat_msg,file_msg) VALUES('$icon','$subject','$from_userid','$to_userid','$msg_time','$message','','','$anim','1','$upfile')";
$result=$xoopsDB->queryF($sq2);
$result = $xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("priv_msgs")." SET reply_msg = '1' WHERE msg_id = ".$msg_id."");
$sendt .= xoops_getLinkedUnameFromId(intval($from_userid)).",";
}
if (!$result) {
redirect_header($_SERVER['PHP_SELF']."?op=sendbox&send2=1&to_userid=$to_userid",1, _PM_GOBACK);
} else {
if ($xoopsModuleConfig['notification'] == "1" && $myopt['notif'] == "1") {
mp_mail ($to_userid);
}
if ($myopt['resend'] == "1") {
$sq1 = "INSERT INTO ".$xoopsDB->prefix("priv_msgs")."(msg_image,subject,from_userid,to_userid,msg_time,msg_text,read_msg,reply_msg,anim_msg,cat_msg,file_msg) VALUES('$icon','$subject','$from_userid','".$xoopsUser->getVar('uid')."','$msg_time','$messagernrn$sendt','1','','$anim','2','$upfile')";
$result=$xoopsDB->queryF($sq1);
}
redirect_header("javascript:history.go(-1)",1, _PM_MESSAGEPOSTED.'<script type="text/javascript">auto_close(1000);</script>');
}
break;
case "sendbox":
default:
if(!( $view_perms & GPERM_MESS ) ) {
redirect_header("javascript:history.go(-1)",1, _PM_REDNON);
exit();
}
$send = !empty($_GET['send']) ? 1 : 0;
$send2 = !empty($HTTP_GET_VARS['send2']) ? 1 : 0;
$to_userid = !empty($HTTP_GET_VARS['to_userid']) ? intval($HTTP_GET_VARS['to_userid']) : 0;
$msg_id = !empty($HTTP_POST_VARS['msg_id']) ? intval($HTTP_POST_VARS['msg_id']) : 0;
if ( $send == 1 || $send2 == 1) {
if ( $mp_alert > $xoopsModuleConfig['maxuser']) {
redirect_header("javascript:history.go(-1)",1, _PM_PURGEMES.'<script type="text/javascript">auto_close(1000);</script>');
}
//form
$form = new XoopsThemeForm(_MP_READMSG, "read", $_SERVER['PHP_SELF']);
$form->setExtra( "enctype='multipart/form-data'" );
$user_select_tray = new XoopsFormLabel(_PM_TO, XoopsUser::getUnameFromId($to_userid));
$texte_hidden = new XoopsFormHidden("to_userid", $to_userid);
$form->addElement($user_select_tray);
$form->addElement($texte_hidden);
$icons_radio = new XoopsFormRadio(_MP_MESSAGEICON, 'icon', $icon);
$subject_icons = XoopsLists::getSubjectsList();
foreach ($subject_icons as $iconfile) {
$icons_radio->addOption($iconfile, '<img src="'.XOOPS_URL.'/images/subject/'.$iconfile.'" alt="" />');
}
$form->addElement($icons_radio);
if( ( $view_perms & GPERM_OEIL ) ) {
$indeximage_select = new XoopsFormText('', 'anim', 25, 50, $anim);
$indeximage_select -> setExtra("readonly="readonly" ");
$indeximage_tray = new XoopsFormElementTray(_MP_MESSAGEOEIL, ' ');
$indeximage_tray->addElement($indeximage_select);
$indeximage_tray->addElement(new XoopsFormLabel('', "<A HREF="#" onClick="window.open('".XOOPS_URL."/modules/mpmanager/pop.php','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0, width=700, height=400');return false;"><img src="".XOOPS_URL."/modules/mpmanager/images/popup.gif"> "._MP_MESSAGEVUOEIL."</A>"));
$form->addElement($indeximage_tray);
}
$form->addElement(new XoopsFormText(_PM_SUBJECTC, "subject", 50, 100, $_POST['subject']), true);
$editor = WysiwygForm(_PM_MESSAGEC, "message", $_POST['message'], '100%', '400px');
$form->addElement($editor);
if( ( $view_perms & GPERM_UP ) ) {
$indeximage_up = new XoopsFormFile('', 'fileup', $xoopsModuleConfig['mimemax']);
$indeximage_uptray = new XoopsFormElementTray(_MP_MIMEFILE, ' ');
$indeximage_uptray->addElement($indeximage_up);
$indeximage_uptray->addElement(new XoopsFormLabel('', '<br />'._MP_MIMETYPE.mp_mimetypes().'<br />'._MP_MIMEMAX.sprintf(_MD_NUMBYTES, $xoopsModuleConfig['mimemax'])));
$form->addElement($indeximage_uptray);
}
$button_tray = new XoopsFormElementTray('' ,'');
$button_tray->addElement(new XoopsFormButton('', 'reset', _MP_CLEAR, 'reset'));
$button_tray->addElement(new XoopsFormButton('', 'post_messages', _MP_SUBMIT, 'submit'));
$form->addElement($button_tray);
$msg_hidden = new XoopsFormHidden("msg_id", $msg_id);
$form->addElement($msg_hidden);
echo $form -> render();
}
break;
}
xoops_footer();
}
?>
|
|