33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
39 return ignore_user_abort(
true);
44 $this->soap_check =
false;
47 public function sendMail($sid, $to, $cc, $bcc, $senderId, $subject,
$message, $attach)
54 if (!$this->__checkSession($sid)) {
59 $senderFactory =
$GLOBALS[
"DIC"][
"mail.mime.sender.factory"];
61 if (is_numeric($senderId)) {
62 $sender = $senderFactory->getSenderByUsrId($senderId);
64 $sender = $senderFactory->userByEmailAddress($senderId);
68 $mmail->From($sender);
69 $mmail->To(explode(
',', $to));
70 $mmail->Subject($subject);
74 $mmail->Cc(explode(
',', $cc));
78 $mmail->Bcc(explode(
',', $bcc));
82 $authUserFileData = new \ilFileDataMail($DIC->user()->getId());
83 $anonymousFileData = new \ilFileDataMail(ANONYMOUS_USER_ID);
88 if (strpos($attach,
'#:#') === 0) {
89 $attach = substr($attach, strlen(
'#:#'));
90 $attachments = explode(
'#:#', $attach);
92 $attachments = explode(
',', $attach);
95 foreach ($attachments as $attachment) {
96 $final_filename = null;
100 $final_filename = preg_replace(
'/^(\d+?_)(.*)/',
'$2',
$filename);
103 $allowedPathPrefixes = [
104 $authUserFileData->getAbsoluteAttachmentPoolPathPrefix()
107 if (is_numeric($senderId) && $senderId == ANONYMOUS_USER_ID) {
108 $allowedPathPrefixes[] = $anonymousFileData->getAbsoluteAttachmentPoolPathPrefix();
111 $absoluteAttachmentPath = realpath($attachment);
113 $matchedPathPrefixes = array_filter($allowedPathPrefixes,
function (
$path) use ($absoluteAttachmentPath) {
114 return strpos($absoluteAttachmentPath,
$path) === 0;
117 if (count($matchedPathPrefixes) > 0) {
118 $mmail->Attach($attachment,
'',
'inline', $final_filename);
119 $DIC->logger()->mail()->debug(sprintf(
"Accepted attachment: %s", $attachment));
121 $DIC->logger()->mail()->warning(sprintf(
122 "Ignored attachment when sending message via SOAP: Given path '%s' is not in allowed prefix list: %s",
123 $absoluteAttachmentPath,
124 implode(
', ', $allowedPathPrefixes)
146 if (!$this->__checkSession($sid)) {
150 include_once
'Services/Mail/classes/class.ilMail.php';
151 include_once
'webservice/soap/classes/class.ilSoapMailXmlParser.php';
156 libxml_use_internal_errors(
true);
157 $ok = simplexml_load_string($a_mail_xml);
159 foreach (libxml_get_errors() as $err) {
160 $error .= ($err->message .
' ');
166 $GLOBALS[
'ilLog']->write(__METHOD__ .
' ' . $e->getMessage());
169 $GLOBALS[
'ilLog']->write(__METHOD__ .
' ' . $e->getMessage());
177 foreach ($mails as $mail) {
179 include_once
'./Services/Mail/classes/class.ilFileDataMail.php';
181 foreach ((
array) $mail[
'attachments'] as $attachment) {
183 $file->storeAsAttachment($attachment[
'name'], $attachment[
'content']);
187 $mail_obj =
new ilMail($ilUser->getId());
189 $mail_obj->saveAttachments((
array) $attachments);
191 implode(
',', (
array) $mail[
'to']),
192 implode(
',', (
array) $mail[
'cc']),
193 implode(
',', (
array) $mail[
'bcc']),
195 implode(
"\n", (
array) $mail[
'body']),
196 (
array) $attachments,
197 array($mail[
'type']),
198 (
bool) $mail[
'usePlaceholders']
202 foreach ((
array) $attachments as $att) {
203 $file->unlinkFile($att);
205 $mail_obj->savePostData(
226 if (!$this->__checkSession($sid)) {
230 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
239 if (!$this->__checkSession($sid)) {
243 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
259 if (!$this->__checkSession($sid)) {
265 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
269 if (!$cp_options->checkOwner($ilUser->getId())) {
270 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
275 if (($node = $cp_options->fetchFirstDependenciesNode()) ===
false) {
276 $cp_options->deleteAll();
282 $options = $cp_options->getOptions($node[
'child']);
286 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
291 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
297 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
303 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
318 public function ilClone($sid, $copy_identifier)
323 if (!$this->__checkSession($sid)) {
329 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
333 if (!$cp_options->checkOwner($ilUser->getId())) {
334 ilLoggerFactory::getLogger(
'obj')->error(
'Permission check failed for user id: ' . $ilUser->getId() .
', copy id: ' . $copy_identifier);
340 if (($node = $cp_options->fetchFirstNode()) ===
false) {
346 $options = $cp_options->getOptions($node[
'child']);
351 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
353 $cp_options->appendMapping($node[
'child'], 0);
359 ilLoggerFactory::getLogger(
'obj')->debug(
'Start cloning node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
360 $new_ref_id = $this->
cloneNode($node, $cp_options);
365 ilLoggerFactory::getLogger(
'obj')->debug(
'Start linking node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
366 $new_ref_id = $this->
linkNode($node, $cp_options);
371 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
389 $cp_options->dropFirstNode();
391 if ($cp_options->isSOAPEnabled()) {
393 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
395 $soap_client->setResponseTimeout(1);
396 $soap_client->enableWSDL(
true);
397 $soap_client->init();
398 $soap_client->call(
'ilClone',
array($sid,$cp_options->getCopyId()));
402 include_once(
'./webservice/soap/include/inc.soap_functions.php');
412 $cp_options->dropFirstDependenciesNode();
414 if ($cp_options->isSOAPEnabled()) {
416 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
418 $soap_client->setResponseTimeout(1);
419 $soap_client->enableWSDL(
true);
420 $soap_client->init();
421 $soap_client->call(
'ilCloneDependencies',
array($sid,$cp_options->getCopyId()));
425 include_once(
'./webservice/soap/include/inc.soap_functions.php');
440 global
$ilLog,$tree,$ilAccess,$rbacreview;
444 $source_id = $node[
'child'];
445 $parent_id = $node[
'parent'];
446 $options = $cp_options->getOptions($node[
'child']);
447 $mappings = $cp_options->getMappings();
449 if (!$ilAccess->checkAccess(
'copy',
'', $node[
'child'])) {
450 ilLoggerFactory::getLogger(
'obj')->error(
'No copy permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
453 if (!isset($mappings[$parent_id])) {
454 ilLoggerFactory::getLogger(
'obj')->info(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
460 ilLoggerFactory::getLogger(
'obj')->notice(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. Object has been deleted.');
465 $new_obj =
$orig->cloneObject((
int)
$target_id, $cp_options->getCopyId());
467 if (!is_object($new_obj)) {
468 ilLoggerFactory::getLogger(
'obj')->error(
'Error copying ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
473 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
474 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(),
false);
479 $cp_options->appendMapping($source_id, $new_obj->getRefId());
480 return $new_obj->getRefId();
494 $source_id = $node[
'child'];
495 $mappings = $cp_options->getMappings();
497 if (!isset($mappings[$source_id])) {
498 ilLoggerFactory::getLogger(
'obj')->debug(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No mapping found.');
517 global
$ilLog,$ilAccess,$rbacreview;
519 $source_id = $node[
'child'];
520 $parent_id = $node[
'parent'];
521 $options = $cp_options->getOptions($node[
'child']);
522 $mappings = $cp_options->getMappings();
524 if (!$ilAccess->checkAccess(
'delete',
'', $node[
'child'])) {
525 ilLoggerFactory::getLogger(
'obj')->warning(
'No delete permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
528 if (!isset($mappings[$parent_id])) {
529 ilLoggerFactory::getLogger(
'obj')->warning(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
535 $new_ref_id =
$orig->createReference();
539 if (!($new_ref_id)) {
540 ilLoggerFactory::getLogger(
'obj')->error(
'Error linking ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
545 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
546 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
551 $cp_options->appendMapping($source_id, $new_ref_id);
568 foreach (
$error as $err) {
569 $msg []=
"(" . $err[
"line"] .
"," . $err[
"col"] .
"): " . $err[
"errormessage"];
574 $msg = join(
"\n", $msg);
585 if (!$this->__checkSession($sid)) {
589 include_once(
'./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
593 $ilLog->write(__METHOD__ .
': Starting task execution...');
595 $scheduler->startTaskExecution();
621 $ilLog->write(__METHOD__ .
': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
623 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
633 if ((
int) $usr_id > 0) {
634 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 635 .
'WHERE active = 0 ' 636 .
'AND reg_hash IS NOT NULL ' 637 .
'AND usr_id = ' . $ilDB->quote($usr_id,
'integer') .
' ';
641 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 642 .
'WHERE active = 0 ' 643 .
'AND reg_hash IS NOT NULL ' 644 .
'AND usr_id != ' . $ilDB->quote($usr_id,
'integer') .
' ';
648 $ilLog->write(__METHOD__ .
': ' . $ilDB->numRows(
$res) .
' inactive user objects with confirmation hash values (dual opt in) found ...');
656 $num_deleted_users = 0;
657 while (
$row = $ilDB->fetchAssoc(
$res)) {
658 if (
$row[
'usr_id'] == ANONYMOUS_USER_ID ||
$row[
'usr_id'] == SYSTEM_USER_ID) {
661 if (!strlen(
$row[
'reg_hash'])) {
665 if ((
int) $oRegSettigs->getRegistrationHashLifetime() > 0 &&
666 $row[
'create_date'] !=
'' &&
667 time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row[
'create_date'])) {
670 $ilLog->write(__METHOD__ .
': User ' . $user->getLogin() .
' (obj_id: ' . $user->getId() .
') will be deleted due to an expired registration hash ...');
672 ++$num_deleted_users;
677 $ilLog->write(__METHOD__ .
': ' . $num_deleted_users .
' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
679 $ilLog->write(__METHOD__ .
': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
callNextNode($sid, $cp_options)
Call next node using soap.
This class handles all operations on files (attachments) in directory ilias_data/mail.
static ilClone($sid, $copy_identifier)
domxml_open_mem($str, $mode=0, &$error=null)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
saveTempFileAsMediaObject($sid, $name, $tmp_name)
setSaveInSentbox($a_save_in_sentbox)
SaxParserException thrown by ilSaxParser if property throwException is set.
distributeMails($sid, $a_mail_xml)
mail via soap
getMobsOfObject($sid, $a_type, $a_id)
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
static _sanitizeFilemame($a_filename)
catch(Exception $e) $message
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
XML parser for soap mails.
static validateXML($xml)
validates an xml file, if dtd is attached
This class handles base functions for mail handling.
__raiseError($a_message, $a_code)
deleteExpiredDualOptInUserObjects($sid, $usr_id)
Method for soap webservice: deleteExpiredDualOptInUserObjects.
callNextDependency($sid, $cp_options)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _getInstanceByServerId($a_server_id)
get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTas...
ilCloneDependencies($sid, $copy_identifier)
clone object dependencies (e.g.
static ilCloneDependencies($sid, $copy_identifier)
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
handleECSTasks($sid, $a_server_id)
static getLogger($a_component_id)
Get component logger.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
cloneDependencies($node, $cp_options)
cloneDependencies
linkNode($node, $cp_options)
Link node.
ilClone($sid, $copy_identifier)
Clone object.
cloneNode($node, $cp_options)
Clone node.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options