Id(); } function get_children($Group) { global $children; $kids = array(); if ( isset( $children[$Group->Id()] ) ) { $kids += array_map('get_Id', $children[$Group->Id()]); foreach ( $children[$Group->Id()] as $G ) { foreach ( get_children($G) as $id ) { $kids[] = $id; } } } return $kids; } function parentGrpSelect($newGroup) { $Groups = array(); foreach ( ZM\Group::find() as $Group ) { $Groups[$Group->Id()] = $Group; } # This array is indexed by parent_id $children = array(); foreach ( $Groups as $id=>$Group ) { if ( $Group->ParentId() != null ) { if ( ! isset( $children[$Group->ParentId()] ) ) $children[$Group->ParentId()] = array(); $children[$Group->ParentId()][] = $Group; } } $kids = get_children($newGroup); if ( $newGroup->Id() ) $kids[] = $newGroup->Id(); $sql = 'SELECT Id,Name FROM `Groups`'.(count($kids)?' WHERE Id NOT IN ('.implode(',',array_map(function(){return '?';}, $kids)).')' : '').' ORDER BY Name'; $options = array(''=>'None'); foreach ( dbFetchAll($sql, null, $kids) as $option ) { $options[$option['Id']] = str_repeat(' ', $Groups[$option['Id']]->depth()) . $option['Name']; } return htmlSelect('newGroup[ParentId]', $options, $newGroup->ParentId(), array('data-on-change'=>'configureButtons')); } function monitorList($newGroup) { $result = ''; $monitors = dbFetchAll('SELECT Id,Name FROM Monitors ORDER BY Sequence ASC'); $monitorIds = $newGroup->MonitorIds(); foreach ( $monitors as $monitor ) { if ( visibleMonitor($monitor['Id']) ) { $result .= ''.PHP_EOL; } } return $result; } // // INITIAL SANITY CHECKS // if ( !canEdit('Groups') ) { $view = 'error'; return; } if ( !empty($_REQUEST['gid']) ) { $newGroup = new ZM\Group($_REQUEST['gid']); } else { $newGroup = new ZM\Group(); } // // BEGIN HTML // xhtmlHeaders(__FILE__, translate('Group').' - '.$newGroup->Name()); ?>