Bug 565370 - Optimize the downloadDirectory class
Change-Id: I60b3f21028a1790ee2c269a4981f8e83a1dbb788
Signed-off-by: Eric Poirier <eric.poirier@eclipse-foundation.org>
diff --git a/classes/downloads/downloadDirectory.class.php b/classes/downloads/downloadDirectory.class.php
index 6c6c8f0..71bf5bd 100644
--- a/classes/downloads/downloadDirectory.class.php
+++ b/classes/downloads/downloadDirectory.class.php
@@ -32,13 +32,23 @@
*
* The directory to work with
*/
- private $basedir = "";
+ private $basedir = "";
/**
* Person ID
*/
private $person_id = "";
+ /**
+ * LDAP Group
+ */
+ private $ldap_group = NULL;
+
+ /**
+ * User is committer
+ */
+ private $user_is_committer = NULL;
+
public function __construct() {
$this->App = new App();
@@ -262,6 +272,10 @@
*/
private function _userIsCommitterOnProject() {
+ if (!is_null($this->user_is_committer)) {
+ return $this->user_is_committer;
+ }
+
$sql = "SELECT count(1) as count
FROM PeopleProjects
WHERE PersonID = " . $this->App->returnQuotedString($this->App->sqlSanitize($this->_getPersonID())) . "
@@ -269,14 +283,14 @@
AND Relation = " . $this->App->returnQuotedString("CM") . "
AND (InactiveDate IS NULL OR InactiveDate = '0000-00-00')";
$result = $this->App->foundation_sql($sql);
- $is_committer = FALSE;
+ $this->user_is_committer = FALSE;
while($myrow = mysql_fetch_array($result)) {
if ($myrow['count']) {
- $is_committer = TRUE;
+ $this->user_is_committer = TRUE;
}
}
- return $is_committer;
+ return $this->user_is_committer;
}
@@ -345,7 +359,11 @@
* @return string
*/
public function getLdapGroupByGid($gid) {
+ if (!is_null($this->ldap_group)) {
+ return $this->ldap_group;
+ }
$LDAPConnection = new LDAPConnection();
- return $LDAPConnection->getGroupByGid($gid);
+ $this->ldap_group = $LDAPConnection->getGroupByGid($gid);
+ return $this->ldap_group;
}
}