예제 #1
0
	public function convert()
	{
		// get data from database
		$query = 'SELECT GROUP_CONCAT( ug.user_id SEPARATOR \',\' ) AS group_members, g.* FROM ' .
			$this->getDB()->getSourcePrefix() . 'groups g LEFT JOIN ' .
			$this->getDB()->getSourcePrefix() . 'users_in_groups ug ON ug.group_id = g.group_id GROUP BY group_id';
		$stmt = $this->getDB()->getSource()->query($query);

		$pp_permissions = array();

		while($row = $stmt->fetch(PDO::FETCH_ASSOC))
		{
			$pp_project = new PP_Projects($this->getDB());
			$pp_project->setOldId($row['project_id']);
			
			// set values for each fields
			$pp_project->setName($row['project_title']);
			// $pp_project->setPriority();
			$pp_project->setDescription($row['intro_message']);
			$pp_project->setCreated_on(time2SqlDateTime($row['last_updated']));
			$pp_project->setCreated_by_id($config['default_user_id']);
			$pp_project->setUpdated_on(time2SqlDateTime($row['last_updated']));
			$pp_project->setUpdated_by_id($config['default_user_id']);

			$pp_permissions[ $row['project_id'] ] = $pp_project;
		}
		$stmt->closeCursor();
				
		// insert in db
		$this->setNewIds($pp_permissions[ array_rand($pp_permissions) ]->writes2DB($pp_permissions));
		
		// clean memory
		unset($pp_permissions);
	}
예제 #2
0
	public function convert()
	{
		// get data from database
		$query = 'SELECT * FROM ' . $this->getDB()->getSourcePrefix() . 'users';
		$stmt = $this->getDB()->getSource()->query($query);

		// create array of PP_Users
		$pp_users = array();
		while($row = $stmt->fetch(PDO::FETCH_ASSOC))
		{
			$pp_user = new PP_Users($this->getDB());
			$pp_user->setOldId($row['user_id']);
			// set values for each fields
			$pp_user->setUsername($row['user_name']);
			$pp_user->setEmail($row['email_address']);
			// $pp_user->setToken();
			// $pp_user->setSalt();
			// $pp_user->setTwister();
			$pp_user->setDisplay_name($row['real_name']);
			//$pp_user->setHomepage();
			//$pp_user->setTitle();
			//$pp_user->setAvatar_file();
			//$pp_user->setUse_gravatar();
			$pp_user->setTimezone($row['time_zone']);
			$pp_user->setCreated_on(time2SqlDateTime($row['register_date']));
			$pp_user->setUpdated_on(time2SqlDateTime(time()));
			//$pp_user->setLast_login();
			//$pp_user->setLast_visit();
			//$pp_user->setLast_activity();
			//$pp_user->setIs_admin();
			//$pp_user->setAuto_assign();
			$config = $this->getConfig();
			$pp_user->company_id = $config['projectpier']['default_compagny_id'];

			$pp_users[ $row['user_id'] ] = $pp_user;
		}
		$stmt->closeCursor();
				
		// insert in db
		$this->setNewIds($pp_users[ array_rand($pp_users) ]->writes2DB($pp_users));
		
		// clean memory
		unset($pp_users);
	}
예제 #3
0
	private function _convertTasks()
	{
		// get data from database
		$query = 'SELECT t.*, GROUP_CONCAT(a.user_id SEPARATOR \',\') AS assigned_user_id FROM ' . $this->getDB()->getSourcePrefix() . 'tasks t
				LEFT JOIN ' . $this->getDB()->getSourcePrefix() . 'assigned a ON a.task_id = t.task_id GROUP BY task_id';
		$stmt = $this->getDB()->getSource()->query($query);

		$pp_tickets = array();
		$assigned = array();
		while($row = $stmt->fetch(PDO::FETCH_ASSOC))
		{
			$pp_ticket = new PP_Project_Tickets($this->getDB());
			$pp_ticket->setOldId($row['task_id']);
			$pp_ticket->setProject_id($this->_projects->getNewId($row['project_id']));
			$pp_ticket->setCategory_id($this->_categories->getNewId($row['task_type']));
			$pp_ticket->setCreated_on(time2SqlDateTime($row['date_opened']));
			$pp_ticket->setCreated_by_id($this->_users->getNewId($row['opened_by']));
			$this->_closureComments[ $row['task_id'] ] = array($row['is_closed'], $this->_users->getNewId($row['opened_by']), $row['closure_comment']);
			if ($row['is_closed'] == '1')
			{
				$pp_ticket->setClosed_on(time2SqlDateTime($row['date_closed']));
				$pp_ticket->setClosed_by_id($this->_users->getNewId($row['closed_by']));
				$pp_ticket->setUpdated('closed');
				$pp_ticket->setState('closed');
			}
			else
			{
				$pp_ticket->setClosed_on('0000-00-00 00:00:00');
				$pp_ticket->setClosed_by_id(null);
				$pp_ticket->setUpdated('open');
				$pp_ticket->setState('opened');
			}
			$pp_ticket->updated_on = time2SqlDateTime($row['date_opened']);
			$pp_ticket->updated_by_id = $this->_users->getNewId($row['opened_by']);

			if ($row['mark_private'] == '1')
			{
				$pp_ticket->setIs_private(1);
			}
			else
			{
				$pp_ticket->setIs_private(0);
			}
			
			$pp_ticket->setSummary($row['item_summary']);
			$pp_ticket->setDescription($row['detailed_desc']);
			$pp_ticket->setPriority($row['task_priority']);
			if (!empty($row['assigned_user_id']))
			{
				$users_assigned = explode(',', $row['assigned_user_id']);
				$pp_ticket->setAssigned_to_user_id($this->_users->getNewId($users_assigned[0]));
				$assigned[ $row['task_id'] ] = $users_assigned;
			}
			else
			{
				$pp_ticket->setAssigned_to_user_id(null);
			}
		
			$pp_tickets[ $row['task_id'] ] = $pp_ticket;
		}
		$stmt->closeCursor();

		// insert in db
		$this->setNewIds($pp_tickets[ array_rand($pp_tickets) ]->writes2DB($pp_tickets));
		
		// clean memory
		unset($pp_tickets);
		
		// ticket subscription (no multiple assignement on pp, so use subscriptions ...)
		$ticketSubscriptions = array();
		foreach ($assigned as $oldTicketId => $assigned_users)
		{
			foreach ($assigned_users as $user_id)
			{
				$ticketSubscriptions[ $oldTicketId ] = new PP_Project_Ticket_Subscriptions($this->getDB());
				$ticketSubscriptions[ $oldTicketId ]->setTicket_id($this->getNewId($oldTicketId));
				$ticketSubscriptions[ $oldTicketId ]->setUser_id($this->_users->getNewId($user_id));
			}
		}
		$ticketSubscriptions[ array_rand($ticketSubscriptions) ]->writes2DB($ticketSubscriptions);
		unset($ticketSubscriptions);
	}
예제 #4
0
	private function _convertUsersInProject()
	{
		// get data from database
		$query = 'SELECT ug.user_id, g.project_id FROM ' . $this->getDB()->getSourcePrefix() . 'users_in_groups ug, flyspray_groups g WHERE ug.group_id = g.group_id AND (is_admin = 1 OR manage_project = 1)';
		$stmt = $this->getDB()->getSource()->query($query);

		$pp_uips = array();
		$config = $this->getConfig();
		$config = $config['projectpier'];

		while($row = $stmt->fetch(PDO::FETCH_ASSOC))
		{
			$pp_uip = new PP_Project_Users($this->getDB());
			
			// set values for each fields
			$pp_uip->project_id = $row['project_id'];
			$pp_uip->user_id = $this->_users->getNewId($row['user_id']);
			$pp_uip->role_id = 0;
			$pp_uip->created_on = time2SqlDateTime($row['project_id']);
			$pp_uip->created_by_id = $config['default_user_id'];
			
			$pp_uips[] = $pp_uip;
		}
		$stmt->closeCursor();
				
		// insert in db
		$pp_uips[ array_rand($pp_uips) ]->writes2DB($pp_uips);
		
		// clean memory
		unset($pp_uips);
	}