diff --git a/class.paperless.php b/class.paperless.php index 1916d42..552e82a 100644 --- a/class.paperless.php +++ b/class.paperless.php @@ -291,10 +291,29 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */ } /* }}} */ function correspondents($request, $response) { /* {{{ */ + $dms = $this->container->dms; + $userobj = $this->container->userobj; + $settings = $this->container->config; + $logger = $this->container->logger; + //file_put_contents("php://stdout", var_dump($request, true)); - $correspondents = array( - ); + $correspondents = array(); + if(!empty($settings->_extensions['paperless']['correspondentsattr']) && $attrdef = $dms->getAttributeDefinition($settings->_extensions['paperless']['correspondentsattr'])) { + $valueset = $attrdef->getValueSetAsArray(); + foreach($valueset as $id=>$val) { + $correspondents[] = array( + 'id'=>$id+1, + 'slug'=>strtolower($val), + 'name'=>$val, + 'match'=>'', + 'matching_algorithm'=>1, + 'is_insensitive'=>true, + 'document_count'=>0, + 'last_correspondence'=>null + ); + } + } return $response->withJson(array('count'=>count($correspondents), 'next'=>null, 'previous'=>null, 'results'=>$correspondents), 200); } /* }}} */ diff --git a/conf.php b/conf.php index 1b47aa4..179c5be 100644 --- a/conf.php +++ b/conf.php @@ -50,6 +50,14 @@ $EXT_CONF['paperless'] = array( 'options'=>['title'=>'Title', 'content'=>'Content'], 'allow_empty'=>true, ), + 'correspondentsattr' => array( + 'title'=>'Attribute for storing the correspondence', + 'help'=>'This attribute stores the correspondence of a document and must have a list of correspondents.', + 'type'=>'select', + 'internal'=>'attributedefinitions', + 'objtype'=>'2', + 'allow_empty'=>true, + ), ), 'constraints' => array( 'depends' => array('php' => '7.4.0-', 'seeddms' => array('5.1.29-5.1.99', '6.0.22-6.0.99')),