1+ <?php
2+ /**
3+ * Copyright 2018 OpenStack Foundation
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ * Unless required by applicable law or agreed to in writing, software
9+ * distributed under the License is distributed on an "AS IS" BASIS,
10+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+ * See the License for the specific language governing permissions and
12+ * limitations under the License.
13+ **/
14+
15+ final class GridFieldSeedAllowedTagOnAllSummitTracksColumnAction
16+ implements GridField_ColumnProvider, GridField_ActionProvider
17+ {
18+ public function augmentColumns ($ gridField , &$ columns )
19+ {
20+ if (!in_array ('Actions ' , $ columns )) {
21+ $ columns [] = 'Actions ' ;
22+ }
23+ }
24+
25+ public function getColumnAttributes ($ gridField , $ record , $ columnName )
26+ {
27+ return ['class ' => 'col-buttons ' ];
28+ }
29+
30+ public function getColumnMetadata ($ gridField , $ columnName )
31+ {
32+ if ($ columnName == 'Actions ' ) {
33+ return ['title ' => '' ];
34+ }
35+ }
36+
37+ public function getColumnsHandled ($ gridField )
38+ {
39+ return array ('Actions ' );
40+ }
41+
42+ public function getColumnContent ($ gridField , $ record , $ columnName )
43+ {
44+ if (!$ record ->canEdit ()) return ;
45+
46+ $ tag = $ gridField ->getList ()->byID ($ record ->ID );
47+
48+ $ title = 'Seed Tag on All Tracks Allowed Tags ' ;
49+ $ icon = 'add ' ;
50+
51+ $ field = GridField_FormAction::create ($ gridField , 'seedallowedtagonallsummittracks ' . $ record ->ID , false , "seedallowedtagonallsummittracks " ,
52+ ['RecordID ' => $ record ->ID ])
53+ ->setAttribute ('title ' , $ title )
54+ ->setAttribute ('data-icon ' , $ icon )
55+ ->setDescription ($ title );
56+
57+ return $ field ->Field ();
58+ }
59+
60+ public function getActions ($ gridField )
61+ {
62+ return ['seedallowedtagonallsummittracks ' ];
63+ }
64+
65+ public function handleAction (GridField $ gridField , $ actionName , $ arguments , $ data )
66+ {
67+ if ($ actionName == 'seedallowedtagonallsummittracks ' ) {
68+
69+ $ tag = $ gridField ->getList ()->byID ($ arguments ['RecordID ' ]);
70+ $ summit_id = $ _REQUEST ['SummitID ' ];
71+
72+ Summit::seedTagOnAllTracksAllowedTags (
73+ Summit::get ()->byID ($ summit_id ),
74+ $ tag
75+ );
76+ $ code = 200 ;
77+ $ msg = 'tag added sucessfull from all summit tracks ' ;
78+
79+ try {
80+
81+ } catch (Exception $ ex ) {
82+ throw new ValidationException ($ ex ->getMessage (), 0 );
83+ }
84+
85+ Controller::curr ()->getResponse ()->setStatusCode ($ code , $ msg );
86+ }
87+ }
88+ }
0 commit comments