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 $allowedPathPrefixes = array_map(
112 static function (
$path) {
113 $basename = basename(
$path);
114 $dirname = dirname(
$path);
116 return realpath($dirname) . DIRECTORY_SEPARATOR . $basename;
121 $absoluteAttachmentPath = realpath($attachment);
123 $matchedPathPrefixes = array_filter(
124 $allowedPathPrefixes,
125 static function (
$path) use ($absoluteAttachmentPath) {
126 return strpos($absoluteAttachmentPath,
$path) === 0;
130 if (count($matchedPathPrefixes) > 0) {
131 $mmail->Attach($attachment,
'',
'inline', $final_filename);
132 $DIC->logger()->mail()->debug(sprintf(
"Accepted attachment: %s", $attachment));
134 $DIC->logger()->mail()->warning(sprintf(
135 "Ignored attachment when sending message via SOAP: Given path '%s' is not in allowed prefix list: %s",
136 $absoluteAttachmentPath,
137 implode(
', ', $allowedPathPrefixes)
159 if (!$this->__checkSession($sid)) {
163 include_once
'Services/Mail/classes/class.ilMail.php';
164 include_once
'webservice/soap/classes/class.ilSoapMailXmlParser.php';
169 libxml_use_internal_errors(
true);
170 $ok = simplexml_load_string($a_mail_xml);
172 foreach (libxml_get_errors() as $err) {
173 $error .= ($err->message .
' ');
179 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
' ' . $e->getMessage());
182 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
' ' . $e->getMessage());
192 foreach ($mails as $mail) {
194 include_once
'./Services/Mail/classes/class.ilFileDataMail.php';
196 foreach ((array) $mail[
'attachments'] as $attachment) {
204 $mail_obj->saveAttachments((array) $attachments);
206 implode(
',', (array) $mail[
'to']),
207 implode(
',', (array) $mail[
'cc']),
208 implode(
',', (array) $mail[
'bcc']),
210 implode(
"\n", (array) $mail[
'body']),
211 (array) $attachments,
212 array($mail[
'type']),
213 (
bool) $mail[
'usePlaceholders']
217 foreach ((array) $attachments as $att) {
218 $file->unlinkFile($att);
220 $mail_obj->savePostData(
241 if (!$this->__checkSession($sid)) {
245 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
254 if (!$this->__checkSession($sid)) {
258 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
274 if (!$this->__checkSession($sid)) {
283 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
287 if (!$cp_options->checkOwner(
$ilUser->getId())) {
293 if (($node = $cp_options->fetchFirstDependenciesNode()) ===
false) {
294 $cp_options->deleteAll();
300 $options = $cp_options->getOptions($node[
'child']);
304 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
309 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
315 ilLoggerFactory::getLogger(
'obj')->debug(
': Start cloning dependencies: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
321 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
336 public function ilClone($sid, $copy_identifier)
341 if (!$this->__checkSession($sid)) {
349 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
353 if (!$cp_options->checkOwner(
$ilUser->getId())) {
360 if (($node = $cp_options->fetchFirstNode()) ===
false) {
366 $options = $cp_options->getOptions($node[
'child']);
373 ilLoggerFactory::getLogger(
'obj')->debug(
': Omitting node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
375 $cp_options->appendMapping($node[
'child'], 0);
381 ilLoggerFactory::getLogger(
'obj')->debug(
'Start cloning node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
382 $new_ref_id = $this->
cloneNode($node, $cp_options);
387 ilLoggerFactory::getLogger(
'obj')->debug(
'Start linking node: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
388 $new_ref_id = $this->
linkNode($node, $cp_options);
392 case \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET:
393 ilLoggerFactory::getLogger(
'obj')->debug(
'Start creating internal link for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
399 ilLoggerFactory::getLogger(
'obj')->warning(
'No valid action type given for: ' . $node[
'obj_id'] .
', ' . $node[
'title'] .
', ' . $node[
'type']);
414 if (array_key_exists(
'type', $options)) {
415 $default_mode = $options[
'type'];
418 array_key_exists(
'child', $node) &&
421 return $default_mode;
427 return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
430 return $default_mode;
442 $logger = $DIC->logger()->obj();
443 $tree = $DIC->repositoryTree();
445 $obj_id = $node[
'obj_id'];
450 $logger->debug(
'Validating node: ' . $ref_id .
' and root ' .
$root );
451 $logger->dump($DIC->repositoryTree()->getRelation($ref_id , $root));
454 $logger->debug(
'Ignoring non child relation');
458 $logger->dump($mappings);
459 if (array_key_exists($ref_id, $mappings)) {
460 $logger->debug(
'Found existing mapping for linked node.');
461 return $mappings[$ref_id];
464 $logger->info(
'Nothing found');
482 $cp_options->dropFirstNode();
484 if ($cp_options->isSOAPEnabled()) {
486 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
488 $soap_client->setResponseTimeout(1);
489 $soap_client->enableWSDL(
true);
490 $soap_client->init();
491 $soap_client->call(
'ilClone', array($sid,$cp_options->getCopyId()));
495 include_once(
'./webservice/soap/include/inc.soap_functions.php');
507 $cp_options->dropFirstDependenciesNode();
509 if ($cp_options->isSOAPEnabled()) {
511 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
513 $soap_client->setResponseTimeout(1);
514 $soap_client->enableWSDL(
true);
515 $soap_client->init();
516 $soap_client->call(
'ilCloneDependencies', array($sid,$cp_options->getCopyId()));
520 include_once(
'./webservice/soap/include/inc.soap_functions.php');
538 $tree = $DIC[
'tree'];
539 $ilAccess = $DIC[
'ilAccess'];
540 $rbacreview = $DIC[
'rbacreview'];
544 $source_id = $node[
'child'];
545 $parent_id = $node[
'parent'];
546 $options = $cp_options->getOptions($node[
'child']);
547 $mappings = $cp_options->getMappings();
549 if (!$ilAccess->checkAccess(
'copy',
'', $node[
'child'])) {
550 ilLoggerFactory::getLogger(
'obj')->error(
'No copy permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
553 if (!isset($mappings[$parent_id])) {
554 ilLoggerFactory::getLogger(
'obj')->info(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
560 ilLoggerFactory::getLogger(
'obj')->notice(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. Object has been deleted.');
565 $new_obj = $orig->cloneObject((
int)
$target_id, $cp_options->getCopyId());
567 if (!is_object($new_obj)) {
568 ilLoggerFactory::getLogger(
'obj')->error(
'Error copying ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
573 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
574 $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(),
false);
579 $cp_options->appendMapping($source_id, $new_obj->getRefId());
580 return $new_obj->getRefId();
596 $source_id = $node[
'child'];
597 $mappings = $cp_options->getMappings();
599 if (!isset($mappings[$source_id])) {
600 ilLoggerFactory::getLogger(
'obj')->debug(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No mapping found.');
606 $orig->cloneDependencies(
$target_id, $cp_options->getCopyId());
622 $ilAccess = $DIC->access();
623 $logger = $DIC->logger()->obj();
624 $rbacreview = $DIC->rbac()->review();
625 $tree = $DIC->repositoryTree();
626 $mappings = $cp_options->getMappings();
632 $logger->error(
'Cannot create object instance.');
637 $logger->error(
'Cannot create object instance for ref_id: ' . $source_id);
638 $logger->error($e->getMessage());
643 $node_parent = $node[
'parent'];
644 if (!array_key_exists($node_parent, $mappings)) {
645 $logger->error(
'Cannot new parent id for node: ' . $node[
'parent']);
648 $parent_id = $mappings[$node_parent];
650 $new_ref_id = $orig->createReference();
651 $orig->putInTree($parent_id);
652 $orig->setPermissions($parent_id);
654 if (!($new_ref_id)) {
655 $logger->warning(
'Creating internal link failed.');
660 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
665 $cp_options->appendMapping($node[
'child'], $new_ref_id);
667 $logger->notice(
'Added mapping for ' . $node[
'child'] .
' ' . $new_ref_id);
685 $ilAccess = $DIC[
'ilAccess'];
686 $rbacreview = $DIC[
'rbacreview'];
688 $source_id = $node[
'child'];
689 $parent_id = $node[
'parent'];
690 $options = $cp_options->getOptions($node[
'child']);
691 $mappings = $cp_options->getMappings();
693 if (!$ilAccess->checkAccess(
'delete',
'', $node[
'child'])) {
694 ilLoggerFactory::getLogger(
'obj')->warning(
'No delete permission granted: ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type']);
697 if (!isset($mappings[$parent_id])) {
698 ilLoggerFactory::getLogger(
'obj')->warning(
'Omitting node ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
704 $new_ref_id = $orig->createReference();
708 if (!($new_ref_id)) {
709 ilLoggerFactory::getLogger(
'obj')->error(
'Error linking ' . $source_id .
', ' . $node[
'title'] .
', ' . $node[
'type'] .
'. No target found.');
714 include_once
"Services/AccessControl/classes/class.ilRbacLog.php";
715 $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id,
false);
720 $cp_options->appendMapping($source_id, $new_ref_id);
736 if (is_array($error)) {
737 foreach ($error as $err) {
738 $msg []=
"(" . $err[
"line"] .
"," . $err[
"col"] .
"): " . $err[
"errormessage"];
743 $msg = join(
"\n", $msg);
754 if (!$this->__checkSession($sid)) {
758 include_once(
'./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
764 $ilLog->write(__METHOD__ .
': Starting task execution...');
766 $scheduler->startTaskExecution();
792 $ilDB = $DIC[
'ilDB'];
795 $ilLog->write(__METHOD__ .
': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
797 require_once
'Services/Registration/classes/class.ilRegistrationSettings.php';
807 if ((
int) $usr_id > 0) {
808 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 809 .
'WHERE active = 0 ' 810 .
'AND reg_hash IS NOT NULL ' 811 .
'AND usr_id = ' .
$ilDB->quote($usr_id,
'integer') .
' ';
815 $query .=
'SELECT usr_id, create_date, reg_hash FROM usr_data ' 816 .
'WHERE active = 0 ' 817 .
'AND reg_hash IS NOT NULL ' 818 .
'AND usr_id != ' .
$ilDB->quote($usr_id,
'integer') .
' ';
822 $ilLog->write(__METHOD__ .
': ' .
$ilDB->numRows(
$res) .
' inactive user objects with confirmation hash values (dual opt in) found ...');
830 $num_deleted_users = 0;
832 if (
$row[
'usr_id'] == ANONYMOUS_USER_ID ||
$row[
'usr_id'] == SYSTEM_USER_ID) {
835 if (!strlen(
$row[
'reg_hash'])) {
839 if ((
int) $oRegSettigs->getRegistrationHashLifetime() > 0 &&
840 $row[
'create_date'] !=
'' &&
841 time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime(
$row[
'create_date'])) {
844 $ilLog->write(__METHOD__ .
': User ' .
$user->getLogin() .
' (obj_id: ' .
$user->getId() .
') will be deleted due to an expired registration hash ...');
846 ++$num_deleted_users;
851 $ilLog->write(__METHOD__ .
': ' . $num_deleted_users .
' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
853 $ilLog->write(__METHOD__ .
': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
internalLinkNode($node, $cp_options)
Link node private.
callNextNode($sid, $cp_options)
Call next node using soap.
const COPY_WIZARD_UNDEFINED
static ilClone($sid, $copy_identifier)
domxml_open_mem($str, $mode=0, &$error=null)
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)
rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
Object not found exception.
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
static _getAllReferences($a_id)
get all reference ids of object
storeAsAttachment($a_filename, $a_content)
Store content as attachment.
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.
findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
static validateXML($xml)
validates an xml file, if dtd is attached
__raiseError($a_message, $a_code)
deleteExpiredDualOptInUserObjects($sid, $usr_id)
Method for soap webservice: deleteExpiredDualOptInUserObjects.
callNextDependency($sid, $cp_options)
isRootNode($a_root)
Is root node.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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.
getMappings()
Get Mappings.
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.
cloneDependencies($node, $cp_options)
cloneDependencies
linkNode($node, $cp_options)
Link node.
ilClone($sid, $copy_identifier)
Clone object.
cloneNode($node, $cp_options)
Clone node.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.