Ejemplo n.º 1
0
 function do_main()
 {
     $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents'));
     $this->oPage->setBreadcrumbDetails(_kt('view'));
     $aDocuments =& Document::getList('status_id=' . DELETED);
     if (!empty($aDocuments)) {
         $items = count($aDocuments);
         if (fmod($items, 10) > 0) {
             $pages = floor($items / 10) + 1;
         } else {
             $pages = $items / 10;
         }
         for ($i = 1; $i <= $pages; $i++) {
             $aPages[] = $i;
         }
         if ($items < 10) {
             $limit = $items - 1;
         } else {
             $limit = 9;
         }
         for ($i = 0; $i <= $limit; $i++) {
             $aDocumentsList[] = $aDocuments[$i];
         }
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/deletedlist');
     $oTemplate->setData(array('context' => $this, 'fullList' => $aDocuments, 'documents' => $aDocumentsList, 'pagelist' => $aPages, 'pagecount' => $pages, 'itemcount' => $items));
     return $oTemplate;
 }
Ejemplo n.º 2
0
 function do_main()
 {
     $this->aBreadcrumbs[] = array('name' => _kt('Document Checkout'));
     $this->oPage->setBreadcrumbDetails(_kt('list checked out documents'));
     $aDocuments = Document::getList('is_checked_out = 1');
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/checkoutlisting');
     $oTemplate->setData(array('context' => $this, 'documents' => $aDocuments));
     return $oTemplate;
 }
Ejemplo n.º 3
0
 function do_main()
 {
     $aDocuments = Document::getList();
     $s = '';
     foreach ($aDocuments as $oDocument) {
         $this->startTransaction();
         KTDocumentUtil::reindexDocument($oDocument);
         $s .= $oDocument->getName() . '<br />';
         $this->commitTransaction();
     }
     return $s;
 }
Ejemplo n.º 4
0
 function do_verify()
 {
     global $aFoldersToRemove;
     global $aFilesToRemove;
     global $aRepoDocumentProblems;
     global $aRepoFolderProblems;
     global $aRepoVersionProblems;
     $this->checkDirectory("");
     $aDocuments =& Document::getList();
     foreach ($aDocuments as $oDocument) {
         $this->checkRepoDocument($oDocument);
     }
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/document/cleanup');
     $oTemplate->setData(array('aFilesToRemove' => $this->aFilesToRemove, 'aRepoDocumentProblems' => $this->aRepoDocumentProblems));
     return $oTemplate->render();
 }
Ejemplo n.º 5
0
 function copy($oSrcFolder, $oDestFolder, $oUser, $sReason, $sDestFolderName = NULL, $copyAll = true)
 {
     $sDestFolderName = empty($sDestFolderName) ? $oSrcFolder->getName() : $sDestFolderName;
     if (KTFolderUtil::exists($oDestFolder, $sDestFolderName)) {
         return PEAR::raiseError(_kt("Folder with the same name already exists in the new parent folder"));
     }
     //
     // FIXME the failure cleanup code here needs some serious work.
     //
     $oPerm = KTPermission::getByName('ktcore.permissions.read');
     $oBaseFolderPerm = KTPermission::getByName('ktcore.permissions.addFolder');
     if (!KTPermissionUtil::userHasPermissionOnItem($oUser, $oBaseFolderPerm, $oDestFolder)) {
         return PEAR::raiseError(_kt('You are not allowed to create folders in the destination.'));
     }
     // Check if the source folder inherits its permissions
     // Get source PO id and its parent PO id
     $iSrcPoId = $oSrcFolder->getPermissionObjectID();
     $oSrcParent = Folder::get($oSrcFolder->getParentID());
     $iSrcParentPoId = $oSrcParent->getPermissionObjectID();
     // If the folder defines its own permissions then we copy the permission object
     // If the source folder inherits permissions we must change it to inherit from the new parent folder
     $bInheritPermissions = false;
     if ($iSrcPoId == $iSrcParentPoId) {
         $bInheritPermissions = true;
     }
     $aFolderIds = array();
     // of oFolder
     $aDocuments = array();
     // of oDocument
     $aFailedDocuments = array();
     // of String
     $aFailedFolders = array();
     // of String
     $aRemainingFolders = array($oSrcFolder->getId());
     DBUtil::startTransaction();
     while (!empty($aRemainingFolders) && $copyAll) {
         $iFolderId = array_pop($aRemainingFolders);
         $oFolder = Folder::get($iFolderId);
         if (PEAR::isError($oFolder) || $oFolder == false) {
             DBUtil::rollback();
             return PEAR::raiseError(sprintf(_kt('Failure resolving child folder with id = %d.'), $iFolderId));
         }
         // don't just stop ... plough on.
         if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oFolder)) {
             $aFolderIds[] = $iFolderId;
         } else {
             $aFailedFolders[] = $oFolder->getName();
         }
         // child documents
         $aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId)));
         foreach ($aChildDocs as $oDoc) {
             if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDoc)) {
                 $aDocuments[] = $oDoc;
             } else {
                 $aFailedDocuments[] = $oDoc->getName();
             }
         }
         // child folders.
         $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
         $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
     }
     if (!empty($aFailedDocuments) || !empty($aFailedFolders)) {
         $sFD = '';
         $sFF = '';
         if (!empty($aFailedDocuments)) {
             $sFD = _kt('Documents: ') . implode(', ', $aFailedDocuments) . '. ';
         }
         if (!empty($aFailedFolders)) {
             $sFF = _kt('Folders: ') . implode(', ', $aFailedFolders) . '.';
         }
         return PEAR::raiseError(_kt('You do not have permission to copy these items. ') . $sFD . $sFF);
     }
     // first we walk the tree, creating in the new location as we go.
     // essentially this is an "ok" pass.
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $aFolderMap = array();
     $sTable = 'folders';
     $sGetQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ? ';
     $aParams = array($oSrcFolder->getId());
     $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams));
     unset($aRow['id']);
     $aRow['name'] = $sDestFolderName;
     $aRow['description'] = $sDestFolderName;
     $aRow['parent_id'] = $oDestFolder->getId();
     $aRow['parent_folder_ids'] = sprintf('%s,%s', $oDestFolder->getParentFolderIDs(), $oDestFolder->getId());
     $aRow['full_path'] = $oDestFolder->getFullPath() . '/' . $aRow['name'];
     $id = DBUtil::autoInsert($sTable, $aRow);
     if (PEAR::isError($id)) {
         DBUtil::rollback();
         return $id;
     }
     $sSrcFolderId = $oSrcFolder->getId();
     $aFolderMap[$sSrcFolderId]['parent_id'] = $id;
     $aFolderMap[$sSrcFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids'];
     $aFolderMap[$sSrcFolderId]['full_path'] = $aRow['full_path'];
     $aFolderMap[$sSrcFolderId]['name'] = $aRow['name'];
     $oNewBaseFolder = Folder::get($id);
     $res = $oStorage->createFolder($oNewBaseFolder);
     if (PEAR::isError($res)) {
         // it doesn't exist, so rollback and raise..
         DBUtil::rollback();
         return $res;
     }
     $aRemainingFolders = Folder::getList(array('parent_id = ?', array($oSrcFolder->getId())), array('ids' => true));
     while (!empty($aRemainingFolders) && $copyAll) {
         $iFolderId = array_pop($aRemainingFolders);
         $aParams = array($iFolderId);
         $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams));
         unset($aRow['id']);
         // since we are nested, we will have solved the parent first.
         $sPrevParentId = $aRow['parent_id'];
         $aRow['parent_id'] = $aFolderMap[$aRow['parent_id']]['parent_id'];
         $aRow['parent_folder_ids'] = sprintf('%s,%s', $aFolderMap[$sPrevParentId]['parent_folder_ids'], $aRow['parent_id']);
         $aRow['full_path'] = sprintf('%s/%s', $aFolderMap[$sPrevParentId]['full_path'], $aRow['name']);
         $id = DBUtil::autoInsert($sTable, $aRow);
         if (PEAR::isError($id)) {
             $oStorage->removeFolder($oNewBaseFolder);
             DBUtil::rollback();
             return $id;
         }
         $aFolderMap[$iFolderId]['parent_id'] = $id;
         $aFolderMap[$iFolderId]['parent_folder_ids'] = $aRow['parent_folder_ids'];
         $aFolderMap[$iFolderId]['full_path'] = $aRow['full_path'];
         $aFolderMap[$iFolderId]['name'] = $aRow['name'];
         $oNewFolder = Folder::get($id);
         $res = $oStorage->createFolder($oNewFolder);
         if (PEAR::isError($res)) {
             // first delete, then rollback, then fail out.
             $oStorage->removeFolder($oNewBaseFolder);
             DBUtil::rollback();
             return $res;
         }
         $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
         $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
     }
     // now we can go ahead.
     foreach ($aDocuments as $oDocument) {
         $oChildDestinationFolder = Folder::get($aFolderMap[$oDocument->getFolderID()]['parent_id']);
         $res = KTDocumentUtil::copy($oDocument, $oChildDestinationFolder);
         if (PEAR::isError($res) || $res === false) {
             $oStorage->removeFolder($oNewBaseFolder);
             DBUtil::rollback();
             return PEAR::raiseError(_kt('Delete Aborted. Unexpected failure to copydocument: ') . $oDocument->getName() . $res->getMessage());
         }
     }
     $sComment = sprintf(_kt("Folder copied from %s to %s"), $oSrcFolder->getFullPath(), $oDestFolder->getFullPath());
     if ($sReason !== null) {
         $sComment .= sprintf(_kt(" (reason: %s)"), $sReason);
     }
     $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $oFolder->getId(), 'comment' => $sComment, 'transactionNS' => 'ktcore.transactions.copy', 'userid' => $oUser->getId(), 'ip' => Session::getClientIP()));
     // If the folder inherits its permissions then we set it to inherit from the new parent folder and update permissions
     // If it defines its own then copy the permission object over
     if ($bInheritPermissions) {
         $aOptions = array('evenifnotowner' => true);
         KTPermissionUtil::inheritPermissionObject($oNewBaseFolder, $aOptions);
     } else {
         KTPermissionUtil::copyPermissionObject($oNewBaseFolder);
     }
     // and store
     DBUtil::commit();
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Updates permission lookups for this folder and any ancestors, but
  * only if they use the same permission object.
  *
  * To be used any time a folder permission object is changed.
  */
 function updatePermissionLookupRecursive(&$oDocumentOrFolder)
 {
     if (is_a($oDocumentOrFolder, 'Document')) {
         // XXX: metadata versions may need attention here
         KTPermissionUtil::updatePermissionLookup($oDocumentOrFolder);
         return;
     }
     $iFolderID = $oDocumentOrFolder->getID();
     $sFolderIDs = Folder::generateFolderIDs($iFolderID);
     $sFolderIDs .= '%';
     $sWhere = 'permission_object_id = ? AND parent_folder_ids LIKE ?';
     $aParams = array($oDocumentOrFolder->getPermissionObjectID(), $sFolderIDs);
     $aFolders =& Folder::getList(array($sWhere, $aParams));
     foreach ($aFolders as $oFolder) {
         KTPermissionUtil::updatePermissionLookup($oFolder);
     }
     $aDocuments =& Document::getList(array($sWhere, $aParams));
     foreach ($aDocuments as $oDocument) {
         KTPermissionUtil::updatePermissionLookup($oDocument);
     }
 }
Ejemplo n.º 7
0
 $setting_profile_block = $_POST['setting_profile_block'];
 $download_allow = $_POST['download_allow'];
 $download_option_show = $_POST['download_option_show'];
 $secure_allow = $_POST['secure_allow'];
 $secure_option_show = $_POST['secure_option_show'];
 $email_allow = $_POST['email_allow'];
 $email_option_show = $_POST['email_option_show'];
 $license_key = $_POST['lsettings'];
 $document = new Document($api_key, $secret_key);
 $return_lsettings = document_lsettings($license_key, 'document');
 if (!empty($return_lsettings)) {
     $is_error = 1;
     $smarty->assign('error_message_lsetting', $return_lsettings);
 }
 try {
     $result = $document->getList();
 } catch (Exception $e) {
     $code = $e->getCode();
     if ($code == 401) {
         $message = $e->getMessage() . ': Api key is not correct';
         $is_error = 1;
         $smarty->assign('api_error', $message);
     }
 }
 if ($secret_key == "") {
     $is_error = 1;
     $smarty->assign('error', 650003124);
 }
 if ($_POST['submit'] == 'Update') {
     if ($is_error != 1) {
         $query = "UPDATE se_document_parameters SET api_key = '" . $api_key . "', secret_key = '" . $secret_key . "', default_visibility='" . $default_visibility . "', visibility_option='" . $visibility_option . "',  secure_allow='" . $secure_allow . "', secure_option_show='" . $secure_option_show . "',  download_allow='" . $download_allow . "', download_option_show='" . $download_option_show . "', email_allow='" . $email_allow . "', email_option_show='" . $email_option_show . "', licensing_scribd='" . $licensing_scribd . "', licensing_option='" . $licensing_option . "', download_format='" . $download_format . "',  include_full_text = '" . $include_full_text . "', save_local_server = '" . $save_local_server . "', permission_document = '{$setting_permission}', document_block = '{$setting_profile_block}', license_key = '{$license_key}' WHERE id = 1";
Ejemplo n.º 8
0
function showDocs()
{
    global $connector;
    global $result;
    $course = new Course();
    $doc = new Document();
    $course->setConnector($connector);
    $doc->setConnector($connector);
    if (isset($_POST['operation'])) {
        list($operation, $params) = explode("#", $_POST['operation']);
        switch ($operation) {
            case 'saveChanges':
                $doc->storeFormValues($_POST, BASE_PATH . "/upload/");
                $error_msg = $doc->insert();
                break;
            case 'delete':
                $error_msg = $doc->delete($params);
                break;
            default:
                $error_msg = "Operazione non valida";
        }
        if ($error_msg != "") {
            $result["errorMessage"] = $error_msg;
        } elseif ($operation != 'edit') {
            $result["statusMessage"] = "Operazione completata!";
        }
    }
    $result["courses"] = $course->getList("nome");
    $result['docs'] = $doc->getList();
    $page = "document.php";
    include_once BASE_PATH . "template.php";
}
Ejemplo n.º 9
0
 public function portletModifiedDocumentsAction()
 {
     $list = Document::getList(array("limit" => 10, "order" => "DESC", "orderKey" => "modificationDate"));
     $response = array();
     $response["documents"] = array();
     foreach ($list as $doc) {
         $response["documents"][] = array("id" => $doc->getId(), "type" => $doc->getType(), "path" => $doc->getFullPath(), "date" => $doc->getModificationDate(), "condition" => "userModification = '" . $this->getUser()->getId() . "'");
     }
     $this->_helper->json($response);
 }
Ejemplo n.º 10
0
 function is_active($oUser)
 {
     $this->oUser = $oUser;
     $this->checked_out_documents = Document::getList(array('checked_out_user_id = ?', $this->oUser->getId()));
     global $default;
     $oConfig =& KTConfig::getSingleton();
     if ($oConfig->get('dashboard/alwaysShowYCOD')) {
         return true;
     }
     return !empty($this->checked_out_documents);
 }
Ejemplo n.º 11
0
}
print "\n";
print "Would remove these files:\n";
foreach ($aFilesToRemove as $path) {
    print "\t{$path}\n";
}
print "\n";
$aFolders =& Folder::getList();
foreach ($aFolders as $oFolder) {
    checkRepoFolder($oFolder);
}
print "These folders are not on the filesystem:\n";
foreach ($aRepoFolderProblems as $path) {
    print "\t{$path}\n";
}
$aDocuments =& Document::getList(array('status_id = ?', array(LIVE)));
foreach ($aDocuments as $oDocument) {
    checkRepoDocument($oDocument);
}
print "\n";
print "These documents are not on the filesystem:\n";
foreach ($aRepoDocumentProblems as $path) {
    print "\t{$path}\n";
}
print "\n";
print "These documents have versions not on the filesystem:\n";
foreach ($aRepoVersionProblems as $path) {
    list($path, $version) = $path;
    print "\t{$path} - version {$version}\n";
}
print "\n";
Ejemplo n.º 12
0
 /**
  * Get's a folder listing, recursing to the maximum depth.
  * Derived from the get_listing function.
  *
  * <code>
  * $root = $this->ktapi->get_root_folder();
  * $listing = $root->get_full_listing();
  * foreach($listing as $val) {
  * 	if($val['item_type'] == 'F') {
  *   // It's a folder
  *   echo $val['title'];
  *  }
  * }
  * </code>
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $what
  * @return array
  */
 function get_full_listing($what = 'DFS')
 {
     $what = strtoupper($what);
     $read_permission =& KTPermission::getByName(KTAPI_PERMISSION_READ);
     $folder_permission =& KTPermission::getByName(KTAPI_PERMISSION_VIEW_FOLDER);
     $config = KTConfig::getSingleton();
     $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
     $user = $this->ktapi->get_user();
     $contents = array();
     if (strpos($what, 'F') !== false) {
         $folder_children = Folder::getList(array('parent_id = ?', $this->folderid));
         foreach ($folder_children as $folder) {
             if (KTPermissionUtil::userHasPermissionOnItem($user, $folder_permission, $folder) || KTPermissionUtil::userHasPermissionOnItem($user, $read_permission, $folder)) {
                 $sub_folder =& $this->ktapi->get_folder_by_id($folder->getId());
                 if (!PEAR::isError($sub_folder)) {
                     $items = $sub_folder->get_full_listing($what);
                 } else {
                     $items = array();
                 }
                 $creator = $this->_resolve_user($folder->getCreatorID());
                 if ($wsversion >= 2) {
                     $array = array('id' => (int) $folder->getId(), 'item_type' => 'F', 'custom_document_no' => 'n/a', 'oem_document_no' => 'n/a', 'title' => $folder->getName(), 'document_type' => 'n/a', 'filename' => $folder->getName(), 'filesize' => 'n/a', 'created_by' => is_null($creator) ? 'n/a' : $creator->getName(), 'created_date' => 'n/a', 'checked_out_by' => 'n/a', 'checked_out_date' => 'n/a', 'modified_by' => 'n/a', 'modified_date' => 'n/a', 'owned_by' => 'n/a', 'version' => 'n/a', 'is_immutable' => 'n/a', 'permissions' => KTAPI_Folder::get_permission_string($folder), 'workflow' => 'n/a', 'workflow_state' => 'n/a', 'mime_type' => 'folder', 'mime_icon_path' => 'folder', 'mime_display' => 'Folder', 'storage_path' => 'n/a');
                     if ($wsversion >= 3) {
                         $array['linked_folder_id'] = $folder->getLinkedFolderId();
                         if ($folder->isSymbolicLink()) {
                             $array['item_type'] = "S";
                         }
                     }
                     $array['items'] = $items;
                     if ($wsversion < 3 || strpos($what, 'F') !== false && !$folder->isSymbolicLink() || $folder->isSymbolicLink() && strpos($what, 'S') !== false) {
                         $contents[] = $array;
                     }
                 } else {
                     $contents[] = array('id' => (int) $folder->getId(), 'item_type' => 'F', 'title' => $folder->getName(), 'creator' => is_null($creator) ? 'n/a' : $creator->getName(), 'checkedoutby' => 'n/a', 'modifiedby' => 'n/a', 'filename' => $folder->getName(), 'size' => 'n/a', 'major_version' => 'n/a', 'minor_version' => 'n/a', 'storage_path' => 'n/a', 'mime_type' => 'folder', 'mime_icon_path' => 'folder', 'mime_display' => 'Folder', 'items' => $items, 'workflow' => 'n/a', 'workflow_state' => 'n/a');
                 }
             }
         }
     }
     if (strpos($what, 'D') !== false) {
         $document_children = Document::getList(array('folder_id = ? AND status_id = 1', $this->folderid));
         // I hate that KT doesn't cache things nicely...
         $mime_cache = array();
         foreach ($document_children as $document) {
             if (KTPermissionUtil::userHasPermissionOnItem($user, $read_permission, $document)) {
                 $created_by = $this->_resolve_user($document->getCreatorID());
                 $created_date = $document->getCreatedDateTime();
                 if (empty($created_date)) {
                     $created_date = 'n/a';
                 }
                 $checked_out_by = $this->_resolve_user($document->getCheckedOutUserID());
                 $checked_out_date = $document->getCheckedOutDate();
                 if (empty($checked_out_date)) {
                     $checked_out_date = 'n/a';
                 }
                 $modified_by = $this->_resolve_user($document->getCreatorID());
                 $modified_date = $document->getLastModifiedDate();
                 if (empty($modified_date)) {
                     $modified_date = 'n/a';
                 }
                 $owned_by = $this->_resolve_user($document->getOwnerID());
                 $mimetypeid = $document->getMimeTypeID();
                 if (!array_key_exists($mimetypeid, $mime_cache)) {
                     $type = KTMime::getMimeTypeName($mimetypeid);
                     $icon = KTMime::getIconPath($mimetypeid);
                     $display = KTMime::getFriendlyNameForString($type);
                     $mime_cache[$mimetypeid] = array('type' => $type, 'icon' => $icon, 'display' => $display);
                 }
                 $mimeinfo = $mime_cache[$mimetypeid];
                 $workflow = 'n/a';
                 $state = 'n/a';
                 $wf = KTWorkflowUtil::getWorkflowForDocument($document);
                 if (!is_null($wf) && !PEAR::isError($wf)) {
                     $workflow = $wf->getHumanName();
                     $ws = KTWorkflowUtil::getWorkflowStateForDocument($document);
                     if (!is_null($ws) && !PEAR::isError($ws)) {
                         $state = $ws->getHumanName();
                     }
                 }
                 if ($wsversion >= 2) {
                     $docTypeId = $document->getDocumentTypeID();
                     $documentType = DocumentType::get($docTypeId);
                     $oemDocumentNo = $document->getOemNo();
                     if (empty($oemDocumentNo)) {
                         $oemDocumentNo = 'n/a';
                     }
                     $array = array('id' => (int) $document->getId(), 'item_type' => 'D', 'custom_document_no' => 'n/a', 'oem_document_no' => $oemDocumentNo, 'title' => $document->getName(), 'document_type' => $documentType->getName(), 'filename' => $document->getFileName(), 'filesize' => $document->getFileSize(), 'created_by' => is_null($created_by) ? 'n/a' : $created_by->getName(), 'created_date' => $created_date, 'checked_out_by' => is_null($checked_out_by) ? 'n/a' : $checked_out_by->getName(), 'checked_out_date' => $checked_out_date, 'modified_by' => is_null($modified_by) ? 'n/a' : $modified_by->getName(), 'modified_date' => $modified_date, 'owned_by' => is_null($owned_by) ? 'n/a' : $owned_by->getName(), 'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(), 'content_id' => $document->getContentVersionId(), 'is_immutable' => $document->getImmutable() ? 'true' : 'false', 'permissions' => KTAPI_Document::get_permission_string($document), 'workflow' => $workflow, 'workflow_state' => $state, 'mime_type' => $mime_cache[$mimetypeid]['type'], 'mime_icon_path' => $mime_cache[$mimetypeid]['icon'], 'mime_display' => $mime_cache[$mimetypeid]['display'], 'storage_path' => $document->getStoragePath());
                     if ($wsversion >= 3) {
                         $document->switchToRealCore();
                         $array['linked_document_id'] = $document->getLinkedDocumentId();
                         $document->switchToLinkedCore();
                         if ($document->isSymbolicLink()) {
                             $array['item_type'] = "S";
                         }
                     }
                     $array['items'] = array();
                     if ($wsversion < 3 || strpos($what, 'D') !== false && !$document->isSymbolicLink() || $document->isSymbolicLink() && strpos($what, 'S') !== false) {
                         $contents[] = $array;
                     }
                 } else {
                     $contents[] = array('id' => (int) $document->getId(), 'item_type' => 'D', 'title' => $document->getName(), 'creator' => is_null($created_by) ? 'n/a' : $created_by->getName(), 'checkedoutby' => is_null($checked_out_by) ? 'n/a' : $checked_out_by->getName(), 'modifiedby' => is_null($modified_by) ? 'n/a' : $modified_by->getName(), 'filename' => $document->getFileName(), 'size' => $document->getFileSize(), 'major_version' => $document->getMajorVersionNumber(), 'minor_version' => $document->getMinorVersionNumber(), 'storage_path' => $document->getStoragePath(), 'mime_type' => $mime_cache[$mimetypeid]['type'], 'mime_icon_path' => $mime_cache[$mimetypeid]['icon'], 'mime_display' => $mime_cache[$mimetypeid]['display'], 'items' => array(), 'workflow' => $workflow, 'workflow_state' => $state);
                 }
             }
         }
     }
     return $contents;
 }
Ejemplo n.º 13
0
if (!$user->level_info['level_document_allow']) {
    header("Location: user_home.php");
    exit;
}
$submit_value = 'Publish';
$document_attachment = 1;
$document_download = 1;
$document_secure = 1;
$error_array = array();
$query = "SELECT * FROM se_document_parameters";
$params = $database->database_fetch_assoc($database->database_query($query));
$scribd_api_key = $params['api_key'];
$scribd_secret = $params['secret_key'];
$scribd = new Document($scribd_api_key, $scribd_secret, $user->user_info['user_id']);
try {
    $result = $scribd->getList();
} catch (Exception $e) {
    $code = $e->getCode();
    if ($code == 401) {
        $message = $e->getMessage() . ': Api key is not correct';
        $is_error = 1;
        $smarty->assign('api_error', $message);
    }
}
if ($is_error == 1) {
    $page = "error";
    $smarty->assign('error_header', 639);
    $smarty->assign('error_message', 650003224);
    $smarty->assign('error_submit', 641);
    include "footer.php";
}
Ejemplo n.º 14
0
 /**
  * Checks if there are symlinks that are linking to items in the current list
  * Useful if you want to prompt the user with a confirmation because they're
  * automatically deleted when their targets are deleted or archived.
  *
  * @return boolean
  */
 function symlinksLinkingToCurrentList()
 {
     $symlinksPresent = false;
     foreach ($this->oActiveEntityList->getDocumentIds() as $iDocument) {
         $oDocument = Document::get($iDocument);
         if (count($oDocument->getSymbolicLinks()) > 0) {
             $symlinksPresent = true;
             break;
         }
     }
     if ($symlinksPresent == false) {
         foreach ($this->oActiveEntityList->getFolderIds() as $iFolder) {
             $oStartFolder = Folder::get($iFolder);
             $aRemainingFolders = array($oStartFolder->getId());
             while (!empty($aRemainingFolders)) {
                 $iFolderId = array_pop($aRemainingFolders);
                 $oFolder = Folder::get($iFolderId);
                 if (count($oFolder->getSymbolicLinks()) > 0) {
                     $symlinksPresent = true;
                     break;
                 }
                 $aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId)));
                 foreach ($aChildDocs as $oDoc) {
                     if (count($oDoc->getSymbolicLinks()) > 0) {
                         $symlinksPresent = true;
                         break;
                     }
                 }
                 $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true));
                 $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds);
             }
         }
     }
     return $symlinksPresent;
 }
Ejemplo n.º 15
0
 /**
  * @param string $condition
  * @param string $order
  * @param string $orderKey
  * @param string $offset
  * @param string $limit
  * @param string $groupBy
  * @return Webservice_Data_Document_List_Item[]
  */
 public function getDocumentList($condition = null, $order = null, $orderKey = null, $offset = null, $limit = null, $groupBy = null)
 {
     try {
         $list = Document::getList(array("condition" => $condition, "order" => $order, "orderKey" => $orderKey, "offset" => $offset, "limit" => $limit, "groupBy" => $groupBy));
         $items = array();
         foreach ($list as $doc) {
             $item = new Webservice_Data_Document_List_Item();
             $item->id = $doc->getId();
             $item->type = $doc->getType();
             $items[] = $item;
         }
         return $items;
     } catch (Exception $e) {
         Logger::error($e);
         throw $e;
     }
 }
Ejemplo n.º 16
0
function homepage()
{
    global $connector;
    global $result;
    if (isset($_SESSION['admin'])) {
        header("Location: admin/");
    }
    if (isset($_SESSION['login'])) {
        include_once "classes/Student.php";
        include_once "classes/Exam.php";
        include_once "classes/Plan.php";
        include_once "classes/Payment.php";
        include_once "classes/Notice.php";
        include_once "classes/Booking.php";
        include_once "classes/Document.php";
        $student = new Student();
        $student->setConnector($connector);
        $student = $student->getById($_SESSION['id_student']);
        $student->setConnector($connector);
        $exam = new Exam();
        $plan = new Plan();
        $payment = new Payment();
        $notice = new Notice();
        $booking = new Booking();
        $document = new Document();
        $exam->setConnector($connector);
        $plan->setConnector($connector);
        $payment->setConnector($connector);
        $notice->setConnector($connector);
        $booking->setConnector($connector);
        $document->setConnector($connector);
        if (isset($_POST['operation'])) {
            list($operation, $params) = explode("#", $_POST['operation']);
            switch ($operation) {
                case 'editChanges':
                    $student->storeFormValues($_POST);
                    $student->id = $params;
                    if (isset($_POST['password']) && $_POST['password'] != '') {
                        $student->generatePassword($_POST['password']);
                    }
                    $error_msg = $student->update();
                    break;
                case 'saveBook':
                    $error_msg = $booking->saveBooking($student->id, $params);
                    break;
                case 'sendMail':
                    $error_msg = sendMail();
                    break;
                default:
                    $error_msg = $operation . "#" . $params;
                    break;
            }
            if ($error_msg != "") {
                $result["errorMessage"] = $error_msg;
            } elseif ($operation != 'edit' && $operation != "nextPage") {
                $result["statusMessage"] = "Operazione completata!";
            }
        }
        if ($student) {
            $result["edit"] = $student;
            $result["edit"]->exam = $exam->getList($student);
            $result["edit"]->plan = $plan->getById($student->id_plan);
            $result['edit']->payment = $payment->getById($student->id);
            $result['edit']->notice = $notice->getList();
            $result['edit']->booking = $booking->getListForStudent($student);
            $result['edit']->booked = $booking->getBookedList($student->id);
            $result['edit']->document = $document->getList();
        }
        $page = "home.php";
        include_once BASE_PATH . "/template.php";
    } else {
        $page = "login.php";
        include_once BASE_PATH . "/template.php";
    }
}
Ejemplo n.º 17
0
 /**
  * Get a list of Documents
  *
  * @param  String  Where clause (not required)
  * @return Array array of Documents objects, false otherwise.
  */
 public static function getList($whereClause = null)
 {
     return Document::getList($whereClause);
 }
Ejemplo n.º 18
0
 function renegeratePermissionsForRole($iRoleId, $iFolderId)
 {
     $iStartFolderId = $iFolderId;
     /*
      * 1. find all folders & documents "below" this one which use the role
      *    definition _active_ (not necessarily present) at this point.
      * 2. tell permissionutil to regen their permissions.
      *
      * The find algorithm is:
      *
      *  folder_queue <- (iStartFolderId)
      *  while folder_queue is not empty:
      *     active_folder =
      *     for each folder in the active_folder:
      *         find folders in _this_ folder without a role-allocation on the iRoleId
      *            add them to the folder_queue
      *         update the folder's permissions.
      *         find documents in this folder:
      *            update their permissions.
      */
     $sRoleAllocTable = KTUtil::getTableName('role_allocations');
     $sFolderTable = KTUtil::getTableName('folders');
     $sQuery = sprintf('SELECT f.id as id FROM %s AS f LEFT JOIN %s AS ra ON (f.id = ra.folder_id) WHERE ra.id IS NULL AND f.parent_id = ?', $sFolderTable, $sRoleAllocTable);
     $folder_queue = array($iStartFolderId);
     while (!empty($folder_queue)) {
         $active_folder = array_pop($folder_queue);
         $aParams = array($active_folder);
         $aNewFolders = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id');
         if (PEAR::isError($aNewFolders)) {
             //$this->errorRedirectToMain(_kt('Failure to generate folderlisting.'));
             echo _kt('Failure to generate folderlisting.');
         }
         $folder_queue = kt_array_merge($folder_queue, (array) $aNewFolders);
         // push.
         // update the folder.
         $oFolder =& Folder::get($active_folder);
         if (PEAR::isError($oFolder) || $oFolder == false) {
             //$this->errorRedirectToMain(_kt('Unable to locate folder: ') . $active_folder);
             echo _kt('Unable to locate folder: ') . $active_folder;
         }
         KTPermissionUtil::updatePermissionLookup($oFolder);
         $aDocList =& Document::getList(array('folder_id = ?', $active_folder));
         if (PEAR::isError($aDocList) || $aDocList === false) {
             //$this->errorRedirectToMain(sprintf(_kt('Unable to get documents in folder %s: %s'), $active_folder, $aDocList->getMessage()));
             echo _kt('Unable to get documents in folder ') . $active_folder;
         }
         foreach ($aDocList as $oDoc) {
             if (!PEAR::isError($oDoc)) {
                 KTPermissionUtil::updatePermissionLookup($oDoc);
             }
         }
     }
 }
Ejemplo n.º 19
0
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * KnowledgeTree" logo and retain the original copyright notice. If the display of the 
 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
 * must display the words "Powered by KnowledgeTree" and retain the original 
 * copyright notice.
 * Contributor( s): ______________________________________
 */
require_once '../../../config/dmsDefaults.php';
require_once KT_LIB_DIR . '/browse/browseutil.inc.php';
require_once KT_LIB_DIR . '/documentmanagement/Document.inc';
require_once KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc';
$sWhere = "status_id=" . DELETED;
$aDocuments =& Document::getList($sWhere);
$pageNum = $_REQUEST['page'];
$items = count($aDocuments);
if (fmod($items, 10) > 0) {
    $pages = floor($items / 10) + 1;
} else {
    $pages = $items / 10;
}
for ($i = 1; $i <= $pages; $i++) {
    $aPages[] = $i;
}
if ($pageNum == 1) {
    $listStart = 0;
    $listEnd = 9;
} elseif ($pageNum == $pages) {
    $listStart = 10 * ($pageNum - 1);
Ejemplo n.º 20
0
 /**
  * PROPFIND helper for Folders
  *
  * @param array  options
  * @param array  Return array for file props
  * @param int  Folder ID
  * @return bool   true on success
  */
 function _PROPFINDFolder(&$options, &$files, $iFolderID)
 {
     global $default;
     $this->ktwebdavLog("Entering PROPFINDFolder. options are " . print_r($options, true), 'info', true);
     $folder_path = $options["path"];
     if (substr($folder_path, -1) != "/") {
         $folder_path .= "/";
     }
     $options["path"] = $folder_path;
     $files["files"] = array();
     $files["files"][] = $this->_fileinfoForFolderID($iFolderID, $folder_path);
     $oPerm =& KTPermission::getByName('ktcore.permissions.read');
     $oUser =& User::get($this->userID);
     if (!empty($options["depth"])) {
         $aChildren = Folder::getList(array('parent_id = ?', $iFolderID));
         // FIXME: Truncation Time Workaround
         //foreach (array_slice($aChildren, 0, 50) as $oChildFolder) {
         foreach ($aChildren as $oChildFolder) {
             // Check if the user has permissions to view this folder
             $oFolderDetailsPerm =& KTPermission::getByName('ktcore.permissions.folder_details');
             if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oFolderDetailsPerm, $oChildFolder)) {
                 $this->ktwebdavLog("Folder Details permissions GRANTED for user " . $_SESSION["userID"] . " on folder " . $oChildFolder->getName(), 'info', true);
                 $files["files"][] = $this->_fileinfoForFolder($oChildFolder, $folder_path . $oChildFolder->getName());
             } else {
                 $this->ktwebdavLog("Folder Details permissions DENIED for " . $_SESSION["userID"] . " on folder " . $oChildFolder->getName(), 'info', true);
             }
         }
         $aDocumentChildren = Document::getList(array('folder_id = ? AND status_id = 1', $iFolderID));
         // FIXME: Truncation Time Workaround
         //foreach (array_slice($aDocumentChildren, 0, 50) as $oChildDocument) {
         foreach ($aDocumentChildren as $oChildDocument) {
             // Check if the user has permissions to view this document
             if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oChildDocument)) {
                 $this->ktwebdavLog("Read permissions GRANTED for " . $_SESSION["userID"] . " on document " . $oChildDocument->getName(), 'info', true);
                 $files["files"][] = $this->_fileinfoForDocument($oChildDocument, $folder_path . $oChildDocument->getFileName());
             } else {
                 $this->ktwebdavLog("Read permissions DENIED for " . $_SESSION["userID"] . " on document " . $oChildDocument->getName(), 'info', true);
             }
         }
     }
     return true;
 }
Ejemplo n.º 21
0
     echo json_encode(Snapshot::getList($document));
     break;
 case 'saveSnapshot':
     $document = Document::fromDatabase($_POST['documentID']);
     Snapshot::create($document, json_decode(stripslashes($_POST['documentData']), true), $_POST['timestamp']);
     break;
 case 'loadSnapshot':
     $document = Document::fromDatabase($_POST['documentID']);
     echo json_encode(Snapshot::getData($document, $_POST['snapshotID']));
     break;
 case 'deleteDocument':
     $document = Document::fromDatabase($_POST['id']);
     $document->delete();
     break;
 case 'loadDocuments':
     echo json_encode(Document::getList(Document::FORMAT_JSON));
     break;
 case 'createDocument':
     $document = Document::create($_POST['name']);
     echo $document->getId();
     break;
 case 'renameDocument':
     $document = Document::fromDatabase($_POST['id']);
     $document->rename($_POST['newname']);
     break;
 case 'copyDocument':
     $document = Document::fromDatabase($_POST['id']);
     $newdoc = $document->copy($_POST['copyname']);
     echo json_encode($newdoc->toJSON());
     break;
 case 'exportDocument':