[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1781-g7db1a76

Franck Villaume nerville at libremir.placard.fr.eu.org
Sun May 7 13:03:35 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  7db1a765904d323a0db6ea133ec02d0dc48333bd (commit)
       via  9af69f7b06c745e6df4826dd853548f9d9629d9b (commit)
       via  67aaa36cdd6132777af00b2b706716ea73ced7fa (commit)
       via  9ad9c93e790985e92655d624e387e436ff1361bd (commit)
      from  7408d5f5523505f9f3cfa812eb2429ac07f23585 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=7db1a765904d323a0db6ea133ec02d0dc48333bd

commit 7db1a765904d323a0db6ea133ec02d0dc48333bd
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun May 7 13:02:55 2017 +0200

    implement [#853]: add comments to CSV export in tracker feature

diff --git a/src/common/tracker/actions/downloadcsv.php b/src/common/tracker/actions/downloadcsv.php
index d553b34..98af501 100644
--- a/src/common/tracker/actions/downloadcsv.php
+++ b/src/common/tracker/actions/downloadcsv.php
@@ -24,7 +24,7 @@ require_once $gfcommon.'tracker/ArtifactFactory.class.php';
 
 global $ath;
 
-session_require_perm ('tracker', $ath->getID(), 'read') ;
+session_require_perm('tracker', $ath->getID(), 'read');
 
 $af = new ArtifactFactory($ath);
 if (!$af || !is_object($af)) {
@@ -61,7 +61,7 @@ if ($received_changed_from) {
 	$_changed_from = 0;
 }
 
-$af->setup($offset,$_sort_col,$_sort_ord,$max_rows,$set,$_assigned_to,$_status, array(), $_changed_from);
+$af->setup($offset, $_sort_col, $_sort_ord, $max_rows, $set, $_assigned_to, $_status, array(), $_changed_from);
 
 $at_arr = $af->getArtifacts();
 
@@ -95,10 +95,11 @@ if ($headers) {
 		}
 		echo $sep.'"'.$ef[$keys[$i]]['field_name'].'"';
 	}
+	echo $sep.'comments';
 	echo "\n";
 }
 
-for ($i=0; $i<count($at_arr); $i++) {
+for ($i = 0; $i < count($at_arr); $i++) {
 
 	$open_date   = $at_arr[$i]->getOpenDate() ? date(_('Y-m-d H:i'),$at_arr[$i]->getOpenDate()) : '';
 	$update_date = $at_arr[$i]->getLastModifiedDate() ? date(_('Y-m-d H:i'),$at_arr[$i]->getLastModifiedDate()) : '';
@@ -123,9 +124,7 @@ for ($i=0; $i<count($at_arr); $i++) {
 		$votes[1].$sep.
 		$votes[2];
 
-	//
-	//	Show the extra fields
-	//
+	// Show the extra fields
 	$efd = $at_arr[$i]->getExtraFieldDataText();
 	foreach ( $efd as $key => $efd_pair ) {
 		if ($efd_pair['type'] == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
@@ -141,18 +140,31 @@ for ($i=0; $i<count($at_arr); $i++) {
 					$unittexts = $unit->getName();
 				}
 			}
-			echo $sep.'"'. fix4csv($unittexts) .'"';
+			echo $sep.'"'.fix4csv($unittexts).'"';
 			$value = $effortUnitFactory->encodedToValue($efd_pair['value']);
 		} else {
 			$value = $efd_pair["value"];
 		}
-		echo $sep.'"'. fix4csv($value) .'"';
+		echo $sep.'"'.fix4csv($value).'"';
+	}
+
+	// Include comments
+	$result = $at_arr[$i]->getMessages();
+	$comments = '';
+	while ($arr = db_fetch_array($result)) {
+		$date = date(_('Y-m-d H:i'), $arr['adddate']);
+		$realname = $arr['realname'];
+		$body = $arr['body'];
+		// replace all newline by ' ~ '
+		$body = str_replace(array("\r\n", "\r", "\n", PHP_EOL, chr(10), chr(13), chr(10).chr(13)), " ~ ", $body);
+		$comments .= ' *** '.$date.' --- '.$realname.' --- '.$body;
 	}
+	echo $sep.'"'.fix4csv($comments).'"';
 	echo "\n";
 }
 
-function fix4csv ($value) {
-	$value = util_unconvert_htmlspecialchars( $value );
+function fix4csv($value) {
+	$value = util_unconvert_htmlspecialchars($value);
 	$value = str_replace("\r\n", "\n", $value);
 	$value = str_replace('"', '""', $value);
 	return $value;

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=9af69f7b06c745e6df4826dd853548f9d9629d9b

commit 9af69f7b06c745e6df4826dd853548f9d9629d9b
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun May 7 12:40:24 2017 +0200

    forge cli: userDump & userImport support

diff --git a/src/bin/forge b/src/bin/forge
index 14f0cf3..f929cda 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -28,6 +28,7 @@ require_once $gfcommon.'include/pre.php';
 require_once $gfcommon.'tracker/ArtifactFactory.class.php';
 require_once $gfcommon.'tracker/ArtifactTypeFactory.class.php';
 require_once $gfcommon.'docman/DocumentReviewFactory.class.php';
+require_once $gfcommon.'include/User.class.php';
 
 class CliActions {
 	function help($method = null) {
@@ -113,6 +114,11 @@ class CliActions {
 				echo "to dump FRS from a specific project.\n";
 				echo $dumpFormatInfo;
 				break;
+			case 'pmDump':
+				echo "Use: .../forge pmDump <groupid> [json|raw]\n";
+				echo "to dump Project Management (tasks) from a specific project.\n";
+				echo $dumpFormatInfo;
+				break;
 			case 'surveyDump':
 				echo "Use: .../forge surveyDump <surveyid> [json|raw]\n";
 				echo "to dump a specific survey from a specific project.\n";
@@ -123,6 +129,26 @@ class CliActions {
 				echo "to dump a group.\n";
 				echo $dumpFormatInfo;
 				break;
+			case 'groupImport':
+				echo "Use: .../forge groupImport <file> [json|raw]\n";
+				echo "to import a full group and all his elements.\n";
+				echo $dumpFormatInfo.$importFormatInfo;
+				break;
+			case 'userDump':
+				echo "Use: .../forge userDump <user_id> [json|raw]\n";
+				echo "to dump an user from the forge.\n";
+				echo $dumpFormatInfo;
+				break;
+			case 'userImport':
+				echo "Use: .../forge userImport <file> [json|raw]\n";
+				echo "to import an user.\n";
+				echo $dumpFormatInfo.$importFormatInfo;
+				break;
+			case 'forumDump':
+				echo "Use: .../forge forumDump <forum_id> [json|raw]\n";
+				echo "to dump a forum from the specific project.\n";
+				echo $dumpFormatInfo;
+				break;
 			case 'getZipDump':
 				echo "Use: .../forge getDataDump file [json|raw]\n";
 				echo "to generate a zip file that includes all data based on parameter file.\n";
@@ -311,7 +337,12 @@ class CliActions {
 			$groupDump['setup']['membersArr'] = $group->getMembers(false);
 			$groupDump['setup']['roles'] = $group->getRoles();
 			foreach ($groupDump['setup']['roles'] as $role) {
+				$users = $role->getUsers();
 				unset($role->Group);
+				$role->userids = array();
+				foreach ($users as $user) {
+					$role->userids[] = $user->getID();
+				}
 			}
 			$groupDump['setup']['homepage'] = $group->getWidgetLayoutConfig();
 			if ($group->usesDocman()) {
@@ -378,16 +409,162 @@ class CliActions {
 		if (!$stream) {
 			return false;
 		}
+		if (isset($stream['setup']['membersArr']) && is_array($stream['setup']['membersArr'])) {
+			foreach ($stream['setup']['membersArr'] as $member) {
+				$filename = 'userDump-'.$member['data_array']['user_id'].'.'.$format;
+				$this->createSubfile($filename, $member, $format);
+				if (!$this->userImport($filename, $format)) {
+					echo _('Unable to inject member')."\n";
+					db_rollback();
+					return false;
+				}
+				@unlink($filename);
+			}
+		}
+	}
+
+	function userDump($userid, $format = 'json') {
+		$user = user_get_object($userid);
+		if ($user && is_object($user) && !$user->isError()) {
+			$userDump = (array)$user;
+			unset($userDump['Group']);
+		} else {
+			$userDump['error'][] = _('Unable to get user id')._(': ').$userid;
+		}
+		$userDump['id'] = $userid;
+		ksort($userDump);
+		$this->print_result($userDump, $format);
+		return $userDump;
+		return true;
+	}
+
+	function userImport($file, $format = 'json') {
+		global $importRefMapping;
+		$stream = $this->loadFile($file, $format);
+		if (!$stream) {
+			return false;
+		}
+		$ffuser = user_get_object_by_name($stream['data_array']['user_name']);
+		if ($ffuser && is_object($ffuser) && !$ffuser->isError()) {
+			$importRefMapping['user'][$stream['data_array']['user_id']] = $ffuser->getID();
+			printf(_('User %s already exists. Mapping retrieved.'), $stream['data_array']['user_name'])."\n";
+			return true;
+		}
+		$ffuser = new FFUser();
+		if ($ffuser && is_object($ffuser) && !$ffuser->isError()) {
+			db_begin();
+			// need to check for each value to test if isset else set default value
+			if (isset($stream['data_array']['password'])) {
+				$password = $stream['data_array']['password'];
+			} else {
+				$password = 'Inject123$';
+			}
+			if (isset($stream['data_array']['mail_siteupdates'])) {
+				$mail_siteupdates = $stream['data_array']['mail_siteupdates'];
+			} else {
+				$mail_siteupdates = 0;
+			}
+			if (isset($stream['data_array']['mail_va'])) {
+				$mail_va = $stream['data_array']['mail_va'];
+			} else {
+				$mail_va = 0;
+			}
+			if (isset($stream['data_array']['language'])) {
+				$language_id = $stream['data_array']['language'];
+			} else {
+				$language_id = 1;
+			}
+			if (isset($stream['data_array']['timezone'])) {
+				$timezone = $stream['data_array']['timezone'];
+			} else {
+				$timezone = 'UTC';
+			}
+			if (isset($stream['data_array']['theme_id'])) {
+				$theme_id = $stream['data_array']['theme_id'];
+			} else {
+				$theme_id = getThemeIdFromName(forge_get_config('default_theme'));
+			}
+			if (isset($stream['data_array']['unix_box'])) {
+				$unix_box = $stream['data_array']['unix_box'];
+			} else {
+				$unix_box = 'shell';
+			}
+			if (isset($stream['data_array']['address'])) {
+				$address = $stream['data_array']['address'];
+			} else {
+				$address = '';
+			}
+			if (isset($stream['data_array']['address2'])) {
+				$address2 = $stream['data_array']['address2'];
+			} else {
+				$address2 = '';
+			}
+			if (isset($stream['data_array']['phone'])) {
+				$phone = $stream['data_array']['phone'];
+			} else {
+				$phone = '';
+			}
+			if (isset($stream['data_array']['fax'])) {
+				$fax = $stream['data_array']['fax'];
+			} else {
+				$fax = '';
+			}
+			if (isset($stream['data_array']['title'])) {
+				$title = $stream['data_array']['title'];
+			} else {
+				$title = '';
+			}
+			if (isset($stream['data_array']['ccode'])) {
+				$ccode = $stream['data_array']['ccode'];
+			} else {
+				$ccode = 'US';
+			}
+			if (isset($stream['data_array']['send_mail'])) {
+				$send_mail = $stream['data_array']['send_mail'];
+			} else {
+				$send_mail = true;
+			}
+			if (isset($stream['data_array']['tooltips'])) {
+				$tooltips = $stream['data_array']['tooltips'];
+			} else {
+				$tooltips = true;
+			}
+			if (isset($stream['data_array']['add_date'])) {
+				$createtimestamp = $stream['data_array']['add_date'];
+			} else {
+				$createtimestamp = null;
+			}
+			if (!$ffuser->create($stream['data_array']['user_name'], $stream['data_array']['firstname'], $stream['data_array']['lastname'], $password, $password,
+					$stream['data_array']['email'], $mail_siteupdates, $mail_va, $language_id, $timezone, null, null, $theme_id, $unix_box,
+					$address, $address2, $phone, $fax, $title, $ccode, $send_mail, $tooltips)) {
+				echo $ffuser->getErrorMessage()."\n";
+				db_rollback();
+				return false;
+			}
+			if (isset($stream['data_array']['user_id'])) {
+				$importRefMapping['user'][$stream['data_array']['user_id']] = $ffuser->getID();
+			}
+			echo _('User injected')."\n";
+			db_commit();
+			return true;
+		} else {
+			echo _('Unable to get user object to inject user')."\n";
+			return false;
+		}
 	}
 
 	function surveyDump($sid, $format = 'json') {
 		$surveyDump['id'] = $sid;
-		$surveyObject = survey_get_object($sid);
-		$surveyObject->getQuestionInstances();
-		$surveyDump['setup'] = (array)$surveyObject;
-		unset($surveyDump['setup']['Group']);
-		foreach($surveyDump['setup']['all_question_array'] as $question) {
-			unset($question->Group);
+		$survey = survey_get_object($sid);
+		if ($survey && is_object($survey) && !$survey->isError()) {
+			$survey->getQuestionInstances();
+			$surveyDump['setup'] = (array)$survey;
+			unset($surveyDump['setup']['Group']);
+			foreach($surveyDump['setup']['all_question_array'] as $question) {
+				unset($question->Group);
+			}
+		} else {
+			$surveyDump['error'][] = _('Unable to get survey id')._(': ').$sid;
 		}
 		ksort($surveyDump);
 		$this->print_result($surveyDump, $format);

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=67aaa36cdd6132777af00b2b706716ea73ced7fa

commit 67aaa36cdd6132777af00b2b706716ea73ced7fa
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun May 7 12:40:03 2017 +0200

    PHP doc

diff --git a/src/common/include/User.class.php b/src/common/include/User.class.php
index 6dc5469..0d55bb6 100644
--- a/src/common/include/User.class.php
+++ b/src/common/include/User.class.php
@@ -304,6 +304,7 @@ class FFUser extends FFError {
 	 * @param	string		$ccode		The users ISO country_code.
 	 * @param	bool		$send_mail	Whether to send an email or not
 	 * @param	bool|int	$tooltips	The users preference for tooltips
+	 * @param	int		$createtime	The epoch creation time. Useful for migration
 	 * @return	bool|int	The newly created user ID
 	 *
 	 */
@@ -311,7 +312,7 @@ class FFUser extends FFError {
 					$mail_site, $mail_va, $language_id, $timezone,
 					$dummy1, $dummy2, $theme_id, $unix_box = 'shell',
 					$address = '', $address2 = '', $phone = '', $fax = '', $title = '',
-					$ccode = 'US', $send_mail = true, $tooltips = true, $createtimestamp = null) {
+					$ccode = 'US', $send_mail = true, $tooltips = true, $createtime = 0) {
 		global $SYS;
 		if (!$theme_id) {
 			$this->setError(_('You must supply a theme'));
@@ -417,7 +418,7 @@ class FFUser extends FFError {
 		// if we got this far, it must be good
 		$confirm_hash = substr(md5($password1.util_randbytes().microtime()), 0, 16);
 		db_begin();
-		$createtimestamp = (($createtimestamp) ? $createtimestamp : time());
+		$createtime = (($createtime) ? $createtime : time());
 		$result = db_query_params('INSERT INTO users (user_name,unix_pw,realname,firstname,lastname,email,add_date,status,confirm_hash,mail_siteupdates,mail_va,language,timezone,unix_box,address,address2,phone,fax,title,ccode,theme_id,tooltips,shell)
 							VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23)',
 			array($unix_name,
@@ -426,7 +427,7 @@ class FFUser extends FFError {
 				htmlspecialchars($firstname),
 				htmlspecialchars($lastname),
 				$email,
-				$createtimestamp,
+				$createtime,
 				'P',
 				$confirm_hash,
 				(($mail_site)? "1" : "0"),
@@ -451,7 +452,7 @@ class FFUser extends FFError {
 
 			$id = db_insertid($result, 'users', 'user_id');
 			if (!$id) {
-				$this->setError(_('Could Not Get User Id: ') .db_error());
+				$this->setError(_('Could Not Get User Id')._(': ').db_error());
 				db_rollback();
 				return false;
 			}
@@ -466,7 +467,7 @@ class FFUser extends FFError {
 			$hook_params['user_id'] = $this->getID();
 			$hook_params['user_name'] = $unix_name;
 			$hook_params['user_password'] = $password1;
-			$hook_params['user_timecreate'] = $createtimestamp;
+			$hook_params['user_timecreate'] = $createtime;
 			plugin_hook("user_create", $hook_params);
 
 			if ($send_mail) {

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=9ad9c93e790985e92655d624e387e436ff1361bd

commit 9ad9c93e790985e92655d624e387e436ff1361bd
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun May 7 12:39:43 2017 +0200

    reuse existing var

diff --git a/src/bin/inject-users.php b/src/bin/inject-users.php
index 713365d..4c7f3a1 100755
--- a/src/bin/inject-users.php
+++ b/src/bin/inject-users.php
@@ -50,7 +50,7 @@ while (! feof ($f)) {
 	$u = new FFUser () ;
 
 	$r = $u->create ($login, $fname, $lname, $password, $password, $email,
-			 1, 0, 1, 'UTC', '', '', getThemeIdFromName(forge_get_config('default_theme')),
+			 1, 0, 1, 'UTC', '', '', $themeId,
 			 'shell', '', '', '', '', '', 'US', false);
 
 	if (!$r) {

-----------------------------------------------------------------------

Summary of changes:
 src/bin/forge                              | 189 ++++++++++++++++++++++++++++-
 src/bin/inject-users.php                   |   2 +-
 src/common/include/User.class.php          |  11 +-
 src/common/tracker/actions/downloadcsv.php |  32 +++--
 4 files changed, 212 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list