"Fossies" - the Fresh Open Source Software Archive

Member "fogproject-1.5.9/packages/web/lib/plugins/site/pages/sitemanagementpage.class.php" (13 Sep 2020, 26576 Bytes) of package /linux/misc/fogproject-1.5.9.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "sitemanagementpage.class.php": 1.5.8_vs_1.5.9.

    1 <?php
    2 /**
    3  * Site plugin
    4  *
    5  * PHP version 5
    6  *
    7  * @category SiteManagementPage
    8  * @package  FOGProject
    9  * @author   Fernando Gietz <fernando.gietz@gmail.com>
   10  * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
   11  * @link     https://fogproject.org
   12  */
   13 /**
   14  * Site plugin
   15  *
   16  * @category SiteManagementPage
   17  * @package  FOGProject
   18  * @author   Fernando Gietz <fernando.gietz@gmail.com>
   19  * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
   20  * @link     https://fogproject.org
   21  */
   22 class SiteManagementPage extends FOGPage
   23 {
   24     public $node = 'site';
   25     /**
   26      * Constructor
   27      *
   28      * @param string $name The name for the page.
   29      *
   30      * @return void
   31      */
   32     public function __construct($name = '')
   33     {
   34         /**
   35          * The name to give.
   36          */
   37         $this->name = 'Site Control Management';
   38         /**
   39          * Add this page to the PAGES_WITH_OBJECTS hook event.
   40          */
   41         self::$HookManager->processEvent(
   42             'PAGES_WITH_OBJECTS',
   43             array('PagesWithObjects' => &$this->PagesWithObjects)
   44         );
   45         /**
   46          * Get our $_GET['node'], $_GET['sub'], and $_GET['id']
   47          * in a nicer to use format.
   48          */
   49         global $node;
   50         global $sub;
   51         global $id;
   52         self::$foglang['ExportSite'] = _('Export Sites');
   53         self::$foglang['ImportSite'] = _('Import Sites');
   54         parent::__construct($this->name);
   55         if ($id) {
   56             $this->subMenu = array(
   57                 "$this->linkformat" => self::$foglang['General'],
   58                 $this->membership => self::$foglang['Membership'],
   59                 sprintf(
   60                     '?node=%s&sub=%s&id=%s',
   61                     $this->node,
   62                     'membershipHost',
   63                     $id
   64                 ) => _('Hosts Associated'),
   65                     "$this->delformat" => self::$foglang['Delete'],
   66                 );
   67             $this->notes = array(
   68                 _('Site') => $this->obj->get('name'),
   69                 _('Description') => sprintf(
   70                     '%s',
   71                     $this->obj->get('description')
   72                 ),
   73                 _('Host Associated') => sprintf(
   74                     '%s',
   75                     count($this->obj->get('hosts'))
   76                 )
   77             );
   78         }
   79         $this->headerData = array(
   80             '<input type="checkbox" name="toggle-checkbox" class='
   81             . '"toggle-checkboxAction" checked/>',
   82             _('Site Name'),
   83             _('Site Description'),
   84             _('Hosts')
   85         );
   86         $this->templates = array(
   87             '<input type="checkbox" name="location[]" value='
   88             . '"${id}" class="toggle-action" checked/>',
   89             '<a href="?node=site&sub=edit&id=${id}" title="Edit">${name}</a>',
   90             '${description}',
   91             '${hosts}'
   92         );
   93         $this->attributes = array(
   94             array(
   95                 'class' => 'filter-false',
   96                 'width' => 16
   97             ),
   98             array(),
   99             array(),
  100             array('class' => 'filter-false'),
  101         );
  102         /**
  103          * Lambda function to return data either by list or search.
  104          *
  105          * @param object $Site the object to use
  106          *
  107          * @return void
  108          */
  109         self::$returnData = function (&$Site) {
  110             $this->data[] = array(
  111                 'id' => $Site->id,
  112                 'name' => $Site->name,
  113                 'description' => $Site->description,
  114 //                'hosts' => $Site->getHostCount()
  115                 'hosts' => self::getClass('SiteHostAssociationManager')
  116                         ->count(
  117                             ['siteID' => $Site->id]
  118                         )
  119             );
  120             unset($Site);
  121         };
  122     }
  123     /**
  124      * Creates new item.
  125      *
  126      * @return void
  127      */
  128     public function add()
  129     {
  130         $this->title = _('New Site');
  131         unset(
  132             $this->data,
  133             $this->form,
  134             $this->headerData,
  135             $this->templates,
  136             $this->attributes
  137         );
  138         $this->templates = array(
  139             '${field}',
  140             '${input}',
  141         );
  142         $this->attributes = array(
  143             array('class' => 'col-xs-4'),
  144             array('class' => 'col-xs-8 form-group'),
  145         );
  146         $name = filter_input(INPUT_POST, 'name');
  147         $description = filter_input(INPUT_POST, 'description');
  148         $fields = array(
  149             '<label for="site">'
  150             . _('Site Name')
  151             . '</label>' => '<div class="input-group">'
  152             . '<input type="text" name="name" '
  153             . 'value="'
  154             . $name
  155             . '" class="form-control" '
  156             . 'id="site" required/>',
  157             '<label for="description">'
  158             . _('Site Description')
  159             . '</label>' => '<div class="input-group">'
  160             . '<textarea class="form-control" '
  161             . 'id="description" name="description">'
  162             . $description
  163             . '</textarea>'
  164             . '</div>',
  165             '<label for="add">'
  166             . _('Create Site')
  167             . '</label>' => '<button type="submit" class="btn btn-info btn-block" '
  168             . 'id="add" name="add">'
  169             . _('Create')
  170             . '</button>'
  171         );
  172         self::$HookManager
  173             ->processEvent(
  174                 'SITE_FIELDS',
  175                 array(
  176                     'fields' => &$fields,
  177                     'Site' => self::getClass('Site')
  178                 )
  179             );
  180         array_walk($fields, $this->fieldsToData);
  181         unset($fields);
  182         self::$HookManager
  183             ->processEvent(
  184                 'SITE_ADD',
  185                 array(
  186                     'headerData' => &$this->headerData,
  187                     'data' => &$this->data,
  188                     'templates' => &$this->templates,
  189                     'attributes' => &$this->attributes
  190                 )
  191             );
  192         echo '<div class="col-xs-9">';
  193         echo '<div class="panel panel-info">';
  194         echo '<div class="panel-heading text-center">';
  195         echo '<h4 class="title">';
  196         echo $this->title;
  197         echo '</h4>';
  198         echo '</div>';
  199         echo '<div class="panel-body">';
  200         echo '<form class="form-horizontal" method="post" action="'
  201             . $this->formAction
  202             . '">';
  203         $this->render(12);
  204         echo '</form>';
  205         echo '</div>';
  206         echo '</div>';
  207         echo '</div>';
  208     }
  209     /**
  210      * Add post.
  211      *
  212      * @return void
  213      */
  214     public function addPost()
  215     {
  216         self::$HookManager->processEvent('SITE_ADD_POST');
  217         $name = trim(
  218             filter_input(INPUT_POST, 'name')
  219         );
  220         $description = trim(
  221             filter_input(INPUT_POST, 'description')
  222         );
  223         try {
  224             $exists = self::getClass('SiteManager')
  225                 ->exists($name);
  226             if ($exists) {
  227                 throw new Exception(_('A site already exists with this name!'));
  228             }
  229             $Site = self::getClass('Site')
  230                 ->set('name', $name)
  231                 ->set('description', $description);
  232             if (!$Site->save()) {
  233                 throw new Exception(_('Add site failed!'));
  234             }
  235             $hook = 'SITE_ADD_SUCCESS';
  236             $msg = json_encode(
  237                 array(
  238                     'msg' => _('Site added!'),
  239                     'title' => _('Site Create Success')
  240                 )
  241             );
  242         } catch (Exception $e) {
  243             $hook = 'SITE_ADD_FAIL';
  244             $msg = json_encode(
  245                 array(
  246                     'error' => $e->getMessage(),
  247                     'title' => _('Site Create Fail')
  248                 )
  249             );
  250         }
  251         self::$HookManager
  252             ->processEvent(
  253                 $hook,
  254                 array('Site' => &$Site)
  255             );
  256         unset($Site);
  257         echo $msg;
  258         exit;
  259     }
  260     /**
  261      * Display site general information.
  262      *
  263      * @return void
  264      */
  265     public function siteGeneral()
  266     {
  267         unset(
  268             $this->data,
  269             $this->form,
  270             $this->templates,
  271             $this->attributes,
  272             $this->headerData
  273         );
  274         $name = (
  275             filter_input(INPUT_POST, 'name') ?:
  276             $this->obj->get('name')
  277         );
  278         $description = (
  279             filter_input(INPUT_POST, 'description') ?:
  280             $this->obj->get('description')
  281         );
  282         $this->attributes = array(
  283             array('class' => 'col-xs-4'),
  284             array('class' => 'col-xs-8 form-group')
  285         );
  286         $this->templates = array(
  287             '${field}',
  288             '${input}'
  289         );
  290         $fields = array(
  291             '<label for="name">'
  292             . _('Site Name')
  293             . '</label>' => '<div class="input-group">'
  294             . '<input class="form-control sitename-input" type="text" '
  295             . 'name="name" id="name" '
  296             . 'value="'
  297             . $name
  298             . '"/>'
  299             . '</div>',
  300             '<label for="description">'
  301             . _('Site Description')
  302             . '</label>' => '<div class="input-group">'
  303             . '<textarea name="description" class="form-control sitedesc-input" '
  304             . 'id="description">'
  305             . $description
  306             . '</textarea>'
  307             . '</div>',
  308             '<label for="updategen">'
  309             . _('Make Changes?')
  310             . '</label>' => '<button class="btn btn-info btn-block" type="submit" '
  311             . 'id="updategen" name="update">'
  312             . _('Update')
  313             . '</button>'
  314         );
  315         self::$HookManager
  316             ->processEvent(
  317                 'SITE_FIELDS',
  318                 array(
  319                     'fields' => &$fields,
  320                     'Site' => &$this->obj
  321                 )
  322             );
  323         array_walk($fields, $this->fieldsToData);
  324         self::$HookManager
  325             ->processEvent(
  326                 'SITE_EDIT',
  327                 array(
  328                     'headerData' => &$this->headerData,
  329                     'data' => &$this->data,
  330                     'templates' => &$this->templates,
  331                     'attributes' => &$this->attributes
  332                 )
  333             );
  334         echo '<!-- General -->';
  335         echo '<div class="tab-pane fade in active" id="site-gen">';
  336         echo '<div class="panel panel-info">';
  337         echo '<div class="panel-heading text-center">';
  338         echo '<h4 class="title">';
  339         echo _('Site General');
  340         echo '</h4>';
  341         echo '</div>';
  342         echo '<div class="panel-body">';
  343         echo '<form class="form-horizontal" method="post" action="'
  344             . $this->formAction
  345             . '&tab=site-gen">';
  346         $this->render(12);
  347         echo '</form>';
  348         echo '</div>';
  349         echo '</div>';
  350         echo '</div>';
  351         unset(
  352             $this->data,
  353             $this->form,
  354             $this->templates,
  355             $this->attributes,
  356             $this->headerData
  357         );
  358     }
  359     /**
  360      * Edit.
  361      *
  362      * @return void
  363      */
  364     public function edit()
  365     {
  366         echo '<div class="col-xs-9 tab-content">';
  367         $this->siteGeneral();
  368         echo '</div>';
  369     }
  370     /**
  371      * Edit post.
  372      *
  373      * @return void
  374      */
  375     public function editPost()
  376     {
  377         self::$HookManager
  378             ->processEvent(
  379                 'SITE_EDIT_POST',
  380                 array(
  381                     'Site' => &$this->obj
  382                 )
  383             );
  384         global $tab;
  385         $name = trim(
  386             filter_input(INPUT_POST, 'name')
  387         );
  388         $description = trim(
  389             filter_input(INPUT_POST, 'description')
  390         );
  391         try {
  392             switch ($tab) {
  393             case 'site-gen':
  394                 if ($this->obj->get('name') != $name
  395                     && self::getClass('SiteManager')->exists(
  396                         $name,
  397                         $this->obj->get('id')
  398                     )
  399                 ) {
  400                     throw new Exception(
  401                         _('A site alread exists with this name!')
  402                     );
  403                 }
  404                 $this->obj
  405                     ->set('name', $name)
  406                     ->set('description', $description);
  407                 break;
  408             }
  409             if (!$this->obj->save()) {
  410                 throw new Exception(_('Site update failed!'));
  411             }
  412             $hook = 'SITE_UPDATE_SUCCESS';
  413             $msg = json_encode(
  414                 array(
  415                     'msg' => _('Site Updated!'),
  416                     'title' => _('Site Update Success')
  417                 )
  418             );
  419         } catch (Exception $e) {
  420             $hook = 'SITE_UPDATE_FAIL';
  421             $msg = json_encode(
  422                 array(
  423                     'error' => $e->getMessage(),
  424                     'title' => _('Site Update Fail')
  425                 )
  426             );
  427         }
  428         self::$HookManager
  429             ->processEvent(
  430                 $hook,
  431                 array('Site' => &$this->obj)
  432             );
  433         echo $msg;
  434         exit;
  435     }
  436     /**
  437      * List the hosts which are associated to a site
  438      *
  439      * @return void
  440      */
  441     public function membershipHost()
  442     {
  443         unset(
  444             $this->data,
  445             $this->form,
  446             $this->headerData,
  447             $this->templates,
  448             $this->attributes
  449         );
  450         $this->headerData = array(
  451             '<label for="togglerHost">'
  452             . '<input type="checkbox" name="toggle-checkbox'
  453             . $this->node
  454             . '" class="toggle-checkboxhost" id="togglerHost"/>'
  455             . '</label>',
  456             _('Host Name')
  457         );
  458         $this->templates = array(
  459             '<label for="host-${host_id}">'
  460             . '<input type="checkbox" name="host[]" class="toggle-'
  461             . 'host" id="host-${host_id}" '
  462             . 'value="${host_id}"/>'
  463             . '</label>',
  464             '<a href="?node=host&sub=edit&id=${host_id}">'
  465             . '${host_name}</a>'
  466         );
  467         $this->attributes = array(
  468             array(
  469                 'width' => 16,
  470                 'class' => 'filter-false'
  471             ),
  472             array(
  473                 'data-toggle' => 'tooltip',
  474                 'data-placement' => 'bottom',
  475                 'title' => _('Edit')
  476                 . ' '
  477                 . '${host_name}'
  478             )
  479         );
  480         Route::listem('host');
  481         $items = json_decode(
  482             Route::getData()
  483         );
  484         $items = $items->hosts;
  485         $getter = 'hostsnotinme';
  486         $returnData = function (&$item) use (&$getter) {
  487             $this->obj->get($getter);
  488             if (!in_array($item->id, (array)$this->obj->get($getter))) {
  489                 return;
  490             }
  491             $this->data[] = array(
  492                 'host_id' => $item->id,
  493                 'host_name' => $item->name
  494             );
  495         };
  496         array_walk($items, $returnData);
  497         echo '<!-- Host Membership -->';
  498         echo '<div class="col-xs-9">';
  499         echo '<div class="tab-pane fade in active" id="'
  500             . $this->node
  501             . '-membershipHost">';
  502         echo '<div class="panel panel-info">';
  503         echo '<div class="panel-heading text-center">';
  504         echo '<h4 class="title">';
  505         echo _('Host Membership');
  506         echo '</h4>';
  507         echo '</div>';
  508         echo '<div class="panel-body">';
  509         echo '<form class="form-horizontal" method="post" action="'
  510             . $this->formAction
  511             . '">';
  512         if (count($this->data) > 0) {
  513             $notInMe = $meShow = 'host';
  514             $meShow .= 'MeShow';
  515             $notInMe .= 'NotInMe';
  516             echo '<div class="text-center">';
  517             echo '<div class="checkbox">';
  518             echo '<label for="'
  519                 . $meShow
  520                 . '">';
  521             echo '<input type="checkbox" name="'
  522                 . $meShow
  523                 . '" id="'
  524                 . $meShow
  525                 . '"/>';
  526             echo _('Check here to see what hosts can be added');
  527             echo '</label>';
  528             echo '</div>';
  529             echo '</div>';
  530             echo '<br/>';
  531             echo '<div class="hiddeninitially panel panel-info" id="'
  532                 . $notInMe
  533                 . '">';
  534             echo '<div class="panel-heading text-center">';
  535             echo '<h4 class="title">';
  536             echo _('Add Hosts');
  537             echo '</h4>';
  538             echo '</div>';
  539             echo '<div class="panel-body">';
  540             $this->render(12);
  541             echo '<div class="form-group">';
  542             echo '<label for="updatehosts" class="control-label col-xs-4">';
  543             echo _('Add selected hosts');
  544             echo '</label>';
  545             echo '<div class="col-xs-8">';
  546             echo '<button type="submit" name="addHosts" '
  547                 . 'id="updatehosts" class="btn btn-info btn-block">'
  548                 . _('Add')
  549                 . '</button>';
  550             echo '</div>';
  551             echo '</div>';
  552             echo '</div>';
  553             echo '</div>';
  554         }
  555         unset(
  556             $this->data,
  557             $this->form,
  558             $this->headerData,
  559             $this->templates
  560         );
  561         $this->headerData = array(
  562             '<label for="togglerHosts1">'
  563             . '<input type="checkbox" name="toggle-hostrm" '
  564             . 'class="toggle-checkboxhostrm" id="togglerHosts1"/></label>',
  565             _('Host Name')
  566         );
  567         $this->templates = array(
  568             '<label for="hostrm-${host_id}">'
  569             . '<input type="checkbox" name="hostdel[]" '
  570             . 'value="${host_id}" class="toggle-hostrm" id="'
  571             . 'hostrm-${host_id}"/>'
  572             . '</label>',
  573             '<a href="?node=host&sub=edit&id=${host_id}">'
  574             . '${host_name}</a>'
  575         );
  576         $getter = 'hosts';
  577         array_walk($items, $returnData);
  578         if (count($this->data) > 0) {
  579             echo '<div class="panel panel-warning">';
  580             echo '<div class="panel-heading text-center">';
  581             echo '<h4 class="title">';
  582             echo _('Remove Hosts');
  583             echo '</h4>';
  584             echo '</div>';
  585             echo '<div class="panel-body">';
  586             $this->render(12);
  587             echo '<div class="form-group">';
  588             echo '<label for="remhosts" class="control-label col-xs-4">';
  589             echo _('Remove selected hosts');
  590             echo '</label>';
  591             echo '<div class="col-xs-8">';
  592             echo '<button type="submit" name="remhosts" class='
  593                 . '"btn btn-danger btn-block" id="remhosts">'
  594                 . _('Remove')
  595                 . '</button>';
  596             echo '</div>';
  597             echo '</div>';
  598             echo '</div>';
  599             echo '</div>';
  600         }
  601         echo '</form>';
  602         echo '</div>';
  603         echo '</div>';
  604         echo '</div>';
  605         echo '</div>';
  606     }
  607     /**
  608      * Post assoc host adjustments.
  609      *
  610      * @return void
  611      */
  612     public function membershipHostPost()
  613     {
  614         $flags = array(
  615             'flags' => FILTER_REQUIRE_ARRAY
  616         );
  617         $reqitems = filter_input_array(
  618             INPUT_POST,
  619             array(
  620                 'host' => $flags,
  621                 'hostdel' => $flags
  622             )
  623         );
  624         $hosts = $reqitems['host'];
  625         $hostsdel = $reqitems['hostdel'];
  626         if (isset($_POST['addHosts'])) {
  627             $this->obj->addHost($hosts);
  628         }
  629         if (isset($_POST['remhosts'])) {
  630             $this->obj->removeHost($hostsdel);
  631         }
  632         if ($this->obj->save()) {
  633             self::redirect($this->formAction);
  634         }
  635     }
  636     /**
  637      * Custom membership method.
  638      *
  639      * @return void
  640      */
  641     public function membership()
  642     {
  643         unset(
  644             $this->data,
  645             $this->form,
  646             $this->headerData,
  647             $this->templates,
  648             $this->attributes
  649         );
  650         $this->headerData = array(
  651             '<label for="toggler">'
  652             . '<input type="checkbox" name="toggle-checkbox'
  653             . $this->node
  654             . '" class="toggle-checkboxuser" id="toggler"/>'
  655             . '</label>',
  656             _('User Name'),
  657             _('Friendly Name')
  658         );
  659         $this->templates = array(
  660             '<label for="user-${user_id}">'
  661             . '<input type="checkbox" name="user[]" class="toggle-'
  662             . 'user" id="user-${user_id}" '
  663             . 'value="${user_id}"/>'
  664             . '</label>',
  665             '<a href="?node=user&sub=edit&id=${user_id}">'
  666             . '${user_name}</a>',
  667             '${friendly}'
  668         );
  669         $this->attributes = array(
  670             array(
  671                 'width' => 16,
  672                 'class' => 'filter-false'
  673             ),
  674             array(
  675                 'data-toggle' => 'tooltip',
  676                 'data-placement' => 'bottom',
  677                 'title' => _('Edit')
  678                 . ' '
  679                 . '${user_name}'
  680             ),
  681             array()
  682         );
  683         Route::listem('user');
  684         $items = json_decode(
  685             Route::getData()
  686         );
  687         $items = $items->users;
  688         $getter = 'usersnotinme';
  689         $returnData = function (&$item) use (&$getter) {
  690             $this->obj->get($getter);
  691             if (!in_array($item->id, (array)$this->obj->get($getter))) {
  692                 return;
  693             }
  694             $this->data[] = array(
  695                 'user_id' => $item->id,
  696                 'user_name' => $item->name,
  697                 'friendly' => $item->display
  698             );
  699         };
  700         array_walk($items, $returnData);
  701         echo '<!-- Membership -->';
  702         echo '<div class="col-xs-9">';
  703         echo '<div class="tab-pane fade in active" id="'
  704             . $this->node
  705             . '-membership">';
  706         echo '<div class="panel panel-info">';
  707         echo '<div class="panel-heading text-center">';
  708         echo '<h4 class="title">';
  709         echo $this->childClass
  710             . ' '
  711             . _('Membership');
  712         echo '</h4>';
  713         echo '</div>';
  714         echo '<div class="panel-body">';
  715         echo '<form class="form-horizontal" method="post" action="'
  716             . $this->formAction
  717             . '">';
  718         if (count($this->data) > 0) {
  719             $notInMe = $meShow = 'user';
  720             $meShow .= 'MeShow';
  721             $notInMe .= 'NotInMe';
  722             echo '<div class="text-center">';
  723             echo '<div class="checkbox">';
  724             echo '<label for="'
  725                 . $meShow
  726                 . '">';
  727             echo '<input type="checkbox" name="'
  728                 . $meShow
  729                 . '" id="'
  730                 . $meShow
  731                 . '"/>';
  732             echo _('Check here to see what users can be added');
  733             echo '</label>';
  734             echo '</div>';
  735             echo '</div>';
  736             echo '<br/>';
  737             echo '<div class="hiddeninitially panel panel-info" id="'
  738                 . $notInMe
  739                 . '">';
  740             echo '<div class="panel-heading text-center">';
  741             echo '<h4 class="title">';
  742             echo _('Add Users');
  743             echo '</h4>';
  744             echo '</div>';
  745             echo '<div class="panel-body">';
  746             $this->render(12);
  747             echo '<div class="form-group">';
  748             echo '<label for="updateusers" class="control-label col-xs-4">';
  749             echo _('Add selected users');
  750             echo '</label>';
  751             echo '<div class="col-xs-8">';
  752             echo '<button type="submit" name="addUsers" '
  753                 . 'id="updateusers" class="btn btn-info btn-block">'
  754                 . _('Add')
  755                 . '</button>';
  756             echo '</div>';
  757             echo '</div>';
  758             echo '</div>';
  759             echo '</div>';
  760         }
  761         unset(
  762             $this->data,
  763             $this->form,
  764             $this->headerData,
  765             $this->templates
  766         );
  767         $this->headerData = array(
  768             '<label for="toggler1">'
  769             . '<input type="checkbox" name="toggle-checkbox" '
  770             . 'class="toggle-checkboxuserrm" id="toggler1"/></label>',
  771             _('User Name'),
  772             _('Friendly Name')
  773         );
  774         $this->templates = array(
  775             '<label for="userrm-${user_id}">'
  776             . '<input type="checkbox" name="userdel[]" '
  777             . 'value="${user_id}" class="toggle-userrm" id="'
  778             . 'userrm-${user_id}"/>'
  779             . '</label>',
  780             '<a href="?node=user&sub=edit&id=${user_id}">'
  781             . '${user_name}</a>',
  782             '${friendly}'
  783         );
  784         $getter = 'users';
  785         array_walk($items, $returnData);
  786         if (count($this->data) > 0) {
  787             echo '<div class="panel panel-warning">';
  788             echo '<div class="panel-heading text-center">';
  789             echo '<h4 class="title">';
  790             echo _('Remove Users');
  791             echo '</h4>';
  792             echo '</div>';
  793             echo '<div class="panel-body">';
  794             $this->render(12);
  795             echo '<div class="form-group">';
  796             echo '<label for="remusers" class="control-label col-xs-4">';
  797             echo _('Remove selected users');
  798             echo '</label>';
  799             echo '<div class="col-xs-8">';
  800             echo '<button type="submit" name="remusers" class='
  801                 . '"btn btn-danger btn-block" id="remusers">'
  802                 . _('Remove')
  803                 . '</button>';
  804             echo '</div>';
  805             echo '</div>';
  806             echo '</div>';
  807             echo '</div>';
  808         }
  809         echo '</form>';
  810         echo '</div>';
  811         echo '</div>';
  812         echo '</div>';
  813         echo '</div>';
  814     }
  815     /**
  816      * Customize membership actions
  817      *
  818      * @return void
  819      */
  820     public function membershipPost()
  821     {
  822         $flags = array(
  823             'flags' => FILTER_REQUIRE_ARRAY
  824         );
  825         $reqitems = filter_input_array(
  826             INPUT_POST,
  827             array(
  828                 'user' => $flags,
  829                 'userdel' => $flags
  830             )
  831         );
  832         $users = $reqitems['user'];
  833         $usersdel = $reqitems['userdel'];
  834         if (isset($_POST['addUsers'])) {
  835             $this->obj->addUser($users);
  836         }
  837         if (isset($_POST['remusers'])) {
  838             $this->obj->removeUser($usersdel);
  839         }
  840         if ($this->obj->save()) {
  841             self::redirect($this->formAction);
  842         }
  843     }
  844 }