Пример #1
0
 function form_main()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('context' => &$this, 'identifier' => 'ktcore.folder.add', 'action' => 'addFolder', 'fail_action' => 'main', 'cancel_url' => KTBrowseUtil::getUrlForFolder($this->oFolder), 'label' => _kt('Add a folder'), 'submit_label' => _kt('Add Folder'), 'extraargs' => $this->meldPersistQuery("", "", true)));
     // widgets
     $oForm->setWidgets(array(array('ktcore.widgets.string', array('label' => _kt('Folder name'), 'description' => _kt('The name for the new folder.'), 'required' => true, 'name' => 'name'))));
     // Electronic Signature if enabled
     global $default;
     if ($default->enableESignatures) {
         $oForm->addWidget(array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info')));
         $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.reason', array('label' => _kt('Reason'), 'description' => _kt('Please specify why you are checking out this document.  It will assist other users in understanding why you have locked this file.  Please bear in mind that you can use a maximum of <strong>250</strong> characters.'), 'name' => 'reason')));
     }
     $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'name', 'output' => 'name')), array('ktcore.validators.illegal_char', array('test' => 'name', 'output' => 'name'))));
     if ($default->enableESignatures) {
         $oForm->addValidator(array('electonic.signatures.validators.authenticate', array('object_id' => $this->oFolder->getId(), 'type' => 'folder', 'action' => 'ktcore.transactions.add_folder', 'test' => 'info', 'output' => 'info')));
     }
     return $oForm;
 }
Пример #2
0
 function form_copyselection()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt('Copy Document'), 'submit_label' => _kt('Copy'), 'identifier' => 'ktcore.actions.copydoc', 'action' => 'copy', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), 'fail_action' => 'main', 'context' => $this));
     /*
      *  This is somewhat more complex than most forms, since the "filename"
      *  and title shouldn't appear unless there's a clash.
      *
      *  This is still not the most elegant solution.
      */
     $widgets = array();
     $widgets[] = array('ktcore.widgets.foldercollection', array('label' => _kt('Target Folder'), 'description' => _kt('Use the folder collection and path below to browse to the folder you wish to copy the documents into.'), 'required' => true, 'name' => 'browse', 'folder_id' => $this->oDocument->getFolderID()));
     // Electronic Signature if enabled
     global $default;
     if ($default->enableESignatures) {
         $widgets[] = array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info'));
         $widgets[] = array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true));
         $widgets[] = array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true));
     }
     $widgets[] = array('ktcore.widgets.reason', array('label' => _kt('Reason'), 'description' => _kt('Please specify why you are copying this document.  Bear in mind that you can use a maximum of <strong>250</strong> characters.'), 'name' => 'reason'));
     $oForm->setWidgets($widgets);
     $validators = array();
     $validators[] = array('ktcore.validators.string', array('test' => 'reason', 'min_length' => 1, 'max_length' => 250, 'output' => 'reason'));
     $validators[] = array('ktcore.validators.entity', array('class' => 'Folder', 'test' => 'browse', 'output' => 'browse'));
     if ($default->enableESignatures) {
         $validators[] = array('electonic.signatures.validators.authenticate', array('object_id' => $this->oDocument->iId, 'type' => 'document', 'action' => 'ktcore.transactions.copy', 'test' => 'info', 'output' => 'info'));
     }
     $oForm->setValidators($validators);
     // here's the ugly bit.
     $err = $oForm->getErrors();
     if (!empty($err['name']) || !empty($err['filename'])) {
         $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Document Title'), 'value' => sanitizeForHTML($this->oDocument->getName()), 'important_description' => _kt('Please indicate a new title to use to resolve any title conflicts.'), 'name' => 'name', 'required' => true)));
         $oForm->addValidator(array('ktcore.validators.string', array('output' => 'name', 'test' => 'name')));
         $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Filename'), 'value' => sanitizeForHTML($this->oDocument->getFilename()), 'important_description' => _kt('Please indicate a new filename to use to resolve any conflicts.'), 'name' => 'filename', 'required' => true)));
         $oForm->addValidator(array('ktcore.validators.string', array('output' => 'filename', 'test' => 'filename')));
     }
     return $oForm;
 }
Пример #3
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());
 }
Пример #4
0
 function form_collectinfo()
 {
     $cancelUrl = $this->getReturnUrl();
     $oForm = new KTForm();
     $oForm->setOptions(array('identifier' => 'ktcore.actions.bulk.archive.form', 'label' => _kt('Archive Items'), 'submit_label' => _kt('Archive'), 'action' => 'performaction', 'fail_action' => 'collectinfo', 'cancel_url' => $cancelUrl, 'context' => $this));
     // Electronic Signature if enabled
     global $default;
     if ($default->enableESignatures) {
         $oForm->addWidget(array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info')));
         $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true)));
     }
     $oForm->addWidget(array('ktcore.widgets.reason', array('name' => 'reason', 'label' => _kt('Reason'), 'description' => _kt('The reason for archiving these documents and folders, for historical purposes.'), 'value' => null, 'required' => true)));
     $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'reason', 'output' => 'reason'))));
     if ($default->enableESignatures) {
         $oForm->addValidator(array('electonic.signatures.validators.authenticate', array('object_id' => $this->oFolder->getID(), 'type' => 'bulk', 'action' => 'ktcore.transactions.bulk_archive', 'test' => 'info', 'output' => 'info')));
     }
     return $oForm;
 }
Пример #5
0
 function form_initialdata()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt("Add a document"), 'action' => 'processInitialData', 'actionparams' => 'postExpected=1&fFolderId=' . $this->oFolder->getId(), 'fail_action' => 'main', 'context' => &$this, 'extraargs' => $this->meldPersistQuery("", "", true), 'submit_label' => _kt("Add"), 'file_upload' => true));
     $aTypes = array();
     foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) {
         if (!$oDocumentType->getDisabled()) {
             $aTypes[] = $oDocumentType;
         }
     }
     // Onchange gets the name of the file and inserts it as the document title.
     $sFileOnchange = "javascript:\n            var doc = document.getElementById('document_name');\n            if(doc.value == ''){\n                var arrPath=this.value.split('/');\n                if(arrPath.length == 1){\n                    var arrPath=this.value.split('\\\\');\n                }\n                var name=arrPath[arrPath.length-1];\n                var name=name.split('.');\n                var len = name.length;\n                if(len > 1){\n                    if(name[len-1].length <= 4){\n                        name.pop();\n                    }\n                }\n                var title=name.join('.');\n                doc.value=title;\n            }";
     $oForm->setWidgets(array(array('ktcore.widgets.file', array('label' => _kt('File'), 'description' => _kt('The contents of the document to be added to the document management system.'), 'name' => 'file', 'required' => true, 'onchange' => $sFileOnchange)), array('ktcore.widgets.string', array('label' => _kt('Document Title'), 'description' => sprintf(_kt('The document title is used as the main name of a document throughout %s.'), APP_NAME), 'name' => 'document_name', 'required' => true, 'id' => 'document_name')), array('ktcore.widgets.entityselection', array('label' => _kt('Document Type'), 'description' => _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), 'name' => 'document_type', 'required' => true, 'vocab' => $aTypes, 'initial_string' => _kt('- Please select a document type -'), 'id_method' => 'getId', 'label_method' => 'getName', 'simple_select' => false))));
     // Electronic Signature if enabled
     global $default;
     if ($default->enableESignatures) {
         $oForm->addWidget(array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info')));
         $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.reason', array('label' => _kt('Reason'), 'description' => _kt('Please specify why you are checking out this document.  It will assist other users in understanding why you have locked this file.  Please bear in mind that you can use a maximum of <strong>250</strong> characters.'), 'name' => 'reason')));
     }
     $oForm->setValidators(array(array('ktcore.validators.file', array('test' => 'file', 'output' => 'file')), array('ktcore.validators.fileillegalchar', array('test' => 'file', 'output' => 'file')), array('ktcore.validators.string', array('test' => 'document_name', 'output' => 'document_name')), array('ktcore.validators.entity', array('test' => 'document_type', 'output' => 'document_type', 'class' => 'DocumentType', 'ids' => true))));
     if ($default->enableESignatures) {
         $oForm->addValidator(array('electonic.signatures.validators.authenticate', array('object_id' => $this->oFolder->getId(), 'type' => 'folder', 'action' => 'ktcore.transactions.add_document', 'test' => 'info', 'output' => 'info')));
     }
     return $oForm;
 }