2012-08-28 08:48:56 +00:00
|
|
|
<?php
|
|
|
|
// MyDMS. Document Management System
|
2016-08-09 05:34:30 +00:00
|
|
|
// Copyright (C) 2010-2016 Uwe Steinmann
|
2012-08-28 08:48:56 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2020-12-01 17:23:48 +00:00
|
|
|
require_once("../inc/inc.Settings.php");
|
|
|
|
require_once("../inc/inc.Utils.php");
|
2022-11-09 05:40:50 +00:00
|
|
|
require_once("../inc/inc.LogInit.php");
|
2020-12-01 17:23:48 +00:00
|
|
|
require_once("../inc/inc.Language.php");
|
|
|
|
require_once("../inc/inc.Init.php");
|
|
|
|
require_once("../inc/inc.Extension.php");
|
|
|
|
require_once("../inc/inc.DBInit.php");
|
|
|
|
require_once("../inc/inc.ClassNotificationService.php");
|
|
|
|
require_once("../inc/inc.ClassEmailNotify.php");
|
|
|
|
require_once("../inc/inc.ClassUI.php");
|
|
|
|
require_once("../inc/inc.ClassController.php");
|
2023-03-31 10:00:56 +00:00
|
|
|
require_once("../inc/inc.Notification.php");
|
2012-08-28 08:48:56 +00:00
|
|
|
|
|
|
|
require_once("../inc/inc.ClassSession.php");
|
2020-12-01 17:23:48 +00:00
|
|
|
require_once("../inc/inc.ClassPasswordStrength.php");
|
|
|
|
require_once("../inc/inc.ClassPasswordHistoryManager.php");
|
2012-08-28 08:48:56 +00:00
|
|
|
|
|
|
|
/* Load session */
|
2013-01-29 13:12:12 +00:00
|
|
|
if (isset($_COOKIE["mydms_session"])) {
|
|
|
|
$dms_session = $_COOKIE["mydms_session"];
|
2013-02-14 11:10:53 +00:00
|
|
|
$session = new SeedDMS_Session($db);
|
2013-01-29 13:12:12 +00:00
|
|
|
if(!$resArr = $session->load($dms_session)) {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2013-01-29 13:12:12 +00:00
|
|
|
echo json_encode(array('error'=>1));
|
|
|
|
exit;
|
|
|
|
}
|
2012-08-28 08:48:56 +00:00
|
|
|
|
2014-05-22 04:39:54 +00:00
|
|
|
/* Update last access time */
|
|
|
|
$session->updateAccess($dms_session);
|
|
|
|
|
2013-01-29 13:12:12 +00:00
|
|
|
/* Load user data */
|
|
|
|
$user = $dms->getUser($resArr["userID"]);
|
|
|
|
if (!is_object($user)) {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2013-01-29 13:12:12 +00:00
|
|
|
echo json_encode(array('error'=>1));
|
|
|
|
exit;
|
|
|
|
}
|
2016-08-02 11:37:04 +00:00
|
|
|
|
|
|
|
if($resArr["su"] && $su = $dms->getUser($resArr["su"])) {
|
|
|
|
if($user->isAdmin() || $user->maySwitchToUser($su)) {
|
|
|
|
$user = $su;
|
|
|
|
} else {
|
|
|
|
$session->resetSu();
|
2013-05-24 15:30:02 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-02 11:37:04 +00:00
|
|
|
$dms->setUser($user);
|
2020-12-18 09:08:30 +00:00
|
|
|
if($settings->_useHomeAsRootFolder && !$user->isAdmin() && $user->getHomeFolder()) {
|
|
|
|
$dms->checkWithinRootDir = true;
|
|
|
|
$dms->setRootFolderID($user->getHomeFolder());
|
|
|
|
}
|
2016-08-02 11:37:04 +00:00
|
|
|
$role = $user->getRole();
|
|
|
|
$dms->noReadForStatus = $role->getNoAccess();
|
|
|
|
|
2014-03-06 10:33:31 +00:00
|
|
|
include $settings->_rootDir . "languages/" . $resArr["language"] . "/lang.inc";
|
2013-01-29 13:12:12 +00:00
|
|
|
} else {
|
|
|
|
$user = null;
|
2012-08-28 08:48:56 +00:00
|
|
|
}
|
2013-01-29 13:12:12 +00:00
|
|
|
|
2016-08-22 16:13:57 +00:00
|
|
|
/* make sure the browser doesn't cache the output of this page.
|
|
|
|
* Edge doesn't if not explicitly told to not do it, see bug #280
|
|
|
|
*/
|
|
|
|
header("Cache-Control: no-cache,no-store");
|
|
|
|
|
2020-08-31 10:58:48 +00:00
|
|
|
$command = isset($_REQUEST["command"]) ? $_REQUEST["command"] : '';
|
2012-08-28 08:48:56 +00:00
|
|
|
switch($command) {
|
2014-04-08 08:41:53 +00:00
|
|
|
case 'checkpwstrength': /* {{{ */
|
2012-08-28 08:48:56 +00:00
|
|
|
$ps = new Password_Strength();
|
2013-09-03 06:19:59 +00:00
|
|
|
$ps->set_password($_REQUEST["pwd"]);
|
2012-08-28 08:48:56 +00:00
|
|
|
if($settings->_passwordStrengthAlgorithm == 'simple')
|
|
|
|
$ps->simple_calculate();
|
|
|
|
else
|
|
|
|
$ps->calculate();
|
|
|
|
$score = $ps->get_score();
|
|
|
|
if($settings->_passwordStrength) {
|
2012-12-17 18:30:08 +00:00
|
|
|
if($score >= $settings->_passwordStrength) {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2012-12-14 07:57:03 +00:00
|
|
|
echo json_encode(array('error'=>0, 'strength'=>$score, 'score'=>$score/$settings->_passwordStrength, 'ok'=>1));
|
2012-08-28 08:48:56 +00:00
|
|
|
} else {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2012-12-14 07:57:03 +00:00
|
|
|
echo json_encode(array('error'=>0, 'strength'=>$score, 'score'=>$score/$settings->_passwordStrength, 'ok'=>0));
|
2012-08-28 08:48:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2012-08-28 08:48:56 +00:00
|
|
|
echo json_encode(array('error'=>0, 'strength'=>$score));
|
|
|
|
}
|
2014-04-08 08:41:53 +00:00
|
|
|
break; /* }}} */
|
2012-08-28 08:48:56 +00:00
|
|
|
|
2014-03-06 10:33:31 +00:00
|
|
|
case 'sessioninfo': /* {{{ */
|
|
|
|
if($user) {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-03-06 10:33:31 +00:00
|
|
|
echo json_encode($resArr);
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2020-12-15 09:02:30 +00:00
|
|
|
/* Used for document chooser */
|
2013-06-18 16:14:41 +00:00
|
|
|
case 'searchdocument': /* {{{ */
|
2013-01-29 13:12:12 +00:00
|
|
|
if($user) {
|
|
|
|
$query = $_GET['query'];
|
2020-12-15 09:02:30 +00:00
|
|
|
$status = isset($_GET['status']) ? (is_array($_GET['status']) ? $_GET['status'] : array($_GET['status'])) : array();
|
2013-01-28 10:12:07 +00:00
|
|
|
|
2020-12-18 09:44:33 +00:00
|
|
|
$hits = $dms->search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$dms->getRootFolder(), $owner=null, $status, $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x1, $expirationstartdate=array(), $expirationenddate=array());
|
2013-01-29 13:12:12 +00:00
|
|
|
if($hits) {
|
|
|
|
$result = array();
|
|
|
|
foreach($hits['docs'] as $hit) {
|
2022-09-14 18:40:33 +00:00
|
|
|
if($hit->getAccessMode($user, 'search') >= M_READ) {
|
2020-12-15 09:02:30 +00:00
|
|
|
if($hit->getLatestContent()) {
|
2024-03-18 12:54:35 +00:00
|
|
|
// $result[] = $hit->getID().'#'.$hit->getName();
|
2024-03-23 10:56:11 +00:00
|
|
|
$result[] = array('type'=>'D', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getName()), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/')));
|
2020-12-15 09:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-29 13:12:12 +00:00
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode($result);
|
2013-01-28 10:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-18 16:14:41 +00:00
|
|
|
break; /* }}} */
|
2013-01-28 10:12:07 +00:00
|
|
|
|
2024-10-31 17:02:24 +00:00
|
|
|
/* This is used for searching folders in the folder selectors
|
|
|
|
* 1. the selector also having a tree
|
|
|
|
* 2. the selector based on select2 for <select class="chzn-select-folder" ...>
|
|
|
|
* $format is set to 'select2' in the second case.
|
|
|
|
*/
|
2013-06-18 16:14:41 +00:00
|
|
|
case 'searchfolder': /* {{{ */
|
2013-01-29 13:12:12 +00:00
|
|
|
if($user) {
|
2024-10-31 17:02:24 +00:00
|
|
|
$format = $_GET['format'] ?? '';
|
|
|
|
$query = $_GET['query'] ?? '';
|
|
|
|
if(!$query) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
if($format == 'select2')
|
|
|
|
echo json_encode(['results'=>[]]);
|
|
|
|
else
|
|
|
|
echo json_encode([]);
|
|
|
|
return;
|
|
|
|
}
|
2013-01-28 10:12:07 +00:00
|
|
|
|
2021-05-04 07:03:10 +00:00
|
|
|
if(false !== ($pos = strpos($query, '/'))) {
|
|
|
|
$subquery = substr($query, 0, $pos);
|
2024-10-31 17:02:24 +00:00
|
|
|
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(2), $startFolder=$dms->getRootFolder(), $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
|
2021-05-04 07:03:10 +00:00
|
|
|
if($hits) {
|
|
|
|
if(count($hits['folders']) == 1) {
|
|
|
|
$hit = $hits['folders'][0];
|
|
|
|
$basefolder = $dms->getFolder($hit->getID());
|
2022-09-14 16:07:57 +00:00
|
|
|
if($basefolder->getAccessMode($user, 'search') >= M_READ) {
|
|
|
|
if($subquery = substr($query, $pos+1)) {
|
2024-10-31 17:02:24 +00:00
|
|
|
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(2), $startFolder=$basefolder, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
|
2022-09-14 16:07:57 +00:00
|
|
|
if($hits) {
|
|
|
|
$result = array();
|
|
|
|
foreach($hits['folders'] as $hit) {
|
|
|
|
if($hit->getAccessMode($user, 'search') >= M_READ)
|
2024-03-30 11:12:47 +00:00
|
|
|
// $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/');
|
2024-10-31 17:02:24 +00:00
|
|
|
$result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getName()), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/')));
|
2022-09-14 16:07:57 +00:00
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
2024-10-31 17:02:24 +00:00
|
|
|
if($format == 'select2')
|
|
|
|
echo json_encode(['results'=>$result]);
|
|
|
|
else
|
|
|
|
echo json_encode($result);
|
2022-09-14 16:07:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$subfolders = $basefolder->getSubFolders();
|
|
|
|
$subfolders = SeedDMS_Core_DMS::filterAccess($subfolders, $user, M_READ);
|
2021-05-04 07:03:10 +00:00
|
|
|
$result = array();
|
2022-09-14 16:07:57 +00:00
|
|
|
foreach($subfolders as $subfolder) {
|
2022-11-29 16:33:04 +00:00
|
|
|
//$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName();
|
2024-03-30 11:12:47 +00:00
|
|
|
// $result[] = $subfolder->getID().'#'.$subfolder->getFolderPathPlain(true, '/');
|
2024-10-31 17:02:24 +00:00
|
|
|
$result[] = array('type'=>'F', 'id'=>$subfolder->getId(), 'name'=>htmlspecialchars($subfolder->getName()), 'path'=>htmlspecialchars($subfolder->getParent()->getFolderPathPlain(true, '/')));
|
2021-05-04 07:03:10 +00:00
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
2024-10-31 17:02:24 +00:00
|
|
|
if($format == 'select2')
|
|
|
|
echo json_encode(['results'=>$result]);
|
|
|
|
else
|
|
|
|
echo json_encode($result);
|
2021-05-04 07:03:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-18 09:08:30 +00:00
|
|
|
$hits = $dms->search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$dms->getRootFolder(), $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
|
2013-01-29 13:12:12 +00:00
|
|
|
if($hits) {
|
|
|
|
$result = array();
|
|
|
|
foreach($hits['folders'] as $hit) {
|
2022-09-14 16:07:57 +00:00
|
|
|
if($hit->getAccessMode($user, 'search') >= M_READ)
|
2024-03-30 11:12:47 +00:00
|
|
|
// $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/');
|
2024-10-31 17:02:24 +00:00
|
|
|
$result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getName()), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/')));
|
2013-01-29 13:12:12 +00:00
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
2024-10-31 17:02:24 +00:00
|
|
|
if($format == 'select2')
|
|
|
|
echo json_encode(['results'=>$result]);
|
|
|
|
else
|
|
|
|
echo json_encode($result);
|
2013-01-28 10:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-18 16:14:41 +00:00
|
|
|
break; /* }}} */
|
2013-05-24 15:30:02 +00:00
|
|
|
|
2019-08-08 07:32:42 +00:00
|
|
|
/* The subtree command is deprecated. It has been moved into view */
|
2019-02-04 13:51:19 +00:00
|
|
|
case 'subtree': /* {{{ */
|
2014-03-06 10:33:31 +00:00
|
|
|
if($user) {
|
|
|
|
if(empty($_GET['node']))
|
2020-12-17 20:31:03 +00:00
|
|
|
$folder = $dms->getHomeFolder();
|
2014-03-06 10:33:31 +00:00
|
|
|
else
|
2020-12-17 20:31:03 +00:00
|
|
|
$folder = $dms->getFolder((int) $_GET['node']);
|
|
|
|
if (!is_object($folder)) return '';
|
2014-03-06 10:33:31 +00:00
|
|
|
if(empty($_GET['showdocs']))
|
|
|
|
$showdocs = false;
|
|
|
|
else
|
|
|
|
$showdocs = true;
|
2014-03-14 14:10:29 +00:00
|
|
|
if(empty($_GET['orderby']))
|
|
|
|
$orderby = $settings->_sortFoldersDefault;
|
|
|
|
else
|
|
|
|
$orderby = $_GET['orderby'];
|
2013-05-24 15:30:02 +00:00
|
|
|
|
2014-03-14 14:10:29 +00:00
|
|
|
$subfolders = $folder->getSubFolders($orderby);
|
2014-03-06 10:33:31 +00:00
|
|
|
$subfolders = SeedDMS_Core_DMS::filterAccess($subfolders, $user, M_READ);
|
|
|
|
$tree = array();
|
|
|
|
foreach($subfolders as $subfolder) {
|
2014-03-24 09:39:02 +00:00
|
|
|
$loadondemand = $subfolder->hasSubFolders() || ($subfolder->hasDocuments() && $showdocs);
|
|
|
|
$level = array('label'=>$subfolder->getName(), 'id'=>$subfolder->getID(), 'load_on_demand'=>$loadondemand, 'is_folder'=>true);
|
2014-03-06 10:33:31 +00:00
|
|
|
if(!$subfolder->hasSubFolders())
|
|
|
|
$level['children'] = array();
|
2013-05-24 15:30:02 +00:00
|
|
|
$tree[] = $level;
|
|
|
|
}
|
2014-03-06 10:33:31 +00:00
|
|
|
if($showdocs) {
|
2014-03-14 14:10:29 +00:00
|
|
|
$documents = $folder->getDocuments($orderby);
|
2014-03-06 10:33:31 +00:00
|
|
|
$documents = SeedDMS_Core_DMS::filterAccess($documents, $user, M_READ);
|
|
|
|
foreach($documents as $document) {
|
|
|
|
$level = array('label'=>$document->getName(), 'id'=>$document->getID(), 'load_on_demand'=>false, 'is_folder'=>false);
|
|
|
|
$tree[] = $level;
|
|
|
|
}
|
|
|
|
}
|
2013-05-24 15:30:02 +00:00
|
|
|
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-03-06 10:33:31 +00:00
|
|
|
echo json_encode($tree);
|
|
|
|
// echo json_encode(array(array('label'=>'test1', 'id'=>1, 'load_on_demand'=> true), array('label'=>'test2', 'id'=>2, 'load_on_demand'=> true)));
|
|
|
|
}
|
2013-06-18 16:14:41 +00:00
|
|
|
break; /* }}} */
|
|
|
|
|
|
|
|
case 'addtoclipboard': /* {{{ */
|
2014-03-06 10:33:31 +00:00
|
|
|
if($user) {
|
|
|
|
if (isset($_GET["id"]) && is_numeric($_GET["id"]) && isset($_GET['type'])) {
|
|
|
|
switch($_GET['type']) {
|
|
|
|
case "folder":
|
|
|
|
$session->addToClipboard($dms->getFolder($_GET['id']));
|
|
|
|
break;
|
|
|
|
case "document":
|
|
|
|
$session->addToClipboard($dms->getDocument($_GET['id']));
|
|
|
|
break;
|
|
|
|
}
|
2014-06-05 13:00:44 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 10:02:41 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_added_to_clipboard')));
|
2014-06-05 13:00:44 +00:00
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error')));
|
2014-03-06 10:33:31 +00:00
|
|
|
}
|
2014-06-05 13:00:44 +00:00
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
|
|
|
case 'removefromclipboard': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
if (isset($_GET["id"]) && is_numeric($_GET["id"]) && isset($_GET['type'])) {
|
|
|
|
switch($_GET['type']) {
|
|
|
|
case "folder":
|
|
|
|
$session->removeFromClipboard($dms->getFolder($_GET['id']));
|
|
|
|
break;
|
|
|
|
case "document":
|
|
|
|
$session->removeFromClipboard($dms->getDocument($_GET['id']));
|
|
|
|
break;
|
|
|
|
}
|
2014-03-06 10:33:31 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-06-05 13:00:44 +00:00
|
|
|
echo json_encode(array('success'=>true));
|
2014-03-06 10:33:31 +00:00
|
|
|
} else {
|
2014-06-05 13:00:44 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error')));
|
2013-06-18 16:14:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
2013-09-13 12:52:32 +00:00
|
|
|
|
|
|
|
case 'testmail': /* {{{ */
|
|
|
|
if($user && $user->isAdmin()) {
|
|
|
|
if($user->getEmail()) {
|
2024-09-18 07:40:41 +00:00
|
|
|
$emailobj = new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword, $settings->_smtpLazySSL, $settings->_smtpForceFrom);
|
2018-11-09 16:21:47 +00:00
|
|
|
$emailobj->setDebug(true);
|
2013-09-13 12:52:32 +00:00
|
|
|
$params = array();
|
2024-09-18 07:24:51 +00:00
|
|
|
$params['url'] = getBaseUrl().$settings->_httpRoot;
|
|
|
|
$params['sitename'] = $settings->_siteName;
|
|
|
|
$params['version'] = (new SeedDMS_Version())->version();
|
2024-09-18 07:40:41 +00:00
|
|
|
$params['smtpserver'] = $settings->_smtpServer;
|
|
|
|
$params['smtpport'] = $settings->_smtpPort;
|
|
|
|
$params['lazyssl'] = $settings->_smtpLazySSL ? 'Yes' : 'No';
|
|
|
|
$params['forcefrom'] = $settings->_smtpForceFrom ? 'Yes' : 'No';
|
|
|
|
$params['__skip_header__'] = true;
|
|
|
|
$params['__skip_footer__'] = true;
|
2013-09-13 12:52:32 +00:00
|
|
|
|
2018-11-09 16:21:47 +00:00
|
|
|
ob_start();
|
|
|
|
$ret = $emailobj->toIndividual($settings->_smtpSendFrom, $user, "testmail_subject", "testmail_body", $params);
|
|
|
|
$debugoutput = ob_get_clean();
|
|
|
|
if($ret) {
|
|
|
|
echo json_encode(array("error"=>0, "msg"=>"Sending email succeded", "data"=>$debugoutput));
|
2013-09-13 12:52:32 +00:00
|
|
|
} else {
|
2018-11-09 16:21:47 +00:00
|
|
|
echo json_encode(array("error"=>1, "msg"=>"Sending email failed", "data"=>$debugoutput));
|
2013-09-13 12:52:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-11-09 16:21:47 +00:00
|
|
|
echo json_encode(array("error"=>1, "msg"=>"Your account has no email address set", "data"=>""));
|
2013-09-13 12:52:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
2014-02-21 21:04:22 +00:00
|
|
|
|
2016-08-09 16:14:32 +00:00
|
|
|
case 'clearclipboard': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
$session->clearClipboard();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_cleared_clipboard')));
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2014-02-21 20:25:26 +00:00
|
|
|
case 'movefolder': /* {{{ */
|
|
|
|
if($user) {
|
2019-07-12 14:45:28 +00:00
|
|
|
if(!checkFormKey('', 'GET')) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-06-04 17:17:08 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$mfolder = $dms->getFolder($_REQUEST['folderid']);
|
|
|
|
if($mfolder) {
|
2018-07-12 20:36:44 +00:00
|
|
|
if ($mfolder->getAccessMode($user, 'moveFolder') >= M_READWRITE) {
|
2014-06-04 17:17:08 +00:00
|
|
|
if($folder = $dms->getFolder($_REQUEST['targetfolderid'])) {
|
2018-07-12 20:36:44 +00:00
|
|
|
if($folder->getAccessMode($user, 'moveFolder') >= M_READWRITE) {
|
2021-05-15 10:17:07 +00:00
|
|
|
$oldFolder = $mfolder->getParent();
|
2014-06-04 17:17:08 +00:00
|
|
|
if($mfolder->setParent($folder)) {
|
2021-05-15 10:17:07 +00:00
|
|
|
if($notifier) {
|
|
|
|
$notifier->sendMovedFolderMail($mfolder, $user, $oldFolder);
|
|
|
|
}
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_move_folder'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("move folder ".$mfolder->getId()." to ".$folder->getId());
|
2014-06-04 17:17:08 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-06-04 17:17:08 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error moving folder', 'data'=>''));
|
|
|
|
}
|
2014-02-21 20:25:26 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_folder_id'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_folder_id'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
|
|
|
case 'movedocument': /* {{{ */
|
|
|
|
if($user) {
|
2019-07-12 14:45:28 +00:00
|
|
|
if(!checkFormKey('', 'GET')) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-06-04 17:15:28 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$mdocument = $dms->getDocument($_REQUEST['docid']);
|
|
|
|
if($mdocument) {
|
2018-07-12 20:36:44 +00:00
|
|
|
if ($mdocument->getAccessMode($user, 'moveDocument') >= M_READWRITE) {
|
2014-06-04 17:15:28 +00:00
|
|
|
if($folder = $dms->getFolder($_REQUEST['targetfolderid'])) {
|
2018-07-12 20:36:44 +00:00
|
|
|
if($folder->getAccessMode($user, 'moveDocument') >= M_READWRITE) {
|
2021-05-15 10:17:07 +00:00
|
|
|
$oldFolder = $mdocument->getFolder();
|
2014-06-04 17:15:28 +00:00
|
|
|
if($mdocument->setFolder($folder)) {
|
2021-04-26 10:24:55 +00:00
|
|
|
if(isset($_REQUEST['sequence'])) {
|
|
|
|
$mdocument->setSequence((float) $_REQUEST['sequence']);
|
|
|
|
}
|
2021-05-15 10:17:07 +00:00
|
|
|
if($notifier) {
|
|
|
|
$notifier->sendMovedDocumentMail($mdocument, $user, $oldFolder);
|
|
|
|
}
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 09:37:57 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_move_document'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("move document ".$mdocument->getId()." to folder ".$folder->getId());
|
2014-06-04 17:15:28 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error moving document', 'data'=>''));
|
2014-06-04 17:15:28 +00:00
|
|
|
}
|
2014-02-21 20:25:26 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_folder_id'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-06-05 07:48:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
2014-06-05 07:48:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2019-07-11 15:15:40 +00:00
|
|
|
case 'transfercontent': /* {{{ */
|
|
|
|
if($user) {
|
2019-07-12 14:45:28 +00:00
|
|
|
if(!checkFormKey('', 'GET')) {
|
2019-07-11 15:15:40 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$mdocument = $dms->getDocument($_REQUEST['docid']);
|
|
|
|
if($mdocument) {
|
|
|
|
if ($mdocument->getAccessMode($user, 'transferContent') >= M_READWRITE) {
|
|
|
|
/* Check if source document has more than one version */
|
|
|
|
$versions = $mdocument->getContent();
|
|
|
|
if(count($versions) == 1) {
|
|
|
|
if($targetdoc = $dms->getDocument($_REQUEST['targetdocumentid'])) {
|
|
|
|
if($targetdoc->getAccessMode($user, 'transferContent') >= M_READWRITE) {
|
|
|
|
if($targetdoc->addContent($versions[0]->getComment(), $versions[0]->getUser(), $dms->contentDir . $versions[0]->getPath(), $versions[0]->getOriginalFileName(), $versions[0]->getFileType(), $versions[0]->getMimeType())) { //, $reviewers=array(), $approvers=array(), $version=0, $attributes=array(), $workflow=null) {
|
|
|
|
if($mdocument->remove()) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_transfer_content'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("transfer content of document ".$mdocument->getId()." to document ".$targetdoc->getId());
|
2019-07-11 15:15:40 +00:00
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error removing source document', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error transfering content', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('splash_source_doc_has_versions'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
|
|
|
case 'linkdocument': /* {{{ */
|
|
|
|
if($user) {
|
2019-07-12 14:45:28 +00:00
|
|
|
if(!checkFormKey('', 'GET')) {
|
2019-07-11 15:15:40 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$mdocument = $dms->getDocument($_REQUEST['docid']);
|
|
|
|
if($mdocument) {
|
|
|
|
if ($mdocument->getAccessMode($user, 'linkDocument') >= M_READ) {
|
|
|
|
if($targetdoc = $dms->getDocument($_REQUEST['targetdocumentid'])) {
|
|
|
|
if($targetdoc->getAccessMode($user, 'linkDocument') >= M_READWRITE) {
|
|
|
|
if($targetdoc->addDocumentLink($mdocument->getID(), $user->getID(), false)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_link_document'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("link document ".$mdocument->getId()." to ".$targetdoc->getId());
|
2019-07-11 15:15:40 +00:00
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error linking document', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2014-06-05 07:48:45 +00:00
|
|
|
case 'deletefolder': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
if(!checkFormKey('removefolder', 'GET')) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-06-05 07:48:45 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$folder = $dms->getFolder($_REQUEST['id']);
|
|
|
|
if($folder) {
|
2018-07-12 20:36:44 +00:00
|
|
|
if ($folder->getAccessMode($user, 'removeFolder') >= M_READWRITE) {
|
2016-03-13 07:32:46 +00:00
|
|
|
$parent=$folder->getParent();
|
2018-09-29 14:10:20 +00:00
|
|
|
$fnl = $folder->getNotifyList();
|
|
|
|
$pnl = $parent->getNotifyList();
|
|
|
|
$nl = array(
|
2018-10-02 16:18:24 +00:00
|
|
|
'users'=>array_unique(array_merge($fnl['users'], $pnl['users']), SORT_REGULAR),
|
|
|
|
'groups'=>array_unique(array_merge($fnl['groups'], $pnl['groups']), SORT_REGULAR)
|
2018-09-29 14:10:20 +00:00
|
|
|
);
|
2016-03-13 07:32:46 +00:00
|
|
|
$foldername = $folder->getName();
|
2020-02-25 16:08:38 +00:00
|
|
|
function removePreviews($arr, $document) {
|
|
|
|
$previewer = $arr[0];
|
|
|
|
|
|
|
|
$previewer->deleteDocumentPreviews($document);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
|
|
|
$dms->addCallback('onPreRemoveDocument', 'removePreviews', array($previewer));
|
|
|
|
|
2014-06-05 07:48:45 +00:00
|
|
|
if($folder->remove()) {
|
2016-03-08 16:23:07 +00:00
|
|
|
if ($notifier) {
|
2021-05-15 20:46:46 +00:00
|
|
|
$notifier->sendDeleteFolderMail($folder, $user);
|
2016-03-08 16:23:07 +00:00
|
|
|
}
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-05-28 08:35:39 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_folder_deleted'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("delete folder ".$folder->getId());
|
2014-06-05 07:48:45 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-12-06 17:00:14 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_remove_folder'), 'data'=>''));
|
2014-06-05 07:48:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_folder_id'), 'data'=>''));
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
2014-06-04 17:15:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
|
|
|
case 'deletedocument': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
if(!checkFormKey('removedocument', 'GET')) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-06-04 17:15:28 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$document = $dms->getDocument($_REQUEST['id']);
|
|
|
|
if($document) {
|
2018-07-12 20:36:44 +00:00
|
|
|
if ($document->getAccessMode($user, 'removeDocument') >= M_READWRITE) {
|
2015-11-26 12:01:20 +00:00
|
|
|
$folder = $document->getFolder();
|
|
|
|
/* Get the notify list before removing the document */
|
|
|
|
$dnl = $document->getNotifyList();
|
|
|
|
$fnl = $folder->getNotifyList();
|
|
|
|
$docname = $document->getName();
|
|
|
|
|
2018-11-09 16:21:47 +00:00
|
|
|
$controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user));
|
|
|
|
$controller->setParam('document', $document);
|
2020-09-09 17:49:15 +00:00
|
|
|
$controller->setParam('fulltextservice', $fulltextservice);
|
2022-07-29 19:44:04 +00:00
|
|
|
if($controller()) {
|
2015-11-26 12:01:20 +00:00
|
|
|
if ($notifier){
|
2021-05-15 20:46:46 +00:00
|
|
|
/* $document still has the data from the just deleted document,
|
|
|
|
* which is just enough to send the email.
|
|
|
|
*/
|
|
|
|
$notifier->sendDeleteDocumentMail($document, $user);
|
2015-11-26 12:01:20 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-05-28 08:35:39 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_deleted'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("delete document ".$document->getId());
|
2014-06-04 17:15:28 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2020-03-25 07:07:43 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_remove_document')."<br />".getMLText($controller->getErrorMsg()), 'data'=>''));
|
2014-06-04 17:15:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-06-04 17:15:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2016-03-08 16:23:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
2014-06-04 17:15:28 +00:00
|
|
|
}
|
2014-02-21 20:25:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2014-06-06 11:59:12 +00:00
|
|
|
case 'tooglelockdocument': /* {{{ */
|
|
|
|
if($user) {
|
2021-06-16 12:23:53 +00:00
|
|
|
if(checkFormKey('tooglelockdocument', 'GET')) {
|
|
|
|
$document = $dms->getDocument($_REQUEST['id']);
|
|
|
|
if($document) {
|
|
|
|
if ($document->getAccessMode($user) >= M_READWRITE) {
|
|
|
|
if ($document->isLocked()) {
|
|
|
|
$lockingUser = $document->getLockingUser();
|
|
|
|
if (($lockingUser->getID() == $user->getID()) || ($document->getAccessMode($user) == M_ALL)) {
|
|
|
|
if (!$document->setLocked(false)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error unlocking document', 'data'=>''));
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_unlocked'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("unlock document ".$document->getId());
|
2021-06-16 12:23:53 +00:00
|
|
|
}
|
2014-06-06 11:59:12 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-06-16 12:23:53 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-06-06 11:59:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-06-16 12:23:53 +00:00
|
|
|
if (!$document->setLocked($user)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error locking document', 'data'=>''));
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_locked'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("lock document ".$document->getId());
|
2021-06-16 12:23:53 +00:00
|
|
|
}
|
2014-06-06 11:59:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-06-16 12:23:53 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2014-06-06 11:59:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-06-16 12:23:53 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
2014-06-06 11:59:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-06-16 12:23:53 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
2020-09-07 14:20:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
|
|
|
case 'setdocumentname': /* {{{ */
|
2021-06-14 07:09:36 +00:00
|
|
|
if($user) {
|
|
|
|
if(checkFormKey('setdocumentname')) {
|
|
|
|
$document = $dms->getDocument($_REQUEST['id']);
|
|
|
|
if($document) {
|
|
|
|
if ($document->getAccessMode($user) >= M_READWRITE) {
|
|
|
|
$oldname = $document->getName();
|
|
|
|
if (!$document->setName($_REQUEST['name'])) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error setting name', 'data'=>''));
|
|
|
|
} else {
|
|
|
|
if($notifier) {
|
|
|
|
$notifier->sendChangedNameMail($document, $user, $oldname);
|
|
|
|
}
|
2024-05-02 16:12:41 +00:00
|
|
|
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
|
|
|
|
$lucenesearch = $fulltextservice->Search();
|
|
|
|
if($hit = $lucenesearch->getDocument($document->getId())) {
|
|
|
|
$index->reindexDocument($hit->id);
|
|
|
|
$index->commit();
|
|
|
|
}
|
|
|
|
}
|
2021-06-14 07:09:36 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_name_changed'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("set name '".$_REQUEST['name']."' of document ".$document->getId());
|
2021-05-15 10:17:07 +00:00
|
|
|
}
|
2021-06-14 07:09:36 +00:00
|
|
|
} else {
|
2020-09-07 14:20:37 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-06-14 07:09:36 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
2020-09-07 14:20:37 +00:00
|
|
|
}
|
2014-06-06 11:59:12 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-06-14 07:09:36 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
2014-06-06 11:59:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-06-14 07:09:36 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
2014-06-06 11:59:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2022-11-15 15:05:27 +00:00
|
|
|
case 'setmimetype': /* {{{ */
|
|
|
|
if($user && $user->isAdmin()) {
|
|
|
|
if(checkFormKey('setmimetype', 'GET')) {
|
|
|
|
$content = $dms->getDocumentContent($_REQUEST['contentid']);
|
|
|
|
if($content) {
|
|
|
|
$document = $content->getDocument();
|
|
|
|
if ($document->getAccessMode($user) >= M_READWRITE) {
|
2024-08-12 07:49:06 +00:00
|
|
|
$realmimetype = $content->getRealMimeType();
|
2022-11-15 15:05:27 +00:00
|
|
|
if (!$content->setMimeType($realmimetype)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error setting mimetype', 'data'=>''));
|
|
|
|
} else {
|
2024-05-02 16:12:41 +00:00
|
|
|
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
|
|
|
|
$lucenesearch = $fulltextservice->Search();
|
|
|
|
if($hit = $lucenesearch->getDocument($document->getId())) {
|
|
|
|
$index->reindexDocument($hit->id);
|
|
|
|
$index->commit();
|
|
|
|
}
|
|
|
|
}
|
2022-11-15 15:05:27 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_mimetype_changed'), 'data'=>''));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("set mimetype '".$realmimetype."' of document ".$document->getId().":".$content->getVersion());
|
2022-11-15 15:05:27 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2014-04-08 08:41:53 +00:00
|
|
|
case 'submittranslation': /* {{{ */
|
2014-04-08 08:43:59 +00:00
|
|
|
if($settings->_showMissingTranslations) {
|
|
|
|
if($user && !empty($_POST['phrase'])) {
|
2018-02-05 13:27:54 +00:00
|
|
|
if($fp = fopen($settings->_cacheDir.'/newtranslations.txt', 'a+')) {
|
2014-04-08 08:43:59 +00:00
|
|
|
fputcsv($fp, array(date('Y-m-d H:i:s'), $user->getLogin(), $_POST['key'], $_POST['lang'], $_POST['phrase']));
|
|
|
|
fclose($fp);
|
|
|
|
}
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-04-08 08:43:59 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>'Thank you for your contribution', 'data'=>''));
|
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-04-08 08:43:59 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Missing translation', 'data'=>''));
|
2014-04-08 08:41:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2014-07-11 06:38:26 +00:00
|
|
|
case 'uploaddocument': /* {{{ */
|
|
|
|
if($user) {
|
2019-07-12 14:45:28 +00:00
|
|
|
if(checkFormKey('')) {
|
2014-07-11 06:38:26 +00:00
|
|
|
if (!isset($_POST["folderid"]) || !is_numeric($_POST["folderid"]) || intval($_POST["folderid"])<1) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 06:38:26 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_folder_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$folderid = $_POST["folderid"];
|
|
|
|
$folder = $dms->getFolder($folderid);
|
|
|
|
|
|
|
|
if (!is_object($folder)) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 06:38:26 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_folder_id")));
|
|
|
|
exit;
|
|
|
|
}
|
2014-11-11 14:42:07 +00:00
|
|
|
|
2018-07-12 20:36:44 +00:00
|
|
|
if ($folder->getAccessMode($user, 'addDocument') < M_READWRITE) {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-11-11 14:42:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("access_denied")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($settings->_quota > 0) {
|
|
|
|
$remain = checkQuota($user);
|
|
|
|
if ($remain < 0) {
|
2016-08-22 16:13:57 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-11-11 14:42:07 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("quota_exceeded", array('bytes'=>SeedDMS_Core_File::format_filesize(abs($remain))))));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:38:26 +00:00
|
|
|
if (!is_uploaded_file($_FILES["userfile"]["tmp_name"]) || $_FILES['userfile']['error']!=0){
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 06:38:26 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_failed")));
|
|
|
|
exit;
|
|
|
|
}
|
2014-07-11 09:14:27 +00:00
|
|
|
if ($_FILES["userfile"]["size"]==0) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 09:14:27 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_zerosize")));
|
|
|
|
exit;
|
|
|
|
}
|
2014-07-11 06:38:26 +00:00
|
|
|
|
2020-05-13 07:25:30 +00:00
|
|
|
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
|
|
|
if ($maxuploadsize && $_FILES["userfile"]["size"] > $maxuploadsize) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_maxsize")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:38:26 +00:00
|
|
|
$userfiletmp = $_FILES["userfile"]["tmp_name"];
|
|
|
|
$userfiletype = $_FILES["userfile"]["type"];
|
|
|
|
$userfilename = $_FILES["userfile"]["name"];
|
|
|
|
|
|
|
|
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
|
|
|
|
2015-06-23 05:45:18 +00:00
|
|
|
if($settings->_overrideMimeType) {
|
2023-09-27 09:28:39 +00:00
|
|
|
$userfiletype = SeedDMS_Core_File::mimetype($userfiletmp);
|
2015-06-23 05:45:18 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 10:36:22 +00:00
|
|
|
if (!empty($_POST["name"]))
|
2014-07-11 06:38:26 +00:00
|
|
|
$name = $_POST["name"];
|
|
|
|
else
|
2017-03-03 09:34:46 +00:00
|
|
|
$name = utf8_basename($userfilename);
|
2014-07-11 06:38:26 +00:00
|
|
|
|
|
|
|
/* Check if name already exists in the folder */
|
|
|
|
if(!$settings->_enableDuplicateDocNames) {
|
|
|
|
if($folder->hasDocumentByName($name)) {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 06:38:26 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("document_duplicate_name")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-07 14:19:22 +00:00
|
|
|
if(isset($_POST["attributes"]))
|
|
|
|
$attributes = $_POST["attributes"];
|
|
|
|
else
|
|
|
|
$attributes = array();
|
|
|
|
|
|
|
|
if(isset($_POST["comment"]))
|
|
|
|
$comment = trim($_POST["comment"]);
|
|
|
|
else
|
|
|
|
$comment = '';
|
|
|
|
|
2014-07-11 10:36:22 +00:00
|
|
|
// Get the list of reviewers and approvers for this document.
|
|
|
|
$reviewers = array();
|
|
|
|
$approvers = array();
|
|
|
|
$reviewers["i"] = array();
|
|
|
|
$reviewers["g"] = array();
|
|
|
|
$approvers["i"] = array();
|
|
|
|
$approvers["g"] = array();
|
2019-09-16 06:32:50 +00:00
|
|
|
$workflow = null;
|
2014-07-11 10:36:22 +00:00
|
|
|
|
2019-09-10 15:43:32 +00:00
|
|
|
if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') {
|
|
|
|
// add mandatory reviewers/approvers
|
|
|
|
if($settings->_workflowMode == 'traditional') {
|
2024-02-08 20:02:12 +00:00
|
|
|
$mreviewers = getMandatoryReviewers($folder, null, $user);
|
2021-02-24 12:44:04 +00:00
|
|
|
if($mreviewers['i'])
|
|
|
|
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
|
2021-05-14 10:37:10 +00:00
|
|
|
if($mreviewers['g'])
|
|
|
|
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
|
2014-07-11 10:36:22 +00:00
|
|
|
}
|
2024-02-08 20:02:12 +00:00
|
|
|
$mapprovers = getMandatoryApprovers($folder, null, $user);
|
2021-02-24 12:44:04 +00:00
|
|
|
if($mapprovers['i'])
|
|
|
|
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
|
2021-05-14 10:37:10 +00:00
|
|
|
if($mapprovers['g'])
|
|
|
|
$approvers['g'] = array_merge($approvers['g'], $mapprovers['g']);
|
2019-09-10 15:43:32 +00:00
|
|
|
|
|
|
|
} elseif($settings->_workflowMode == 'advanced') {
|
|
|
|
$workflow = $user->getMandatoryWorkflow();
|
2014-07-11 10:36:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-29 16:28:40 +00:00
|
|
|
$expires = false;
|
|
|
|
if($settings->_presetExpirationDate) {
|
|
|
|
$expires = strtotime($settings->_presetExpirationDate);
|
|
|
|
}
|
|
|
|
|
2022-03-09 07:38:19 +00:00
|
|
|
$keywords = isset($_POST["keywords"]) ? trim($_POST["keywords"]) : '';
|
|
|
|
|
|
|
|
$categories = isset($_POST["categories"]) ? $_POST["categories"] : null;
|
2014-07-11 06:38:26 +00:00
|
|
|
$cats = array();
|
2022-03-09 07:38:19 +00:00
|
|
|
if($categories) {
|
|
|
|
foreach($categories as $catid) {
|
|
|
|
if($cat = $dms->getDocumentCategory($catid))
|
|
|
|
$cats[] = $cat;
|
|
|
|
}
|
|
|
|
}
|
2014-07-11 06:38:26 +00:00
|
|
|
|
2018-03-12 17:34:17 +00:00
|
|
|
$controller = Controller::factory('AddDocument', array('dms'=>$dms, 'user'=>$user));
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('documentsource', 'upload');
|
|
|
|
$controller->setParam('folder', $folder);
|
2020-09-09 17:49:15 +00:00
|
|
|
$controller->setParam('fulltextservice', $fulltextservice);
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('name', $name);
|
2022-03-07 14:19:22 +00:00
|
|
|
$controller->setParam('comment', $comment);
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('expires', $expires);
|
2022-03-09 07:38:19 +00:00
|
|
|
$controller->setParam('keywords', $keywords);
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('categories', $cats);
|
|
|
|
$controller->setParam('owner', $user);
|
|
|
|
$controller->setParam('userfiletmp', $userfiletmp);
|
|
|
|
$controller->setParam('userfilename', $userfilename);
|
|
|
|
$controller->setParam('filetype', $fileType);
|
|
|
|
$controller->setParam('userfiletype', $userfiletype);
|
2018-02-07 08:52:23 +00:00
|
|
|
$minmax = $folder->getDocumentsMinMax();
|
2022-11-11 09:42:28 +00:00
|
|
|
$deviation = rand(10, 1000)/10;
|
2018-02-07 08:52:23 +00:00
|
|
|
if($settings->_defaultDocPosition == 'start')
|
2022-11-11 09:42:28 +00:00
|
|
|
$controller->setParam('sequence', $minmax['min'] - $deviation);
|
2018-02-07 08:52:23 +00:00
|
|
|
else
|
2022-11-11 09:42:28 +00:00
|
|
|
$controller->setParam('sequence', $minmax['max'] + $deviation);
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('reviewers', $reviewers);
|
|
|
|
$controller->setParam('approvers', $approvers);
|
|
|
|
$controller->setParam('reqversion', 1);
|
|
|
|
$controller->setParam('versioncomment', '');
|
2022-03-07 14:19:22 +00:00
|
|
|
$controller->setParam('attributes', $attributes);
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('attributesversion', array());
|
|
|
|
$controller->setParam('workflow', $workflow);
|
|
|
|
$controller->setParam('notificationgroups', array());
|
|
|
|
$controller->setParam('notificationusers', array());
|
2023-10-13 14:38:44 +00:00
|
|
|
$controller->setParam('initialdocumentstatus', $settings->_initialDocumentStatus);
|
2017-06-09 10:29:20 +00:00
|
|
|
$controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText);
|
|
|
|
$controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs);
|
|
|
|
|
2022-07-29 19:44:04 +00:00
|
|
|
if(!$document = $controller()) {
|
2023-05-11 14:59:18 +00:00
|
|
|
$err = $controller->getErrorMsg();
|
|
|
|
if(is_string($err))
|
|
|
|
$errmsg = getMLText($err);
|
|
|
|
elseif(is_array($err)) {
|
|
|
|
$errmsg = getMLText($err[0], $err[1]);
|
|
|
|
} else {
|
|
|
|
$errmsg = $err;
|
|
|
|
}
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2023-05-11 14:59:18 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>$errmsg));
|
2014-07-11 06:38:26 +00:00
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
// Send notification to subscribers of folder.
|
|
|
|
if($notifier) {
|
2021-05-14 19:56:37 +00:00
|
|
|
$notifier->sendNewDocumentMail($document, $user);
|
2014-07-11 06:38:26 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 09:14:27 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_added'), 'data'=>$document->getID()));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("add document ".$document->getId()." in folder ".$folder->getId());
|
2014-07-11 06:38:26 +00:00
|
|
|
} else {
|
2015-10-22 11:36:23 +00:00
|
|
|
header('Content-Type: application/json');
|
2014-07-11 06:38:26 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2016-08-22 04:23:22 +00:00
|
|
|
/* Deprecated, has moved to op/op.TransmittalMgr.php */
|
|
|
|
case '___removetransmittalitem': /* {{{ */
|
2015-05-13 15:34:50 +00:00
|
|
|
if($user) {
|
|
|
|
if(!checkFormKey('removetransmittalitem', 'GET')) {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$item = SeedDMS_Core_TransmittalItem::getInstance((int) $_REQUEST['id'], $dms);
|
|
|
|
if($item) {
|
|
|
|
$transmittal = $item->getTransmittal();
|
|
|
|
if($transmittal) {
|
|
|
|
if ($transmittal->getUser()->getID() == $user->getID()) {
|
|
|
|
if($item->remove()) {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>'', 'data'=>''));
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error removing transmittal item', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'No access', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'No transmittal', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'No transmittal item', 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2024-03-06 15:31:02 +00:00
|
|
|
case 'updatedocument': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
if(checkFormKey('')) {
|
|
|
|
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_document_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$documentid = $_POST["documentid"];
|
|
|
|
$document = $dms->getDocument($documentid);
|
|
|
|
|
|
|
|
if (!is_object($document)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_document_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($document->getAccessMode($user, 'addDocument') < M_READWRITE) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("access_denied")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($settings->_quota > 0) {
|
|
|
|
$remain = checkQuota($user);
|
|
|
|
if ($remain < 0) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("quota_exceeded", array('bytes'=>SeedDMS_Core_File::format_filesize(abs($remain))))));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_uploaded_file($_FILES["userfile"]["tmp_name"]) || $_FILES['userfile']['error']!=0){
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_failed")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if ($_FILES["userfile"]["size"]==0) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_zerosize")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
|
|
|
if ($maxuploadsize && $_FILES["userfile"]["size"] > $maxuploadsize) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_maxsize")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$userfiletmp = $_FILES["userfile"]["tmp_name"];
|
|
|
|
$userfiletype = $_FILES["userfile"]["type"];
|
|
|
|
$userfilename = $_FILES["userfile"]["name"];
|
|
|
|
|
|
|
|
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
|
|
|
|
|
|
|
if($settings->_overrideMimeType) {
|
|
|
|
$userfiletype = SeedDMS_Core_File::mimetype($userfiletmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST["name"]))
|
|
|
|
$name = $_POST["name"];
|
|
|
|
else
|
|
|
|
$name = utf8_basename($userfilename);
|
|
|
|
|
|
|
|
if(isset($_POST["attributes"]))
|
|
|
|
$attributes = $_POST["attributes"];
|
|
|
|
else
|
|
|
|
$attributes = array();
|
|
|
|
|
|
|
|
if(isset($_POST["comment"]))
|
|
|
|
$comment = trim($_POST["comment"]);
|
|
|
|
else
|
|
|
|
$comment = '';
|
|
|
|
|
|
|
|
// Get the list of reviewers and approvers for this document.
|
|
|
|
$reviewers = array();
|
|
|
|
$approvers = array();
|
|
|
|
$reviewers["i"] = array();
|
|
|
|
$reviewers["g"] = array();
|
|
|
|
$approvers["i"] = array();
|
|
|
|
$approvers["g"] = array();
|
|
|
|
$workflow = null;
|
|
|
|
|
|
|
|
if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') {
|
|
|
|
// add mandatory reviewers/approvers
|
|
|
|
if($settings->_workflowMode == 'traditional') {
|
|
|
|
$mreviewers = getMandatoryReviewers(null, $document, $user);
|
|
|
|
if($mreviewers['i'])
|
|
|
|
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
|
|
|
|
if($mreviewers['g'])
|
|
|
|
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
|
|
|
|
}
|
|
|
|
$mapprovers = getMandatoryApprovers(null, $document, $user);
|
|
|
|
if($mapprovers['i'])
|
|
|
|
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
|
|
|
|
if($mapprovers['g'])
|
|
|
|
$approvers['g'] = array_merge($approvers['g'], $mapprovers['g']);
|
|
|
|
|
|
|
|
} elseif($settings->_workflowMode == 'advanced') {
|
|
|
|
$workflow = $user->getMandatoryWorkflow();
|
|
|
|
}
|
|
|
|
|
|
|
|
$expires = false;
|
|
|
|
if($settings->_presetExpirationDate) {
|
|
|
|
$expires = strtotime($settings->_presetExpirationDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
$controller = Controller::factory('UpdateDocument', array('dms'=>$dms, 'user'=>$user));
|
|
|
|
$controller->setParam('documentsource', 'upload');
|
|
|
|
$controller->setParam('fulltextservice', $fulltextservice);
|
|
|
|
$controller->setParam('document', $document);
|
|
|
|
$controller->setParam('folder', $document->getFolder());
|
|
|
|
$controller->setParam('name', $name);
|
|
|
|
$controller->setParam('comment', $comment);
|
|
|
|
$controller->setParam('expires', $expires);
|
|
|
|
$controller->setParam('userfiletmp', $userfiletmp);
|
|
|
|
$controller->setParam('userfilename', $userfilename);
|
|
|
|
$controller->setParam('filetype', $fileType);
|
|
|
|
$controller->setParam('userfiletype', $userfiletype);
|
|
|
|
$controller->setParam('reviewers', $reviewers);
|
|
|
|
$controller->setParam('approvers', $approvers);
|
|
|
|
$controller->setParam('reqversion', 1);
|
|
|
|
$controller->setParam('attributes', $attributes);
|
|
|
|
$controller->setParam('workflow', $workflow);
|
|
|
|
$controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText);
|
|
|
|
|
|
|
|
if(!$content = $controller()) {
|
|
|
|
$err = $controller->getErrorMsg();
|
|
|
|
if(is_string($err))
|
|
|
|
$errmsg = getMLText($err);
|
|
|
|
elseif(is_array($err)) {
|
|
|
|
$errmsg = getMLText($err[0], $err[1]);
|
|
|
|
} else {
|
|
|
|
$errmsg = $err;
|
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>$errmsg));
|
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
// Send notification to subscribers of folder.
|
|
|
|
if($notifier) {
|
|
|
|
$notifier->sendNewDocumentVersionMail($document, $user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_updated'), 'data'=>$document->getID()));
|
|
|
|
add_log_line("updated document ".$document->getId());
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2016-08-22 04:23:22 +00:00
|
|
|
/* Deprecated, has moved to op/op.TransmittalMgr.php */
|
|
|
|
case '___updatetransmittalitem': /* {{{ */
|
2015-05-13 15:34:50 +00:00
|
|
|
if($user) {
|
|
|
|
if(!checkFormKey('updatetransmittalitem', 'GET')) {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
} else {
|
|
|
|
$item = SeedDMS_Core_TransmittalItem::getInstance((int) $_REQUEST['id'], $dms);
|
|
|
|
if($item) {
|
|
|
|
$transmittal = $item->getTransmittal();
|
|
|
|
if($transmittal) {
|
|
|
|
if ($transmittal->getUser()->getID() == $user->getID()) {
|
|
|
|
if($item->updateContent()) {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>'', 'data'=>''));
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'Error removing transmittal item', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'No access', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'No transmittal', 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-05 12:43:49 +00:00
|
|
|
header('Content-Type: application/json');
|
2015-05-13 15:34:50 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>'No transmittal item', 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2024-03-06 15:31:02 +00:00
|
|
|
case 'addfolder': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
if(checkFormKey('')) {
|
|
|
|
if (!isset($_POST["folderid"]) || !is_numeric($_POST["folderid"]) || intval($_POST["folderid"])<1) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_folder_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$folderid = $_POST["folderid"];
|
|
|
|
$folder = $dms->getFolder($folderid);
|
|
|
|
|
|
|
|
if (!is_object($folder)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_folder_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($folder->getAccessMode($user, 'addFolder') < M_READWRITE) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("access_denied")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST["name"]))
|
|
|
|
$name = $_POST["name"];
|
|
|
|
else
|
|
|
|
$name = utf8_basename($userfilename);
|
|
|
|
|
|
|
|
/* Check if name already exists in the folder */
|
2024-09-29 05:17:31 +00:00
|
|
|
if(!$settings->_enableDuplicateSubFolderNames) {
|
|
|
|
if($folder->hasSubFolderByName($name)) {
|
2024-03-06 15:31:02 +00:00
|
|
|
header('Content-Type: application/json');
|
2024-09-29 05:17:31 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("subfolder_duplicate_name")));
|
2024-03-06 15:31:02 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($_POST["attributes"]))
|
|
|
|
$attributes = $_POST["attributes"];
|
|
|
|
else
|
|
|
|
$attributes = array();
|
|
|
|
|
|
|
|
if(isset($_POST["comment"]))
|
|
|
|
$comment = trim($_POST["comment"]);
|
|
|
|
else
|
|
|
|
$comment = '';
|
|
|
|
|
|
|
|
$controller = Controller::factory('AddSubFolder', array('dms'=>$dms, 'user'=>$user));
|
|
|
|
$controller->setParam('documentsource', 'upload');
|
|
|
|
$controller->setParam('folder', $folder);
|
|
|
|
$controller->setParam('fulltextservice', $fulltextservice);
|
|
|
|
$controller->setParam('name', $name);
|
|
|
|
$controller->setParam('comment', $comment);
|
|
|
|
$minmax = $folder->getFoldersMinMax();
|
|
|
|
$deviation = rand(10, 1000)/10;
|
|
|
|
if($settings->_defaultFolderPosition == 'start')
|
|
|
|
$controller->setParam('sequence', $minmax['min'] - $deviation);
|
|
|
|
else
|
|
|
|
$controller->setParam('sequence', $minmax['max'] + $deviation);
|
|
|
|
$controller->setParam('owner', $user);
|
|
|
|
$controller->setParam('attributes', $attributes);
|
|
|
|
$controller->setParam('notificationgroups', array());
|
|
|
|
$controller->setParam('notificationusers', array());
|
|
|
|
|
|
|
|
if(!$subfolder = $controller()) {
|
|
|
|
$err = $controller->getErrorMsg();
|
|
|
|
if(is_string($err))
|
|
|
|
$errmsg = getMLText($err);
|
|
|
|
elseif(is_array($err)) {
|
|
|
|
$errmsg = getMLText($err[0], $err[1]);
|
|
|
|
} else {
|
|
|
|
$errmsg = $err;
|
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>$errmsg));
|
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
// Send notification to subscribers of folder.
|
|
|
|
if($notifier) {
|
|
|
|
$notifier->sendNewFolderMail($subfolder, $user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_folder_added'), 'data'=>$subfolder->getID()));
|
|
|
|
add_log_line("add folder ".$subfolder->getId()." in folder ".$folder->getId());
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2021-07-16 13:55:47 +00:00
|
|
|
case 'addfile': /* {{{ */
|
|
|
|
if($user) {
|
|
|
|
if(checkFormKey('addfile')) {
|
|
|
|
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_doc_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$documentid = $_POST["documentid"];
|
|
|
|
$document = $dms->getDocument($documentid);
|
|
|
|
|
|
|
|
if (!is_object($document)) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_doc_id")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($document->getAccessMode($user, 'addDocumentFile') < M_READWRITE) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("access_denied")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_uploaded_file($_FILES["userfile"]["tmp_name"]) || $_FILES['userfile']['error']!=0){
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_failed")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if ($_FILES["userfile"]["size"]==0) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_zerosize")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$maxuploadsize = SeedDMS_Core_File::parse_filesize($settings->_maxUploadSize);
|
|
|
|
if ($maxuploadsize && $_FILES["userfile"]["size"] > $maxuploadsize) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText("uploading_maxsize")));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$userfiletmp = $_FILES["userfile"]["tmp_name"];
|
|
|
|
$userfiletype = $_FILES["userfile"]["type"];
|
|
|
|
$userfilename = $_FILES["userfile"]["name"];
|
|
|
|
|
|
|
|
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
|
|
|
|
|
|
|
if($settings->_overrideMimeType) {
|
2023-09-27 09:28:39 +00:00
|
|
|
$userfiletype = SeedDMS_Core_File::mimetype($userfiletmp);
|
2021-07-16 13:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST["name"]))
|
|
|
|
$name = $_POST["name"];
|
|
|
|
else
|
|
|
|
$name = utf8_basename($userfilename);
|
|
|
|
$comment = '';
|
|
|
|
$version = 0;
|
2023-05-03 14:24:33 +00:00
|
|
|
$public = $settings->_uploadedAttachmentIsPublic;
|
2021-07-16 13:55:47 +00:00
|
|
|
$res = $document->addDocumentFile($name, $comment, $user, $userfiletmp,
|
|
|
|
utf8_basename($userfilename),$fileType, $userfiletype, $version, $public);
|
|
|
|
if (is_bool($res) && !$res) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_occured'), 'data'=>''));
|
|
|
|
} else {
|
2021-08-30 17:35:08 +00:00
|
|
|
if($notifier) {
|
|
|
|
$notifier->sendNewFileMail($res, $user);
|
|
|
|
}
|
2021-07-16 13:55:47 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_added'), 'data'=>$document->getID()));
|
2023-05-22 08:43:10 +00:00
|
|
|
add_log_line("add file '".$name."' to document ".$document->getId());
|
2021-07-16 13:55:47 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
|
|
|
|
2021-05-17 05:01:50 +00:00
|
|
|
case 'indexdocument':
|
2020-12-12 15:29:56 +00:00
|
|
|
case 'indexfolder': /* {{{ */
|
2017-02-24 11:13:01 +00:00
|
|
|
if($user && $user->isAdmin()) {
|
2020-09-09 17:49:15 +00:00
|
|
|
if($fulltextservice) {
|
2020-12-12 15:29:56 +00:00
|
|
|
if($command == 'indexdocument') {
|
|
|
|
$hook = 'indexDocument';
|
|
|
|
$object = $dms->getDocument($_REQUEST['id']);
|
|
|
|
$prefix = 'D';
|
|
|
|
} else {
|
|
|
|
$hook = 'indexFolder';
|
|
|
|
$object = $dms->getFolder($_REQUEST['id']);
|
|
|
|
$prefix = 'F';
|
|
|
|
}
|
|
|
|
if($object) {
|
2020-09-09 17:49:15 +00:00
|
|
|
if($index = $fulltextservice->Indexer()) {
|
2023-01-05 07:04:48 +00:00
|
|
|
$index->init($settings->_stopWordsFile);
|
2020-12-12 15:29:56 +00:00
|
|
|
$idoc = $fulltextservice->IndexedDocument($object, true);
|
2018-01-30 05:32:22 +00:00
|
|
|
$error = $idoc->getErrorMsg();
|
|
|
|
if(!$error) {
|
2019-04-17 06:28:46 +00:00
|
|
|
$ires = null;
|
2020-12-12 15:29:56 +00:00
|
|
|
if(isset($GLOBALS['SEEDDMS_HOOKS'][$hook])) {
|
|
|
|
foreach($GLOBALS['SEEDDMS_HOOKS'][$hook] as $hookObj) {
|
|
|
|
if (method_exists($hookObj, 'pre'.ucfirst($hook))) {
|
2021-06-29 06:26:42 +00:00
|
|
|
$ires = $hookObj->{'pre'.ucfirst($hook)}(null, $object, $idoc);
|
2018-01-30 05:32:22 +00:00
|
|
|
}
|
2017-02-24 11:13:01 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:28:46 +00:00
|
|
|
if(false !== $ires)
|
|
|
|
$ires = $index->addDocument($idoc);
|
2018-01-30 05:32:22 +00:00
|
|
|
header('Content-Type: application/json');
|
2019-01-17 17:28:58 +00:00
|
|
|
if(false === $ires) {
|
2023-01-03 13:07:05 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_document_indexed', ['name'=>$object->getName()]), 'data'=>$prefix.$object->getID(), 'mimetype'=>$idoc->getMimeType(), 'cmd'=>$idoc->getCmd()));
|
2018-04-11 14:35:26 +00:00
|
|
|
} else {
|
2023-01-03 13:07:05 +00:00
|
|
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_indexed', ['name'=>$object->getName()]), 'data'=>$prefix.$object->getID(), 'cmd'=>$idoc->getCmd()));
|
2018-04-11 14:35:26 +00:00
|
|
|
}
|
2018-01-30 05:32:22 +00:00
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
2020-12-12 15:29:56 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>$error, 'data'=>$object->getID(), 'mimetype'=>$idoc->getMimeType(), 'cmd'=>$idoc->getCmd()));
|
2017-02-24 11:13:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
2020-12-12 15:29:56 +00:00
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_occured'), 'data'=>$prefix.$object->getID()));
|
2017-02-24 11:13:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_occured'), 'data'=>''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* }}} */
|
2012-08-28 08:48:56 +00:00
|
|
|
}
|
|
|
|
?>
|