Example #1
0
 /**
  * Before filter, basically initializes the controller by actvating the
  * according navigation entry and other settings.
  *
  * @param String $action Action to execute
  * @param Array $args    Arguments passed for the action (might be empty)
  */
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     PageLayout::setTitle(_('Dateiverwaltung'));
     PageLayout::setHelpKeyword('Basis.Dateien');
     Navigation::activateItem('/profile/files');
     PageLayout::addSqueezePackage('document');
 }
 /**
  * Returns all documents for the topic
  * @param $topic_id
  * @return array
  */
 private function getDocuments($topic_id)
 {
     $document_mapper = new DocumentDBMapper();
     $documents = $document_mapper->getDocumentsByTopicId($topic_id);
     $documents_array = array();
     // Sets profiles, links, fields and target groups for each document
     foreach ($documents as $document) {
         $document->setTargetGroups(DocumentController::getTargetGroups($document));
         $document->setLinks(DocumentController::getLinks($document));
         $document->setFields(DocumentController::getFields($document));
         $document_array = $document->toArray();
         array_push($documents_array, $document_array);
     }
     // Sort document list on sequence
     usort($documents_array, function ($a, $b) {
         return $a['sequence'] - $b['sequence'];
     });
     return $documents_array;
 }
Example #3
0
 /**
  * Before filter, basically initializes the controller by actvating the
  * according navigation entry.
  *
  * @param String $action Action to execute
  * @param Array $args    Arguments passed for the action (might be empty)
  */
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     Navigation::activateItem('/profile/files');
 }
 public function test_add_link_to_document_return_document_with_new_link()
 {
     $this->mySetup(__DIR__ . "/basic_document_table.xml");
     $new_data = ["id" => 1, "title" => "Oppdatert dokument", "description" => "Dette dokumentet er oppdatert", "sequence" => "3", "topicId" => "1", "statusId" => "1", "documentTypeId" => "1", "internalId" => "111", "hisNumber" => "222", "comment" => null, "standardId" => null, "previousDocumentId" => null, "nextDocumentId" => null, "links" => [['text' => "aaa", 'description' => "aaa", 'url' => "aaa", 'linkCategoryId' => 1]], "fields" => [], "targetGroups" => []];
     $controller = new DocumentController([1], Response::REQUEST_METHOD_PUT, $new_data);
     $response = $controller->getResponse();
     self::assertIsValidResponse($response);
     print_r($response);
     self::assertIsCorrectResponseData($response->getBody(), $new_data);
 }