2006-01-10";
$uddeConfig_version_number="0.5b";
// Don't allow direct linking
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// include everything needed
require_once ('includes/mambo.php');
include_once( 'includes/pageNavigation.php' );
require_once ('components/com_uddeim/bbparser.php');
require_once ('components/com_uddeim/includes.php');
// Get right language file or use english
$pathtome="components/com_uddeim";
$adminpath="administrator/components/com_uddeim";
if (file_exists($adminpath.'/language/'.$mosConfig_lang.'.php')) {
include($adminpath.'/language/'.$mosConfig_lang.'.php');
} elseif (file_exists($adminpath.'/language/english.php')) {
include($adminpath.'/language/english.php');
}
// if (file_exists($adminpath.'/language/'.$mosConfig_lang.'.php')) {
// include($adminpath.'/language/'.$mosConfig_lang.'.php');
// } elseif (file_exists($adminpath.'/language/english.php')) {
// include($adminpath.'/language/english.php');
// }
// set required values
// (hopefully to be overwritten by config file which is loaded next)
$config_charset="ISO8859-1";
$config_mailcharset="ISO8859-1";
$config_realnames='0';
$config_quotedivider='__________';
// get the configuration file
// config must be loaded after language file
require($mosConfig_absolute_path."/administrator/components/com_uddeim/uddeim_config.php");
// if needed, load getpiclink.php
if($config_getpiclink) {
include_once( 'components/com_uddeim/getpiclink.php' );
}
// adjust non acceptable values
if ($config_firstwordsinbox<8) {
$config_firstwordsinbox=8;
}
if ($ReadMessagesLivespan<1) {
$ReadMessagesLivespan=1;
}
if ($UnreadMessagesLivespan<1) {
$UnreadMessagesLivespan=1;
}
if ($TrashLivespan<0.01) {
$TrashLivespan=0.01;
}
// No access if not logged in, and bye
if(!$my->id) {
$mosmsg=_UDDEIM_NOTLOGGEDIN;
$redirecturl="index.php";
mosRedirect($redirecturl, $mosmsg);
}
// Get passed variables and strip/escape potentially dangerous stuff
$Itemid=mosGetParam( $_REQUEST, 'Itemid');
// if no Itemid is passed on, try to find one somewhere
if(!$Itemid) {
$sql="SELECT id FROM #__menu WHERE link LIKE '%index%' AND published>=0 LIMIT 1";
$database->setQuery($sql);
$found=$database->loadResult();
$Itemid=$found;
}
$item_id=$Itemid;
$task=mosGetParam( $_REQUEST, 'task', 'inbox');
$messageid=mosGetParam ( $_REQUEST, 'messageid');
$recip=mosGetParam ( $_REQUEST, 'recip');
$runame=mosGetParam ( $_REQUEST, 'runame');
$ret=mosGetParam ( $_REQUEST, 'ret');
$popupradio=mosGetParam ( $_REQUEST, 'popupradio', 0);
$to_id=mosGetParam ($_POST, 'to_id');
$to_name=mosGetParam ($_POST, 'to_name');
// $pmessage=mosGetParam ($_POST, 'pmessage');
// changed 0.5 build 11
$pmessage=strip_tags(mosGetParam($_POST, 'pmessage', '', _MOS_ALLOWHTML));
$sendeform_showallusers=mosGetParam ($_POST, 'sendeform_showallusers', '');
$to_all=mosGetParam ($_POST, 'to_all', 0);
$tobedeleted=mosGetParam ($_POST, 'tobedeleted');
$copytome=mosGetParam ($_POST, 'copytome');
$emailradio=mosGetParam ($_POST, 'emailradio', '0');
$emailreplycheck=mosGetParam ($_POST, 'emailreplycheck', '0');
$backto=mosGetParam ($_POST, 'backto');
$returntask=mosGetParam ($_POST, 'returntask', 'inbox');
$returnlimitstart=mosGetParam ($_POST, 'returnlimitstart', 0);
$returnlimit=mosGetParam ($_POST, 'returnlimit');
if(!$returnlimit) { $returnlimit=$config_perpage; }
if(!$returnlimit) { $returnlimit=10; }
$arcmes=mosGetParam ($_POST, 'arcmes');
$limitstart=mosGetParam ($_REQUEST, 'limitstart', 0);
$limit=mosGetParam ($_REQUEST, 'limit');
if(!$limit) { $limit=$config_perpage; }
if(!$limit) { $limit=10; }
$sysgm_sys=mosGetParam ($_POST, 'sysgm_sys');
$sysgm_universe=mosGetParam ($_POST, 'sysgm_universe');
$sysgm_validfor=mosGetParam ($_POST, 'sysgm_validfor');
$sysgm_really=mosGetParam ($_POST, 'sysgm_really');
// load template css file
if(!$config_templatedir) {
$config_templatedir="default";
}
// change image config values to image links
$uddeicons_onlinepic=" ";
$uddeicons_offlinepic=" ";
$uddeicons_readpic=" ";
$uddeicons_unreadpic=" ";
// browser switch
$used_browser = mosGetParam($_SERVER, 'HTTP_USER_AGENT', null);
$css_appendix="";
if (stristr($used_browser, "Opera")) {
$css_appendix="-opera";
} elseif (stristr($used_browser, "MSIE 4")) {
$css_appendix="-ie4";
$css_alternative="-ie";
} elseif (stristr($used_browser, "MSIE 6") || stristr($used_browser, "MSIE/6")) {
$css_appendix="-ie6";
$css_alternative="-ie";
} elseif (stristr($used_browser, "MSIE 7") || stristr($used_browser, "MSIE/7")) {
$css_appendix="-ie7";
$css_alternative="-ie";
} elseif (((stristr($used_browser, "MSIE 5") || stristr($used_browser, "MSIE/5"))) && stristr($used_browser, "Win")) {
$css_appendix="-ie5win";
$css_alternative="-ie";
} elseif (stristr($used_browser, "MSIE 5") && stristr($used_browser, "Mac")) {
$css_appendix="-ie5mac";
$css_alternative="-ie";
} elseif (stristr($used_browser, "Safari")) {
$css_appendix="-safari";
} elseif (stristr($used_browser, "Safari/100")) {
$css_appendix="-safari100";
$css_alternative="-safari";
} elseif (stristr($used_browser, "Safari/85")) {
$css_appendix="-safari85";
$css_alternative="-safari";
} elseif (stristr($used_browser, "Konqueror")) {
$css_appendix="-konq";
} elseif (stristr($used_browser, "Konqueror/2")) {
$css_appendix="-konq2";
$css_alternative="-konq";
} elseif (stristr($used_browser, "Konqueror/3")) {
$css_appendix="-konq3";
$css_alternative="-konq";
}
// now start the output
echo "\n\n";
// load the css file
if(file_exists('components/com_uddeim/templates/'.$config_templatedir.'/css/uddeim'.$css_appendix.'.css')) {
echo '';
echo "\n";
} elseif(file_exists('components/com_uddeim/templates/'.$config_templatedir.'/css/uddeim'.$css_alternative.'.css')) {
echo '';
echo "\n";
} elseif(file_exists('components/com_uddeim/templates/'.$config_templatedir.'/css/uddeim.css')) {
echo '';
echo "\n";
} else {
// template css doesn't exist, now we try to load the default css file
if(file_exists('components/com_uddeim/templates/default/css/uddeim.css')) {
echo '';
echo "\n";
}
}
echo "
";
// fork according to task
switch ($task) {
case "save":
saveMessage($my->id, $to_name, $to_id, $pmessage, $to_all, $tobedeleted, $item_id, $messageid, $copytome, $sendeform_showallusers);
break;
case "delete":
deleteMessage($my->id, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id, $ret);
break;
case "new":
newMessage($my->id, $item_id, $to_id);
break;
case "version":
echo "
Installed uddeIM version
";
echo $versionstring;
echo "\n
\n\n";
break;
case "showstrings":
showStrings($adminpath, $mosConfig_lang);
break;
case "sysgm":
newSysgm($my->id, $item_id, $to_id);
break;
case "savesysgm":
saveSysgm($my->id, $to_name, $to_id, $pmessage, $to_all, $tobedeleted, $item_id, $messageid, $sysgm_sys, $sysgm_universe, $sysgm_validfor, $sysgm_really);
break;
case "show":
showMessage($my->id, $item_id, $messageid);
break;
case "showout":
showOutmessage($my->id, $item_id, $messageid);
break;
case "outbox":
showOutbox($my->id, $item_id);
break;
case "prune":
pruneMessages($my->id, '');
break;
case "trashcan":
trashCan($my->id, $item_id);
break;
case "recall":
recallMessage($my->id, $messageid, $item_id);
break;
case "restore":
restoreMessage($my->id, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id);
break;
case "markread":
markRead($my->id, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id);
break;
case "markunread":
markUnread($my->id, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id);
break;
case "inbox":
showInbox($my->id, $item_id);
break;
case "blockuser":
require_once ('components/com_uddeim/blocking.php');
blockUserUdde($my->id, $item_id, $recip);
break;
case "unblockuser":
require_once ('components/com_uddeim/blocking.php');
unblockUserUdde($my->id, $item_id, $recip);
break;
case "archive":
require_once ('components/com_uddeim/archive.php');
archive($my->id, $item_id);
break;
case "archivemessage":
require_once ('components/com_uddeim/archive.php');
archiveMessage ($my->id, $item_id, $messageid);
break;
case "archivetrash":
require_once ('components/com_uddeim/archive.php');
archiveTrash ($my->id, $item_id, $arcmes);
break;
case "archivedownload":
require_once ('components/com_uddeim/archive.php');
archiveDownload ($my->id, $item_id, $arcmes);
break;
case "settings":
showSettings ($my->id, $item_id);
break;
case "about":
showUddeAbout ($item_id, $versionstring);
break;
case "saveemn":
saveEMN ($my->id, $item_id, $emailradio, $emailreplycheck);
break;
case "savepopup":
savePopup ($my->id, $item_id, $popupradio);
break;
default:
showInbox($my->id, $item_id);
break;
}
// now do the work
function showInbox($myself, $item_id) {
global $database, $my;
global $limit, $limitstart;
global $adminignitiononly;
global $uddeicons_onlinepic, $uddeicons_offlinepic, $uddeicons_readpic, $uddeicons_unreadpic;
global $config_blocksystem;
global $config_showcblink, $config_showonline;
global $config_firstwordsinbox;
global $config_allowemailnotify, $config_allowpopup;
global $config_sysm_username, $config_allowarchive, $config_perpage;
global $config_charset, $config_inboxlimit, $config_showinboxlimit, $config_maxarchive;
global $config_allowbb, $config_allowsmile, $config_showtitle, $config_getpiclink;
global $config_realnames;
// invoke pruning if set so
$my_gid=0;
if($adminignitiononly==1) {
if($my->gid>1) {
$sql="SELECT gid FROM #__users WHERE id=".$my->id;
$database->setQuery($sql);
$my_gid=$database->loadResult();
}
// if ($my_gid>23) { // JACL support
if ($my_gid==24||$my_gid==25) {
pruneMessages($my->id, $my_gid);
}
} elseif($adminignitiononly==0) {
pruneMessages($my->id, $my_gid);
}
// set the remindersent to now, because looking into inbox counts as remindersent
$sql="UPDATE #__uddeim_emn SET remindersent=".uddetime()." WHERE userid=".$my->id;
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error" . $database->stderr(true));
}
// message limit for inbox?
$limitreached="";
if($config_inboxlimit) {
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$myself." AND totrash<1";
$database->setQuery($sql);
$totalarchive=$database->loadResult();
if ($config_allowarchive) {
$universeflag=_UDDEIM_ARC_UNIVERSE_BOTH;
} else {
$universeflag=_UDDEIM_ARC_UNIVERSE_INBOX;
}
$sql="SELECT gid FROM #__users WHERE id=".$myself;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if($totalarchive>$config_maxarchive && $my_gid<24) { // JACL support
if($totalarchive>$config_maxarchive && $my_gid!=24 && $my_gid!=25) {
$limitreached=_UDDEIM_INBOX_LIMIT_1." ".$totalarchive;
$limitreached.=" "._UDDEIM_INBOX_LIMIT_2." ";
$limitreached.=$universeflag;
$limitreached.=". ";
$limitreached.=_UDDEIM_INBOX_LIMIT_3." ".$config_maxarchive.". ";
$limitreached.=_UDDEIM_INBOX_LIMIT_4;
} else {
$limitreached="";
}
}
// how many messages total?
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$my->id." AND totrash<1 AND archived<1";
$database->setQuery($sql);
$total=$database->loadResult();
// now load messages as required
if(!$limitstart) {
$limitstart=0;
}
if(!$limit) {
$limit=$config_perpage;
}
if($config_realnames) {
$sql="SELECT a.*, b.name AS fromname FROM #__uddeim AS a, #__users AS b WHERE a.toid=".$my->id." AND a.totrash<1 AND a.fromid=b.id AND archived<1 ORDER BY datum DESC LIMIT ".$limitstart.", ".$limit;
} else {
$sql="SELECT a.*, b.username AS fromname FROM #__uddeim AS a, #__users AS b WHERE a.toid=".$my->id." AND a.totrash<1 AND a.fromid=b.id AND archived<1 ORDER BY datum DESC LIMIT ".$limitstart.", ".$limit;
}
$database->setQuery($sql);
$allmessages=$database->loadObjectList();
if($config_getpiclink) {
$sql="SELECT id, avatar FROM #__comprofiler";
$database->setQuery($sql);
$allavatars=$database->loadObjectList();
foreach($allavatars as $allavatar) {
$myavatar[$allavatar->id]=$allavatar->avatar;
}
}
// now do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('inbox', $item_id);
if($limitreached) {
echo "
".$limitreached."
\n
\n";
}
// if no messages:
if(count($allmessages)<1) { // no messages to list
echo "
"._UDDEIM_NOMESSAGES_INBOX."
\n
\n";
// and close the HTML output and return
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
}
// now open the inbox container and table; write table headings
echo "
";
echo "
";
echo "\n\n\t
"._UDDEIM_FROM."
"._UDDEIM_MESSAGE."
"._UDDEIM_DATE."
";
$i=1;
// now write the list
foreach($allmessages as $themessage) {
if($themessage->toread>0) {
// $readcell=$uddeicons_readpic;
$readcell="".$uddeicons_readpic."";
} else {
// $readcell=$uddeicons_unreadpic;
$readcell="".$uddeicons_unreadpic."";
}
$fromname=$themessage->fromname;
$personalsys=0;
if($themessage->systemmessage==$fromname) {
$personalsys=1;
}
if($themessage->systemmessage) {
$fromname=$themessage->systemmessage;
}
if(($config_showcblink && !$themessage->systemmessage) || ($config_showcblink && $personalsys)) {
if($config_getpiclink) {
$fromcell=getPicLink($themessage->fromid,$fromname, $myavatar[$themessage->fromid]);
} else {
$fromcell="fromid.">".$fromname."";
}
} else {
$fromcell=$fromname;
}
// is this user currently online?
if (($config_showonline && !$themessage->systemmessage) || ($config_showonline && $personalsys)) {
$sql="SELECT count(userid) FROM #__session WHERE userid=".$themessage->fromid;
$database->setQuery($sql);
$isonline=$database->loadResult();
if($isonline) {
$fromcell.=$uddeicons_onlinepic;
} else {
$fromcell.=$uddeicons_offlinepic;
}
}
$teasermessage=$themessage->message;
if($themessage->systemmessage || $config_allowbb) {
// if it is a system message or bb codes allowed, parse BB codes
$teasermessage=bbcode_strip($teasermessage);
}
$teasermessage=teaser(stripslashes($teasermessage), $config_firstwordsinbox);
$teasermessage=htmlspecialchars($teasermessage, ENT_QUOTES, $config_charset);
$teasermessage=str_replace("&#", "", $teasermessage);
$safemessage=htmlspecialchars(stripslashes($themessage->message), ENT_QUOTES, $config_charset);
$messagecell="id.">".$teasermessage."";
$datumcell=uddeDate($themessage->datum);
$deletecell="id.">"._UDDEIM_DELETELINK."";
echo "\n\t
";
echo "\n\t\t
".$readcell."
";
echo "\n\t\t
".$fromcell."
";
echo "\n\t\t
".$messagecell."
";
echo "\n\t\t
".$datumcell."
";
echo "\n\t\t
".$deletecell."
";
echo "
";
$i++;
if ($i>2) {
$i=1;
}
}
// now close inbox table and container
echo "\n
\n";
// write the inbox navigation links
$pageNav = new mosPageNav($total, $limitstart, $limit);
$referlink="index.php?option=com_uddeim&task=inbox&Itemid=".$item_id;
if($total>$limit) {
$shownav=$pageNav->writePagesLinks($referlink);
$shownav=arrowReplace($shownav);
echo "
\n\n\n";
}
function trashCan($myself, $item_id) {
global $database, $my;
global $limit, $limitstart;
global $uddeicons_onlinepic, $uddeicons_offlinepic, $uddeicons_readpic, $uddeicons_unreadpic, $config_blocksystem;
global $TrashLivespan, $config_getpiclink, $config_realnames;
global $config_showcblink, $config_showonline, $config_showtitle;
global $config_firstwordsinbox, $config_allowbb, $config_allowsmile;
global $config_sysm_username, $config_allowarchive, $config_perpage, $config_charset;
// how many messages total?
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$my->id." AND totrash>0";
$database->setQuery($sql);
$total=$database->loadResult();
// now load messages as required
if(!$limitstart) {
$limitstart=0;
}
if(!$limit) {
$limit=$config_perpage;
}
if($config_realnames) {
$sql="SELECT a.*, b.name AS fromname FROM #__uddeim AS a, #__users AS b WHERE a.toid=".$my->id." AND a.totrash>0 AND a.fromid=b.id ORDER BY totrashdate DESC LIMIT ".$limitstart.", ".$limit;
} else {
$sql="SELECT a.*, b.username AS fromname FROM #__uddeim AS a, #__users AS b WHERE a.toid=".$my->id." AND a.totrash>0 AND a.fromid=b.id ORDER BY totrashdate DESC LIMIT ".$limitstart.", ".$limit;
}
$database->setQuery($sql);
$allmessages=$database->loadObjectList();
if($config_getpiclink) {
$sql="SELECT id, avatar FROM #__comprofiler";
$database->setQuery($sql);
$allavatars=$database->loadObjectList();
foreach($allavatars as $allavatar) {
$myavatar[$allavatar->id]=$allavatar->avatar;
}
}
// now do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('trashcan', $item_id);
$keephours=$TrashLivespan*24;
// if no messages:
if(count($allmessages)<1) { // no messages to list
echo "
"._UDDEIM_NOMESSAGES_TRASHCAN."
\n
\n";
// and close the HTML output and return
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
}
// now open the inbox container and table; write table headings
echo "
";
echo "\n\n\t
"._UDDEIM_FROM."
"._UDDEIM_MESSAGE."
"._UDDEIM_DELETED."
";
$i=1;
// now write the list
foreach($allmessages as $themessage) {
if($themessage->toread) {
$readcell=$uddeicons_readpic;
} else {
$readcell=$uddeicons_unreadpic;
}
$fromname=$themessage->fromname;
$personalsys=0;
if($themessage->systemmessage==$fromname) {
$personalsys=1;
}
if($themessage->systemmessage) {
$fromname=$themessage->systemmessage;
}
if(($config_showcblink && !$themessage->systemmessage) || ($config_showcblink && $personalsys)) {
if($config_getpiclink) {
$fromcell=getPicLink($themessage->fromid,$fromname, $myavatar[$themessage->fromid]);
} else {
$fromcell="fromid.">".$fromname."";
}
} else {
$fromcell=$fromname;
}
// is this user currently online?
if (($config_showonline && !$themessage->systemmessage) || ($config_showonline && $personalsys)) {
$sql="SELECT count(userid) FROM #__session WHERE userid=".$themessage->fromid;
$database->setQuery($sql);
$isonline=$database->loadResult();
if($isonline) {
$fromcell.=$uddeicons_onlinepic;
} else {
$fromcell.=$uddeicons_offlinepic;
}
}
$teasermessage=$themessage->message;
if($themessage->systemmessage || $config_allowbb) {
// if it is a system message or bb codes allowed, parse BB codes
$teasermessage=bbcode_strip($teasermessage);
}
$teasermessage=teaser(stripslashes($teasermessage), $config_firstwordsinbox);
$teasermessage=htmlspecialchars($teasermessage, ENT_QUOTES, $config_charset);
$teasermessage=str_replace("&#", "", $teasermessage);
$safemessage=htmlspecialchars(stripslashes($themessage->message), ENT_QUOTES, $config_charset);
$messagecell=$teasermessage;
// $messagecell="id.">".$teasermessage."";
$datumcell=uddeDate($themessage->totrashdate);
$deletecell="id.">"._UDDEIM_RESTORE."";
echo "\n\t
";
echo "\n\t\t
".$readcell."
";
echo "\n\t\t
".$fromcell."
";
echo "\n\t\t
".$messagecell."
";
echo "\n\t\t
".$datumcell."
";
echo "\n\t\t
".$deletecell."
";
echo "
";
$i++;
if ($i>2) {
$i=1;
}
}
// now close inbox table and container
echo "\n
\n";
// write the inbox navigation links
$pageNav = new mosPageNav($total, $limitstart, $limit);
$referlink="index.php?option=com_uddeim&task=trashcan&Itemid=".$item_id;
if($total>$limit) {
echo "
\n\n\n";
}
function showMessage($myself, $item_id, $messageid) {
global $database, $my;
global $uddeicons_onlinepic, $uddeicons_offlinepic, $uddeicons_readpic, $uddeicons_unreadpic, $config_realnames;
global $config_blocksystem, $config_blockalert, $config_showtitle;
global $config_showcblink, $config_showcbpic, $config_showonline;
global $config_sysm_username, $config_allowarchive, $config_allowcopytome, $config_trashoriginal, $config_charset, $config_inboxlimit, $config_allowarchive, $config_maxarchive, $config_allowbb, $config_allowsmile, $config_quotedivider;
// read message from database
if($config_realnames) {
$sql="SELECT a.*, b.name AS fromname FROM #__uddeim AS a, #__users AS b WHERE a.toid=".$my->id." AND a.id=".$messageid." AND a.fromid=b.id";
} else {
$sql="SELECT a.*, b.username AS fromname FROM #__uddeim AS a, #__users AS b WHERE a.toid=".$my->id." AND a.id=".$messageid." AND a.fromid=b.id";
}
$database->setQuery($sql);
$displaymessages=$database->loadObjectList();
if(count($displaymessages)<1) {
echo _UDDEIM_MESSAGENOACCESS;
return;
}
// now do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('showMessage', $item_id);
foreach($displaymessages as $displaymessage) {
$setreadflag=$displaymessage->id;
$personalsys=0;
if($displaymessage->systemmessage==$displaymessage->fromname) {
$personalsys=1;
}
// display the message
$headerstring="
";
// does comprofiler have a thumbnail image of the sender?
$sql="SELECT avatar FROM #__comprofiler WHERE user_id=".$displaymessage->fromid;
$database->setQuery($sql);
$avatar_id=$database->loadResult();
$filename="images/comprofiler/tn".$avatar_id;
if (file_exists($filename) && $config_showcbpic && ($personalsys || !$displaymessage->systemmessage)) {
$headerstring.="
";
$dmessage=nl2br(htmlspecialchars(stripslashes($displaymessage->message), ENT_QUOTES, $config_charset));
$dmessage=str_replace("&#", "", $dmessage); // unicode workaround
if($displaymessage->systemmessage || $config_allowbb) {
// if system message or bbcodes allowed, call parser
$dmessage=bbcode_replace($dmessage);
}
if($config_allowsmile) {
$dmessage=smile_replace($dmessage);
}
$bodystring=$dmessage;
$replysuggest=stripslashes($displaymessage->message);
// if allowed to contain bbcodes they should be
// stripped for the reply quote
if($displaymessage->systemmessage || $config_allowbb) {
$replysuggest=bbcode_strip($replysuggest);
}
$replytomessage="\n\n".$config_quotedivider."\n".$replysuggest;
$to_id=$displaymessage->fromid;
$replytoid=$displaymessage->id;
$trashmessage=$displaymessage->totrash;
$disablereply=$displaymessage->disablereply;
echo "
".$headerstring."
";
echo "
".replyquoteMarkup($bodystring)."
";
}
// read flag set to true
$sql="UPDATE #__uddeim SET toread=1 WHERE id=".$setreadflag;
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to set message read flag to true" . $database->stderr(true));
}
// over inbox limit size? Then reply not allowed until messages deleted
if($config_inboxlimit) {
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$myself." AND totrash<1";
$database->setQuery($sql);
$totalarchive=$database->loadResult();
if ($config_allowarchive) {
$universeflag=_UDDEIM_ARC_UNIVERSE_BOTH;
} else {
$universeflag=_UDDEIM_ARC_UNIVERSE_INBOX;
}
$sql="SELECT gid FROM #__users WHERE id=".$myself;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if($totalarchive>$config_maxarchive && $my_gid<24 && !$disablereply) { // JACL support
if($totalarchive>$config_maxarchive && $my_gid!=24 && $my_gid!=25 && !$disablereply) {
$limitreached=_UDDEIM_INBOX_LIMIT_1." ".$totalarchive;
$limitreached.=" "._UDDEIM_INBOX_LIMIT_2." ";
$limitreached.=$universeflag;
$limitreached.=". ";
$limitreached.=_UDDEIM_INBOX_LIMIT_3." ".$config_maxarchive.". ";
$limitreached.=_UDDEIM_INBOX_LIMIT_4;
echo "
";
echo $limitreached;
echo "
";
// close main container
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
}
}
if(!$disablereply || !$to_id>0) {
// show reply form
if($trashmessage==0) { // but only if not already moved to trash
// echo "
"._UDDEIM_REPLY." ";
// which page did refer to this "show Message" page?
// because we want to send back the user where (s)he came from
$backto = mosGetParam($_SERVER, 'HTTP_REFERER', null);
if(stristr($backto, "com_pms")) {
$backto="";
}
drawWriteform($item_id, $backto, $to_id, $replytomessage, $replytoid, $config_trashoriginal, $config_allowcopytome, $config_allowbb, $config_allowsmile, 0, 1, 0, "");
} else {
// offer restore link
echo "
\n\n\n";
}
function showOutmessage($myself, $item_id, $messageid) {
global $database, $my;
global $uddeicons_onlinepic, $uddeicons_offlinepic, $uddeicons_readpic, $uddeicons_unreadpic, $config_blocksystem, $config_showtitle, $config_realnames;
global $config_showcbpic, $config_showcblink, $config_showonline, $config_allowarchive, $config_charset, $config_allowbb, $config_allowsmile;
// read message from database
if($config_realnames) {
$sql="SELECT a.*, b.name AS toname FROM #__uddeim AS a, #__users AS b WHERE a.fromid=".$my->id." AND a.id=".$messageid." AND a.toid=b.id";
} else {
$sql="SELECT a.*, b.username AS toname FROM #__uddeim AS a, #__users AS b WHERE a.fromid=".$my->id." AND a.id=".$messageid." AND a.toid=b.id";
}
$database->setQuery($sql);
$displaymessages=$database->loadObjectList();
if(count($displaymessages)<1) {
echo _UDDEIM_MESSAGENOACCESS;
return;
}
// now do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('showOutmessage', $item_id);
foreach($displaymessages as $displaymessage) {
$outmessageid=$displaymessage->id;
// display the message
$headerstring="
";
// does comprofiler have a thumbnail image of the sender?
$sql="SELECT avatar FROM #__comprofiler WHERE user_id=".$displaymessage->toid;
$database->setQuery($sql);
$avatar_id=$database->loadResult();
$filename="images/comprofiler/tn".$avatar_id;
if (file_exists($filename) && $config_showcbpic) {
$headerstring.="
";
$headerstring.=_UDDEIM_MESSAGETO;
if ($config_showcblink) {
$headerstring.="toid.">";
}
$headerstring.=$displaymessage->toname;
if ($config_showcblink) {
$headerstring.="";
}
// is this user currently online?
if ($config_showonline) {
$sql="SELECT count(userid) FROM #__session WHERE userid=".$displaymessage->toid;
$database->setQuery($sql);
$isonline=$database->loadResult();
if($isonline) {
$headerstring.=$uddeicons_onlinepic;
} else {
$headerstring.=$uddeicons_offlinepic;
}
}
$headerstring.=" ";
$headerstring.=uddeLdate($displaymessage->datum);
$headerstring.="
\n\n\n";
}
function saveMessage($myself, $to_name, $to_id, $pmessage, $to_all, $tobedeleted, $item_id, $messageid, $copytome, $sendeform_showallusers) {
global $database, $my;
global $config_blocksystem, $config_blockalert;
global $backto, $config_showtitle, $config_realnames;
global $config_maxlength, $config_allowemailnotify, $config_maxarchive;
global $config_allowemailnotify, $config_allowarchive, $config_allowcopytome, $config_allowbb, $config_allowsmile, $config_showconnex, $config_inboxlimit, $config_quotedivider;
// if inbox limit set and over limit -> no messages must be saved
if($config_inboxlimit) {
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$myself." AND totrash<1";
$database->setQuery($sql);
$totalarchive=$database->loadResult();
$sql="SELECT gid FROM #__users WHERE id=".$myself;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if($totalarchive>$config_maxarchive && $my_gid<24) { // JACL support
if($totalarchive>$config_maxarchive && $my_gid!=24 && $my_gid!=25) {
$mosmsg=_UDDEIM_ARCHIVEFULL;
$redirecturl="index.php?option=com_uddeim";
mosRedirect($redirecturl, $mosmsg);
// close main container
echo "\n\n";
}
}
if(!$to_id && !$to_name) {
$to_name=" ";
}
if($sendeform_showallusers) {
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('new', $item_id);
// display to form again so that the user can correct his/her fault
$to_name=stripslashes($to_name);
$pmessage=stripslashes($pmessage);
drawWriteform($item_id, "", $to_name, $pmessage, "", "", $config_allowcopytome, $config_allowbb, $config_allowsmile, $config_showconnex, 0, 1, "");
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
}
if($to_name) {
if($config_realnames) {
$sql="SELECT id FROM #__users WHERE name='".$to_name."'";
} else {
$sql="SELECT id FROM #__users WHERE username='".$to_name."'";
}
$database->setQuery($sql);
$to_id=$database->loadResult($sql);
if(!$to_id) { // no user with this username found
// do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('new', $item_id);
// display to form again so that the user can correct his/her fault
$to_name=stripslashes($to_name);
$pmessage=stripslashes($pmessage);
drawWriteform($item_id, "", $to_name, $pmessage, "", "", $config_allowcopytome, $config_allowbb, $config_allowsmile, $config_showconnex, 0, 3, "");
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
} elseif ($to_id==$my->id) { // don't send to yourself
// do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('new', $item_id);
// display to form again so that the user can correct his/her fault
$to_name=stripslashes($to_name);
$pmessage=stripslashes($pmessage);
drawWriteform($item_id, "", $to_name, $pmessage, "", "", $config_allowcopytome, $config_allowbb, $config_allowsmile, $config_showconnex, 0, 2, "");
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
}
}
if(!$to_id) {
$mosmsg=_UDDEIM_NOID;
$redirecturl="index.php?option=com_uddeim";
mosRedirect($redirecturl, $mosmsg);
break;
}
if(!$pmessage) {
$mosmsg=_UDDEIM_NOMESSAGE;
$redirecturl='index.php?option=com_uddeim&task=new&Itemid='.$item_id;
mosRedirect($redirecturl, $mosmsg);
}
$sql="SELECT count(id) FROM #__uddeim_blocks WHERE blocker=".$to_id." AND blocked=".$my->id;
$database->setQuery($sql);
$isblocked=$database->loadResult();
if($isblocked && $config_blocksystem) { // must not send message to to_id
if($config_blockalert) { // sending user shall be informed that (s)he's been blocked
$mosmsg=_UDDEIM_YOUAREBLOCKED;
if(!$backto) {
$redirecturl="index.php?option=com_uddeim&Itemid=".$item_id;
} else {
$redirecturl=$backto;
}
mosRedirect($redirecturl, $mosmsg);
} else { // dont tell him/her (s)he is blocked
$mosmsg=_UDDEIM_MESSAGE_SENT;
if(!$backto) {
$redirecturl="index.php?option=com_uddeim&Itemid=".$item_id;
} else {
$redirecturl=$backto;
}
mosRedirect($redirecturl, $mosmsg);
}
}
$savedatum=uddetime();
$savetoid=$to_id;
$savefromid=$my->id;
$savetoall=$to_all;
$savemessage=addslashes(strip_tags($pmessage));
// $savemessage=(strip_tags($message));
// strip bbcodes
if(!$config_allowbb) {
$savemessage=bbcode_strip($savemessage);
}
// set message max length
if($config_maxlength>0) { // because if 0 do not use any maxlength
$savemessage=substr($savemessage, 0, $config_maxlength);
}
// we have all we need, now save it
$sql="INSERT INTO #__uddeim (fromid, toid, message, datum) VALUES (".$savefromid.", ".$savetoid.", '".$savemessage."', ".$savedatum.")";
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to save a message" . $database->stderr(true));
}
// copy to myself?
if($copytome && $config_allowcopytome) {
if($config_realnames) {
$sql="SELECT name FROM #__users WHERE id=".$savetoid;
} else {
$sql="SELECT username FROM #__users WHERE id=".$savetoid;
}
$database->setQuery($sql);
$to_name=$database->loadResult();
$copyheader="
[i]("._UDDEIM_THISISACOPY.$to_name.")[/i]";
$savemessage=$savemessage.$copyheader;
$archiveflag=0;
// if($config_allowarchive) { $archiveflag=1; }
$sql="INSERT INTO #__uddeim (fromid, toid, toread, message, datum, disablereply, systemmessage, archived) VALUES (".$savefromid.", ".$savefromid.", 1, '".$savemessage."', ".$savedatum.", 1, '"._UDDEIM_TO." ".$to_name."', ".$archiveflag.")";
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to save a message" . $database->stderr(true));
}
}
// delete original message?
if($tobedeleted) {
$deletetime=uddetime();
$sql="UPDATE #__uddeim SET totrash=1, totrashdate=".$deletetime." WHERE toid=".$my->id." AND id=".$messageid;
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to delete a message" . $database->stderr(true));
}
}
// e-mail notification code
$itisareply="";
$currentlyonline="";
// is this a reply?
$itisareply=stristr($savemessage, $config_quotedivider);
// is the receiver currently online?
$sql="SELECT userid FROM #__session WHERE userid=".$savetoid;
$database->setQuery($sql);
$currentlyonline=$database->loadResult();
if($config_allowemailnotify==1) {
$sql="SELECT status FROM #__uddeim_emn WHERE userid='".$savetoid."'";
$database->setQuery($sql);
$ison=$database->loadResult();
if (($ison==1) || ($ison==2 && !$currentlyonline) || ($ison==10 && !$itisareply) || ($ison==20 && !$currentlyonline && !$itisareply)) {
dispatchEMN($savefromid, $savetoid, $savemessage, 0);
// 0 stands for normal (not forgetmenot)
}
} elseif($config_allowemailnotify==2) {
$sql="SELECT gid FROM #__users WHERE id=".$savetoid;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if ($my_gid>23) { // JACL support
if ($my_gid==24||$my_gid==25) {
$sql="SELECT status FROM #__uddeim_emn WHERE userid='".$savetoid."'";
$database->setQuery($sql);
$ison=$database->loadResult();
if (($ison==1) || ($ison==2 && !$currentlyonline) || ($ison==10 && !$itisareply) || ($ison==20 && !$currentlyonline && !$itisareply)) {
dispatchEMN($savefromid, $savetoid, $savemessage, 0);
// 0 stands for normal (not forgetmenot)
}
}
}
if($messageid) {
$mosmsg=_UDDEIM_MESSAGE_REPLIEDTO;
} else {
$mosmsg=_UDDEIM_MESSAGE_SENT;
}
if ($tobedeleted) {
$mosmsg.=_UDDEIM_MOVEDTOTRASH;
}
$yesreferer=_UDDEIM_REFERAFTERSAVING;
if($backto) {
$yesreferer=$backto;
}
if($yesreferer) {
$redirecturl=$yesreferer;
} else {
$redirecturl='index.php?option=com_uddeim';
}
mosRedirect($redirecturl, $mosmsg);
}
function saveSysgm($myself, $to_name, $to_id, $pmessage, $to_all, $tobedeleted, $item_id, $messageid, $sysgm_sys, $sysgm_universe, $sysgm_validfor, $sysgm_really) {
global $database, $my;
global $config_blocksystem, $config_blockalert, $config_showtitle;
global $backto, $config_realnames;
global $config_maxlength, $config_allowemailnotify, $config_emailwithmessage, $config_sysm_username, $config_allowsysgm, $config_allowarchive, $config_charset;
// Am I an admin?
$sql="SELECT gid FROM #__users WHERE id=".$myself;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// is this allowed?
// if(!$config_allowsysgm || $my_gid<24) { // JACL support
if(!$config_allowsysgm || ($my_gid!=24 && $my_gid!=25)) {
$mosmsg=_UDDEIM_NOTALLOWED_SYSM_GM;
$redirecturl="index.php?option=com_uddeim";
mosRedirect($redirecturl, $mosmsg);
}
// do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('new', $item_id);
// what is username of sender?
if($config_realnames) {
$sql="SELECT name FROM #__users WHERE id=".$my->id;
} else {
$sql="SELECT username FROM #__users WHERE id=".$my->id;
}
$database->setQuery($sql);
$sendername=$database->loadResult();
if($sysgm_sys) {
$sendername=$config_sysm_username;
}
if(!$sysgm_really) {
// send not confirmed. ask for confirmation
echo "
";
// strip any HTML from message but don't add slashes yet
$dmessage=strip_tags($pmessage);
$dmessage=stripslashes($pmessage);
$hmessage=htmlspecialchars($dmessage, ENT_QUOTES, $config_charset);
$jmessage=$dmessage;
// 0.4c changed below
// if($sysgm_sys) {
$containslink=stristr($dmessage, "[url");
// parse bb code if it is a sysgm
$dmessage=bbcode_replace($dmessage);
$dmessage=smile_replace($dmessage);
// }
// 0.4c changed above
echo "\n\n\t
\n\t\t\n\t\t
".nl2br($dmessage)."
"; // to do
echo "\n
\n";
?>
"._UDDEIM_SYSGM_CHECKLINK."
\n\n";
} ?>
"; ?>
0) {
$now=uddetime();
$validuntil=$now+($sysgm_validfor*3600);
} else {
$validuntil=0;
}
$savefromid=$my->id;
$savedisablereply=0;
$savesysflag="";
if($sysgm_sys) {
$savesysflag=$config_sysm_username; // system message
$savedisablereply=1; // and users can't reply to them
} else {
$savesysflag=$sendername;
$savedisablereply=0;
}
$savemessage=addslashes($pmessage);
// who shall get the message?
if($sysgm_universe=="sysgm_toall") {
$sql="SELECT id FROM #__users WHERE id<>".$my->id;
} elseif($sysgm_universe=="sysgm_toalllogged") {
$sql="SELECT a.id, b.userid FROM #__users AS a, #__session AS b WHERE a.id=b.userid AND a.id<>".$my->id;
} elseif($sysgm_universe=="sysgm_toalladmins") {
// $sql="SELECT id FROM #__users WHERE `gid`>23 AND id<>".$my->id; // JACL support
$sql="SELECT id FROM #__users WHERE gid IN (24,25) AND id<>".$my->id;
}
// query the database
$database->setQuery($sql);
$receivers=$database->loadObjectList();
if (!count($receivers)) {
$mosmsg=_UDDEIM_SYSGM_ERRORNORECIPS;
$redirecturl='index.php?option=com_uddeim&task=sysgm';
mosRedirect($redirecturl, $mosmsg);
}
// we have all we need, now save it
foreach($receivers as $receiver) {
$savetoid=$receiver->id;
$sql="INSERT INTO #__uddeim (fromid, toid, message, datum, expires, systemmessage, disablereply) VALUES (".$savefromid.", ".$savetoid.", '".$savemessage."', ".$savedatum.", ".$validuntil.", '".$savesysflag."', ".$savedisablereply.")";
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to save a message" . $database->stderr(true));
}
// e-mail notification code
$itisareply="";
$currentlyonline="";
// is the receiver currently online?
$sql="SELECT userid FROM #__session WHERE userid=".$savetoid;
$database->setQuery($sql);
$currentlyonline=$database->loadResult();
if($config_allowemailnotify==1) {
$sql="SELECT status FROM #__uddeim_emn WHERE userid='".$savetoid."'";
$database->setQuery($sql);
$ison=$database->loadResult();
if ($ison) {
if($sysgm_sys) {
$emn_fromid=0;
} else {
$emn_fromid=$savefromid;
}
if (($ison==1) || ($ison==2 && !$currentlyonline) || ($ison==10 && !$itisareply) || ($ison==20 && !$currentlyonline && !$itisareply)) {
dispatchEMN($emn_fromid, $savetoid, $savemessage, 0);
// 0 stands for normal (not forgetmenot)
}
}
} elseif($config_allowemailnotify==2) {
$sql="SELECT gid FROM #__users WHERE id=".$savetoid;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if ($my_gid>23) { // JACL support
if ($my_gid==24||$my_gid==25) {
$sql="SELECT status FROM #__uddeim_emn WHERE userid='".$savetoid."'";
$database->setQuery($sql);
$ison=$database->loadResult();
if ($ison) {
if($sysgm_sys) {
$emn_fromid=0;
} else {
$emn_fromid=$savefromid;
}
if (($ison==1) || ($ison==2 && !$currentlyonline) || ($ison==10 && !$itisareply) || ($ison==20 && !$currentlyonline && !$itisareply)) {
dispatchEMN($emn_fromid, $savetoid, $savemessage, 0);
// 0 stands for normal (not forgetmenot)
}
}
}
}
}
$mosmsg=_UDDEIM_MESSAGE_SENT;
$redirecturl='index.php?option=com_uddeim';
mosRedirect($redirecturl, $mosmsg);
}
}
function newMessage($myself, $item_id, $to_id) {
global $database, $my, $pmessage;
global $recip, $runame, $config_showtitle;
global $config_blocksystem, $config_allowsysgm, $config_allowarchive;
global $config_allowcopytome, $config_maxarchive, $config_inboxlimit, $config_trashoriginal, $config_realnames;
global $config_allowbb, $config_allowsmile, $config_showconnex;
$recipname="";
if($recip) {
if($config_realnames) {
$sql="SELECT name FROM #__users WHERE id='".$recip."'";
} else {
$sql="SELECT username FROM #__users WHERE id='".$recip."'";
}
$database->setQuery($sql);
$recipname=$database->loadResult();
} elseif($runame) {
if($config_realnames) {
$sql="SELECT name FROM #__users WHERE username LIKE '".$runame."'";
} else {
$sql="SELECT username FROM #__users WHERE username LIKE '".$runame."'";
}
$database->setQuery($sql);
$recipname=$database->loadResult();
}
// do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('new', $item_id);
// Don't display writeform if inboxlimit set AND over limit
if($config_inboxlimit) {
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$myself." AND totrash<1";
$database->setQuery($sql);
$totalarchive=$database->loadResult();
if ($config_allowarchive) {
$universeflag=_UDDEIM_ARC_UNIVERSE_BOTH;
} else {
$universeflag=_UDDEIM_ARC_UNIVERSE_INBOX;
}
$sql="SELECT gid FROM #__users WHERE id=".$myself;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if($totalarchive>$config_maxarchive && $my_gid<24) { // JACL support
if($totalarchive>$config_maxarchive && $my_gid!=24 && $my_gid!=25) {
$limitreached=_UDDEIM_INBOX_LIMIT_1." ".$totalarchive;
$limitreached.=" "._UDDEIM_INBOX_LIMIT_2." ";
$limitreached.=$universeflag;
$limitreached.=". ";
$limitreached.=_UDDEIM_INBOX_LIMIT_3." ".$config_maxarchive.". ";
$limitreached.=_UDDEIM_INBOX_LIMIT_4;
echo "
";
echo $limitreached;
echo "
";
// close main container
echo "\n
".contentBottomborder('standard', 'none')."
\n\n\n";
return;
}
}
// which page did refer to this page?
// because we want to send back the user where (s)he came from
// $backto=addslashes($_SERVER['HTTP_REFERER']);
$backto = mosGetParam( $_SERVER, 'HTTP_REFERER', null );
if(stristr($backto, "com_pms")) {
$backto="";
}
drawWriteform($item_id, $backto, $recipname, $pmessage, "", $config_trashoriginal, $config_allowcopytome, $config_allowbb, $config_allowsmile, $config_showconnex, 0, 0, "");
// now check if user is an admin and if system messages are allowed
if($config_allowsysgm) {
$sql="SELECT gid FROM #__users WHERE id=".$my->id;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if ($my_gid>23) { // JACL support
if ($my_gid==24||$my_gid==25) {
echo "
\n\n\n";
}
function newSysgm($myself, $item_id, $to_id) {
global $database, $my, $config_showtitle;
global $config_blocksystem, $config_allowsysgm, $config_allowarchive;
global $pmessage;
global $config_allowbb, $config_allowsmile;
// Am I an admin?
$sql="SELECT gid FROM #__users WHERE id=".$my->id;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// is this allowed?
// if($config_allowsysgm!=1 || $my_gid<24) { // JACL support
if($config_allowsysgm!=1 || ($my_gid!=24 && $my_gid!=25)) {
$mosmsg=_UDDEIM_NOTALLOWED_SYSM_GM;
$redirecturl="index.php?option=com_uddeim";
mosRedirect($redirecturl, $mosmsg);
}
// do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
\n\n\n";
}
function deleteMessage($myself, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id, $ret) {
## Delete sets trash flag to true (it does not erase the message from the database,
## this is only done by PRUNING the messages. So messages deleted from the inbox will
## be moved to the trash can of the respective user
global $database, $my, $config_allowarchive;
$deletetime=uddetime();
$sql="UPDATE #__uddeim SET toread=1, totrash=1, totrashdate=".$deletetime." WHERE toid=".$my->id." AND id=".$messageid;
$database->setQuery($sql);
if (!$database->query()) {
die("SQL error when attempting to trash a message" . $database->stderr(true));
}
if($ret=='archive' && $config_allowarchive) {
$redirecturl="index.php?option=com_uddeim&task=archive&Itemid=".$item_id."&limit=".$returnlimit."&limitstart=".$returnlimitstart;
mosRedirect($redirecturl);
} elseif($ret=='top') {
$redirecturl="index.php?option=com_uddeim&task=inbox&Itemid=".$item_id;
mosRedirect($redirecturl);
} else {
$redirecturl="index.php?option=com_uddeim&task=inbox&Itemid=".$item_id."&limit=".$returnlimit."&limitstart=".$returnlimitstart;
mosRedirect($redirecturl);
}
}
function restoreMessage($myself, $messageid, $returntask, $returnlimit, $returnlimitstart, $item_id) {
global $database, $my, $config_maxarchive, $config_allowarchive, $config_inboxlimit;
// to do: show error message when trying to restore message that has been deleted or
// is no longer available
// this is a workaround for now: debug
$sql="SELECT count(id) FROM #__uddeim WHERE id=".$messageid;
$database->setQuery($sql);
$zaehler=$database->loadResult();
if ($zaehler<1) {
$mosmsg=_UDDEIM_CANTRESTORE;
$redirecturl="index.php?option=com_uddeim&task=trashcan&Itemid=".$item_id."&limit=".$returnlimit."&limitstart=".$returnlimitstart;
mosRedirect($redirecturl, $mosmsg);
return;
}
// end of workaround
// count from database all messages I saved
// if greater than max, don't allow. warning text.
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$myself." AND id=".$messageid." AND archived>0 AND totrash>0";
$database->setQuery($sql);
$isinarchive=$database->loadResult();
// if not allowarchive: send back where came from
if(!$config_allowarchive && $isinarchive) {
$mosmsg=_UDDEIM_ARCHIVENOTENABLED;
// $redirecturl=$_SERVER['HTTP_REFERER'];
$redirecturl= mosGetParam( $_SERVER, 'HTTP_REFERER', null );
mosRedirect($redirecturl, $mosmsg);
}
// $arcsql=" AND archived>0";
$sql="SELECT count(id) FROM #__uddeim WHERE toid=".$myself.$arcsql." AND totrash<1";
$database->setQuery($sql);
$inarchive=$database->loadResult();
$sql="SELECT gid FROM #__users WHERE id=".$myself;
$database->setQuery($sql);
$my_gid=$database->loadResult();
// if($inarchive >= $config_maxarchive && $my_gid<24) { // JACL support
if($inarchive >= $config_maxarchive && $my_gid!=24 && $my_gid!=25) {
echo "
\n";
$redirecturl=mosGetParam( $_SERVER, 'HTTP_REFERER', null );
$mosmsg=_UDDEIM_LIMITREACHED;
mosRedirect($redirecturl, $mosmsg);
}
$sql="UPDATE #__uddeim SET totrash=0 WHERE toid=".$my->id." AND id=".$messageid;
$database->setQuery($sql);
$numberofrows=$database->query();
if (!$database->query()) {
die("SQL error when attempting to restore a message" . $database->stderr(true));
}
// if archived then restore back to archive
$redirecturl="index.php?option=com_uddeim&task=trashcan&Itemid=".$item_id."&limit=".$returnlimit."&limitstart=".$returnlimitstart;
mosRedirect($redirecturl);
}
function recallMessage($myself, $messageid, $item_id) {
global $database, $my, $config_blocksystem, $config_allowarchive, $config_allowcopytome, $config_showtitle, $config_realnames;
## this function has three parts
## first, read the message
## second, delete the message from the database (complete erase)
## third, display values for editing
// read message from database
if($config_realnames) {
$sql="SELECT a.*, b.name AS toname FROM #__uddeim AS a, #__users AS b WHERE a.fromid=".$my->id." AND a.id=".$messageid." AND a.toid=b.id AND a.toread<1";
} else {
$sql="SELECT a.*, b.username AS toname FROM #__uddeim AS a, #__users AS b WHERE a.fromid=".$my->id." AND a.id=".$messageid." AND a.toid=b.id AND a.toread<1";
}
$database->setQuery($sql);
$displaymessages=$database->loadObjectList();
if(count($displaymessages)<1) {
$mosmsg=_UDDEIM_COULDNOTRECALL;
$redirecturl="index.php?option=com_uddeim&task=outbox&Itemid=".$item_id;
mosRedirect($redirecturl, $mosmsg);
}
foreach($displaymessages as $themessage) {
$recalled_toname=$themessage->toname;
$recalled_message=stripslashes($themessage->message);
}
// delete it from database
$sql="DELETE FROM #__uddeim WHERE fromid=".$my->id." AND id=".$messageid;
$database->setQuery($sql);
$queryresult = $database->query();
// show form with message values to allow for editing
// do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
".$config_showtitle."
";
}
// write the uddeim menu
print_uddemenu('new', $item_id);
echo "
";
echo "
"._UDDEIM_RECALLEDMESSAGE_INFO."
\n";
echo "
\n";
?>
\n
".contentBottomborder('standard', 'none')."
\n\n\n";
}
function showSettings($myself, $item_id) {
global $config_blocksystem, $config_blockalert, $database, $config_allowemailnotify;
global $config_showcblink, $config_allowarchive, $config_showtitle, $config_allowpopup;
global $mosConfig_lang, $config_setpopup, $config_setsound, $config_realnames;
// now do the HTML output, neatly CSSed
if($config_showtitle) {
echo "
";
}
if($config_blocksystem) {
$emptysettings="";
if($config_realnames) {
$sql="SELECT a.*, b.name AS displayname FROM #__uddeim_blocks AS a, #__users AS b WHERE blocker=".$myself." AND a.blocked=b.id";
} else {
$sql="SELECT a.*, b.username AS displayname FROM #__uddeim_blocks AS a, #__users AS b WHERE blocker=".$myself." AND a.blocked=b.id";
}
$database->setQuery($sql);
$blockedusers=$database->loadObjectList();
$howmanyblocks=count($blockedusers);
echo "
\n\n\n";
}
function pruneMessages($myself, $my_gid) {
global $database, $my, $task;
global $config_longwaitingemail, $config_longwaitingdays, $adminignitiononly;
// for pruning we also need the following variables:
global $ReadMessagesLivespan, $UnreadMessagesLivespan, $TrashLivespan;
global $config_forgetmenotstart;
if(!$my_gid) {
$sql="SELECT gid FROM #__users WHERE id=".$my->id;
$database->setQuery($sql);
$my_gid=$database->loadResult();
}
// called by superadmin and by showinbox function?
// if($adminignitiononly>0 && $my_gid<24) { // JACL support
if($adminignitiononly>0 && !($my_gid==24 || $my_gid==25)) {
mosRedirect("index.php?option=com_uddeim", _UDDEIM_VIOLATION);
}
$rightnow=uddetime();
// erase read messages after configured time frame
$offset=$ReadMessagesLivespan*86400;
$timeframe=$rightnow-$offset;
$trashoffset=$TrashLivespan*86400;
$trashframe=$rightnow-$trashoffset;
// $sql="DELETE FROM #__uddeim WHERE toread>0 AND totrash<1 AND datum<".$timeframe;
// change in behaviour: (move to trash, don't erase after timeframe elapsed)
// $sql="UPDATE #__uddeim SET totrash=1, totrashdate=".$rightnow." WHERE toread>0 AND totrash<1 AND datum<".$timeframe;
$sql="UPDATE #__uddeim SET totrash=1, totrashdate=".$rightnow." WHERE toread>0 AND totrash<1 AND datum<".$timeframe." AND (totrashdate<".$trashframe." OR totrashdate IS NULL)";
$database->setQuery($sql);
$queryresult = $database->query();
// erase unread messages after configured time frame
$offset=$UnreadMessagesLivespan*86400;
$timeframe=$rightnow-$offset;
// $sql="DELETE FROM #__uddeim WHERE totrash<1 AND datum<".$timeframe;
// change in behaviour: (move to trash, don't erase after timeframe elapsed)
// $sql="UPDATE #__uddeim SET totrash=1, totrashdate=".$rightnow." WHERE toread>0 AND totrash<1 AND datum<".$timeframe;
$sql="UPDATE #__uddeim SET totrash=1, totrashdate=".$rightnow." WHERE toread<1 AND totrash<1 AND datum<".$timeframe;
$database->setQuery($sql);
$queryresult = $database->query();
// erase messages from trashcans after configured time frame
$offset=$TrashLivespan*86400;
$timeframe=$rightnow-$offset;
$sql="DELETE FROM #__uddeim WHERE totrash>0 AND totrashdate<".$timeframe;
$database->setQuery($sql);
$queryresult = $database->query();
// erase unread expired messages
$rightnow=uddetime();
$sql="DELETE FROM #__uddeim WHERE toread<1 AND expires>0 AND expires<".$rightnow;
$database->setQuery($sql);
$queryresult = $database->query();
// send reminder if forgetmenot is activated
if ($config_longwaitingemail && $config_longwaitingdays>0) {
if(!$config_forgetmenotstart) {
$config_forgetmenotstart=0;
}
$sincewhen=uddetime()-($config_longwaitingdays*86400);
// $sql="SELECT * FROM #__uddeim WHERE toread<1 AND totrash<1 AND datum<".$sincewhen;
$sql="SELECT * FROM #__uddeim WHERE toread<1 AND totrash<1 AND datum<".$sincewhen. " AND datum>".$config_forgetmenotstart;
$database->setQuery($sql);
$castaways=$database->loadObjectList();
$loopcounter=0;
foreach($castaways as $castaway) {
// has this user already received a reminder?
$sql="SELECT remindersent FROM #__uddeim_emn WHERE userid=".$castaway->toid;
$database->setQuery($sql);
$var_remindersent=$database->loadResult();
$next_remindersent=$var_remindersent+($config_longwaitingdays*86400);
if($next_remindersent < uddetime()) { // send only if no reminder has already been sent
$var_message="";
dispatchEMN (0, $castaway->toid, $var_message, 1);
$loopcounter++;
}
// new: never send more than 25 forgetmenot e-mails in one script call to avoid
// to many mails to be sent out at once
if($loopcounter>=25) {
break;
}
}
}
if($task=="prune") {
mosRedirect('index.php', 'uddeIM/Prune');
}
}
?>