Beispiel #1
0
 function do_request($oDocument)
 {
     // Display form for sending a request through the the sys admin to unarchive the document
     // name, document, request, submit
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt('Request restoration of document'), 'submit_label' => _kt('Send request'), 'identifier' => '', 'cancel_url' => KTBrowseUtil::getUrlForFolder($oFolder), 'fail_action' => 'main', 'context' => $this));
     $oForm->addWidget(array('ktcore.widgets.text', array('label' => _kt('Reason'), 'name' => 'reason', 'required' => true)));
     $data = isset($_REQUEST['data']) ? $_REQUEST['data'] : array();
     $iFolderId = $oDocument->getFolderID();
     $oFolder = Folder::get($iFolderId);
     $sFolderUrl = KTBrowseUtil::getUrlForFolder($oFolder);
     if (!empty($data)) {
         $res = $oForm->validate();
         if (!empty($res['errors'])) {
             return $oForm->handleError('', $aError);
         }
         $aAdminGroups = Group::getAdministratorGroups();
         if (!PEAR::isError($aAdminGroups) && !empty($aAdminGroups)) {
             foreach ($aAdminGroups as $oGroup) {
                 $aGroupUsers = $oGroup->getMembers();
                 // ensure unique users
                 foreach ($aGroupUsers as $oUser) {
                     $aUsers[$oUser->getId()] = $oUser;
                 }
             }
             $sSubject = _kt('Request for an archived document to be restored');
             $sDetails = $data['reason'];
             // Send request
             foreach ($aUsers as $oU) {
                 if (!PEAR::isError($oU)) {
                     include_once KT_DIR . '/plugins/ktcore/KTAssist.php';
                     KTAssistNotification::newNotificationForDocument($oDocument, $oU, $this->oUser, $sSubject, $sDetails);
                 }
             }
             // Redirect to folder
             $this->addInfoMessage(_kt('The System Administrators have been notified of your request.'));
             redirect($sFolderUrl);
             exit;
         }
     }
     return $oForm->renderPage(_kt('Archived document request') . ': ' . $oDocument->getName());
 }