예제 #1
0
	public function index()
	{
		$message = ' ';
		$this->load->model('livre_model');
		$this->load->model('auteur_livre_model');
		if($this->input->post('action'))
		{
			extract($this->input->post());
			$this->load->model('auteur_model');
			$this->load->library('data', array('u_id'=>$this->current_user->info()->user_id));

			$this->form_validation->set_rules('titre', 'Titre', 'required');
			$this->form_validation->set_rules('prenom[]', 'Prenom', 'required');

			if($this->form_validation->run() !== FALSE)
			{
				$this->db->trans_start();
					$this->livre_model->livre_id		=	$livre_id;
					$this->livre_model->titre			=	verify_case($titre, 'sentence');
					$this->livre_model->sous_titre	=	verify_case($sous_titre, 'sentence');

					$this->auteur_model->prenom		=	$prenom;
					$this->auteur_model->surnom		=	$surnom;
					$this->auteur_model->nom			=	$nom;
					$auteurs									=	$this->auteur_model->add();

					//this model does not need to be loaded because it is loaded by the livre_model
					$this->auteur_livre_model->auteurs	=	$auteurs;
					$this->auteur_livre_model->l_id		=	$this->livre_model->add();
					$this->auteur_livre_model->add();
				$this->db->trans_complete();

				$message	=	($this->db->trans_status() === FALSE) ? 'Il y a eu un problème :o(' : 'Livre ajouté avec succès !';
			}
		}
		$data = array(
			'data'		=>	$this->auteur_livre_model->get_all(),
			'message'	=>	$message,
			'title'		=>	'Bibliothèque',
			'view'		=>	'bib/main'
		);

		$this->load->view('templates/main', $data);
	}
예제 #2
0
	private function _prep()
	{
		if($this->prenom === '' AND $this->_row)
			$this->prenom	= $this->_row->prenom;
		if($this->nom === '' AND $this->_row)
			$this->nom	=	$this->_row->nom;

		$this->_data	=	array(
			'nom'				=> verify_case($this->nom),
			'prenom'			=> verify_case($this->prenom),
			'updated_at'	=> date_mysql()
		);
	}
예제 #3
0
	/**
	 * Modify an existing class name
	 *
	 * @param string $name the new name for the class we want to update
	 * @param string $type the type of the class we want to update
	 * @param int $old_id the id number of the class we want to update
	 * @return string a message stating whether the operation was successful or not
	 * @since 0.1
	 * @version 1.0
	 */
	public function update($name, $type, $old_id)
	{
		if($old_id === '2')return 'Vous ne pouvez pas mettre à jour ce cours.';
		if($name !== '')
		{
			switch($type)
			{
				case 'v': $var = 'upper';break;
				default : $var = 'class';
			}
			$this->db->set('cours_nom', verify_case($name, $var));
		}

		$this->db->set('type', $type);

		if( ! $this->db->where('cours_id', $old_id)->update('cours', $this->data->prep('', 'update')))return 'Il y a eu un problème :o(';

		return 'Le nom a été bien mis à jour.';
	}