/** * Sends a PM notification * * @param cbmypmsproTable $pm * @param null|string $message */ private function sendNotification($pm, $message = null) { if (!$pm->get('id')) { return; } $itemId = uddeIMgetItemid($this->uddeIMConfigRAW); if (!uddeIMexistsEMN($pm->get('toid'))) { uddeIMinsertEMNdefaults($pm->get('toid'), $this->uddeIMConfigRAW); } $emailNotify = $this->uddeIMConfig->get('allowemailnotify', 0); $isModerated = uddeIMgetEMNmoderated($pm->get('fromid')); $isReply = stristr($pm->get('message'), $this->uddeIMConfig->get('quotedivider'), '__________'); $isOnline = uddeIMisOnline($pm->get('toid')); // Strip the html and bbcode as uddeim supports neither in its notification: $message = strip_tags(uddeIMbbcode_strip($message ? $message : $pm->get('message'), $this->uddeIMConfigRAW)); if (!$isModerated) { if ($emailNotify == 1 || $emailNotify == 2 && Application::User($pm->get('toid'))->isSuperAdmin()) { $status = uddeIMgetEMNstatus($pm->get('toid')); if ($status == 1 || $status == 2 && !$isOnline || $status == 10 && !$isReply || $status == 20 && !$isOnline && !$isReply) { uddeIMdispatchEMN($pm->get('id'), $itemId, 0, $pm->get('fromid'), $pm->get('toid'), $message, 0, $this->uddeIMConfigRAW); } } } }
function sendNewSysMessage($fromid, $recipients, $message, $systemmsg=0, $validfor=0, $sendnotification=0, $forceembedded=0) { $database = uddeIMgetDatabase(); if ($systemmsg) { // system message $sendername = $this->config->sysm_username; $savesysflag = addslashes($sendername); // system message $savedisablereply = 1; // and users can't reply to them $emn_fromid = 0; // for email notifications set userid 0 } else { $sendername = uddeIMgetNameFromID($fromid, $this->config); $savesysflag = addslashes($sendername); $savedisablereply = 0; $emn_fromid = $fromid; } $savedatum = uddetime($this->config->timezone); if ($validfor>0) { $now = uddetime($this->config->timezone); $validuntil = $now+($validfor*3600); } else { $validuntil = 0; } if ($this->config->cryptmode>=1) { // because of encoding do not use slashes $savemessage = strip_tags($message); } else { $savemessage = addslashes(strip_tags($message)); // original 0.6+ } getAdditonalGroups($add_special, $add_admin, $config); if (uddeIMcheckJversion()>=2) { // J1.6 if ($recipients=="all") { $sql="SELECT id FROM #__users WHERE block=0"; } elseif($recipients=="online") { $sql="SELECT a.id, b.userid FROM #__users AS a, #__session AS b WHERE block=0 AND a.id=b.userid"; } elseif($recipients=="special") { $sql="SELECT DISTINCT u.id FROM (#__users AS u INNER JOIN #__user_usergroup_map AS um ON u.id=um.user_id) INNER JOIN #__usergroups AS g ON um.group_id=g.id WHERE u.block=0 AND g.id IN (3,4,5,6,7,8".$add_admin.$add_special.")"; } elseif($recipients=="admins") { $sql="SELECT DISTINCT u.id FROM (#__users AS u INNER JOIN #__user_usergroup_map AS um ON u.id=um.user_id) INNER JOIN #__usergroups AS g ON um.group_id=g.id WHERE u.block=0 AND g.id IN (7,8".$add_admin.")"; } else { $sql="SELECT DISTINCT u.id FROM (#__users AS u INNER JOIN #__user_usergroup_map AS um ON u.id=um.user_id) INNER JOIN #__usergroups AS g ON um.group_id=g.id WHERE u.block=0 AND g.id=".(int)$recipients; } } else { if ($recipients=="all") { $sql="SELECT id FROM #__users WHERE block=0"; } elseif($recipients=="online") { $sql="SELECT a.id, b.userid FROM #__users AS a, #__session AS b WHERE block=0 AND a.id=b.userid"; } elseif($recipients=="special") { $sql="SELECT id FROM #__users WHERE block=0 AND gid IN (19,20,21,23,24,25".$add_admin.")"; } elseif($recipients=="admins") { $sql="SELECT id FROM #__users WHERE block=0 AND gid IN (24,25".$add_admin.")"; } else { $sql="SELECT id FROM #__users WHERE block=0 AND gid=".(int)$recipients; } } $database->setQuery($sql); $receivers=$database->loadObjectList(); if (!count($receivers)) { return 1; } foreach($receivers as $receiver) { $toid = $receiver->id; $themode = 0; if ($this->config->cryptmode==1 || $this->config->cryptmode==2 || $this->config->cryptmode==4) { $themode = 1; $cm = uddeIMencrypt($savemessage,$this->config->cryptkey,CRYPT_MODE_BASE64); $sql="INSERT INTO #__uddeim (fromid, toid, message, datum, expires, systemmessage, systemflag, disablereply, totrashoutbox, totrashdateoutbox, cryptmode, crypthash) VALUES (".(int)$fromid.", ".(int)$toid.", '".$cm."', ".$savedatum.", ".$validuntil.", '".$savesysflag."', 1,".$savedisablereply.", 1, ".$savedatum.",1,'".md5($this->config->cryptkey)."')"; } elseif ($this->config->cryptmode==3) { $themode = 3; $cm = uddeIMencrypt($savemessage,"",CRYPT_MODE_STOREBASE64); $sql="INSERT INTO #__uddeim (fromid, toid, message, datum, expires, systemmessage, systemflag, disablereply, totrashoutbox, totrashdateoutbox, cryptmode) VALUES (".(int)$fromid.", ".(int)$toid.", '".$cm."', ".$savedatum.", ".$validuntil.", '".$savesysflag."', 1,".$savedisablereply.", 1, ".$savedatum.",3)"; } else { $sql="INSERT INTO #__uddeim (fromid, toid, message, datum, expires, systemmessage, systemflag, disablereply, totrashoutbox, totrashdateoutbox) VALUES (".(int)$fromid.", ".(int)$toid.", '".$savemessage."', ".$savedatum.", ".$validuntil.", '".$savesysflag."', 1,".$savedisablereply.", 1,".$savedatum.")"; } $database->setQuery($sql); if (!$database->query()) { die("SQL error when attempting to save a message" . $database->stderr(true)); } $insID = $database->insertid(); if ($sendnotification) { // Check if E-Mail notification or popups are enabled by default, if so create a record for the receiver. if ($this->config->notifydefault>0 || $this->config->popupdefault>0 || $this->config->pubfrontenddefault>0 || $this->config->autoresponder>0 || $this->config->autoforward>0) { if (!uddeIMexistsEMN($toid)) uddeIMinsertEMNdefaults($toid, $this->config); } } // ################################################################################################## // email notification // ################################################################################################## if ($sendnotification) { $currentlyonline = uddeIMisOnline($toid); if ($this->config->cryptmode>=1) { $email = stripslashes($savemessage); } else { $email = stripslashes(stripslashes($savemessage)); } $type = 0; if ($forceembedded) $type = 2; if ($this->config->allowemailnotify==1) { $ison = uddeIMgetEMNstatus($toid); if (($ison==1) || ($ison==2 && !$currentlyonline) || $ison==10 || ($ison==20 && !$currentlyonline)) { uddeIMdispatchEMN($insID, $item_id, $themode, $emn_fromid, $toid, $email, $type, $this->config); } } elseif($this->config->allowemailnotify==2) { $gid = uddeIMgetGID((int)$toid); if (uddeIMisAdmin($gid) || uddeIMisAdmin2($gid, $this->config)) { $ison = uddeIMgetEMNstatus($toid); if (($ison==1) || ($ison==2 && !$currentlyonline) || $ison==10 || ($ison==20 && !$currentlyonline)) { uddeIMdispatchEMN($insID, $item_id, $themode, $emn_fromid, $toid, $email, $type, $this->config); } } } } } return 0; }
function uddeIMpublicDispatchEMN($var_msgid, $var_fromname, $var_toid, $var_message, $emn_option, $config) { $mosConfig_sitename = uddeIMgetSitename(); $pathtosite = uddeIMgetPath('live_site'); // if e-mail traffic stopped, don't send. if(!$config->emailtrafficenabled) { return; } $fromname = $var_fromname; if (!$fromname) $fromname = _UDDEIM_PUBLICUSER; // $ret = uddeIMgetNameEmailFromID($var_toid, $var_toname, $var_tomail, $config); $var_toname = uddeIMgetNameFromID($var_toid, $config); $var_tomail = uddeIMgetEMailFromID($var_toid, $config); if(!$var_tomail) return; if (!$var_toname) $var_toname = "Anonymous"; $msglink = ""; if ($cryptmode==2) { // Message is encrypted, so go to enter password page $msglink = uddeIMsefRelToAbs("index.php?option=com_uddeim&task=showpass&Itemid=".$item_id."&messageid=".$var_msgid); } else { // normal message $msglink = uddeIMsefRelToAbs("index.php?option=com_uddeim&task=show&Itemid=".$item_id."&messageid=".$var_msgid); } if($emn_option==1) { $var_body = _UDDEIM_EMN_FORGETMENOT; $var_body = str_replace("%livesite%", $pathtosite, $var_body); $var_body = str_replace("%you%", $var_toname, $var_body); $var_body = str_replace("%site%", $mosConfig_sitename, $var_body); $var_body = str_replace("%msglink%", $msglink, $var_body); } else { if($config->emailwithmessage==1 || $emn_option==2) { $var_body = _UDDEIM_EMN_BODY_WITHMESSAGE; $var_body = str_replace("%livesite%", $pathtosite, $var_body); $var_body = str_replace("%you%", $var_toname, $var_body); $var_body = str_replace("%site%", $mosConfig_sitename, $var_body); $var_body = str_replace("%msglink%", $msglink, $var_body); $var_body = str_replace("%user%", $var_fromname, $var_body); $var_body = str_replace("%pmessage%", $var_message, $var_body); } else { $var_body = _UDDEIM_EMN_BODY_NOMESSAGE; $var_body = str_replace("%livesite%", $pathtosite, $var_body); $var_body = str_replace("%you%", $var_toname, $var_body); $var_body = str_replace("%site%", $mosConfig_sitename, $var_body); $var_body = str_replace("%msglink%", $msglink, $var_body); $var_body = str_replace("%user%", $var_fromname, $var_body); } } $subject = _UDDEIM_EMN_SUBJECT; $subject = str_replace("%livesite%", $pathtosite, $subject); $subject = str_replace("%site%", $mosConfig_sitename, $subject); $subject = str_replace("%you%", $var_toname, $subject); $subject = str_replace("%user%", $var_fromname, $subject); $replyto = $var_tomail; $replytoname = ""; if(uddeIMsendmail($config->emn_sendername, $config->emn_sendermail, $var_toname, $var_tomail, $subject, $var_body, $replyto, $replytoname, "", $config)) { // set the remindersent status of this user to true if(!uddeIMexistsEMN($var_toid)) uddeIMinsertEMNdefaults($var_toid, $config); uddeIMupdateEMNreminder($var_toid, uddetime($config->timezone)); } }
function uddeIMdispatchEMN($var_msgid, $item_id, $cryptmode, $var_fromid, $var_toid, $var_message, $emn_option, $config) { $mosConfig_sitename = uddeIMgetSitename(); $pathtosite = uddeIMgetPath('live_site'); // if e-mail traffic stopped, don't send. if(!$config->emailtrafficenabled) { return; } if ($var_fromid>0) { $var_fromname = uddeIMgetNameFromID($var_fromid, $config); if (!$var_fromname) $var_fromname=$config->sysm_username; } else { $var_fromname=$config->sysm_username; } // $sql="SELECT ".($config->realnames ? "name" : "username")." AS displayname, email FROM #__users WHERE id=".(int)$var_toid; // $___atabase->setQuery($sql); // $results=$___atabase->loadObjectList(); // foreach($results as $result) { // $var_toname = $result->displayname; // $var_tomail = $result->email; // } // $ret = uddeIMgetNameEmailFromID($var_toid, $var_toname, $var_tomail, $config); $var_toname = uddeIMgetNameFromID($var_toid, $config); $var_tomail = uddeIMgetEMailFromID($var_toid, $config); if(!$var_tomail) return; if (!$var_toname) $var_toname = "Anonymous"; $msglink = ""; if ($cryptmode==2 || $cryptmode==4) { // Message is encrypted, so go to enter password page if ($config->dontsefmsglink) $msglink = $pathtosite."/index.php?option=com_uddeim&task=showpass&Itemid=".$item_id."&messageid=".$var_msgid; else $msglink = uddeIMsefRelToAbs("index.php?option=com_uddeim&task=showpass&Itemid=".$item_id."&messageid=".$var_msgid); } else { // normal message if ($config->dontsefmsglink) $msglink = $pathtosite."/index.php?option=com_uddeim&task=show&Itemid=".$item_id."&messageid=".$var_msgid; else $msglink = uddeIMsefRelToAbs("index.php?option=com_uddeim&task=show&Itemid=".$item_id."&messageid=".$var_msgid); } if($emn_option==1) { $var_body = _UDDEIM_EMN_FORGETMENOT; $var_body = str_replace("%livesite%", $pathtosite, $var_body); $var_body = str_replace("%you%", $var_toname, $var_body); $var_body = str_replace("%site%", $mosConfig_sitename, $var_body); $var_body = str_replace("%msglink%", $msglink, $var_body); } else { if($config->emailwithmessage==1 || $emn_option==2) { $var_body = _UDDEIM_EMN_BODY_WITHMESSAGE; $var_body = str_replace("%livesite%", $pathtosite, $var_body); $var_body = str_replace("%you%", $var_toname, $var_body); $var_body = str_replace("%site%", $mosConfig_sitename, $var_body); $var_body = str_replace("%msglink%", $msglink, $var_body); $var_body = str_replace("%user%", $var_fromname, $var_body); $var_body = str_replace("%pmessage%", $var_message, $var_body); } else { $var_body = _UDDEIM_EMN_BODY_NOMESSAGE; $var_body = str_replace("%livesite%", $pathtosite, $var_body); $var_body = str_replace("%you%", $var_toname, $var_body); $var_body = str_replace("%site%", $mosConfig_sitename, $var_body); $var_body = str_replace("%msglink%", $msglink, $var_body); $var_body = str_replace("%user%", $var_fromname, $var_body); } } $subject = _UDDEIM_EMN_SUBJECT; $subject = str_replace("%livesite%", $pathtosite, $subject); $subject = str_replace("%site%", $mosConfig_sitename, $subject); $subject = str_replace("%you%", $var_toname, $subject); $subject = str_replace("%user%", $var_fromname, $subject); $replyto = $var_tomail; $replytoname = ""; if(uddeIMsendmail($config->emn_sendername, $config->emn_sendermail, $var_toname, $var_tomail, $subject, $var_body, $replyto, $replytoname, "", $config)) { // set the remindersent status of this user to true if(!uddeIMexistsEMN($var_toid)) uddeIMinsertEMNdefaults($var_toid, $config); uddeIMupdateEMNreminder($var_toid, uddetime($config->timezone)); } }
function uddeIMsaveUserEMN ($myself, $item_id, $popupcheck, $publiccheck, $config) { // $popupcheck and $publiccheck contain "on" $valuepopup = 0; if ($popupcheck) $valuepopup=1; $valuepublic = 0; if ($publiccheck) $valuepublic=1; if (!uddeIMexistsEMN($myself)) uddeIMinsertEMNdefaults($myself, $config); uddeIMupdateEMNpopup($myself, $valuepopup); uddeIMupdateEMNpublic($myself, $valuepublic); uddeJSEFredirect("index.php?option=com_uddeim&task=settings&Itemid=".$item_id); }