BaseHandler.php
11 years ago
EmptyTrashHandler.php
11 years ago
GetTaxonomiesHandler.php
11 years ago
ListingSortHandler.php
11 years ago
NestToggleHandler.php
11 years ago
NewChildHandler.php
11 years ago
NewLinkHandler.php
11 years ago
QuickEditHandler.php
11 years ago
QuickEditLinkHandler.php
11 years ago
SearchHandler.php
11 years ago
SortHandler.php
11 years ago
SyncMenuHandler.php
11 years ago
NestToggleHandler.php
39 lines
| 1 | <?php namespace NestedPages\Form\Handlers; |
| 2 | |
| 3 | use NestedPages\Entities\User\UserRepository; |
| 4 | |
| 5 | /** |
| 6 | * Syncs User's Visible/Toggled Pages |
| 7 | */ |
| 8 | class NestToggleHandler extends BaseHandler { |
| 9 | |
| 10 | public function __construct() |
| 11 | { |
| 12 | parent::__construct(); |
| 13 | $this->updateUserMeta(); |
| 14 | } |
| 15 | |
| 16 | |
| 17 | /** |
| 18 | * Make sure this is an array of integers |
| 19 | */ |
| 20 | private function validateIDs() |
| 21 | { |
| 22 | if ( !is_array($this->data['ids']) ) $this->sendErrorResponse(); |
| 23 | foreach ($this->data['ids'] as $id){ |
| 24 | if ( !is_numeric($id) ) $this->sendErrorResponse(); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | |
| 29 | /** |
| 30 | * Update the user meta with the array of IDs |
| 31 | */ |
| 32 | private function updateUserMeta() |
| 33 | { |
| 34 | $this->user->updateVisiblePages($this->data['posttype'], $this->data['ids']); |
| 35 | $this->response = array('status'=>'success', 'data'=>$this->data); |
| 36 | $this->sendResponse(); |
| 37 | } |
| 38 | |
| 39 | } |