fields['id'] = 0; $this->fields['nombre'] = 'All'; } else if (is_numeric($id_group) === true) { parent::__construct('tgrupo', ['id_grupo' => $id_group]); if ($recursive === true) { // Customize certain fields. $this->fields['parent'] = new Group($this->fields['parent']); } } else { // Empty skel. parent::__construct('tgrupo'); } } /** * Return an array of ids with all children * * @param boolean $ids_only Return an array of id_groups or * entire rows. * @param boolean $ignorePropagationState Search all children ignoring or * depending on propagate_acl flag. * * @return array With all children. */ public function getChildren( bool $ids_only=false, bool $ignorePropagationState=false ) { $available_groups = \groups_get_children( $this->id_grupo(), $ignorePropagationState ); if (is_array($available_groups) === false) { return []; } if ($ids_only === true) { return array_keys($available_groups); } return $available_groups; } /** * Saves current group definition to database. * * @return mixed Affected rows of false in case of error. */ public function save() { global $config; if (isset($config['centralized_management']) && $config['centralized_management'] > 0 ) { throw new \Exception( get_class($this).' error, cannot be modified in a centralized management environment.' ); } if ($this->fields['id_grupo'] > 0) { $updates = $this->fields; if (is_numeric($updates['parent']) === false) { $updates['parent'] = $this->parent()->id_grupo(); } return db_process_sql_update( 'tgrupo', $this->fields, ['id_grupo' => $this->fields['id_grupo']] ); } return false; } }