Exemplo n.º 1
0
 /**
  * Shows current folder. Current Folder is determined by $_GET["mobj_id"]
  */
 public function showFolder($a_show_confirmation = false)
 {
     /**
      * @var $ilUser ilObjUser
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilUser, $ilToolbar;
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail.html', 'Services/Mail');
     $this->tpl->setTitle($this->lng->txt('mail'));
     $sentFolderId = $this->mbox->getSentFolder();
     $draftsFolderId = $this->mbox->getDraftsFolder();
     $isTrashFolder = $_GET['mobj_id'] == $this->mbox->getTrashFolder();
     $isSentFolder = $_GET['mobj_id'] == $sentFolderId;
     $isDraftFolder = $_GET['mobj_id'] == $draftsFolderId;
     if ($this->current_selected_cmd == 'deleteMails' && !$this->errorDelete && $this->current_selected_cmd != 'confirm' && $isTrashFolder) {
         if (isset($_REQUEST['mail_id']) && !is_array($_REQUEST['mail_id'])) {
             $_REQUEST['mail_id'] = array($_REQUEST['mail_id']);
         }
         $confirmation = new ilConfirmationGUI();
         $confirmation->setHeaderText($this->lng->txt('mail_sure_delete'));
         $this->ctrl->setParameter($this, 'mail_id', implode(',', (array) $_REQUEST['mail_id']));
         $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteMails'));
         $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmDeleteMails');
         $confirmation->setCancel($this->lng->txt('cancel'), 'cancelDeleteMails');
         $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
         $a_show_confirmation = true;
     }
     $folders = $this->mbox->getSubFolders();
     $mtree = new ilTree($ilUser->getId());
     $mtree->setTableNames('mail_tree', 'mail_obj_data');
     $check_uf = false;
     $check_local = false;
     if ('tree' == ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
         $folder_d = $mtree->getNodeData($_GET['mobj_id']);
         if ($folder_d['m_type'] == 'user_folder') {
             $check_uf = true;
         } else {
             if ($folder_d['m_type'] == 'local') {
                 $check_local = true;
             }
         }
     }
     $mailtable = new ilMailFolderTableGUI($this, (int) $_GET['mobj_id'], 'showFolder');
     $mailtable->isSentFolder($isSentFolder)->isDraftFolder($isDraftFolder)->isTrashFolder($isTrashFolder)->initFilter();
     $mailtable->setSelectedItems($_POST['mail_id']);
     try {
         $mailtable->prepareHTML();
     } catch (Exception $e) {
         ilUtil::sendFailure($this->lng->txt($e->getMessage()) != '-' . $e->getMessage() . '-' ? $this->lng->txt($e->getMessage()) : $e->getMessage());
     }
     $table_html = $mailtable->getHtml();
     $folder_options = array();
     if ('tree' != ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
         foreach ($folders as $folder) {
             $folder_d = $mtree->getNodeData($folder['obj_id']);
             if ($folder['obj_id'] == $_GET['mobj_id']) {
                 if ($folder['type'] == 'user_folder') {
                     $check_uf = true;
                 } else {
                     if ($folder['type'] == 'local') {
                         $check_local = true;
                         $check_uf = false;
                     }
                 }
             }
             if ($folder['type'] == 'user_folder') {
                 $pre = '';
                 for ($i = 2; $i < $folder_d['depth'] - 1; $i++) {
                     $pre .= '&nbsp';
                 }
                 if ($folder_d['depth'] > 1) {
                     $pre .= '+';
                 }
                 $folder_options[$folder['obj_id']] = $pre . ' ' . $folder['title'];
             } else {
                 $folder_options[$folder['obj_id']] = $this->lng->txt('mail_' . $folder['title']);
             }
         }
     }
     if ($a_show_confirmation == false && $this->askForConfirmation == false) {
         if ('tree' != ilSession::get(ilMailGUI::VIEWMODE_SESSION_KEY)) {
             $ilToolbar->addText($this->lng->txt('mail_change_to_folder'));
             include_once './Services/Form/classes/class.ilSelectInputGUI.php';
             $si = new ilSelectInputGUI("", "mobj_id");
             $si->setOptions($folder_options);
             $si->setValue($_GET['mobj_id']);
             $ilToolbar->addInputItem($si);
             $ilToolbar->addFormButton($this->lng->txt('change'), 'showFolder');
             $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'showFolder'));
         }
         if ($check_local == true || $check_uf == true) {
             $this->addSubfolderCommands($check_uf);
         }
     }
     // END SHOW_FOLDER
     if ($mailtable->isTrashFolder() && $mailtable->getNumerOfMails() > 0 && $this->askForConfirmation) {
         $confirmation = new ilConfirmationGUI();
         $confirmation->setHeaderText($this->lng->txt('mail_empty_trash_confirmation'));
         $confirmation->setFormAction($this->ctrl->getFormAction($this, 'performEmptyTrash'));
         $confirmation->setConfirm($this->lng->txt('confirm'), 'performEmptyTrash');
         $confirmation->setCancel($this->lng->txt('cancel'), 'cancelEmptyTrash');
         $this->tpl->setVariable('CONFIRMATION', $confirmation->getHTML());
     }
     $this->tpl->setVariable('MAIL_TABLE', $table_html);
     $this->tpl->show();
 }