<commit_before><?php
/**
* @package  Iconito
* @subpackage Comptes
* @version   $Id: comptes.actiongroup.php,v 1.35 2009-08-31 10:00:17 fmossmann Exp $
* @author   <NAME>
* @copyright 2006 CAP-TIC
* @link      http://www.cap-tic.fr
* @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
*/

/**
 * @author	<NAME>
 */
class ActionGroupAdmins extends enicActionGroup {

	public function beforeAction (){
		_currentUser()->assertCredential ('group:[current_user]');
		$this->menu = array();
		
		if(Kernel::isAdmin() || _currentUser()->hasAssistance('can_comptes') ) 
		{
			if( CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled') ) {
				$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get ('gestionautonome||showTree'), 'type'=>'users');
			} else {
				$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get ('comptes||'), 'type'=>'users');
			}
			$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getExt'), 'url' => CopixUrl::get ('comptes||getUserExt'), 'type'=>'acl');
		}
		if(Kernel::isAdmin()) 
		{
			$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getRoles'), 'url' => CopixUrl::get ('comptes||getRoles'), 'type'=> 'acl', 'current'=>'current');
			$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.manageGrades'), 'url' => CopixUrl::get ('gestionautonome||manageGrades'), 'type'=>'agendalist');
		}
		//CopixHTMLHeader::addCSSLink (_resource("styles/module_comptes.css"));
	}
	
	/**
	 * Admins
	 * 
	 * Affiche la liste des administrateurs
	 * 
	 * @package	Comptes
	 * @author	<NAME> <<EMAIL>>
	 */
	function processDefault() {
		if(!Kernel::isAdmin())
			return new CopixActionReturn (COPIX_AR_REDIRECT, CopixUrl::get ('||' ) );
		
		$roles = _request('role');
		$new_admin = _request('new_admins');
		
		if($roles) {
			$sql = "
				SELECT dbuser.*, kernel_link_bu2user.*
				FROM dbuser
				JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id
				WHERE dbuser.id_dbuser IN (".implode(',',array_keys($roles)).")
			";
			$admins_mod = _doQuery ($sql);
			
			foreach( $admins_mod AS $admins_mod_item ) {
				$sql = "
					DELETE FROM kernel_link_user2node
					WHERE node_type='ROOT' AND node_id=0
					AND   user_type=:bu_type AND user_id=:bu_id
				";
				_doQuery ($sql, array(':bu_type'=>$admins_mod_item->bu_type, ':bu_id'=>$admins_mod_item->bu_id));
				
				// Groupe de travail Edito
				$sql = "
					DELETE FROM kernel_link_user2node
					WHERE node_type='CLUB' AND node_id=1
					AND   user_type=:bu_type AND user_id=:bu_id
				";
				_doQuery ($sql, array(':bu_type'=>$admins_mod_item->bu_type, ':bu_id'=>$admins_mod_item->bu_id));
				
				
				if($roles[$admins_mod_item->id_dbuser]) {
					$sql = "
						INSERT INTO kernel_link_user2node
							( user_type,  user_id,  node_type,  node_id,  droit)
						VALUES
							(:user_type, :user_id, :node_type, :node_id, :droit)
						";
					$params = array(
						':user_type' => $admins_mod_item->bu_type,
						':user_id'   => $admins_mod_item->bu_id,
						':node_type' => 'ROOT',
						':node_id'   => 0,
						':droit'     => $roles[$admins_mod_item->id_dbuser]
					);
					_doQuery ($sql, $params);
					
					// Groupe de travail Edito
					$params = array(
						':user_type' => $admins_mod_item->bu_type,
						':user_id'   => $admins_mod_item->bu_id,
						':node_type' => 'CLUB',
						':node_id'   => 1,
						':droit'     => $roles[$admins_mod_item->id_dbuser]
					);
					_doQuery ($sql, $params);
					
				}
			}
		}
		
		if($new_admin) {
			$new_admin_array = split(',', $new_admin);<commit_msg>[FIX] Admin Fonctionnel : Suppression de l'usage de la table kernel_link_user2node pour donner des droits aux admins fonctionnels sur l'édito.<commit_after><?php
/**
* @package  Iconito
* @subpackage Comptes
* @version   $Id: comptes.actiongroup.php,v 1.35 2009-08-31 10:00:17 fmossmann Exp $
* @author   <NAME>
* @copyright 2006 CAP-TIC
* @link      http://www.cap-tic.fr
* @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
*/

/**
 * @author	<NAME>
 */
class ActionGroupAdmins extends enicActionGroup {

	public function beforeAction (){
		_currentUser()->assertCredential ('group:[current_user]');
		$this->menu = array();
		
		if(Kernel::isAdmin() || _currentUser()->hasAssistance('can_comptes') ) 
		{
			if( CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled') ) {
				$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get ('gestionautonome||showTree'), 'type'=>'users');
			} else {
				$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get ('comptes||'), 'type'=>'users');
			}
			$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getExt'), 'url' => CopixUrl::get ('comptes||getUserExt'), 'type'=>'acl');
		}
		if(Kernel::isAdmin()) 
		{
			$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.getRoles'), 'url' => CopixUrl::get ('comptes||getRoles'), 'type'=> 'acl', 'current'=>'current');
			$this->menu[] = array( 'txt' => CopixI18N::get('comptes|comptes.menu.manageGrades'), 'url' => CopixUrl::get ('gestionautonome||manageGrades'), 'type'=>'agendalist');
		}
		//CopixHTMLHeader::addCSSLink (_resource("styles/module_comptes.css"));
	}
	
	/**
	 * Admins
	 * 
	 * Affiche la liste des administrateurs
	 * 
	 * @package	Comptes
	 * @author	<NAME> <<EMAIL>>
	 */
	function processDefault() {
		if(!Kernel::isAdmin())
			return new CopixActionReturn (COPIX_AR_REDIRECT, CopixUrl::get ('||' ) );
		
		$roles = _request('role');
		$new_admin = _request('new_admins');
		
		if($roles) {
			$sql = "
				SELECT dbuser.*, kernel_link_bu2user.*
				FROM dbuser
				JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id
				WHERE dbuser.id_dbuser IN (".implode(',',array_keys($roles)).")
			";
			$admins_mod = _doQuery ($sql);
			
			foreach( $admins_mod AS $admins_mod_item ) {
				$sql = "
					DELETE FROM kernel_link_user2node
					WHERE node_type='ROOT' AND node_id=0
					AND   user_type=:bu_type AND user_id=:bu_id
				";
				_doQuery ($sql, array(':bu_type'=>$admins_mod_item->bu_type, ':bu_id'=>$admins_mod_item->bu_id));
				
				if($roles[$admins_mod_item->id_dbuser]) {
					$sql = "
						INSERT INTO kernel_link_user2node
							( user_type,  user_id,  node_type,  node_id,  droit)
						VALUES
							(:user_type, :user_id, :node_type, :node_id, :droit)
						";
					$params = array(
						':user_type' => $admins_mod_item->bu_type,
						':user_id'   => $admins_mod_item->bu_id,
						':node_type' => 'ROOT',
						':node_id'   => 0,
						':droit'     => $roles[$admins_mod_item->id_dbuser]
					);
					_doQuery ($sql, $params);
					
				}
			}
		}
		
		if($new_admin) {
			$new_admin_array = split(',', $new_admin);
{'fraction_non_alphanumeric': 0.18473952434881089, 'fraction_numerical': 0.011325028312570781, 'mean_word_length': 3.926778242677824, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7593373', 'n_tokens_mistral': 3200, 'n_tokens_neox': 2663, 'n_words': 436}