<commit_before><?php

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

/**
 * Migration script for ...
 **/
class Migration20140108233319ComGroups extends Hubzero_Migration
{
	protected static function up($db)
	{
		// import needed libraries
		jimport('joomla.filesystem.folder');
		jimport('joomla.filesystem.file');
		
		$old = umask(0);
		
		// define base path
		$base = JPATH_ROOT . DS . 'site' . DS . 'groups';
		
		// get group folders
		$groupFolders = JFolder::folders( $base, '.', false, true );
		
		// loop through group folders
		foreach ($groupFolders as $groupFolder)
		{
			$groupUploadFolder = $groupFolder . DS . 'uploads';
			
			// make sure we havent already moved files
			if (!is_dir( $groupUploadFolder ))
			{
				// create uploads folder
				if (!JFolder::create( $groupUploadFolder, 0774 ))
				{
					$return = new stdClass();
					$return->error = new stdClass();
					$return->error->type = 'warning';
					$return->error->message = 'Failed to create uploads folder. Try running again with elevated privileges';
					return $return;
				}
			}
			
			//get group files
			$groupFiles = JFolder::files( $groupFolder );<commit_msg>[MIGRATION] Fixed issue with group migration to move all group uploads in a folder called uploads within their group file space.<commit_after><?php

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

/**
 * Migration script for ...
 **/
class Migration20140108233319ComGroups extends Hubzero_Migration
{
	protected static function up($db)
	{
		// import needed libraries
		jimport('joomla.filesystem.folder');
		jimport('joomla.filesystem.file');
		
		$old = umask(0);
		
		// define base path
		$base = JPATH_ROOT . DS . 'site' . DS . 'groups';
		
		// get group folders
		$groupFolders = JFolder::folders( $base, '.', false, true );
		
		// make sure we have one!
		if (count($groupFolders) < 1)
		{
			return;
		}
		
		// loop through group folders
		foreach ($groupFolders as $groupFolder)
		{
			$groupUploadFolder = $groupFolder . DS . 'uploads';
			
			// make sure we havent already moved files
			if (!is_dir( $groupUploadFolder ))
			{
				// create uploads folder
				if (!JFolder::create( $groupUploadFolder, 0774 ))
				{
					$return = new stdClass();
					$return->error = new stdClass();
					$return->error->type = 'warning';
					$return->error->message = 'Failed to create uploads folder. Try running again with elevated privileges';
					return $return;
				}
			}
			
			//get group files
			$groupFiles = JFolder::files( $groupFolder );
{'fraction_non_alphanumeric': 0.13030187237294613, 'fraction_numerical': 0.014902560183416125, 'mean_word_length': 3.1358609794628753, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3513181', 'n_tokens_mistral': 988, 'n_tokens_neox': 791, 'n_words': 241}