Index: trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php |
— | — | @@ -23,6 +23,8 @@ |
24 | 24 | */ |
25 | 25 | protected $time; |
26 | 26 | |
| 27 | + protected $id; |
| 28 | + |
27 | 29 | /** |
28 | 30 | * The title of the page the changeset holds changes for. |
29 | 31 | * |
— | — | @@ -31,15 +33,40 @@ |
32 | 34 | protected $title = false; |
33 | 35 | |
34 | 36 | /** |
| 37 | + * |
| 38 | + * |
| 39 | + * @param $set |
| 40 | + * |
| 41 | + * @return SWLChangeSet |
| 42 | + */ |
| 43 | + public static function newFromDBResult( $set ) { |
| 44 | + $changeSet = new SMWChangeSet( |
| 45 | + SMWDIWikiPage::newFromTitle( Title::newFromID( $set->cg_page_id ) ) |
| 46 | + ); |
| 47 | + |
| 48 | + $changeSet = new SWLChangeSet( // swl_change_groups |
| 49 | + $changeSet, |
| 50 | + User::newFromName( $set->cg_user_name ), |
| 51 | + $set->cg_time, |
| 52 | + $set->cg_id |
| 53 | + ); |
| 54 | + |
| 55 | + return $changeSet; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
35 | 59 | * Constructor. |
36 | 60 | * |
| 61 | + * @param SMWChangeSet $changeSet |
37 | 62 | * @param User $user |
38 | 63 | * @param integer $time |
| 64 | + * @param integer $id |
39 | 65 | */ |
40 | | - public function __construct( SMWChangeSet $changeSet, /* User */ $user = null, $time = null ) { |
| 66 | + public function __construct( SMWChangeSet $changeSet, /* User */ $user = null, $time = null, $id = null ) { |
41 | 67 | $this->changeSet = $changeSet; |
42 | 68 | $this->time = $time; |
43 | 69 | $this->user = is_null( $user ) ? $GLOBALS['wgUser'] : $user; |
| 70 | + $this->id = $id; |
44 | 71 | } |
45 | 72 | |
46 | 73 | /** |
— | — | @@ -68,8 +95,8 @@ |
69 | 96 | $dbr->insert( |
70 | 97 | 'swl_change_groups', |
71 | 98 | array( |
72 | | - 'cg_user_name' => $this->getUser(), |
73 | | - 'cg_page_id' => $this->getTitle(), |
| 99 | + 'cg_user_name' => $this->getUser()->getName(), |
| 100 | + 'cg_page_id' => $this->getTitle()->getArticleID(), |
74 | 101 | 'cg_time' => is_null( $this->getTime() ) ? $dbw->timestamp() : $this->getTime() |
75 | 102 | ) |
76 | 103 | ); |
— | — | @@ -83,20 +110,20 @@ |
84 | 111 | return $this->title; |
85 | 112 | } |
86 | 113 | |
87 | | - public function setUser() { |
88 | | - |
| 114 | + public function setUser( User $user ) { |
| 115 | + $this->user = $user; |
89 | 116 | } |
90 | 117 | |
91 | 118 | public function getUser() { |
92 | | - |
| 119 | + return $this->user; |
93 | 120 | } |
94 | 121 | |
95 | | - public function setTime() { |
96 | | - |
| 122 | + public function setTime( $time ) { |
| 123 | + $this->time = $time; |
97 | 124 | } |
98 | 125 | |
99 | 126 | public function getTime() { |
100 | | - |
| 127 | + return $this->time; |
101 | 128 | } |
102 | 129 | |
103 | 130 | } |
\ No newline at end of file |