[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1580-g1d43281

Franck Villaume nerville at libremir.placard.fr.eu.org
Tue Mar 21 17:01:46 CET 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  1d43281036ec1e73aaeaecdcd3029181938df8bb (commit)
       via  09cb72235ce8a6cde9583694da0a2b57f0319c0c (commit)
      from  6e26477950c362ce467f708c6fe17797d5047d2a (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=1d43281036ec1e73aaeaecdcd3029181938df8bb

commit 1d43281036ec1e73aaeaecdcd3029181938df8bb
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Tue Mar 21 17:01:10 2017 +0100

    forge cli: start surveyDump

diff --git a/src/bin/forge b/src/bin/forge
index b39fc3c..b01a384 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -203,13 +203,14 @@ class CliActions {
 		$group = group_get_object($group_id);
 		if ($group && is_object($group) && !$group->isError()) {
 			$groupDump['setup'] = (array)$group;
-			$groupDump['setup']['members'] = $group->getMembers(false);
+			$groupDump['setup']['membersArr'] = $group->getMembers(false);
 			$groupDump['setup']['roles'] = $group->getRoles();
 			$groupDump['setup']['homepage'] = $group->getWidgetLayoutConfig();
 			if ($group->usesDocman()) {
 				$groupDump['docman'] = $this->docmanDump($group_id, 'return');
 			}
 			if ($group->usesTracker()) {
+				$groupDump['trackers'] = array();
 				$atf = new ArtifactTypeFactory($group);
 				$atid_arr = $atf->getAllArtifactTypeIds();
 				foreach ($atid_arr as $atid) {
@@ -217,6 +218,7 @@ class CliActions {
 				}
 			}
 			if ($group->usesForum()) {
+				$groupDump['forums'] = array();
 				$ff = new ForumFactory($group);
 				$ffid_arr = $ff->getAllForumIds();
 				foreach ($ffid_arr as $ffid) {
@@ -229,6 +231,14 @@ class CliActions {
 			if ($group->usesNews()) {
 				$groupDump['news'] = array();
 			}
+			if ($group->usesSurvey()) {
+				$groupDump['surveys'] = array();
+				$sf = new SurveyFactory($group);
+				$sfid_arr = $sf->getSurveysIds();
+				foreach ($sfid_arr as $sfid) {
+					$groupDump['surveys'][] = $this->surveyDump($sfid, 'return');
+				}
+			}
 			plugin_hook_by_reference('pluginDump', $groupDump);
 		} else {
 			$groupDump['error'][] = _('Unable to get group id')._(': ').$group_id;
@@ -237,6 +247,27 @@ class CliActions {
 		$this->print_result($groupDump, $format);
 	}
 
+	function newsDump($nid, $format = 'json') {
+		$newsDump['id'] = $nid;
+		ksort($newsDump);
+		$this->print_result($newsDump, $format);
+		return $newsDump;
+	}
+
+	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);
+		}
+		ksort($surveyDump);
+		$this->print_result($surveyDump, $format);
+		return $surveyDump;
+	}
+
 	function forumDump($fid, $format = 'json') {
 		$forumDump['id'] = $fid;
 		$forum = forum_get_object($fid);
diff --git a/src/common/survey/Survey.class.php b/src/common/survey/Survey.class.php
index 8bc8813..75334e0 100644
--- a/src/common/survey/Survey.class.php
+++ b/src/common/survey/Survey.class.php
@@ -26,6 +26,43 @@
 require_once $gfcommon.'include/FFError.class.php';
 require_once $gfcommon.'survey/SurveyQuestionFactory.class.php';
 
+$SURVEY_OBJ = array();
+
+/**
+ * survey_get_object() - Get the survey object.
+ *
+ * survey_get_object() is useful so you can pool survey objects/save database queries
+ * You should always use this instead of instantiating the object directly.
+ *
+ * You can now optionally pass in a db result handle. If you do, it re-uses that query
+ * to instantiate the objects.
+ *
+ * IMPORTANT! That db result must contain all fields
+ * from surveys table or you will have problems
+ *
+ * @param	int		$survey_id	Required
+ * @param	int|bool	$res		Result set handle ("SELECT * FROM surveys WHERE survey_id = xx")
+ * @return	Survey|bool	A survey object or false on failure
+ */
+function &survey_get_object($survey_id, $res = false) {
+	global $SURVEY_OBJ;
+	if (!isset($SURVEY_OBJ["_".$survey_id."_"])) {
+		if ($res) {
+			//the db result handle was passed in
+		} else {
+			$res = db_query_params('SELECT * FROM surveys WHERE survey_id=$1', array($survey_id));
+		}
+		if (!$res || db_numrows($res) < 1) {
+			$SURVEY_OBJ["_".$survey_id."_"] = false;
+		} else {
+			$arr = db_fetch_array($res);
+			$groupObject = group_get_object($arr['group_id']);
+			$SURVEY_OBJ["_".$survey_id."_"] = new Survey($groupObject, $survey_id, $arr);
+		}
+	}
+	return $SURVEY_OBJ["_".$survey_id."_"];
+}
+
 class Survey extends FFError {
 
 	/**
@@ -88,10 +125,10 @@ class Survey extends FFError {
 	/**
 	 * create - use this function to create a survey
 	 *
-	 * @param string $survey_title The survey title
-	 * @param array  $add_questions The question numbers to be added
-	 * @param int $is_active 1: Active, 0: Inactive
-	 * @param int $is_result_public
+	 * @param	string		$survey_title The survey title
+	 * @param	array		$add_questions The question numbers to be added
+	 * @param	int		$is_active 1: Active, 0: Inactive
+	 * @param	int		$is_result_public
 	 * @param	Allow|int	$double_vote
 	 * @internal	param		\The $string survey title
 	 * @internal	param		array	$int The question numbers to be added
@@ -135,10 +172,10 @@ class Survey extends FFError {
 	/**
 	 * update - use this function to update a survey
 	 *
-	 * @param string $survey_title The survey title
-	 * @param array  $add_questions The question numbers to be added
-	 * @param array  $del_questions The question numbers to be deleted
-	 * @param int $is_active 1: Active, 0: Inactive
+	 * @param	string		$survey_title The survey title
+	 * @param	array		$add_questions The question numbers to be added
+	 * @param	array		$del_questions The question numbers to be deleted
+	 * @param	int		$is_active 1: Active, 0: Inactive
 	 * @param	int		$is_result_public
 	 * @param	Allow|int	$double_vote
 	 * @internal	param		\The $string survey title
@@ -439,7 +476,7 @@ class Survey extends FFError {
 	 * private question string deal methods
 	 * TODO: Add a joint table for surveys and survey_questions.
 	 *       Deal with DBMS not comma separated string
-     ***************************************************************/
+	 ***************************************************************/
 
 	/**
 	 * _fillSurveyQuestions - Get all Survey Questions using SurveyQuestionFactory
diff --git a/src/common/survey/SurveyFactory.class.php b/src/common/survey/SurveyFactory.class.php
index b971574..3f1f633 100644
--- a/src/common/survey/SurveyFactory.class.php
+++ b/src/common/survey/SurveyFactory.class.php
@@ -5,7 +5,7 @@
  * Copyright 2004, Sung Kim/GForge, LLC
  * Copyright 2009, Roland Mas
  * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013, Franck Villaume - TrivialDev
+ * Copyright 2013,2017, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -75,10 +75,9 @@ class SurveyFactory extends FFError {
 	}
 
 	/**
-	 * getSurveyQuestion - get an array of Survey Question objects
-	 * for this Group and Survey id if survey_id is given.
+	 * getSurveys - get an array of Survey objects for this Group.
 	 *
- 	 * @return	array	The array of Survey Question objects.
+ 	 * @return	array	The array of Survey objects.
 	 */
 	function &getSurveys() {
 		/* We already have it */
@@ -101,6 +100,24 @@ class SurveyFactory extends FFError {
 		return $this->surveys;
 	}
 
+	/**
+	 * getSurveysIds - get an array of Survey IDs for this Group
+	 *
+	 * @return	array	The array of Survey IDs
+	 */
+	function getSurveysIds() {
+		$surveyids = array();
+		if ($this->surveys) {
+			foreach ($this->surveys as $surveyObject) {
+				$surveyids[] = $surveyObject->getID();
+			}
+		} else {
+			$result = db_query_params('SELECT survey_id FROM surveys WHERE group_id = $1 ORDER BY survey_id DESC',
+						array($this->Group->getID()));
+			$surveyids = util_result_column_to_array($result);
+		}
+		return $surveyids;
+	}
 }
 
 // Local Variables:
diff --git a/src/common/survey/SurveyQuestionFactory.class.php b/src/common/survey/SurveyQuestionFactory.class.php
index 406b67e..dc30c0e 100644
--- a/src/common/survey/SurveyQuestionFactory.class.php
+++ b/src/common/survey/SurveyQuestionFactory.class.php
@@ -73,7 +73,7 @@ class SurveyQuestionFactory extends FFError {
 	}
 
 	/**
-	 * getSurveyQuestion - get an array of Survey Question objects
+	 * getSurveyQuestions - get an array of Survey Question objects
 	 *                     for this Group and Survey id if survey_id is given.
 	 *
  	 * @return	array	The array of Survey Question objects.

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

commit 09cb72235ce8a6cde9583694da0a2b57f0319c0c
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Tue Mar 21 15:25:39 2017 +0100

    forge cli: groupDump, add roles

diff --git a/src/bin/forge b/src/bin/forge
index 9ca09c1..b39fc3c 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -203,7 +203,8 @@ class CliActions {
 		$group = group_get_object($group_id);
 		if ($group && is_object($group) && !$group->isError()) {
 			$groupDump['setup'] = (array)$group;
-			$groupDump['setup']['membersArr'] = $group->getMembers(false);
+			$groupDump['setup']['members'] = $group->getMembers(false);
+			$groupDump['setup']['roles'] = $group->getRoles();
 			$groupDump['setup']['homepage'] = $group->getWidgetLayoutConfig();
 			if ($group->usesDocman()) {
 				$groupDump['docman'] = $this->docmanDump($group_id, 'return');

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

Summary of changes:
 src/bin/forge                                     | 32 +++++++++++++
 src/common/survey/Survey.class.php                | 55 +++++++++++++++++++----
 src/common/survey/SurveyFactory.class.php         | 25 +++++++++--
 src/common/survey/SurveyQuestionFactory.class.php |  2 +-
 4 files changed, 100 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list