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 1945072b1159aa5615c733a250314a6cc43898b8 (commit) from a9989f5345b01908069a5671170cce92ffebdb48 (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=1945072b1159aa5615c733a250314a6cc43898b8 commit 1945072b1159aa5615c733a250314a6cc43898b8 Author: Franck Villaume <franck.villa...@trivialdev.com> Date: Mon May 3 00:09:57 2021 +0200 clean-up code smell diff --git a/src/common/docman/engine/parser_text.inc.php b/src/common/docman/engine/parser_text.inc.php index 0d920e1..5b3c6c4 100644 --- a/src/common/docman/engine/parser_text.inc.php +++ b/src/common/docman/engine/parser_text.inc.php @@ -5,7 +5,7 @@ * Copyright 2005, Fabio Bertagnin * Copyright 2011, Franck Villaume - Capgemini * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent - * Copyright 2012,2015 Franck Villaume - TrivialDev + * Copyright 2012,2015,2021, Franck Villaume - TrivialDev * http://fusionforge.org * * This file is part of FusionForge. FusionForge is free software; @@ -61,7 +61,9 @@ function parser_text($fichin) { function print_list($list) { $rep = ''; foreach ($list as $el) { - if (strlen($el) > 1) $rep .= $el.' '; + if (strlen($el) > 1) { + $rep .= $el.' '; + } } return $rep; } diff --git a/src/common/docman/include/webdav.php b/src/common/docman/include/webdav.php index 4f6b32d..116d142 100644 --- a/src/common/docman/include/webdav.php +++ b/src/common/docman/include/webdav.php @@ -3,7 +3,7 @@ * FusionForge Documentation Manager * * Copyright 2010-2011, Franck Villaume - Capgemini - * Copyright 2012,2014,2016 Franck Villaume - TrivialDev + * Copyright 2012,2014,2016,2021, Franck Villaume - TrivialDev * http://fusionforge.org * * This file is part of FusionForge. FusionForge is free software; @@ -669,9 +669,9 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server { if (!$g->usesDocman() || !$g->useWebdav()) { exit_disabled(); } - if ($g->isError()) + if ($g->isError()) { exit_error($g->getErrorMessage(), 'docman'); - + } return true; } } diff --git a/src/common/docman/views/menu.php b/src/common/docman/views/menu.php index db35f4e..2cb656b 100644 --- a/src/common/docman/views/menu.php +++ b/src/common/docman/views/menu.php @@ -7,7 +7,7 @@ * Copyright 2002-2004, GForge Team * Copyright 2010-2011, Franck Villaume - Capgemini * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent - * Copyright 2015, Franck Villaume - TrivialDev + * Copyright 2015,2021, Franck Villaume - TrivialDev * http://fusionforge.org * * This file is part of FusionForge. FusionForge is free software; @@ -62,12 +62,10 @@ if ($g->useDocmanSearch()) { $menu_attr[] = array('title' => _('Search documents in this project using keywords.'), 'id' => 'searchDocmanMenu'); } -if (forge_check_perm('docman', $group_id, 'approve')) { - if (!$dm->isTrashEmpty()) { - $menu_text[] = _('Trash'); - $menu_links[] = '/docman/?group_id='.$group_id.'&view=listtrashfile'; - $menu_attr[] = array('title' => _('Recover or delete permanently files with deleted status.'), 'id' => 'trashDocmanMenu'); - } +if (forge_check_perm('docman', $group_id, 'approve') && !$dm->isTrashEmpty()) { + $menu_text[] = _('Trash'); + $menu_links[] = '/docman/?group_id='.$group_id.'&view=listtrashfile'; + $menu_attr[] = array('title' => _('Recover or delete permanently files with deleted status.'), 'id' => 'trashDocmanMenu'); } if (forge_check_perm('docman', $group_id, 'admin')) { diff --git a/src/common/forum/ForumHTML.class.php b/src/common/forum/ForumHTML.class.php index feaa10f..fcdb468 100644 --- a/src/common/forum/ForumHTML.class.php +++ b/src/common/forum/ForumHTML.class.php @@ -619,7 +619,6 @@ class ForumHTML extends FFError { unset($GLOBALS['editor_was_set_up']); ?> <br /> - <!-- <span class="selected"><?php echo _('HTML tags will display in your post as text'); ?></span> --> <br /> <?php $this->LinkAttachForm();?> diff --git a/src/common/forum/ForumMessage.class.php b/src/common/forum/ForumMessage.class.php index c7f5e38..a75601b 100644 --- a/src/common/forum/ForumMessage.class.php +++ b/src/common/forum/ForumMessage.class.php @@ -197,7 +197,9 @@ class ForumMessage extends FFError { db_begin(); $is_pinned = 'f'; - if (ForumHTML::getIsPinned($thread_id)) $is_pinned = 't'; + if (ForumHTML::getIsPinned($thread_id)) { + $is_pinned = 't'; + } $result = db_query_params('INSERT INTO forum (group_forum_id,posted_by,subject,body,post_date,is_followup_to,thread_id,most_recent_date,is_pinned) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)', array($group_forum_id, $posted_by, @@ -300,7 +302,9 @@ class ForumMessage extends FFError { } $is_pinned = 'f'; - if(ForumHTML::getIsPinned($thread_id)) $is_pinned = 't'; + if(ForumHTML::getIsPinned($thread_id)) { + $is_pinned = 't'; + } $result = db_query_params('INSERT INTO forum (group_forum_id,posted_by,subject,body,post_date,is_followup_to,thread_id,most_recent_date, is_pinned) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)', array($this->Forum->getID(), $user_id, @@ -333,9 +337,7 @@ class ForumMessage extends FFError { db_rollback(); return false; } -//echo "Committing"; db_commit(); -//echo "db_error()".db_error(); $this->awaits_moderation = false; return true; } @@ -616,9 +618,7 @@ class ForumMessage extends FFError { * @return string converted text */ function removebbcode($text) { - //$replaced = preg_replace("/\[[_a-zA-Z]:.+\](.+)\[\/[_a-zA-Z]:.*\]/","$1",$text); - $replaced = preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text); - return $replaced; + return preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text); } /** @@ -644,7 +644,7 @@ class ForumMessage extends FFError { } } - if (count ($recipients) == 0) { + if (empty($recipients)) { return true ; } @@ -752,7 +752,6 @@ Or reply to this e-mail entering your response between the following markers: "\n\n______________________________________________________________________". "\nYou are receiving this email because the forum you administrate has a new moderated message awaiting your approval."; - //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.forge_get_config('web_host'); $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n"; $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n"; $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n"; @@ -768,7 +767,7 @@ Or reply to this e-mail entering your response between the following markers: } $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject()); - if (count($ids) != 0) { + if (!empty($ids)) { $bccres = db_query_params ('SELECT email FROM users WHERE status=$1 AND user_id = ANY ($2)', array ('A', db_int_array_to_any_clause ($ids))) ; @@ -776,7 +775,6 @@ Or reply to this e-mail entering your response between the following markers: $BCC = implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo(); util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),$BCC,'Forum',$extra_headers); -// util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.forge_get_config('web_host')); return true; } diff --git a/src/common/forum/ForumMessageFactory.class.php b/src/common/forum/ForumMessageFactory.class.php index 88ccd18..8f13c1a 100644 --- a/src/common/forum/ForumMessageFactory.class.php +++ b/src/common/forum/ForumMessageFactory.class.php @@ -71,7 +71,6 @@ class ForumMessageFactory extends FFError { * @param string $set Whether to set these prefs into the database - use "custom". */ function setup($offset = 0, $style = 'ultimate', $max_rows = 25, $set = 'no') { -//echo "<br />offset: $offset| style: $style|max_rows: $max_rows|set: $set+"; if ((!$offset) || ($offset < 0)) { $this->offset=0; } else { diff --git a/src/common/frs/FRSFile.class.php b/src/common/frs/FRSFile.class.php index 9753dd9..e42389d 100644 --- a/src/common/frs/FRSFile.class.php +++ b/src/common/frs/FRSFile.class.php @@ -5,7 +5,7 @@ * Copyright 2002, Tim Perdue/GForge, LLC * Copyright 2009, Roland Mas * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent - * Copyright 2012-2014, Franck Villaume - TrivialDev + * Copyright 2012-2014,2021, Franck Villaume - TrivialDev * * This file is part of FusionForge. FusionForge is free software; * you can redistribute it and/or modify it under the terms of the @@ -72,7 +72,7 @@ class FRSFile extends FFError { * @param int|bool $file_id The file_id. * @param array $arr The associative array of data. */ - function __construct(&$FRSRelease, $file_id=false, $arr=array()) { + function __construct(&$FRSRelease, $file_id = false, $arr = array()) { parent::__construct(); if (!$FRSRelease || !is_object($FRSRelease)) { $this->setError(_('Invalid FRS Release Object')); @@ -86,15 +86,12 @@ class FRSFile extends FFError { if ($file_id) { if (!$arr || !is_array($arr)) { - if (!$this->fetchData($file_id)) { - return; - } + $this->fetchData($file_id); } else { $this->data_array =& $arr; if ($this->data_array['release_id'] != $this->FRSRelease->getID()) { $this->setError('FRSRelease_id in db result does not match FRSRelease Object'); - $this->data_array=null; - return; + $this->data_array = null; } } } @@ -351,9 +348,9 @@ class FRSFile extends FFError { $this->FRSRelease->getFileName().'/'. $this->getName(); - if (file_exists($file)) + if (file_exists($file)) { unlink($file); - + } if (isset($this->FRSRelease->release_files[$this->getID()])) { unset($this->FRSRelease->release_files[$this->getID()]); } diff --git a/src/common/frs/FRSPackage.class.php b/src/common/frs/FRSPackage.class.php index d86e3ce..a4ac0c6 100644 --- a/src/common/frs/FRSPackage.class.php +++ b/src/common/frs/FRSPackage.class.php @@ -126,15 +126,12 @@ class FRSPackage extends FFError { if ($package_id) { if (!$arr || !is_array($arr)) { - if (!$this->fetchData($package_id)) { - return; - } + $this->fetchData($package_id); } else { $this->data_array =& $arr; if ($this->data_array['group_id'] != $this->Group->getID()) { $this->setError(_('group_id in db result does not match Group Object')); $this->data_array = null; - return; } // // Add an is_public check here @@ -444,8 +441,8 @@ class FRSPackage extends FFError { $olddirlocation = forge_get_config('upload_dir').'/'.$this->Group->getUnixName().'/'.$olddirname; $newdirlocation = forge_get_config('upload_dir').'/'.$this->Group->getUnixName().'/'.$newdirname; - if(($olddirname!=$newdirname)){ - if(is_dir($newdirlocation)){ + if($olddirname != $newdirname) { + if(is_dir($newdirlocation)) { $this->setError(_('Error Updating Package')._(': ')._('Directory Already Exists')); db_rollback(); return false; @@ -531,9 +528,9 @@ class FRSPackage extends FFError { return false; } - if (is_dir($dir)) + if (is_dir($dir)) { rmdir($dir); - + } $this->clearMonitor(); db_query_params('DELETE FROM frs_package WHERE package_id=$1 AND group_id=$2', array ($this->getID(), @@ -585,7 +582,7 @@ class FRSPackage extends FFError { $zipPath = $this->getReleaseZipPath($release_id); $release = frsrelease_get_object($release_id); $filesPath = forge_get_config('upload_dir').'/'.$this->Group->getUnixName().'/'.$this->getFileName().'/'.$release->getFileName(); - if ($zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE) != true) { + if (!$zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { $this->setError(_('Cannot open the file archive')._(': ').$zipPath.'.'); return false; } @@ -606,8 +603,9 @@ class FRSPackage extends FFError { } public function deleteReleaseFilesAsZip($release_id) { - if (file_exists($this->getReleaseZipPath($release_id))) + if (file_exists($this->getReleaseZipPath($release_id))) { unlink($this->getReleaseZipPath($release_id)); + } return true; } diff --git a/src/common/frs/FRSPackageFactory.class.php b/src/common/frs/FRSPackageFactory.class.php index 681372d..8d20e8c 100644 --- a/src/common/frs/FRSPackageFactory.class.php +++ b/src/common/frs/FRSPackageFactory.class.php @@ -102,9 +102,9 @@ class FRSPackageFactory extends FFError { $qpa = db_construct_qpa(); $qpa = db_construct_qpa($qpa, 'SELECT package_id FROM frs_package WHERE group_id=$1 ', array($this->Group->getID())); - if ($status) + if ($status) { $qpa = db_construct_qpa($qpa, 'AND status_id=$1', array(1)); - + } $qpa = db_construct_qpa($qpa, 'ORDER BY package_id DESC'); $res = db_query_qpa($qpa); if ($res) { diff --git a/src/common/frs/FRSRelease.class.php b/src/common/frs/FRSRelease.class.php index ec60c55..684b934 100644 --- a/src/common/frs/FRSRelease.class.php +++ b/src/common/frs/FRSRelease.class.php @@ -109,15 +109,12 @@ class FRSRelease extends FFObject { if ($release_id) { parent::__construct($release_id, 'FRSRelease'); if (!$arr || !is_array($arr)) { - if (!$this->fetchData($release_id)) { - return; - } + $this->fetchData($release_id); } else { $this->data_array =& $arr; if ($this->data_array['package_id'] != $this->FRSPackage->getID()) { $this->setError('FRSPackage_id in db result does not match FRSPackage Object'); $this->data_array = null; - return; } } } else { @@ -339,7 +336,6 @@ class FRSRelease extends FFObject { forge_get_config('forge_name')) . "\n\n" . util_make_url('/frs/monitor.php?filemodule_id='.$this->FRSPackage->getID()."&group_id=".$this->FRSPackage->Group->getID()."&stop=1"); -// $text = util_line_wrap($text); if (count($arr)) { util_handle_message(array_unique($arr), $subject, $text); } @@ -374,9 +370,9 @@ class FRSRelease extends FFObject { } function hasFiles() { - if ($this->files_count != null) + if ($this->files_count != null) { return $this->files_count; - + } $res = db_query_params('select count(file_id) as files_count from frs_file where release_id = $1', array($this->getID())); if (db_numrows($res) >= 1) { $row = db_fetch_array($res); @@ -516,15 +512,13 @@ class FRSRelease extends FFObject { return true; } - function isLinkedRoadmapRelease($roadmap_id, $roadmap_release) { - $roadmaps = array(); + function isLinkedRoadmapRelease($roadmap_release) { $res = db_query_params('SELECT roadmap_id FROM frs_release_tracker_roadmap_link WHERE release_id = $1 and roadmap_release = $2', array($this->getID(), $roadmap_release)); if (!$res) { return false; } - $roadmaps = util_result_column_to_array($res); - return $roadmaps; + return util_result_column_to_array($res); } function deleteLinkedRoadmap($roadmap_id, $roadmap_release) { diff --git a/src/common/frs/actions/editrelease.php b/src/common/frs/actions/editrelease.php index c6ba7f7..1004a04 100644 --- a/src/common/frs/actions/editrelease.php +++ b/src/common/frs/actions/editrelease.php @@ -102,7 +102,7 @@ if ($uploaded_changes['tmp_name']) { } // If we haven't encountered any problems so far then save the changes -if ($exec_changes == true) { +if ($exec_changes) { $release_date = strtotime($release_date); if (!$frsr->update($status_id, $release_name, $notes, $changes, $preformatted, $release_date)) { $error_msg = $frsr->getErrorMessage(); diff --git a/src/common/frs/include/frs_utils.php b/src/common/frs/include/frs_utils.php index 05acd30..88a2733 100644 --- a/src/common/frs/include/frs_utils.php +++ b/src/common/frs/include/frs_utils.php @@ -181,8 +181,9 @@ function frs_add_file_from_form($release, $type_id, $processor_id, $release_date } if ($filechecks) { - if (strlen($fname) < 3) + if (strlen($fname) < 3) { return _('Name is too short. It must be at least 3 characters.'); + } if (!$move) { $tmp = tempnam('', ''); copy($infile, $tmp); @@ -213,8 +214,9 @@ function frs_add_file_from_form($release, $type_id, $processor_id, $release_date function frs_filterfiles($in) { $out = array(); for ($i = 0; $i < count($in); $i++) { - if (strlen($in[$i]) < 3) + if (strlen($in[$i]) < 3) { continue; + } $out[] = $in[$i]; } return $out; diff --git a/src/common/frs/views/linktrackerroadmap.php b/src/common/frs/views/linktrackerroadmap.php index 7dc9a6e..8534dad 100644 --- a/src/common/frs/views/linktrackerroadmap.php +++ b/src/common/frs/views/linktrackerroadmap.php @@ -2,7 +2,7 @@ /** * FusionForge FRS: Link Tracker Roadmaps to FRS Release * - * Copyright 2016, Franck Villaume - TrivialDev + * Copyright 2016,2021, Franck Villaume - TrivialDev * http://fusionforge.org/ * * This file is part of FusionForge. FusionForge is free software; @@ -45,7 +45,7 @@ if (count($enabledRoadmaps)) { $releaseRoadmaps = $enabledRoadmap->getReleases(); if (count($releaseRoadmaps)) { foreach ($releaseRoadmaps as $releaseRoadmap) { - if ($frsr->isLinkedRoadmapRelease($enabledRoadmap->getID(), $releaseRoadmap)) { + if ($frsr->isLinkedRoadmapRelease($releaseRoadmap)) { $type = 'del'; $labelInput = _('Detach this roadmap from this release'); } else { diff --git a/src/common/frs/views/listpackages.php b/src/common/frs/views/listpackages.php index 9cde655..e9d7dfe 100644 --- a/src/common/frs/views/listpackages.php +++ b/src/common/frs/views/listpackages.php @@ -5,7 +5,7 @@ * Copyright 1999-2001 (c) VA Linux Systems * Copyright 2002-2004 (c) GForge Team * Copyright 2010 (c) FusionForge Team - * Copyright 2013-2014,2016-2017,2020, Franck Villaume - TrivialDev + * Copyright 2013-2014,2016-2017,2020-2021, Franck Villaume - TrivialDev * http://fusionforge.org * * This file is part of FusionForge. FusionForge is free software; @@ -130,11 +130,9 @@ EOS; foreach ($FRSPackageReleases as $FRSPackageRelease) { $package_release_id = $FRSPackageRelease->getID(); $ziplink = ''; - if (class_exists('ZipArchive')) { - if (file_exists($FRSPackage->getReleaseZipPath($package_release_id))) { - $ziplink .= html_e('span', array('class' => 'frs-zip-release'), util_make_link('/frs/download.php/zip/'.$FRSPackageRelease->getID().'/'.urlencode($FRSPackage->getReleaseZipName($FRSPackageRelease->getID())), + if (class_exists('ZipArchive') && file_exists($FRSPackage->getReleaseZipPath($package_release_id))) { + $ziplink .= html_e('span', array('class' => 'frs-zip-release'), util_make_link('/frs/download.php/zip/'.$FRSPackageRelease->getID().'/'.urlencode($FRSPackage->getReleaseZipName($FRSPackageRelease->getID())), $HTML->getZipPic(_('Download this release as ZIP.').' '._('This link always points to this release as a ZIP file.'))), false); - } } // Switch whether release_id exists and/or release_id is current one if ( ! $release_id || $release_id == $package_release_id ) { diff --git a/src/common/frs/views/reporting.php b/src/common/frs/views/reporting.php index a1060fe..05d0e0b 100644 --- a/src/common/frs/views/reporting.php +++ b/src/common/frs/views/reporting.php @@ -1,7 +1,7 @@ <?php /** * Copyright (C) 2009-2012 Alain Peyrat, Alcatel-Lucent - * Copyright 2012,2014, Franck Villaume - TrivialDev + * Copyright 2012,2014,2021, Franck Villaume - TrivialDev * http://fusionforge.org * * This file is part of FusionForge. FusionForge is free software; @@ -60,7 +60,9 @@ if ($report->isError()) { exit_error($report->getErrorMessage(), 'frs'); } -if (!$start || !$end) $z =& $report->getMonthStartArr(); +if (!$start || !$end) { + $z =& $report->getMonthStartArr(); +} if (!$start) { $start = $z[0]; @@ -70,7 +72,9 @@ if (!$end) { $end = $z[count($z) - 1]; } -if ($end < $start) list($start, $end) = array($end, $start); +if ($end < $start) { + list($start, $end) = array($end, $start); +} html_use_jqueryjqplotpluginCanvas(); html_use_jqueryjqplotpluginhighlighter(); @@ -93,7 +97,7 @@ if ($report->isError()) { if ($start == $end) { echo $HTML->error_msg(_('Start and end dates must be different')); - } elseif (count($data) == 0) { + } elseif (empty($data)) { echo $HTML->information(_('There have been no downloads for this package.')); } else { echo '<script type="text/javascript">//<![CDATA['."\n"; diff --git a/src/common/frs/views/showreleases.php b/src/common/frs/views/showreleases.php index b244e4a..453c672 100644 --- a/src/common/frs/views/showreleases.php +++ b/src/common/frs/views/showreleases.php @@ -53,7 +53,7 @@ if (!$frsp || !is_object($frsp)) { } $rs = $frsp->getReleases(); -if (count($rs) < 1) { +if (empty($rs)) { echo $HTML->information_('No releases of this package are available.'); } else { echo html_ao('script', array('type' => 'text/javascript')); diff --git a/src/common/import/import_forums.php b/src/common/import/import_forums.php index 1d46462..ff5abba 100644 --- a/src/common/import/import_forums.php +++ b/src/common/import/import_forums.php @@ -62,7 +62,7 @@ class Forums { $attachment = true; } $messageObject->create($message['subject'], $message['content'], $thread_id, $parentMessageId, $attachment, $msg_time); - if ($attachment == true){ + if ($attachment){ $am = new AttachManager(); $am->SetForumMsg($messageObject); $am->Setmsgid($messageObject->getID()); diff --git a/src/common/include/Group.class.php b/src/common/include/Group.class.php index 78517ae..e446b5b 100644 --- a/src/common/include/Group.class.php +++ b/src/common/include/Group.class.php @@ -4,9 +4,9 @@ * * Copyright 1999-2001, VA Linux Systems, Inc. * Copyright 2009-2013, Roland Mas - * Copyright 2010-2011, Franck Villaume - Capgemini + * Copyright 2010-2011,2021, Franck Villaume - Capgemini * Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent - * Copyright 2012-2017, Franck Villaume - TrivialDev + * Copyright 2012-2017,2021, Franck Villaume - TrivialDev * Copyright 2013, French Ministry of National Education * Copyright 2017, Stéphane-Eymeric Bredthauer - TrivialDev * http://fusionforge.org @@ -106,7 +106,7 @@ function &group_get_objects($id_arr) { $fetch[] = $id; } } - if (count($fetch) > 0) { + if (!empty($fetch)) { $res=db_query_params('SELECT * FROM groups WHERE group_id = ANY ($1)', array(db_int_array_to_any_clause($fetch))); while ($arr = db_fetch_array($res)) { @@ -277,9 +277,7 @@ class Group extends FFError { return; } if (!$res) { - if (!$this->fetchData($id)) { - return; - } + $this->fetchData($id); } else { // // Assoc array was passed in @@ -290,8 +288,7 @@ class Group extends FFError { if (db_numrows($res) < 1) { //function in class we extended $this->setError(_('Group Not Found')); - $this->data_array=array(); - return; + $this->data_array = array(); } else { //set up an associative array for use by other functions $this->data_array = db_fetch_array_by_row($res, 0); @@ -444,13 +441,12 @@ class Group extends FFError { * * This function require site admin privilege. * - * @param object $user User requesting operation (for access control). * @param string $unix_box Machine on which group's home directory located. * @param string $http_domain Domain which serves group's WWW. * @return bool status. * @access public */ - function updateAdmin(&$user, $unix_box, $http_domain) { + function updateAdmin($unix_box, $http_domain) { $perm =& $this->getPermission(); if (!$perm || !is_object($perm)) { @@ -545,10 +541,8 @@ class Group extends FFError { } // Validate some values - if ($this->getPublicName() != htmlspecialchars($group_name)) { - if (!$this->validateGroupName($group_name)) { - return false; - } + if ($this->getPublicName() != htmlspecialchars($group_name) && !$this->validateGroupName($group_name)) { + return false; } if ($new_doc_address) { @@ -843,9 +837,8 @@ class Group extends FFError { function isActive() { if ($this->getStatus() == 'A') { return true; - } else { - return false; } + return false; } /** @@ -1297,10 +1290,9 @@ class Group extends FFError { $this->data_array['use_frs']=$booleanparam; db_commit(); return true; - } else { - db_rollback(); - return false; } + db_rollback(); + return false; } /** @@ -1311,9 +1303,8 @@ class Group extends FFError { function usesTracker() { if (forge_get_config('use_tracker')) { return $this->data_array['use_tracker']; - } else { - return false; } + return false; } /** @@ -1331,10 +1322,9 @@ class Group extends FFError { $this->data_array['use_tracker']=$booleanparam; db_commit(); return true; - } else { - db_rollback(); - return false; } + db_rollback(); + return false; } /** @@ -1345,9 +1335,8 @@ class Group extends FFError { function useCreateOnline() { if (forge_get_config('use_docman')) { return $this->data_array['use_docman_create_online']; - } else { - return false; } + return false; } /** @@ -1358,9 +1347,8 @@ class Group extends FFError { function usesDocman() { if (forge_get_config('use_docman')) { return $this->data_array['use_docman']; - } else { - return false; } + return false; } /** @@ -1389,10 +1377,9 @@ class Group extends FFError { $this->data_array['use_docman'] = $booleanparam; db_commit(); return true; - } else { - db_rollback(); - return false; } + db_rollback(); + return false; } /** @@ -1403,9 +1390,8 @@ class Group extends FFError { function useDocmanSearch() { if (forge_get_config('use_docman')) { return $this->data_array['use_docman_search']; - } else { - return false; } + return false; } /** @@ -1416,9 +1402,8 @@ class Group extends FFError { function useWebdav() { if (forge_get_config('use_webdav')) { return $this->data_array['use_webdav']; - } else { - return false; } + return false; } /** @@ -1429,9 +1414,8 @@ class Group extends FFError { function usesFTP() { if (forge_get_config('use_ftp')) { return $this->data_array['use_ftp']; - } else { - return false; } + return false; } /** @@ -1442,9 +1426,8 @@ class Group extends FFError { function usesSurvey() { if (forge_get_config('use_survey')) { return $this->data_array['use_survey']; - } else { - return false; } + return false; } /** @@ -1455,9 +1438,8 @@ class Group extends FFError { function usesPM() { if (forge_get_config('use_pm')) { return $this->data_array['use_pm']; - } else { - return false; } + return false; } /** @@ -1475,10 +1457,9 @@ class Group extends FFError { $this->data_array['use_pm']=$booleanparam; db_commit(); return true; - } else { - db_rollback(); - return false; } + db_rollback(); + return false; } /** @@ -1511,7 +1492,7 @@ class Group extends FFError { */ function usesPlugin($pluginname) { $plugins_data = $this->getPlugins(); - foreach ($plugins_data as $p_id => $p_name) { + foreach ($plugins_data as $p_name) { if ($p_name == $pluginname) { return true; } @@ -1529,7 +1510,7 @@ class Group extends FFError { function usesService($feature) { $plugins_data = $this->getPlugins(); $pm = plugin_manager_get_object(); - foreach ($plugins_data as $p_id => $p_name) { + foreach ($plugins_data as $p_name) { if ($p_name == $feature) { return true; } @@ -1602,11 +1583,10 @@ class Group extends FFError { $this->setError(_('Error')._(': ')._('Cannot Update Group new_doc_address')._(': ').db_error()); db_rollback(); return false; - } else { - $this->data_array['new_doc_address'] = $email; - db_commit(); - return true; } + $this->data_array['new_doc_address'] = $email; + db_commit(); + return true; } /** @@ -1627,11 +1607,10 @@ class Group extends FFError { $this->setError(_('Error')._(': ')._('Cannot Update Group send_all_docs')._(': ').db_error()); db_rollback(); return false; - } else { - $this->data_array['send_all_docs'] = $status; - db_commit(); - return true; } + $this->data_array['send_all_docs'] = $status; + db_commit(); + return true; } /** @@ -1657,11 +1636,10 @@ class Group extends FFError { $this->setError(_('Error')._(': ')._('Cannot Update Group new_frs_address')._(': ').db_error()); db_rollback(); return false; - } else { - $this->data_array['new_frs_address'] = $email; - db_commit(); - return true; } + $this->data_array['new_frs_address'] = $email; + db_commit(); + return true; } /** @@ -1682,11 +1660,10 @@ class Group extends FFError { $this->setError(_('Error')._(': ')._('Cannot Update Group send_frs_docs')._(': ').db_error()); db_rollback(); return false; - } else { - $this->data_array['send_frs_docs'] = $status; - db_commit(); - return true; } + $this->data_array['send_frs_docs'] = $status; + db_commit(); + return true; } /** @@ -1695,10 +1672,8 @@ class Group extends FFError { * @return string homepage URL. */ function getHomePage() { - if (!preg_match("/^[a-zA-Z][a-zA-Z0-9+.-]*:/", - $this->data_array['homepage'])) { - $this->data_array['homepage'] = 'http://' . - $this->data_array['homepage']; + if (!preg_match("/^[a-zA-Z][a-zA-Z0-9+.-]*:/", $this->data_array['homepage'])) { + $this->data_array['homepage'] = 'http://'.$this->data_array['homepage']; } return $this->data_array['homepage']; } @@ -1710,7 +1685,6 @@ class Group extends FFError { * @return bool */ function setHomepage($homepage) { - if ($homepage == $this->data_array['homepage']) { return true; } @@ -1722,15 +1696,13 @@ class Group extends FFError { $this->data_array['homepage'] = $homepage; db_commit(); return true; - } else { - db_rollback(); - $this->setError(_('Could not insert homepage to database')); - return false; } - } else { - $this->setError(_('Homepage cannot be empty')); + db_rollback(); + $this->setError(_('Could not insert homepage to database')); return false; } + $this->setError(_('Homepage cannot be empty')); + return false; } /** @@ -2134,15 +2106,9 @@ class Group extends FFError { // // Delete reporting // - db_query_params('DELETE FROM rep_group_act_monthly WHERE group_id=$1', - array($this->getID())); - //echo 'rep_group_act_monthly'.db_error(); - db_query_params('DELETE FROM rep_group_act_weekly WHERE group_id=$1', - array($this->getID())); - //echo 'rep_group_act_weekly'.db_error(); - db_query_params('DELETE FROM rep_group_act_daily WHERE group_id=$1', - array($this->getID())); - //echo 'rep_group_act_daily'.db_error(); + db_query_params('DELETE FROM rep_group_act_monthly WHERE group_id=$1', array($this->getID())); + db_query_params('DELETE FROM rep_group_act_weekly WHERE group_id=$1', array($this->getID())); + db_query_params('DELETE FROM rep_group_act_daily WHERE group_id=$1', array($this->getID())); unset($this->data_array); return true; } @@ -2290,7 +2256,7 @@ class Group extends FFError { $found_roles[] = $role; } } - if (count($found_roles) == 0) { + if (empty($found_roles)) { $this->setError(_('Error')._(': ')._('User not removed')._(': ').$user_id); db_rollback(); return false; @@ -2701,15 +2667,13 @@ class Group extends FFError { /* use SCM plugin from template group */ $this->setUseSCM($template->usesSCM()); - foreach ($template->getPlugins() as - $plugin_id => $plugin_name) { + foreach ($template->getPlugins() as $plugin_name) { $this->setPluginUse($plugin_name); } } else { /* use SCM choice from registration page */ - foreach ($template->getPlugins() as $plugin_id => $plugin_name) { - if (substr($plugin_name, 3) == 'scm' && - $plugin_name != 'scmhook') { + foreach ($template->getPlugins() as $plugin_name) { + if (substr($plugin_name, 3) == 'scm' && $plugin_name != 'scmhook') { /* skip copying scm plugins */ continue; } @@ -2813,7 +2777,7 @@ class Group extends FFError { function sendApprovalEmail() { $admins = RBACEngine::getInstance()->getUsersByAllowedAction ('project_admin', $this->getID()); - if (count($admins) < 1) { + if (empty($admins)) { $this->setError(_('Group does not have any administrators.')); return false; } @@ -2925,14 +2889,14 @@ class Group extends FFError { foreach (get_group_join_requests ($this) as $gjr) { $submitters[] = user_get_object($gjr->getUserID()); } - if (count ($submitters) < 1) { + if (empty($submitters)) { $this->setError(_('Could not find user who has submitted the project.')); return false; } $admins = RBACEngine::getInstance()->getUsersByAllowedAction('approve_projects', -1); - if (count($admins) < 1) { + if (empty($admins)) { $this->setError(_('There is no administrator to send the mail to.')); return false; } diff --git a/src/www/admin/groupedit.php b/src/www/admin/groupedit.php index 22fa81d..fdab531 100644 --- a/src/www/admin/groupedit.php +++ b/src/www/admin/groupedit.php @@ -6,7 +6,7 @@ * Copyright 2010 (c) Franck Villaume - Capgemini * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent * Copyright 2013, French Ministry of National Education - * Copyright 2013, Franck Villaume - TrivialDev + * Copyright 2013,2021, Franck Villaume - TrivialDev * * This file is part of FusionForge. FusionForge is free software; * you can redistribute it and/or modify it under the terms of the @@ -54,7 +54,7 @@ function do_update(&$group, $is_template, $status, $unix_box, $http_domain, $scm return false; } - if (!$group->updateAdmin(session_get_user(), $unix_box, $http_domain)) { + if (!$group->updateAdmin($unix_box, $http_domain)) { $error_msg .= $group->getErrorMessage(); db_rollback(); return false; diff --git a/src/www/soap/common/group.php b/src/www/soap/common/group.php index 500d9e6..66d48c8 100644 --- a/src/www/soap/common/group.php +++ b/src/www/soap/common/group.php @@ -3,6 +3,7 @@ * SOAP Group Include - this file contains wrapper functions for the SOAP interface * * Copyright 2004 (c) GForge, LLC + * Copyright 2021, Franck Villaume - TrivialDev * http://fusionforge.org * * This file is part of FusionForge. FusionForge is free software; @@ -420,7 +421,7 @@ function updateGroup($session_ser, $group_id, $is_public, $is_template, $status, $error_msg .= $group->getErrorMessage(); } - if (!$group->updateAdmin(session_get_user(), $unix_box, $http_domain)) { + if (!$group->updateAdmin($unix_box, $http_domain)) { $error_msg .= $group->getErrorMessage(); } ----------------------------------------------------------------------- Summary of changes: src/common/docman/engine/parser_text.inc.php | 6 +- src/common/docman/include/webdav.php | 6 +- src/common/docman/views/menu.php | 12 +- src/common/forum/ForumHTML.class.php | 1 - src/common/forum/ForumMessage.class.php | 20 ++-- src/common/forum/ForumMessageFactory.class.php | 1 - src/common/frs/FRSFile.class.php | 15 +-- src/common/frs/FRSPackage.class.php | 18 ++- src/common/frs/FRSPackageFactory.class.php | 4 +- src/common/frs/FRSRelease.class.php | 16 +-- src/common/frs/actions/editrelease.php | 2 +- src/common/frs/include/frs_utils.php | 6 +- src/common/frs/views/linktrackerroadmap.php | 4 +- src/common/frs/views/listpackages.php | 8 +- src/common/frs/views/reporting.php | 12 +- src/common/frs/views/showreleases.php | 2 +- src/common/import/import_forums.php | 2 +- src/common/include/Group.class.php | 146 ++++++++++--------------- src/www/admin/groupedit.php | 4 +- src/www/soap/common/group.php | 3 +- 20 files changed, 121 insertions(+), 167 deletions(-) hooks/post-receive -- FusionForge _______________________________________________ Fusionforge-commits mailing list Fusionforge-commits@lists.fusionforge.org http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits