Пример #1
0
	function newuser3() {
		/* Same as before, except we have to reference our User model
		   This shows how to add new entries */
		$user = new models\User;
		$user->setEmail('*****@*****.**');
		$user->setName('Empat');
		$user->setPassword(md5('password'));
		$user->setHometown('Bandung');
		$user->setAffiliation('Osaka City University');
		$user->setArrivalDate(new DateTime('2008-04-01'));
		$user->setBirthday(new DateTime('1985-01-21'));
		$user->setMarriageStatus(1);
		$user->setGender('M');
		$user->setReligion('Islam');
		$user->setIntroduction('Lorem ipsum bla bla bla');
		$user->setUndergradUniversity('Institut Teknologi Bandung');
		$user->setUndergradDepartment('Teknik Elektro');
		$user->setUndergradGraduationYear('2006');
		$user->setMasterUniversity('Osaka City University');
		$user->setMasterDepartment('Communication System');
		$user->setMasterGraduationYear('2011');
		$user->setPhdUniversity('Osaka City University');
		$user->setPhdDepartment('Communication System');
		$user->setPhdGraduationYear('2014');
		$user->setInformalSkill('iOS development');
		$user->setLeftTheCountry(0);
		$user->setPosition('Web developer');
		//$user->setCreatedAt(new DateTime());
		$this->em->persist($user);
		$this->em->flush();
		
		// Test the new entry, grab the new username
		$message = $user->getIntroduction();
				 
		$data['message'] = $message;
		$this->load->view('home', $data);
	}
Пример #2
0
	public function submit() {
		/*$this->load->library('unit_test');
		echo $this->unit->run($this->input->post('number_of_contacts'), 4);
		return;*/
		/*for ($i=0; $i<$this->input->post('number_of_contacts'); $i++) {
			$address = $this->input->post('address'.($i+1));
			echo $address;
			if(!(is_null($address)) && $address!='') {
				echo 'not null';
			}
		}
		return;*/
		
		if ($this->_submit_validate() === FALSE) {
			$this->index();
			return;
		}
		
		$user = new models\User;
		$user->setEmail($this->input->post('email'));
		$user->setName($this->input->post('name'));
		$user->setPassword(md5($this->input->post('password')));
		$user->setHometown($this->input->post('hometown'));
		$user->setAffiliation($this->input->post('affiliation'));
		$user->setArrivalDate(new DateTime(str_replace('/', '-', $this->input->post('arrival_date'))));
		$user->setBirthday(new DateTime(str_replace('/', '-', $this->input->post('birthday'))));
		$user->setMarriageStatus($this->input->post('status'));
		$user->setGender($this->input->post('gender'));
		$user->setReligion($this->input->post('religion'));
		$user->setIntroduction($this->input->post('introduction'));
		$user->setUndergradUniversity($this->input->post('undergrad_university'));
		$user->setUndergradDepartment($this->input->post('undergrad_department'));
		$user->setUndergradGraduationYear($this->input->post('undergrad_graduation_year'));
		$user->setMasterUniversity($this->input->post('master_university'));
		$user->setMasterDepartment($this->input->post('master_department'));
		$user->setMasterGraduationYear($this->input->post('master_graduation_year'));
		$user->setPhdUniversity($this->input->post('phd_university'));
		$user->setPhdDepartment($this->input->post('phd_department'));
		$user->setPhdGraduationYear($this->input->post('phd_graduation_year'));
		$user->setInformalSkill($this->input->post('informal_skill'));
		$user->setLeftTheCountry($this->input->post('left_the_country'));
		$user->setPosition($this->input->post('position'));
		$this->em->persist($user);
		$this->em->flush();
		
		for ($i=0; $i<$this->input->post('number_of_contacts'); $i++) {
			$address = $this->input->post('address'.($i+1));
			if(!(is_null($address)) && $address!='') {
				$contact1 = new models\Contact;
				$contact1->setUser($user);
				$contact1->setAddress($address);
				$contact1->setType($this->input->post('addresstype'.($i+1)));
				$contact1->setVisibility(0);
				$this->em->persist($contact1);
				$this->em->flush();
			}
		}
		
		// assign role id 7 to the new user
		$this->load->database();
		$date = new DateTime('now');
		$data = array(
		               'userID' => $user->getId(),
		               'roleID' => 7,
		               'addDate' => $date->format('Y-m-d H:i:s')
		            );
		
		$this->db->insert('user_roles', $data); 

		$this->load->view('login_form');

	}