示例#1
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);
	}
示例#2
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);
	}