...
  View open merge request
Commits (3)
  • ~rs's avatar
    add wikimail implantation · 039c0031
    ~rs authored
    039c0031
  • Luke081515's avatar
    Split wikimail · 1b5c66fc
    Luke081515 authored
    * Split the massmail function into a function to send a wikimail and a function to send a massmail
    * You can specify the subject as well
    * Subject and content get replaced to fit to the receiver
    * Added wikimail to debug
    1b5c66fc
  • Luke081515's avatar
    Fix phpcs · 135497cc
    Luke081515 authored
    135497cc
......@@ -1302,6 +1302,49 @@ class Core extends Password {
mail($this->mail, $subject, $this->mailcontent);
$this->mailcontent = "";
}
/** send sendMassmail
* sends wikimails to a list with users
* @author KPFC, Luke081515
* @param $user - Array with users
* @param $subject - subject of the mail - USERNAME will be replaced with the current username
* @param $content - content of the e-mail - USERNAME will be replaced with the current username
*/
public function sendMassmail ($users, $subject, $content) {
for ($i = 0; isset($users[$i]); $i++) {
$personalsubject = str_replace('USERNAME', $users[$i], $subject);
$personalcontent = str_replace('USERNAME', $users[$i], $content);
$this->sendWikimail($users[$i], $personalsubject, $personalcontent);
}
}
/** send Wikimail
* sends a wikimail to a user
* @author KPFC, Luke081515
* @param $user - Username
* @param $subject - subject of the mail
* @param $content - content of the e-mail
* @return boolean - false if there was an error, true if successful
*/
public function sendWikimail($user, $subject, $content) {
if ($this->checkUserMail($user) === false) {
return false;
}
$token = $this->requireToken();
$request = "action=emailuser&format=json" .
"&target=" . urlencode($user) .
"&subject=" . urlencode($subject) .
"&text=" . urlencode($content) .
"&token=" . urlencode($token);
try {
$result = $this->httpRequest($request, $this->job);
} catch (Exception $e) {
throw $e;
}
$result = json_decode($result, true);
if (array_key_exists("error", $result)) {
return false;
}
return true;
}
/** curlRequest
* sends a curl request to a website
* @author: Freddy2001
......
......@@ -544,6 +544,20 @@ class Debug extends Core {
$this->processError($e, $starttime, $endtime);
}
break;
case 'sendWikimail':
$required = array("user", "subject", "content");
$Param = $this->getParams($required);
$this->echoNotice('Starting the function call of sendWikimail...');
$starttime = microtime (true);
try {
$ret = $this->sendWikimail($Param[0], $Param[1], $Param[2]);
$endtime = microtime (true);
$this->processFunction($ret, $starttime, $endtime, true);
} catch (Exception $e) {
$endtime = microtime (true);
$this->processError($e, $starttime, $endtime);
}
break;
// Admin functions
case 'deletePage':
$required = array("title", "reason");
......