xref: /plugin/approve/PageRemoteResponse.php (revision 85d094b0e9288dfb869c943f9805eff0e173d5ca)
1<?php
2
3namespace dokuwiki\plugin\approve;
4
5use dokuwiki\Remote\Response\Page;
6
7/**
8 * Represents a page to return as result in the remote API
9 */
10class PageRemoteResponse extends Page
11{
12    /** @var string User or Group assigned to approve this page */
13    public $approver;
14
15    /** @var string The current state of approval: draft, ready_for_approval, approved */
16    public $status;
17
18    /** @var int Timestamp of approval, 0 if not approved */
19    public $approved;
20
21    /** @var int Timestamp of ready for approval, 0 if not ready */
22    public $ready_for_approval;
23
24    /** @var string User who approved this page, empty if not approved */
25    public $approved_by;
26
27    /** @var string User who marked this page as ready for approval, empty if not ready */
28    public $ready_for_approval_by;
29
30    /** @var string not returned by this endpoint - will always be empty */
31    public $author = '';
32
33    /** @var string not returned by this endpoint - will always be empty */
34    public $hash = '';
35
36
37    /**
38     * @param array $data The data as returned by helper_db::getPages
39     */
40    public function __construct($data)
41    {
42        parent::__construct(
43            $data['id'],
44            $data['rev'],
45        );
46
47        $this->approver = $data['approver'];
48        $this->status = $data['status'];
49
50        $this->approved = $data['approved'] ? strtotime($data['approved']) : 0;
51        $this->ready_for_approval = $data['ready_for_approval'] ? strtotime($data['ready_for_approval']) : 0;
52
53        $this->approved_by = (string)$data['approved_by'];
54        $this->ready_for_approval_by = (string)$data['ready_for_approval_by'];
55    }
56}
57