ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSoapUtils.php
Go to the documentation of this file.
1 <?php
2  /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22  */
23 
24 
33 include_once './webservice/soap/classes/class.ilSoapAdministration.php';
34 
36 {
37  public function ignoreUserAbort()
38  {
39  return ignore_user_abort(true);
40  }
41 
42  public function disableSOAPCheck()
43  {
44  $this->soap_check = false;
45  }
46 
47  public function sendMail($sid, $to, $cc, $bcc, $senderId, $subject, $message, $attach)
48  {
49  global $DIC;
50 
51  $this->initAuth($sid);
52  $this->initIlias();
53 
54  if (!$this->__checkSession($sid)) {
55  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
56  }
57 
59  $senderFactory = $GLOBALS['DIC']["mail.mime.sender.factory"];
60 
61  if (is_numeric($senderId)) {
62  $sender = $senderFactory->getSenderByUsrId($senderId);
63  } else {
64  $sender = $senderFactory->userByEmailAddress($senderId);
65  }
66 
67  $mmail = new ilMimeMail();
68  $mmail->From($sender);
69  $mmail->To(explode(',', $to));
70  $mmail->Subject($subject);
71  $mmail->Body($message);
72 
73  if ($cc) {
74  $mmail->Cc(explode(',', $cc));
75  }
76 
77  if ($bcc) {
78  $mmail->Bcc(explode(',', $bcc));
79  }
80 
81  if ($attach) {
82  $authUserFileData = new \ilFileDataMail($DIC->user()->getId());
83  $anonymousFileData = new \ilFileDataMail(ANONYMOUS_USER_ID);
84 
85  // mjansen: switched separator from "," to "#:#" because of mantis bug #6039
86  // for backward compatibility we have to check if the substring "#:#" exists as leading separator
87  // otherwise we should use ";"
88  if (strpos($attach, '#:#') === 0) {
89  $attach = substr($attach, strlen('#:#'));
90  $attachments = explode('#:#', $attach);
91  } else {
92  $attachments = explode(',', $attach);
93  }
94 
95  foreach ($attachments as $attachment) {
96  $final_filename = null;
97  $filename = basename($attachment);
98  if (strlen($filename) > 0) {
99  // #17740
100  $final_filename = preg_replace('/^(\d+?_)(.*)/', '$2', $filename);
101  }
102 
103  $allowedPathPrefixes = [
104  $authUserFileData->getAbsoluteAttachmentPoolPathPrefix()
105  ];
106 
107  if (is_numeric($senderId) && $senderId == ANONYMOUS_USER_ID) {
108  $allowedPathPrefixes[] = $anonymousFileData->getAbsoluteAttachmentPoolPathPrefix();
109  }
110 
111  $allowedPathPrefixes = array_map(
112  static function ($path) {
113  $basename = basename($path);
114  $dirname = dirname($path);
115 
116  return realpath($dirname) . DIRECTORY_SEPARATOR . $basename;
117  },
118  $allowedPathPrefixes
119  );
120 
121  $absoluteAttachmentPath = realpath($attachment);
122 
123  $matchedPathPrefixes = array_filter(
124  $allowedPathPrefixes,
125  static function ($path) use ($absoluteAttachmentPath) {
126  return strpos($absoluteAttachmentPath, $path) === 0;
127  }
128  );
129 
130  if (count($matchedPathPrefixes) > 0) {
131  $mmail->Attach($attachment, '', 'inline', $final_filename);
132  $DIC->logger()->mail()->debug(sprintf("Accepted attachment: %s", $attachment));
133  } else {
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)
138  ));
139  }
140  }
141  }
142 
143  $mmail->Send();
144 
145  return true;
146  }
147 
154  public function distributeMails($sid, $a_mail_xml)
155  {
156  $this->initAuth($sid);
157  $this->initIlias();
158 
159  if (!$this->__checkSession($sid)) {
160  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
161  }
162 
163  include_once 'Services/Mail/classes/class.ilMail.php';
164  include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
165 
166  $parser = new ilSoapMailXmlParser($a_mail_xml);
167  try {
168  // Check if wellformed
169  libxml_use_internal_errors(true);
170  $ok = simplexml_load_string($a_mail_xml);
171  if (!$ok) {
172  foreach (libxml_get_errors() as $err) {
173  $error .= ($err->message . ' ');
174  }
175  return $this->__raiseError($error, 'CLIENT');
176  }
177  $parser->start();
178  } catch (InvalidArgumentException $e) {
179  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
180  return $this->__raiseError($e->getMessage(), 'CLIENT');
181  } catch (ilSaxParserException $e) {
182  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
183  return $this->__raiseError($e->getMessage(), 'CLIENT');
184  }
185 
186  $mails = $parser->getMails();
187 
188  global $DIC;
189 
190  $ilUser = $DIC['ilUser'];
191 
192  foreach ($mails as $mail) {
193  // Prepare attachments
194  include_once './Services/Mail/classes/class.ilFileDataMail.php';
195  $file = new ilFileDataMail($ilUser->getId());
196  foreach ((array) $mail['attachments'] as $attachment) {
197  // TODO: Error handling
198  $file->storeAsAttachment($attachment['name'], $attachment['content']);
199  $attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
200  }
201 
202  $mail_obj = new ilMail($ilUser->getId());
203  $mail_obj->setSaveInSentbox(true);
204  $mail_obj->saveAttachments((array) $attachments);
205  $mail_obj->sendMail(
206  implode(',', (array) $mail['to']),
207  implode(',', (array) $mail['cc']),
208  implode(',', (array) $mail['bcc']),
209  $mail['subject'],
210  implode("\n", (array) $mail['body']),
211  (array) $attachments,
212  array($mail['type']),
213  (bool) $mail['usePlaceholders']
214  );
215 
216  // Finally unlink attachments
217  foreach ((array) $attachments as $att) {
218  $file->unlinkFile($att);
219  }
220  $mail_obj->savePostData(
221  $ilUser->getId(),
222  array(),
223  '',
224  '',
225  '',
226  '',
227  '',
228  '',
229  '',
230  ''
231  );
232  }
233  return true;
234  }
235 
236  public function saveTempFileAsMediaObject($sid, $name, $tmp_name)
237  {
238  $this->initAuth($sid);
239  $this->initIlias();
240 
241  if (!$this->__checkSession($sid)) {
242  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
243  }
244 
245  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
247  }
248 
249  public function getMobsOfObject($sid, $a_type, $a_id)
250  {
251  $this->initAuth($sid);
252  $this->initIlias();
253 
254  if (!$this->__checkSession($sid)) {
255  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
256  }
257 
258  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
260  }
261 
269  public function ilCloneDependencies($sid, $copy_identifier)
270  {
271  $this->initAuth($sid);
272  $this->initIlias();
273 
274  if (!$this->__checkSession($sid)) {
275  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
276  }
277 
278  global $DIC;
279 
280  $ilLog = $DIC['ilLog'];
281  $ilUser = $DIC['ilUser'];
282 
283  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
284  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
285 
286  // Check owner of copy procedure
287  if (!$cp_options->checkOwner($ilUser->getId())) {
288  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
289  return false;
290  }
291 
292  // Fetch first node
293  if (($node = $cp_options->fetchFirstDependenciesNode()) === false) {
294  $cp_options->deleteAll();
295  ilLoggerFactory::getLogger('obj')->info('Finished copy step 2. Copy completed');
296  return true;
297  }
298 
299  // Check options of this node
300  $options = $cp_options->getOptions($node['child']);
301  $new_ref_id = 0;
302  switch ($options['type']) {
304  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
305  $this->callNextDependency($sid, $cp_options);
306  break;
307 
309  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
310  $this->cloneDependencies($node, $cp_options);
311  $this->callNextDependency($sid, $cp_options);
312  break;
313 
315  ilLoggerFactory::getLogger('obj')->debug(': Start cloning dependencies: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
316  $this->cloneDependencies($node, $cp_options);
317  $this->callNextDependency($sid, $cp_options);
318  break;
319 
320  default:
321  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
322  $this->callNextDependency($sid, $cp_options);
323  break;
324  }
325  return true;
326  }
327 
336  public function ilClone($sid, $copy_identifier)
337  {
338  $this->initAuth($sid);
339  $this->initIlias();
340 
341  if (!$this->__checkSession($sid)) {
342  ilLoggerFactory::getLogger('obj')->error('Object cloning failed. Invalid session given: ' . $this->__getMessage());
343  }
344 
345  global $DIC;
346 
347  $ilUser = $DIC->user();
348 
349  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
350  $cp_options = ilCopyWizardOptions::_getInstance($copy_identifier);
351 
352  // Check owner of copy procedure
353  if (!$cp_options->checkOwner($ilUser->getId())) {
354  ilLoggerFactory::getLogger('obj')->error('Permission check failed for user id: ' . $ilUser->getId() . ', copy id: ' . $copy_identifier);
355  return false;
356  }
357 
358 
359  // Fetch first node
360  if (($node = $cp_options->fetchFirstNode()) === false) {
361  ilLoggerFactory::getLogger('obj')->info('Finished copy step 1. Starting copying of object dependencies...');
362  return $this->ilCloneDependencies($sid, $copy_identifier);
363  }
364 
365  // Check options of this node
366  $options = $cp_options->getOptions($node['child']);
367 
368  $action = $this->rewriteActionForNode($cp_options, $node, $options);
369 
370  $new_ref_id = 0;
371  switch ($action) {
373  ilLoggerFactory::getLogger('obj')->debug(': Omitting node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
374  // set mapping to zero
375  $cp_options->appendMapping($node['child'], 0);
376  $this->callNextNode($sid, $cp_options);
377  break;
378 
380 
381  ilLoggerFactory::getLogger('obj')->debug('Start cloning node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
382  $new_ref_id = $this->cloneNode($node, $cp_options);
383  $this->callNextNode($sid, $cp_options);
384  break;
385 
387  ilLoggerFactory::getLogger('obj')->debug('Start linking node: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
388  $new_ref_id = $this->linkNode($node, $cp_options);
389  $this->callNextNode($sid, $cp_options);
390  break;
391 
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']);
394  $new_ref_id = $this->internalLinkNode($node, $cp_options);
395  $this->callNextNode($sid, $cp_options);
396  break;
397 
398  default:
399  ilLoggerFactory::getLogger('obj')->warning('No valid action type given for: ' . $node['obj_id'] . ', ' . $node['title'] . ', ' . $node['type']);
400  $this->callNextNode($sid, $cp_options);
401  break;
402 
403  }
404  return $new_ref_id;
405  }
406 
411  protected function rewriteActionForNode(ilCopyWizardOptions $cpo, array $node, array $options)
412  {
414  if (array_key_exists('type', $options)) {
415  $default_mode = $options['type'];
416  }
417  if (
418  array_key_exists('child', $node) &&
419  $cpo->isRootNode($node)
420  ) {
421  return $default_mode;
422  }
423 
424  if ($this->findMappedReferenceForNode($cpo, $node)) {
425 
426  if ($default_mode == \ilCopyWizardOptions::COPY_WIZARD_COPY) {
427  return \ilCopyWizardOptions::COPY_WIZARD_LINK_TO_TARGET;
428  }
429  }
430  return $default_mode;
431  }
432 
438  protected function findMappedReferenceForNode(\ilCopyWizardOptions $cpo, array $node)
439  {
440  global $DIC;
441 
442  $logger = $DIC->logger()->obj();
443  $tree = $DIC->repositoryTree();
444  $root = $cpo->getRootNode();
445  $obj_id = $node['obj_id'];
446 
447  $mappings = $cpo->getMappings();
448  foreach (\ilObject::_getAllReferences($obj_id) as $ref_id => $also_ref_id) {
449 
450  $logger->debug('Validating node: ' . $ref_id . ' and root ' . $root );
451  $logger->dump($DIC->repositoryTree()->getRelation($ref_id , $root));
452 
453  if($DIC->repositoryTree()->getRelation($ref_id , $root) != \ilTree::RELATION_CHILD) {
454  $logger->debug('Ignoring non child relation');
455  continue;
456  }
457  // check if mapping is already available
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];
462  }
463  }
464  $logger->info('Nothing found');
465  return null;
466  }
467 
468 
469 
476  private function callNextNode($sid, $cp_options)
477  {
478  global $DIC;
479 
480  $ilLog = $DIC['ilLog'];
481 
482  $cp_options->dropFirstNode();
483 
484  if ($cp_options->isSOAPEnabled()) {
485  // Start next soap call
486  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
487  $soap_client = new ilSoapClient();
488  $soap_client->setResponseTimeout(1);
489  $soap_client->enableWSDL(true);
490  $soap_client->init();
491  $soap_client->call('ilClone', array($sid,$cp_options->getCopyId()));
492  } else {
493  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
494  $cp_options->read();
495  include_once('./webservice/soap/include/inc.soap_functions.php');
496  $res = ilSoapFunctions::ilClone($sid, $cp_options->getCopyId());
497  }
498  return true;
499  }
500 
501  private function callNextDependency($sid, $cp_options)
502  {
503  global $DIC;
504 
505  $ilLog = $DIC['ilLog'];
506 
507  $cp_options->dropFirstDependenciesNode();
508 
509  if ($cp_options->isSOAPEnabled()) {
510  // Start next soap call
511  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
512  $soap_client = new ilSoapClient();
513  $soap_client->setResponseTimeout(1);
514  $soap_client->enableWSDL(true);
515  $soap_client->init();
516  $soap_client->call('ilCloneDependencies', array($sid,$cp_options->getCopyId()));
517  } else {
518  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
519  $cp_options->read();
520  include_once('./webservice/soap/include/inc.soap_functions.php');
521  $res = ilSoapFunctions::ilCloneDependencies($sid, $cp_options->getCopyId());
522  }
523  return true;
524  }
525 
533  private function cloneNode($node, $cp_options)
534  {
535  global $DIC;
536 
537  $ilLog = $DIC['ilLog'];
538  $tree = $DIC['tree'];
539  $ilAccess = $DIC['ilAccess'];
540  $rbacreview = $DIC['rbacreview'];
541 
542  #sleep(20);
543 
544  $source_id = $node['child'];
545  $parent_id = $node['parent'];
546  $options = $cp_options->getOptions($node['child']);
547  $mappings = $cp_options->getMappings();
548 
549  if (!$ilAccess->checkAccess('copy', '', $node['child'])) {
550  ilLoggerFactory::getLogger('obj')->error('No copy permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
551  return false;
552  }
553  if (!isset($mappings[$parent_id])) {
554  ilLoggerFactory::getLogger('obj')->info('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
555  return true;
556  }
557  $target_id = $mappings[$parent_id];
558 
559  if (!$tree->isInTree($target_id)) {
560  ilLoggerFactory::getLogger('obj')->notice('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. Object has been deleted.');
561  return false;
562  }
563 
564  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
565  $new_obj = $orig->cloneObject((int) $target_id, $cp_options->getCopyId());
566 
567  if (!is_object($new_obj)) {
568  ilLoggerFactory::getLogger('obj')->error('Error copying ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
569  return false;
570  }
571 
572  // rbac log
573  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
574  $rbac_log_roles = $rbacreview->getParentRoleIds($new_obj->getRefId(), false);
575  $rbac_log = ilRbacLog::gatherFaPa($new_obj->getRefId(), array_keys($rbac_log_roles), true);
576  ilRbacLog::add(ilRbacLog::COPY_OBJECT, $new_obj->getRefId(), $rbac_log, (int) $source_id);
577 
578  // Finally add new mapping entry
579  $cp_options->appendMapping($source_id, $new_obj->getRefId());
580  return $new_obj->getRefId();
581  }
582 
590  private function cloneDependencies($node, $cp_options)
591  {
592  global $DIC;
593 
594  $ilLog = $DIC['ilLog'];
595 
596  $source_id = $node['child'];
597  $mappings = $cp_options->getMappings();
598 
599  if (!isset($mappings[$source_id])) {
600  ilLoggerFactory::getLogger('obj')->debug('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No mapping found.');
601  return true;
602  }
603  $target_id = $mappings[$source_id];
604 
605  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
606  $orig->cloneDependencies($target_id, $cp_options->getCopyId());
607  return true;
608  }
609 
618  private function internalLinkNode($node, $cp_options)
619  {
620  global $DIC;
621 
622  $ilAccess = $DIC->access();
623  $logger = $DIC->logger()->obj();
624  $rbacreview = $DIC->rbac()->review();
625  $tree = $DIC->repositoryTree();
626  $mappings = $cp_options->getMappings();
627 
628  $source_id = $this->findMappedReferenceForNode($cp_options, $node);
629  try {
630  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
631  if(!$orig instanceof \ilObject) {
632  $logger->error('Cannot create object instance.');
633  return false;
634  }
635  }
636  catch (\ilObjectNotFoundException $e) {
637  $logger->error('Cannot create object instance for ref_id: ' . $source_id);
638  $logger->error($e->getMessage());
639  return false;
640  }
641 
642  // target (parent id) is the mapped parent id of the current node
643  $node_parent = $node['parent'];
644  if (!array_key_exists($node_parent, $mappings)) {
645  $logger->error('Cannot new parent id for node: ' . $node['parent']);
646  return false;
647  }
648  $parent_id = $mappings[$node_parent];
649 
650  $new_ref_id = $orig->createReference();
651  $orig->putInTree($parent_id);
652  $orig->setPermissions($parent_id);
653 
654  if (!($new_ref_id)) {
655  $logger->warning('Creating internal link failed.');
656  return false;
657  }
658 
659  // rbac log
660  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
661  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
662  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
663 
664  // Finally add new mapping entry
665  $cp_options->appendMapping($node['child'], $new_ref_id);
666 
667  $logger->notice('Added mapping for ' . $node['child'] . ' ' . $new_ref_id);
668 
669 
670  return $new_ref_id;
671  }
672 
680  private function linkNode($node, $cp_options)
681  {
682  global $DIC;
683 
684  $ilLog = $DIC['ilLog'];
685  $ilAccess = $DIC['ilAccess'];
686  $rbacreview = $DIC['rbacreview'];
687 
688  $source_id = $node['child'];
689  $parent_id = $node['parent'];
690  $options = $cp_options->getOptions($node['child']);
691  $mappings = $cp_options->getMappings();
692 
693  if (!$ilAccess->checkAccess('delete', '', $node['child'])) {
694  ilLoggerFactory::getLogger('obj')->warning('No delete permission granted: ' . $source_id . ', ' . $node['title'] . ', ' . $node['type']);
695  return false;
696  }
697  if (!isset($mappings[$parent_id])) {
698  ilLoggerFactory::getLogger('obj')->warning('Omitting node ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
699  return true;
700  }
701  $target_id = $mappings[$parent_id];
702 
703  $orig = ilObjectFactory::getInstanceByRefId((int) $source_id);
704  $new_ref_id = $orig->createReference();
705  $orig->putInTree($target_id);
706  $orig->setPermissions($target_id);
707 
708  if (!($new_ref_id)) {
709  ilLoggerFactory::getLogger('obj')->error('Error linking ' . $source_id . ', ' . $node['title'] . ', ' . $node['type'] . '. No target found.');
710  return false;
711  }
712 
713  // rbac log
714  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
715  $rbac_log_roles = $rbacreview->getParentRoleIds($new_ref_id, false);
716  $rbac_log = ilRbacLog::gatherFaPa($new_ref_id, array_keys($rbac_log_roles), true);
717  ilRbacLog::add(ilRbacLog::LINK_OBJECT, $new_ref_id, $rbac_log, (int) $source_id);
718 
719  // Finally add new mapping entry
720  $cp_options->appendMapping($source_id, $new_ref_id);
721  return $new_ref_id;
722  }
723 
730  public static function validateXML($xml)
731  {
732  // validate to prevent wrong XMLs
733  $dom = @domxml_open_mem($xml, DOMXML_LOAD_VALIDATING, $error);
734  if ($error) {
735  $msg = array();
736  if (is_array($error)) {
737  foreach ($error as $err) {
738  $msg []= "(" . $err["line"] . "," . $err["col"] . "): " . $err["errormessage"];
739  }
740  } else {
741  $msg[] = $error;
742  }
743  $msg = join("\n", $msg);
744  return $msg;
745  }
746  return true;
747  }
748 
749  public function handleECSTasks($sid, $a_server_id)
750  {
751  $this->initAuth($sid);
752  $this->initIlias();
753 
754  if (!$this->__checkSession($sid)) {
755  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
756  }
757 
758  include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
759 
760  global $DIC;
761 
762  $ilLog = $DIC['ilLog'];
763 
764  $ilLog->write(__METHOD__ . ': Starting task execution...');
765  $scheduler = ilECSTaskScheduler::_getInstanceByServerId($a_server_id);
766  $scheduler->startTaskExecution();
767 
768  return true;
769  }
770 
783  public function deleteExpiredDualOptInUserObjects($sid, $usr_id)
784  {
785  $this->initAuth($sid);
786  $this->initIlias();
787 
788  // Session check not possible -> anonymous user is the trigger
789 
790  global $DIC;
791 
792  $ilDB = $DIC['ilDB'];
793  $ilLog = $DIC['ilLog'];
794 
795  $ilLog->write(__METHOD__ . ': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
796 
797  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
798  $oRegSettigs = new ilRegistrationSettings();
799 
800  $query = '';
801 
802  /*
803  * Fetch the current actuator user object first, because this user will try to perform very probably
804  * a new registration with the same login name in a few seconds ;-)
805  *
806  */
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') . ' ';
812  $query .= 'UNION ';
813  }
814 
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') . ' ';
819 
820  $res = $ilDB->query($query);
821 
822  $ilLog->write(__METHOD__ . ': ' . $ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...');
823 
824  /*
825  * mjansen: 15.12.2010:
826  * I perform the expiration check in php because of multi database support (mysql, postgresql).
827  * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()
828  */
829 
830  $num_deleted_users = 0;
831  while ($row = $ilDB->fetchAssoc($res)) {
832  if ($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) {
833  continue;
834  }
835  if (!strlen($row['reg_hash'])) {
836  continue;
837  }
838 
839  if ((int) $oRegSettigs->getRegistrationHashLifetime() > 0 &&
840  $row['create_date'] != '' &&
841  time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
842  $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
843  if ($user instanceof ilObjUser) {
844  $ilLog->write(__METHOD__ . ': User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...');
845  $user->delete();
846  ++$num_deleted_users;
847  }
848  }
849  }
850 
851  $ilLog->write(__METHOD__ . ': ' . $num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
852 
853  $ilLog->write(__METHOD__ . ': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
854 
855  return true;
856  }
857 }
internalLinkNode($node, $cp_options)
Link node private.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$path
Definition: aliased.php:25
callNextNode($sid, $cp_options)
Call next node using soap.
$action
global $DIC
Definition: saml.php:7
Class ilFileDataMail.
static ilClone($sid, $copy_identifier)
domxml_open_mem($str, $mode=0, &$error=null)
saveTempFileAsMediaObject($sid, $name, $tmp_name)
$target_id
Definition: goto.php:49
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)
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
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.
$a_type
Definition: workflow.php:92
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
Class ilMimeMail.
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)
const COPY_OBJECT
$ilUser
Definition: imgupload.php:18
deleteExpiredDualOptInUserObjects($sid, $usr_id)
Method for soap webservice: deleteExpiredDualOptInUserObjects.
const LINK_OBJECT
$query
callNextDependency($sid, $cp_options)
$root
Definition: sabredav.php:45
$user
Definition: migrateto20.php:57
isRootNode($a_root)
Is root node.
const RELATION_CHILD
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$filename
Definition: buildRTE.php:89
static _getInstanceByServerId($a_server_id)
get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTas...
$row
ilCloneDependencies($sid, $copy_identifier)
clone object dependencies (e.g.
$parser
Definition: BPMN2Parser.php:23
static ilCloneDependencies($sid, $copy_identifier)
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
initAuth($sid)
Init authentication.
global $ilDB
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.