ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
logout-iframe.php
Go to the documentation of this file.
1 <?php
2 
3 $id = $this->data['auth_state'];
4 $type = $this->data['type'];
5 $from = $this->data['from'];
6 $SPs = $this->data['SPs'];
7 
8 $stateImage = array(
9  'unsupported' => '/'.$this->data['baseurlpath'].'resources/icons/silk/delete.png',
10  'completed' => '/'.$this->data['baseurlpath'].'resources/icons/silk/accept.png',
11  'onhold' => '/'.$this->data['baseurlpath'].'resources/icons/bullet16_grey.png',
12  'inprogress' => '/'.$this->data['baseurlpath'].'resources/progress.gif',
13  'failed' => '/'.$this->data['baseurlpath'].'resources/icons/silk/exclamation.png',
14 );
15 
16 $stateText = array(
17  'unsupported' => '',
18  'completed' => $this->t('{logout:completed}'),
19  'onhold' => '',
20  'inprogress' => $this->t('{logout:progress}'),
21  'failed' => $this->t('{logout:failed}'),
22 );
23 
24 $spStatus = array();
25 $spTimeout = array();
28 foreach ($SPs as $assocId => $sp) {
29  assert(isset($sp['core:Logout-IFrame:State']));
30  $state = $sp['core:Logout-IFrame:State'];
31  $spStatus[sha1($assocId)] = $state;
32  if (isset($sp['core:Logout-IFrame:Timeout'])) {
33  $spTimeout[sha1($assocId)] = $sp['core:Logout-IFrame:Timeout'] - time();
34  } else {
35  $spTimeout[sha1($assocId)] = 5;
36  }
37  if ($state === 'failed') {
38  $nFailed += 1;
39  } elseif ($state === 'inprogress') {
40  $nProgress += 1;
41  }
42 }
43 
44 if ($from !== null) {
45  $from = $this->getTranslator()->getPreferredTranslation($from);
46 }
47 
48 if (!isset($this->data['head'])) {
49  $this->data['head'] = '';
50 }
51 
52 $this->data['head'] .= '
53 <script type="text/javascript" language="JavaScript">
54 window.stateImage = '.json_encode($stateImage).';
55 window.stateText = '.json_encode($stateText).';
56 window.spStatus = '.json_encode($spStatus).';
57 window.spTimeout = '.json_encode($spTimeout).';
58 window.type = "'.$type.'";
59 </script>';
60 
61 $this->data['head'] .= '<script type="text/javascript" src="logout-iframe.js"></script>';
62 
63 if ($type === 'embed') {
64  $this->data['head'] .= '<meta http-equiv="refresh" content="1" />';
65 }
66 
67 $this->data['header'] = $this->t('{logout:progress}');
68 if ($type === 'embed') {
69  $this->includeAtTemplateBase('includes/header-embed.php');
70 } else {
71  $this->includeAtTemplateBase('includes/header.php');
72 }
73 ?>
74  <div id="wrap">
75  <div id="content">
76 <?php
77 if ($from !== null) {
78  echo '<div><img style="float: left; margin-right: 12px" src="/'.$this->data['baseurlpath'].
79  'resources/icons/checkmark.48x48.png" alt="Successful logout" />';
80  echo '<p style="padding-top: 16px; ">'.
81  $this->t('{logout:loggedoutfrom}', array('%SP%' => '<strong>'.htmlspecialchars($from).'</strong>')).'</p>';
82  echo '<p style="height: 0px; clear: left;"></p></div>';
83 }
84 
85 echo '<div style="margin-top: 3em; clear: both">';
86 
87 echo '<p style="margin-bottom: .5em">';
88 if ($type === 'init') {
89  echo $this->t('{logout:also_from}');
90 } else {
91  echo $this->t('{logout:logging_out_from}');
92 }
93 echo('</p>');
94 ?>
95  <table id="slostatustable">
96 <?php
97 foreach ($SPs as $assocId => $sp) {
98  if (isset($sp['core:Logout-IFrame:Name'])) {
99  $spName = $this->getTranslator()->getPreferredTranslation($sp['core:Logout-IFrame:Name']);
100  } else {
101  $spName = $assocId;
102  }
103 
104  assert(isset($sp['core:Logout-IFrame:State']));
105  $spState = $sp['core:Logout-IFrame:State'];
106 
107  $spId = sha1($assocId);
108 
109  echo '<tr>';
110  echo '<td style="width: 3em;"></td>';
111  echo '<td>';
112  echo '<img class="logoutstatusimage" id="statusimage-'.$spId.'" src="'.htmlspecialchars($stateImage[$spState]).
113  '" alt="'.htmlspecialchars($stateText[$spState]).'"/>';
114  echo '</td>';
115  echo '<td>'.htmlspecialchars($spName).'</td>';
116  echo '</tr>';
117 }
118 
119 if (isset($from)) {
120  $logoutCancelText = $this->t('{logout:logout_only}', array('%SP%' => htmlspecialchars($from)));
121 } else {
122  $logoutCancelText = $this->t('{logout:no}');
123 }
124 
125 ?>
126  </table>
127  </div>
128 
129 <?php
130 if ($type === 'init') {
131 ?>
132  <div id="confirmation" style="margin-top: 1em">
133  <p><?php echo $this->t('{logout:logout_all_question}'); ?> <br/></p>
134  <form id="startform" method="get" style="display:inline;" action="logout-iframe.php">
135  <input type="hidden" name="id" value="<?php echo $id; ?>"/>
136  <input type="hidden" id="logout-type-selector" name="type" value="nojs"/>
137  <button type="submit" id="logout-all" name="ok" class="btn"><?php echo $this->t('{logout:logout_all}'); ?></button>
138  </form>
139  <form method="get" style="display:inline;" action="logout-iframe-done.php">
140  <input type="hidden" name="id" value="<?php echo $id; ?>"/>
141  <button type="submit" name="cancel" class="btn"><?php echo $logoutCancelText; ?></button>
142  </form>
143  </div>
144 <?php
145 } else {
146  if ($nFailed > 0) {
147  $displayStyle = '';
148  } else {
149  $displayStyle = 'display: none;';
150  }
151  echo '<div id="logout-failed-message" style="margin-top: 1em; border: 1px solid #ccc; padding: 1em; '.
152  'background: #eaeaea;'.$displayStyle.'">';
153  echo '<img src="/'.$this->data['baseurlpath'].'resources/icons/experience/gtk-dialog-warning.48x48.png" alt="" '.
154  'style="float: left; margin-right: 5px;" />';
155  echo '<p>'.$this->t('{logout:failedsps}').'</p>';
156  echo '<form method="post" action="logout-iframe-done.php" id="failed-form" target="_top">';
157  echo '<input type="hidden" name="id" value="'.$id.'" />';
158  echo '<button type="submit" name="continue" class="btn">'.$this->t('{logout:return}').'</button>';
159  echo '</form>';
160  echo '</div>';
161 
162  if ($nProgress == 0 && $nFailed == 0) {
163  echo '<div id="logout-completed">';
164  } else {
165  echo '<div id="logout-completed" style="display:none;">';
166  }
167  echo '<p>'.$this->t('{logout:success}').'</p>';
168 ?>
169  <form method="post" action="logout-iframe-done.php" id="done-form" target="_top">
170  <input type="hidden" name="id" value="<?php echo $id; ?>"/>
171  <button type="submit" name="continue" class="btn"><?php echo $this->t('{logout:return}'); ?></button>
172  </form>
173  </div>
174 <?php
175  if ($type === 'js') {
176  foreach ($SPs as $assocId => $sp) {
177  $spId = sha1($assocId);
178  if ($sp['core:Logout-IFrame:State'] !== 'inprogress') {
179  continue;
180  }
181  assert(isset($sp['core:Logout-IFrame:URL']));
182  echo '<iframe style="width:0; height:0; border:0;" src="'.
183  htmlspecialchars($sp['core:Logout-IFrame:URL']).'"></iframe>';
184  }
185  }
186 }
187 ?>
188  </div><!-- #content -->
189  </div><!-- #wrap -->
190 <?php
191 if ($type === 'embed') {
192  $this->includeAtTemplateBase('includes/footer-embed.php');
193 } else {
194  $this->includeAtTemplateBase('includes/footer.php');
195 }
$stateText
foreach($SPs as $assocId=> $sp) if($from !==null) if(!isset($this->data['head'])) $this data['head']
"color:#CC0000 style
Definition: example_001.php:92
$from
$SPs
$spTimeout
$id
input
Definition: langcheck.php:166
$nFailed
$spStatus
$type
if(!isset($_REQUEST['association'])) $assocId
$nProgress
$stateImage
if($type !=='embed') $state