Airship\Cabin\Bridge\Blueprint\UserAccounts::getGroupTree PHP Method

getGroupTree() public method

Get the group tree
public getGroupTree ( integer $parent, string $column = 'children', array $seen = [] ) : array
$parent integer
$column string What to call the child element?
$seen array
return array
    public function getGroupTree(int $parent = 0, string $column = 'children', array $seen = []) : array
    {
        if ($parent > 0) {
            if (empty($seen)) {
                $groups = $this->db->run('SELECT * FROM airship_groups WHERE inherits = ? ORDER BY name ASC', $parent);
            } else {
                $groups = $this->db->run('SELECT * FROM airship_groups WHERE groupid NOT IN ' . $this->db->escapeValueSet($seen, 'int') . ' AND inherits = ? ORDER BY name ASC', $parent);
            }
        } elseif (empty($seen)) {
            $groups = $this->db->run('SELECT * FROM airship_groups WHERE inherits IS NULL ORDER BY name ASC');
        } else {
            $groups = $this->db->run('SELECT * FROM airship_groups WHERE groupid NOT IN ' . $this->db->escapeValueSet($seen, 'int') . ' AND inherits IS NULL ORDER BY name ASC');
        }
        if (empty($groups)) {
            return [];
        }
        foreach ($groups as $i => $grp) {
            $groups[$i][$column] = $this->getGroupTree((int) $grp['groupid'], $column, $seen);
        }
        return $groups;
    }

Usage Example

コード例 #1
0
ファイル: Admin.php プロジェクト: paragonie/airship
 /**
  * @route admin/settings
  */
 public function manageSettings()
 {
     $state = State::instance();
     $settings = ['universal' => $state->universal];
     $post = $this->post(new SettingsFilter());
     if (!empty($post)) {
         if ($this->saveSettings($post)) {
             \Airship\clear_cache();
             \Airship\redirect($this->airship_cabin_prefix . '/admin/settings', ['msg' => 'saved']);
         } else {
             $this->log('Could not save new settings', LogLevel::ALERT);
         }
     }
     // Load individual files...
     $settings['cabins'] = $this->loadJSONConfigFile('cabins.json');
     $settings['content_security_policy'] = $this->loadJSONConfigFile('content_security_policy.json');
     $settings['keyring'] = $this->loadJSONConfigFile('keyring.json');
     foreach (\Airship\list_all_files(ROOT . '/config/supplier_keys/', 'json') as $supplier) {
         $name = \Airship\path_to_filename($supplier, true);
         $settings['suppliers'][$name] = \Airship\loadJSON($supplier);
     }
     $this->lens('admin_settings', ['active_link' => 'bridge-link-admin-settings', 'config' => $settings, 'groups' => $this->acct->getGroupTree()]);
 }
All Usage Examples Of Airship\Cabin\Bridge\Blueprint\UserAccounts::getGroupTree