ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailOptionsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 require_once "Services/Mail/classes/class.ilMailbox.php";
25 require_once "Services/Mail/classes/class.ilFormatMail.php";
26 
34 {
35  private $tpl = null;
36  private $ctrl = null;
37  private $lng = null;
38 
39  private $umail = null;
40  private $mbox = null;
41 
42  private $errorDelete = false;
43 
44  public function __construct()
45  {
46  global $tpl, $ilCtrl, $lng, $ilUser;
47 
48  $this->tpl = $tpl;
49  $this->ctrl = $ilCtrl;
50  $this->lng = $lng;
51 
52  $this->ctrl->saveParameter($this, "mobj_id");
53 
54  $this->umail = new ilFormatMail($ilUser->getId());
55  $this->mbox = new ilMailBox($ilUser->getId());
56  }
57 
58  public function executeCommand()
59  {
60  $forward_class = $this->ctrl->getNextClass($this);
61  switch($forward_class)
62  {
63  default:
64  if (!($cmd = $this->ctrl->getCmd()))
65  {
66  $cmd = "showOptions";
67  }
68 
69  $this->$cmd();
70  break;
71  }
72  return true;
73  }
74 
75  public function saveOptions()
76  {
77  $this->umail->mail_options->updateOptions(ilUtil::stripSlashes($_POST["signature"]), ilUtil::stripSlashes((int) $_POST["linebreak"]), ilUtil::stripSlashes((int) $_POST["incoming_type"]), ilUtil::stripSlashes((int) $_POST['cronjob_notification']));
78 # ilUtil::sendInfo($this->lng->txt("mail_options_saved"),true);
79 # $this->ctrl->redirectByClass("ilmailfoldergui");
80  ilUtil::sendInfo($this->lng->txt("mail_options_saved"));
81  $this->showOptions();
82 
83  }
84 
85  public function showOptions()
86  {
87  global $ilUser, $ilias;
88 
89  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_options.html", "Services/Mail");
90  $this->tpl->setVariable("HEADER", $this->lng->txt("mail"));
91 
92  // FORM GLOBAL OPTIONS
93 
94  $this->tpl->setCurrentBlock("options");
95 
96  // BEGIN INCOMING
97  $this->tpl->setCurrentBlock("option_inc_line");
98 
99  $inc = array($this->lng->txt("mail_incoming_local"),$this->lng->txt("mail_incoming_smtp"),$this->lng->txt("mail_incoming_both"));
100  foreach($inc as $key => $option)
101  {
102  $this->tpl->setVariable("OPTION_INC_VALUE",$key);
103  $this->tpl->setVariable("OPTION_INC_NAME",$option);
104  $this->tpl->setVariable("OPTION_INC_SELECTED",$this->umail->mail_options->getIncomingType() == $key ? "selected=\"selected\"" : "");
105  $this->tpl->parseCurrentBlock();
106  }
107 
108  // BEGIN LINEBREAK_OPTIONS
109  $this->tpl->setCurrentBlock("option_line");
110  $linebreak = $this->umail->mail_options->getLinebreak();
111 
112  for($i = 50; $i <= 80;$i++)
113  {
114  $this->tpl->setVariable("OPTION_VALUE",$i);
115  $this->tpl->setVariable("OPTION_NAME",$i);
116  if( $i == $linebreak)
117  {
118  $this->tpl->setVariable("OPTION_SELECTED","selected");
119  }
120  $this->tpl->parseCurrentBlock();
121  }
122 
123  if(!strlen(ilObjUser::_lookupEmail($ilUser->getId())))
124  {
125  $this->tpl->setVariable('INC_DISABLED','disabled="disabled"');
126  }
127 
128  $this->tpl->setVariable("GLOBAL_OPTIONS",$this->lng->txt("mail_global_options"));
129  $this->tpl->setVariable("TXT_INCOMING", $this->lng->txt("mail_incoming"));
130  $this->tpl->setVariable("TXT_LINEBREAK", $this->lng->txt("linebreak"));
131  $this->tpl->setVariable("TXT_SIGNATURE", $this->lng->txt("signature"));
132  $this->tpl->setVariable("CONTENT",$this->umail->mail_options->getSignature());
133 
134  if ($ilias->getSetting("mail_notification"))
135  {
136  $this->tpl->setVariable("TXT_CRONJOB_NOTIFICATION", $this->lng->txt("cron_mail_notification"));
137  $this->tpl->setVariable("TXT_CRONJOB_NOTIFICATION_INFO", $this->lng->txt("mail_cronjob_notification_info"));
138  if ($this->umail->mail_options->getCronjobNotification())
139  {
140  $this->tpl->setVariable("CRONJOB_NOTIFICATION_SELECTED", " checked=\"checked\"");
141  }
142  }
143 
144  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
145 
146  $this->ctrl->setParameter($this, "cmd", "post");
147  $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, 'saveOptions'));
148  $this->ctrl->clearParameters($this);
149 
150  $this->tpl->parseCurrentBlock();
151 
152  $this->tpl->show();
153  }
154 
155 }
156 
157 ?>