sunnysideup /
silverstripe-sharethis
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SunnysideUp\ShareThis; |
||
| 4 | |||
| 5 | use SilverStripe\Core\Config\Config; |
||
| 6 | use SilverStripe\Core\Convert; |
||
| 7 | use SunnysideUp\ShareThis\FacebookFeed_Item; |
||
| 8 | use SilverStripe\Control\Controller; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * RemoveFacebookItemController |
||
| 12 | */ |
||
| 13 | class RemoveFacebookItemController extends Controller |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | private static $allowed_actions = [ |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 19 | 'remove' => 'ADMIN' |
||
| 20 | ]; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private static $url_segment = 'removefacebooklink'; |
||
|
0 ignored issues
–
show
|
|||
| 26 | |||
| 27 | /** |
||
| 28 | * Link |
||
| 29 | * |
||
| 30 | * @return string |
||
| 31 | */ |
||
| 32 | public function Link($action = null) |
||
| 33 | { |
||
| 34 | $urlSegment = Config::inst()->get(RemoveFacebookItemController::class, 'url_segment'); |
||
| 35 | return '/'.$urlSegment.'/'.$action; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * remove |
||
| 40 | * |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | public function remove($request) |
||
| 44 | { |
||
| 45 | $uid = Convert::raw2sql($request->param('ID')); |
||
| 46 | $item = FacebookFeed_Item::get()->filter(array("UID" => $uid))->first(); |
||
| 47 | if ($item) { |
||
|
0 ignored issues
–
show
|
|||
| 48 | $item->Hide = true; |
||
| 49 | $item->write(); |
||
| 50 | $this->redirect('/?flush=all'); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 |