function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('browseabledashlet/dashlet');
     $aFolders = KTBrowseUtil::getBrowseableFolders($this->oUser);
     if (PEAR::isError($aFolders)) {
         // just hide it.
         $aFolders = array();
     }
     $aTemplateData = array('folders' => $aFolders);
     return $oTemplate->render($aTemplateData);
 }
示例#2
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;
 }
 function _fieldValues()
 {
     if (empty($this->dDateTime)) {
         $this->dDateTime = getCurrentDateTime();
     }
     if (empty($this->iSessionId)) {
         $this->iSessionId = $_SESSION['sessionID'];
     }
     $oFolder = Folder::get($this->iFolderId);
     // head off the certain breakage down the line.
     if (PEAR::isError($oFolder) || $oFolder === false) {
         $this->bAdminMode = 0;
     } else {
         if (KTBrowseUtil::inAdminMode($oUser, $oFolder)) {
             $this->bAdminMode = 1;
         } else {
             $this->bAdminMode = 0;
         }
     }
     return parent::_fieldValues();
 }
示例#4
0
 /**
  * Deletes a symbolic link folder
  *
  * @param Folder $folder tthe symbolic link folder to delete
  * @param User $user the current user
  * @return unknown
  */
 static function deleteSymbolicLink($folder, $user = null)
 {
     //validate input
     if (is_numeric($folder)) {
         $folder = Folder::get($folder);
     }
     if (!$folder instanceof Folder) {
         return PEAR::raiseError(_kt('Folder not specified'));
     }
     if (!$folder->isSymbolicLink()) {
         return PEAR::raiseError(_kt('Folder must be a symbolic link entity'));
     }
     if (is_null($user)) {
         $user = $_SESSION['userID'];
     }
     if (is_numeric($user)) {
         $user = User::get($user);
     }
     //check if the user has sufficient permissions
     $oPerm = KTPermission::getByName('ktcore.permissions.delete');
     if (!KTBrowseUtil::inAdminMode($user, $folder)) {
         if (!KTPermissionUtil::userHasPermissionOnItem($user, $oPerm, $folder)) {
             return PEAR::raiseError(_kt('You\'re not authorized to delete shortcuts'));
         }
     }
     // we only need to delete the folder entry for the link
     $sql = "DELETE FROM folders WHERE id=?";
     DBUtil::runQuery(array($sql, array($folder->getId())));
 }
 function getConfigDescription()
 {
     if (!$this->isLoaded()) {
         return _kt('This trigger has no configuration.');
     }
     // the actual permissions are stored in the array.
     $perms = array();
     if (empty($this->aConfig) || is_null($this->aConfig['folder_id'])) {
         return _kt('<strong>This transition cannot be performed:  no folder has been selected.</strong>');
     }
     $oFolder = Folder::get($this->aConfig['folder_id']);
     if (PEAR::isError($oFolder)) {
         return _kt('<strong>The folder required for this trigger has been deleted, so the transition cannot be performed.</strong>');
     } else {
         if ($this->isCopy) {
             return sprintf(_kt('The document will be copied to folder "<a href="%s">%s</a>".'), KTBrowseUtil::getUrlForFolder($oFolder), htmlentities($oFolder->getName(), ENT_NOQUOTES, 'UTF-8'));
         } else {
             return sprintf(_kt('The document will be moved to folder "<a href="%s">%s</a>".'), KTBrowseUtil::getUrlForFolder($oFolder), htmlentities($oFolder->getName(), ENT_NOQUOTES, 'UTF-8'));
         }
     }
 }
 function form_owner()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt('Change Document Ownership'), 'description' => _kt('Changing document ownership allows you to keep the "owner" role relevant, even when the original user no longer is an appropriate choice.'), 'action' => 'reown', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), 'fail_action' => 'main', 'identifier' => 'ktcore.actions.document.owner', 'context' => $this));
     $oForm->setWidgets(array(array('ktcore.widgets.entityselection', array('label' => _kt('New Owner'), 'description' => _kt('The owner of a document is usually the person with ultimate responsibility for its contents.  It is initially set to the person who created the document, but can be changed to any other user.'), 'important_description' => _kt('Please note that changing the owner may affect access to this document.'), 'label_method' => 'getName', 'vocab' => User::getList('id > 0'), 'value' => $this->oDocument->getOwnerID(), 'name' => 'user_id'))));
     $oForm->setValidators(array(array('ktcore.validators.entity', array('test' => 'user_id', 'class' => 'User', 'output' => 'user'))));
     return $oForm;
 }
示例#7
0
 function renderData($aDataRow)
 {
     // only _ever_ show this for documents.
     if ($aDataRow["type"] === "folder") {
         return '&nbsp;';
     }
     $link = KTBrowseUtil::getUrlForFolder($aDataRow['document']->getFolderId());
     return sprintf('<a href="%s" class="ktAction ktMoveUp" title="%s">%s</a>', $link, _kt('View Folder'), _kt('View Folder'));
 }
示例#8
0
 function checkRepoDocument($oDocument)
 {
     global $aRepoDocumentProblems;
     $aDCVs = KTDocumentContentVersion::getByDocument($oDocument);
     foreach ($aDCVs as $oDCV) {
         $sDocumentPath = $oDCV->getStoragePath();
         $sFullPath = sprintf("%s/%s", $this->fsPath, $sDocumentPath);
         if (!is_file($sFullPath)) {
             $this->aRepoDocumentProblems[] = array('document' => $oDocument, 'content' => $oDCV, 'path' => $sDocumentPath, 'doclink' => KTBrowseUtil::getUrlForDocument($oDocument));
         }
     }
 }
示例#9
0
 function do_removeDynamicCondition()
 {
     $aOptions = array('redirect_to' => array('main', 'fFolderId=' . $this->oFolder->getId()));
     if (!KTBrowseUtil::inAdminMode($this->oUser, $this->oFolder)) {
         $this->oValidator->userHasPermissionOnItem($this->oUser, $this->_sEditShowPermission, $this->oFolder, $aOptions);
     }
     $aOptions = array('redirect_to' => array('edit', 'fFolderId=' . $this->oFolder->getId()));
     $oDynamicCondition =& $this->oValidator->validateDynamicCondition($_REQUEST['fDynamicConditionId'], $aOptions);
     $res = $oDynamicCondition->delete();
     $this->oValidator->notError($res, $aOptions);
     $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => _kt('Removed dynamic permissions'), 'transactionNS' => 'ktcore.transactions.permissions_change', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP()));
     $aOptions = array('defaultmessage' => _kt('Error updating permissions'), 'redirect_to' => array('edit', sprintf('fFolderId=%d', $this->oFolder->getId())));
     $this->oValidator->notErrorFalse($oTransaction, $aOptions);
     $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
     KTPermissionUtil::updatePermissionLookupForPO($oPO);
     $this->successRedirectTo('edit', _kt('Dynamic permission removed'), 'fFolderId=' . $this->oFolder->getId());
 }
 function buildFolderLink($aDataRow)
 {
     if (is_null(KTUtil::arrayGet($this->aOptions, 'direct_folder'))) {
         return KTUtil::addQueryStringSelf('fFolderId=' . $aDataRow['folder']->getId());
     } else {
         return KTBrowseUtil::getUrlForFolder($aDataRow['folder']);
     }
 }
示例#11
0
 function check()
 {
     $this->oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
     if (!$this->_show()) {
         return false;
     }
     $aOptions = array('final' => false, 'documentaction' => 'viewDocument', 'folderaction' => 'browse');
     $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($this->oDocument, $aOptions));
     $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser, 'documentinfo');
     $oPortlet = new KTActionPortlet(sprintf(_kt('Document info')));
     $oPortlet->setActions($actions, $this->sName);
     $this->oPage->addPortlet($oPortlet);
     $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser);
     $oPortlet = new KTActionPortlet(sprintf(_kt('Document actions')));
     $oPortlet->setActions($actions, $this->sName);
     $this->oPage->addPortlet($oPortlet);
     $this->oPage->setSecondaryTitle($this->oDocument->getName());
     return true;
 }
示例#12
0
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . '/browse/browseutil.inc.php';
error_reporting(E_ALL);
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/test.sxw"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/test.sxw/ktcore.delete"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/test.sxw/ktcore.delete", true));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/Default Unit"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/Default Unit/ktcore.delete"));
var_dump(KTBrowseUtil::folderOrDocument("/Root Folder/Default Unit/ktcore.delete", true));
示例#13
0
 function do_main()
 {
     redirect(KTBrowseUtil::getBrowseBaseUrl());
 }
示例#14
0
    function do_performaction()
    {
        // Get reason for checkout & check if docs must be downloaded
        $this->store_lists();
        $this->get_lists();
        $oForm = $this->form_collectinfo();
        $res = $oForm->validate();
        if (!empty($res['errors'])) {
            $oForm->handleError();
        }
        $this->sReason = $_REQUEST['data']['reason'];
        $this->bDownload = $_REQUEST['data']['download_file'];
        $oKTConfig =& KTConfig::getSingleton();
        $this->bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations");
        $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder);
        $sReturn = sprintf('<p>' . _kt('Return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl);
        $this->startTransaction();
        // if files are to be downloaded - create the temp directory for the bulk export
        if ($this->bDownload) {
            $folderName = $this->oFolder->getName();
            $this->oZip = new ZipFolder($folderName);
            $res = $this->oZip->checkConvertEncoding();
            if (PEAR::isError($res)) {
                $this->addErrorMessage($res->getMessage());
                return $sReturn;
            }
        }
        $result = parent::do_performaction();
        if (PEAR::isError($result)) {
            $this->addErrorMessage($result->getMessage());
            return $sReturn;
        }
        if ($this->bDownload) {
            $sExportCode = $this->oZip->createZipFile();
            if (PEAR::isError($sExportCode)) {
                $this->addErrorMessage($sExportCode->getMessage());
                return $sReturn;
            }
        }
        $this->commitTransaction();
        if ($this->bDownload) {
            $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode));
            $str = sprintf('<p>' . _kt('Go <a href="%s">here</a> to download the zip file if you are not automatically redirected there') . "</p>\n", $url);
            $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder);
            $str .= sprintf('<p>' . _kt('Once downloaded, return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl);
            $str .= sprintf("</div></div></body></html>\n");
            $str .= sprintf('<script language="JavaScript">
                    function kt_bulkexport_redirect() {
                        document.location.href = "%s";
                    }
                    callLater(1, kt_bulkexport_redirect);

                    </script>', $url);
            return $str;
        }
        return $result;
    }
 function form_main()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt('Convert Document to PDF'), 'action' => 'selectType', 'fail_action' => 'main', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), 'submit_label' => _kt('Convert Document'), 'context' => &$this));
     $oForm->setWidgets(array(array('ktcore.widgets.selection', array('label' => _kt("Type of conversion"), 'description' => _kt('The following are the types of conversions you can perform on this document.'), 'name' => 'convert_type', 'vocab' => array('Download as PDF'), 'simple_select' => true, 'required' => true))));
     return $oForm;
 }
    function do_main()
    {
        $config = KTConfig::getSingleton();
        $useQueue = $config->get('export/useDownloadQueue', true);
        // Create the export code
        $exportCode = KTUtil::randomString();
        $this->oZip = new ZipFolder('', $exportCode);
        if (!$this->oZip->checkConvertEncoding()) {
            redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
            exit(0);
        }
        $bNoisy = $config->get("tweaks/noisyBulkOperations");
        $bNotifications = $config->get('export/enablenotifications', 'on') == 'on' ? true : false;
        $sCurrentFolderId = $this->oFolder->getId();
        $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $sCurrentFolderId, $exportCode));
        $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder);
        if ($useQueue) {
            DownloadQueue::addItem($exportCode, $sCurrentFolderId, $sCurrentFolderId, 'folder');
            $task_url = KTUtil::kt_url() . '/bin/ajaxtasks/downloadTask.php';
            $oTemplating =& KTTemplating::getSingleton();
            $oTemplate = $oTemplating->loadTemplate('ktcore/action/bulk_download');
            $aParams = array('folder_url' => $folderurl, 'url' => $task_url, 'code' => $exportCode, 'download_url' => $url);
            return $oTemplate->render($aParams);
        }
        // Get all folders and sub-folders
        $sWhereClause = "parent_folder_ids = '{$sCurrentFolderId}' OR\n        parent_folder_ids LIKE '{$sCurrentFolderId},%' OR\n        parent_folder_ids LIKE '%,{$sCurrentFolderId},%' OR\n        parent_folder_ids LIKE '%,{$sCurrentFolderId}'";
        $aFolderList = $this->oFolder->getList($sWhereClause);
        // Get any folder shortcuts within the folders
        $aLinkedFolders = KTBulkAction::getLinkingEntities($aFolderList);
        $aFolderList = array_merge($aFolderList, $aLinkedFolders);
        // Add the folders to the zip file
        $aFolderObjects = array($sCurrentFolderId => $this->oFolder);
        if (!empty($aFolderList)) {
            foreach ($aFolderList as $oFolderItem) {
                $itemId = $oFolderItem->getId();
                $linkedFolder = $oFolderItem->getLinkedFolderId();
                // If the folder has been added or is a shortcut then skip
                // The shortcut folders don't need to be added as their targets will be added.
                if (array_key_exists($itemId, $aFolderObjects) || !empty($linkedFolder)) {
                    continue;
                }
                $this->oZip->addFolderToZip($oFolderItem);
                $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
            }
        }
        // Get the list of folder ids
        $aFolderIds = array_keys($aFolderObjects);
        // Get all documents in the folder list
        $aQuery = $this->buildQuery($aFolderIds);
        $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id');
        if (PEAR::isError($aDocumentIds)) {
            $this->addErrorMessage(_kt('There was a problem exporting the documents: ') . $aDocumentIds->getMessage());
            redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
            exit(0);
        }
        // Redirect if there are no documents and no folders to export
        if (empty($aDocumentIds) && empty($aFolderList)) {
            $this->addErrorMessage(_kt("No documents found to export"));
            redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
            exit(0);
        }
        $this->oPage->template = "kt3/minimal_page";
        $this->handleOutput("");
        // Add the documents to the zip file
        if (!empty($aDocumentIds)) {
            foreach ($aDocumentIds as $iId) {
                $oDocument = Document::get($iId);
                $sFolderId = $oDocument->getFolderID();
                if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.view')) {
                    $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document cannot be exported as it is restricted by the workflow.'));
                    continue;
                }
                $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId);
                if ($bNoisy) {
                    $oDocumentTransaction =& new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
                    $oDocumentTransaction->create();
                }
                // fire subscription alerts for the downloaded document
                if ($bNotifications) {
                    //$oSubscriptionEvent = new SubscriptionEvent();
                    //$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder);
                }
                $this->oZip->addDocumentToZip($oDocument, $oFolder);
            }
        }
        $sExportCode = $this->oZip->createZipFile(TRUE);
        $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP()));
        $sReturn = '<p>' . _kt('Creating zip file. Compressing and archiving in progress ...') . '</p>';
        $sReturn .= "<p style='margin-bottom: 10px;'><br /><b>" . _kt('Warning! Please wait for archiving to complete before closing the page.') . '</b><br />' . _kt('Note: Closing the page before the download link displays will cancel your Bulk Download.') . '</p>';
        $sReturn .= '<p>' . _kt('Once your download is complete, click <a href="' . $folderurl . '">here</a> to return to the original folder') . "</p>\n";
        print $sReturn;
        printf("</div></div></body></html>\n");
        printf('<script language="JavaScript">
                function kt_bulkexport_redirect() {
                    document.location.href = "%s";
                }
                callLater(2, kt_bulkexport_redirect);

                </script>', $url);
        exit(0);
    }
示例#17
0
 function render()
 {
     $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1);
     $iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     if (!$iFolderId && !$iDocumentId) {
         return null;
     }
     if ($iDocumentId) {
         $oDocument = Document::get($iDocumentId);
         if (PEAR::isError($oDocument) || $oDocument === false) {
             return null;
         }
         $iFolderId = $oDocument->getFolderId();
     }
     require_once KT_LIB_DIR . '/security/Permission.inc';
     $oUser =& User::get($_SESSION['userID']);
     if (!Permission::userIsSystemAdministrator($oUser) && !Permission::isUnitAdministratorForFolder($oUser, $iFolderId)) {
         return null;
     }
     require_once KT_LIB_DIR . '/browse/browseutil.inc.php';
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("kt3/portlets/admin_mode_portlet");
     $toggleMode = 'action=disableAdminMode';
     if (KTUtil::arrayGet($_SESSION, 'adminmode', false) == false) {
         $toggleMode = 'action=enableAdminMode';
     }
     $QS = sprintf('fDocumentId=%s&fFolderId=%s&%s', $iDocumentId, $iFolderId, $toggleMode);
     $toggleUrl = KTUtil::addQueryString(KTBrowseUtil::getBrowseBaseUrl(), $QS);
     $aTemplateData = array("context" => $this, 'toggleurl' => $toggleUrl, 'enabled' => KTUtil::arrayGet($_SESSION, 'adminmode', false));
     return $oTemplate->render($aTemplateData);
 }
示例#18
0
 /**
  * Returns an associative array with permissions mapped onto users, groups and roles.
  *
  * @author KnowledgeTree Team
  * @access public
  * @access protected
  */
 protected function _resolveAllocations()
 {
     $object = $this->folderItem->getObject();
     $objectId = $object->getPermissionObjectID();
     $oPO = KTPermissionObject::get($objectId);
     $permissions = KTPermission::getList();
     $cleanPermissions = array();
     $map = array('roles' => array('active' => array(), 'map' => array()), 'users' => array('active' => array(), 'map' => array()), 'groups' => array('active' => array(), 'map' => array()), 'permissions' => array());
     foreach ($permissions as $permission) {
         $permissionId = $permission->getId();
         $cleanPermissions[$permissionId] = false;
         $map['permissions'][$permissionId] = $permission->getHumanName();
     }
     // The next 3 sections of code are slightly repetitive.
     // Get all group permission assignments
     $sql = "SELECT\n                    pa.permission_id, g.name, g.id\n                FROM\n                    permission_assignments pa\n                    INNER JOIN permissions p ON p.id = pa.permission_id\n                    INNER JOIN permission_descriptor_groups pdg ON pa.permission_descriptor_id = pdg.descriptor_id\n                    INNER JOIN groups_lookup g ON pdg.group_id = g.id\n                WHERE\n                    pa.permission_object_id = ?\n                ORDER BY g.name\n        ";
     $groupPermissions = DBUtil::getResultArray(array($sql, array($objectId)));
     foreach ($groupPermissions as $group) {
         $groupId = $group['id'];
         if (!array_key_exists($groupId, $map['groups']['active'])) {
             $map['groups']['map'][$groupId] = $cleanPermissions;
         }
         $map['groups']['active'][$groupId] = $group['name'];
         $map['groups']['map'][$groupId][$group['permission_id']] = true;
     }
     // Get all role permission assignments
     $sql = "SELECT\n                    pa.permission_id, r.name, r.id\n                FROM\n                    permission_assignments pa\n                    INNER JOIN permissions p ON p.id = pa.permission_id\n                    INNER JOIN permission_descriptor_roles pdr ON pa.permission_descriptor_id = pdr.descriptor_id\n                    INNER JOIN roles r ON pdr.role_id = r.id\n                WHERE\n                    pa.permission_object_id = ?\n                ORDER BY r.name\n        ";
     $rolePermissions = DBUtil::getResultArray(array($sql, array($objectId)));
     foreach ($rolePermissions as $role) {
         $roleId = $role['id'];
         if (!array_key_exists($roleId, $map['roles']['active'])) {
             $map['roles']['map'][$roleId] = $cleanPermissions;
         }
         $map['roles']['active'][$roleId] = $role['name'];
         $map['roles']['map'][$roleId][$role['permission_id']] = true;
     }
     // Get all user permission assignments
     $sql = "SELECT\n                    pa.permission_id, u.name, u.id\n                FROM\n                    permission_assignments pa\n                    INNER JOIN permissions p ON p.id = pa.permission_id\n                    INNER JOIN permission_descriptor_users pdu ON pa.permission_descriptor_id = pdu.descriptor_id\n                    INNER JOIN users u ON pdu.user_id = u.id\n                WHERE\n                    pa.permission_object_id = ?\n                ORDER BY u.name\n        ";
     $userPermissions = DBUtil::getResultArray(array($sql, $objectId));
     foreach ($userPermissions as $user) {
         $userId = $user['id'];
         if (!array_key_exists($userId, $map['users']['active'])) {
             $map['users']['map'][$userId] = $cleanPermissions;
         }
         $map['users']['active'][$userId] = $user['name'];
         $map['users']['map'][$userId][$user['permission_id']] = true;
     }
     // resolve editable, inherited, inheritable
     $user = $this->ktapi->get_session()->get_user();
     $editable = KTPermissionUtil::userHasPermissionOnItem($user, 'ktcore.permissions.security', $object) || KTBrowseUtil::inAdminMode($user, $this->folderItem);
     $inherited = KTPermissionUtil::findRootObjectForPermissionObject($oPO);
     $inheritedId = $inherited->getId();
     $objectId = $object->getId();
     $map['inherited'] = $inheritedId !== $objectId && $objectId != 1;
     // only allow inheritance of permissions from parent if not inherited, -and- folder is editable
     $map['inheritable'] = $editable && !$map['inherited'] && $objectId != 1;
     // only allow edit if the folder is editable and not inherited
     $map['editable'] = $editable && !$map['inherited'];
     $this->map = $map;
     $this->mapCopy = $map;
     $this->changed = false;
 }
示例#19
0
 function getRestoreLocationFor($oDocument)
 {
     $iFolderId = $oDocument->getRestoreFolderId();
     $oFolder = Folder::get($iFolderId);
     if (PEAR::isError($oFolder)) {
         return _kt('Original folder no longer exists.  Document will be restored in the root folder.');
     } else {
         $aCrumbs = KTBrowseUtil::breadcrumbsForFolder($oFolder);
         $aParts = array();
         foreach ($aCrumbs as $aInfo) {
             $aParts[] = $aInfo['name'];
         }
         return implode(' &raquo; ', $aParts);
     }
 }
 function form_main()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt('Make Immutable'), 'action' => 'immutable', 'fail_action' => 'main', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), 'submit_label' => _kt('Make Immutable'), 'context' => &$this));
     // 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 making this document immutable.  Please bear in mind that you can use a maximum of <strong>250</strong> characters.'), 'name' => 'reason'));
     $oForm->setWidgets($widgets);
     $validators[] = array('ktcore.validators.string', array('test' => 'reason', 'min_length' => 1, 'max_length' => 250, 'output' => 'reason'));
     if ($default->enableESignatures) {
         $validators[] = array('electonic.signatures.validators.authenticate', array('object_id' => $this->oDocument->iId, 'type' => 'document', 'action' => 'ktcore.transactions.immutable', 'test' => 'info', 'output' => 'info'));
     }
     $oForm->setValidators($validators);
     return $oForm;
 }
示例#21
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());
 }
示例#22
0
 function do_update()
 {
     $oForm = $this->form_edit();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     // we need to format these in MDPack format
     // which is a little archaic:
     //
     //  array(
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //      array($oField, $sValue),
     //  );
     //
     // we do this the "easy" way.
     $doctypeid = $this->oDocument->getDocumentTypeId();
     if ($_REQUEST['new_type']) {
         $oTestType = DocumentType::get($_REQUEST['new_type']);
         if (!PEAR::isError($oTestType)) {
             $doctypeid = $oTestType->getId();
         }
     }
     $fieldsets = KTMetadataUtil::fieldsetsForDocument($this->oDocument, $doctypeid);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             // FIXME "null" has strange meanings here.
             if (!is_null($val)) {
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     $this->startTransaction();
     if ($this->oDocument->getDocumentTypeId() != $doctypeid) {
         $this->oDocument->setDocumentTypeId($doctypeid);
     }
     $this->oDocument->setName($data['document_title']);
     $this->oDocument->setLastModifiedDate(getCurrentDateTime());
     $this->oDocument->setModifiedUserId($this->oUser->getId());
     // Update the content version / document version
     global $default;
     if ($default->updateContentVersion) {
         $this->oDocument->startNewContentVersion($this->oUser);
         $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber() + 1);
     } else {
         $this->oDocument->startNewMetadataVersion($this->oUser);
     }
     $res = $this->oDocument->update();
     if (PEAR::isError($res)) {
         $oForm->handleError(sprintf(_kt("Unexpected failure to update document title: %s"), $res->getMessage()));
     }
     $core_res = KTDocumentUtil::saveMetadata($this->oDocument, $MDPack);
     if (PEAR::isError($core_res)) {
         $oForm->handleError(sprintf(_kt("Unexpected validation failure: %s."), $core_res->getMessage()));
     }
     // post-triggers.
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array("document" => $this->oDocument, "aOptions" => $MDPack);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
     }
     $this->commitTransaction();
     // create the document transaction record
     $oDocumentTransaction =& new DocumentTransaction($this->oDocument, _kt('Document metadata updated'), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     // Check if there are any dynamic conditions / permissions that need to be updated on the document
     // If there are dynamic conditions then update the permissions on the document
     // The dynamic condition test fails unless the changes exists in the DB therefore update permissions after committing the transaction.
     $iPermissionObjectId = $this->oDocument->getPermissionObjectID();
     $dynamicCondition = KTPermissionDynamicCondition::getByPermissionObjectId($iPermissionObjectId);
     if (!PEAR::isError($dynamicCondition) && !empty($dynamicCondition)) {
         $res = KTPermissionUtil::updatePermissionLookup($this->oDocument);
     }
     redirect(KTBrowseUtil::getUrlForDocument($this->oDocument->getId()));
     exit(0);
 }
 function getDocInfo($iDocId)
 {
     $oDocument = Document::get($iDocId);
     if (PEAR::isError($oDocument)) {
         return _kt('Document no longer exists.');
     }
     $sName = htmlentities($oDocument->getName(), ENT_NOQUOTES, 'UTF-8');
     $sLink = KTBrowseUtil::getUrlForDocument($oDocument);
     $aAnchorData = array();
     $aAnchorData[] = $sLink;
     $aAnchorData[] = $sName;
     return $aAnchorData;
 }
示例#24
0
 function getCrumbStringForDocument($params, &$smarty)
 {
     $aBreadcrumbs = KTBrowseUtil::breadcrumbsForDocument($params['document'], array('final' => true));
     if (PEAR::isError($aBreadcrumbs)) {
         return _kt('No breadcrumbs available');
     }
     $aCrumbs = array();
     foreach ($aBreadcrumbs as $aBreadcrumb) {
         $aCrumbs[] = $aBreadcrumb['name'];
     }
     return implode('/', $aCrumbs);
 }
示例#25
0
 function display_viewlet()
 {
     $oKTTemplating =& KTTemplating::getSingleton();
     $oTemplate =& $oKTTemplating->loadTemplate("ktstandard/links/links_viewlet");
     if (is_null($oTemplate)) {
         return '';
     }
     $iDocId = $this->oDocument->getId();
     $temp_links_from = DocumentLink::getLinksFromDocument($iDocId);
     $temp_links_to = DocumentLink::getLinksToDocument($iDocId);
     $temp_links_external = DocumentLink::getExternalLinks($iDocId);
     $links_to = array();
     $links_from = array();
     $links_external = array();
     if (!empty($temp_links_from)) {
         foreach ($temp_links_from as $link) {
             $oDoc = $link->getChildDocument();
             if (PEAR::isError($oDoc)) {
                 continue;
             }
             if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) {
                 $type = $link->getLinkType();
                 $aInfo = array('url' => KTBrowseUtil::getUrlForDocument($oDoc), 'name' => $oDoc->getName(), 'type' => $type->getName(), 'description' => $type->getDescription());
                 $links_from[] = $aInfo;
             }
         }
     }
     if (!empty($temp_links_to)) {
         foreach ($temp_links_to as $link) {
             $oDoc = $link->getParentDocument();
             if (PEAR::isError($oDoc)) {
                 continue;
             }
             if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) {
                 $type = $link->getLinkType();
                 $aInfo = array('url' => KTBrowseUtil::getUrlForDocument($oDoc), 'name' => $oDoc->getName(), 'type' => $type->getName(), 'description' => $type->getDescription());
                 $links_to[] = $aInfo;
             }
         }
     }
     if (!empty($temp_links_external)) {
         foreach ($temp_links_external as $link) {
             $type = $link->getLinkType();
             $aInfo = array('url' => $link->getTargetUrl(), 'name' => $link->getTargetName(), 'type' => $type->getName(), 'description' => $type->getDescription());
             $links_external[] = $aInfo;
         }
     }
     if (empty($links_from) && empty($links_to) && empty($links_external)) {
         return '';
     }
     $oTemplate->setData(array('context' => $this, 'links_from' => $links_from, 'links_to' => $links_to, 'links_external' => $links_external));
     return $oTemplate->render();
 }
示例#26
0
 function getRssLink($iItemId, $sItemType)
 {
     $item = strToLower($sItemType);
     if ($item == 'folder') {
         $sItemParameter = '?folderId';
     } else {
         if ($item == 'document') {
             $sItemParameter = '?docId';
         }
     }
     // built server path
     global $default;
     $sHostPath = "http" . ($default->sslEnabled ? "s" : "") . "://" . $_SERVER['HTTP_HOST'];
     // build link
     $sLink = $sHostPath . KTBrowseUtil::buildBaseUrl('rss') . $sItemParameter . '=' . $iItemId;
     return $sLink;
 }
示例#27
0
 function do_disableAdminMode()
 {
     $iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId');
     if ($iDocumentId) {
         $oDocument = Document::get($iDocumentId);
         if (PEAR::isError($oDocument) || $oDocument === false) {
             return null;
         }
         $iFolderId = $oDocument->getFolderId();
     }
     if (!Permission::userIsSystemAdministrator() && !Permission::isUnitAdministratorForFolder($this->oUser, $iFolderId)) {
         $this->errorRedirectToMain(_kt('You are not an administrator'));
     }
     // log this entry
     $oLogEntry =& KTUserHistory::createFromArray(array('userid' => $this->oUser->getId(), 'datetime' => date('Y-m-d H:i:s', time()), 'actionnamespace' => 'ktcore.user_history.disable_admin_mode', 'comments' => 'Admin Mode disabled', 'sessionid' => $_SESSION['sessionID']));
     $aOpts = array('redirect_to' => 'main', 'message' => _kt('Unable to log admin mode exit.  Not de-activating admin mode.'));
     $this->oValidator->notError($oLogEntry, $aOpts);
     $_SESSION['adminmode'] = false;
     if ($_REQUEST['fDocumentId']) {
         $_SESSION['KTInfoMessage'][] = _kt('Administrator mode disabled');
         redirect(KTBrowseUtil::getUrlForDocument($iDocumentId));
         exit(0);
     }
     if ($_REQUEST['fFolderId']) {
         $this->successRedirectToMain(_kt('Administrator mode disabled'), sprintf('fFolderId=%d', $_REQUEST['fFolderId']));
     }
     $this->successRedirectToMain(_kt('Administrator mode disabled'));
 }
示例#28
0
 function getSearchResultURL()
 {
     return KTBrowseUtil::buildBaseUrl('search2');
 }
示例#29
0
 function do_rename()
 {
     $aErrorOptions = array('redirect_to' => array('', sprintf('fFolderId=%d', $this->oFolder->getId())));
     $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername');
     $aErrorOptions['defaultmessage'] = _kt("No folder name given");
     $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions);
     $sFolderName = $this->oValidator->validateIllegalCharacters($sFolderName, $aErrorOptions);
     $sOldFolderName = $this->oFolder->getName();
     if ($this->oFolder->getId() != 1) {
         $oParentFolder =& Folder::get($this->oFolder->getParentID());
         if (PEAR::isError($oParentFolder)) {
             $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]);
             exit(0);
         }
         if (KTFolderUtil::exists($oParentFolder, $sFolderName)) {
             $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]);
             exit(0);
         }
     }
     $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser);
     if (PEAR::isError($res)) {
         $_SESSION['KTErrorMessage'][] = $res->getMessage();
         redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
         exit(0);
     } else {
         $_SESSION['KTInfoMessage'][] = sprintf(_kt('Folder "%s" renamed to "%s".'), $sOldFolderName, $sFolderName);
     }
     $this->commitTransaction();
     redirect(KTBrowseUtil::getUrlForFolder($this->oFolder));
     exit(0);
 }
示例#30
0
 function do_main()
 {
     $sCode = KTUtil::arrayGet($_REQUEST, 'code');
     $sName = KTUtil::arrayGet($_REQUEST, 'varname', 'fFolderId');
     $oWidget = unserialize($_SESSION['collection_widgets'][$sCode]);
     $oCollection = $oWidget->getCollection();
     $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1));
     if (PEAR::isError($oFolder)) {
         $this->errorRedirectToMain(_kt('Invalid folder selected.'));
         exit(0);
     }
     $aOptions = array('ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder));
     $oCollection->_queryObj->folder_id = $oFolder->getId();
     $aOptions = $oCollection->getEnvironOptions();
     $aOptions['return_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array('code' => $sCode, 'varname' => $sName, 'fFolderId' => $oFolder->getId()));
     $oCollection->setOptions($aOptions);
     // add the collection code to the title column QS params
     foreach ($oWidget->aCols as $ns) {
         $aColOpts = $oCollection->getColumnOptions($ns);
         $aColOpts['qs_params'] = kt_array_merge(KTUtil::arrayGet($aColOpts, 'qs_params', array()), array('code' => $sCode, 'varname' => $sName));
         $oCollection->setColumnOptions($ns, $aColOpts);
     }
     // make the breadcrumbs
     $aBreadcrumbs = $this->_generate_breadcrumbs($oFolder, $sCode, $oWidget->aBCUrlParams, $sName);
     print KTTemplating::renderTemplate('ktcore/forms/widgets/collection', array('collection' => $oCollection, 'folder' => $oFolder, 'breadcrumbs' => $aBreadcrumbs, 'targetname' => $sName));
     exit(0);
 }