示例#1
0
 /**
  * Override prepareViewForColumnActions to hide/show lock/unlock actions
  * @param \Nethgui\View\ViewInterface $view
  * @param string $key The data row key
  * @param array $values The data row values
  * @return \Nethgui\View\ViewInterface 
  */
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     $killList = array();
     # Users are from remote source, do not display any action
     if (!isset($values['new']) && !isset($values['new']) && !isset($values['new'])) {
         return null;
     }
     if ($values['new'] || $values['expired']) {
         $killList[] = 'lock';
         $killList[] = 'unlock';
     } else {
         if ($values['locked']) {
             $killList[] = 'lock';
         } else {
             $killList[] = 'unlock';
         }
     }
     foreach (array_keys(iterator_to_array($cellView)) as $key) {
         if (in_array($key, $killList)) {
             unset($cellView[$key]);
         }
     }
     return $cellView;
 }
 /**
  * Override prepareViewForColumnActions to hide/show lock/unlock actions
  * @param \Nethgui\View\ViewInterface $view
  * @param string $key The data row key
  * @param array $values The data row values
  * @return \Nethgui\View\ViewInterface 
  */
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     $killList = array();
     $state = isset($values['__state']) ? $values['__state'] : 'new';
     switch ($state) {
         case 'new':
             $killList[] = 'lock';
             $killList[] = 'unlock';
             break;
         case 'active':
             $killList[] = 'unlock';
             break;
         case 'locked':
             $killList[] = 'lock';
             break;
         default:
             break;
     }
     foreach (array_keys(iterator_to_array($cellView)) as $key) {
         if (in_array($key, $killList)) {
             unset($cellView[$key]);
         }
     }
     if (isset($values['Removable']) && $values['Removable'] === 'no') {
         unset($cellView['delete']);
     }
     return $cellView;
 }
 /**
  * Honour "Removable=no" prop.
  *
  * @param \Nethgui\Controller\Table\Read $action
  * @param \Nethgui\View\ViewInterface $view
  * @param type $key
  * @param type $values
  * @param type $rowMetadata
  * @return type
  */
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     if (isset($values['Removable']) && $values['Removable'] === 'no') {
         unset($cellView['delete']);
     }
     return $cellView;
 }
示例#4
0
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     if ($values['Default']) {
         unset($cellView['SetDefault']);
     }
     return $cellView;
 }
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     if (!isset($values['LeaseStatus']) || $values['LeaseStatus'] & 0x2) {
         unset($cellView['Reserve']);
     } else {
         unset($cellView['update']);
         unset($cellView['delete']);
         $rowMetadata['rowCssClass'] .= ' free';
     }
     if (!isset($values['LeaseStatus']) || !($values['LeaseStatus'] & 0x1)) {
         $rowMetadata['rowCssClass'] .= ' expired padicon';
     }
     return $cellView;
 }
 /**
  * Override prepareViewForColumnActions to hide/show enable/disable actions
  * @param \Nethgui\View\ViewInterface $view
  * @param string $key The data row key
  * @param array $values The data row values
  * @return \Nethgui\View\ViewInterface 
  */
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     $killList = array();
     $state = isset($values['active']) ? $values['active'] : 'YES';
     switch ($state) {
         case 'YES':
             $remove = 'enable';
             break;
         case 'NO':
             $remove = 'disable';
             break;
         default:
             break;
     }
     unset($cellView[$remove]);
     return $cellView;
 }
 /**
  * Override prepareViewForColumnActions to hide/show delete action
  * @param \Nethgui\View\ViewInterface $view
  * @param string $key The data row key
  * @param array $values The data row values
  * @return \Nethgui\View\ViewInterface
  */
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     $nicInfo = $this->getNicInfo();
     $role = isset($values['role']) ? $values['role'] : '';
     $isPresent = isset($nicInfo[$key]) && strtolower($nicInfo[$key]) === strtolower($values['hwaddr']);
     $isLogicalDevice = in_array($values['type'], array('alias', 'bridge', 'bond', 'vlan', 'xdsl'));
     $isPhysicalInterface = in_array($values['type'], array('ethernet'));
     $isEditable = !in_array($values['type'], array('alias', 'xdsl')) && !in_array($role, array('slave', 'bridged', 'pppoe'));
     $canHaveIpAlias = $isPresent && $values['type'] !== 'alias' && !in_array($role, array('slave', 'bridged', 'pppoe'));
     $isXdsl = $values['type'] === 'xdsl';
     if (!$isLogicalDevice) {
         unset($cellView['DeleteLogicalInterface']);
     }
     if (!$isPhysicalInterface || $role === '') {
         unset($cellView['ReleasePhysicalInterface']);
     }
     if (!$isEditable) {
         unset($cellView['Edit']);
     }
     if (!$canHaveIpAlias) {
         unset($cellView['CreateIpAlias']);
     }
     if ($isPresent || $isLogicalDevice) {
         unset($cellView['CleanPhysicalInterface']);
     } else {
         unset($cellView['Edit']);
     }
     if ($isXdsl) {
         unset($cellView['CleanPhysicalInterface']);
     } else {
         unset($cellView['SetPppoeParameters']);
     }
     return $cellView;
 }
 public function prepareViewForColumnActions(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $serviceStatusCache = $this->getServiceStatusCache();
     $cellView = $action->prepareViewForColumnActions($view, $key, $values, $rowMetadata);
     if (isset($serviceStatusCache[$key]) && isset($serviceStatusCache[$key]['running'])) {
         if ($serviceStatusCache[$key]['running']) {
             unset($cellView['start']);
         } else {
             unset($cellView['stop']);
             unset($cellView['restart']);
         }
     }
     return $cellView;
 }