[Fusionforge-commits] FusionForge branch master updated. ac02336d20cc3604fbd10c71c2210d1debe3c2b9
Franck Villaume
nerville at fusionforge.org
Sun Sep 14 19:14:16 CEST 2014
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 ac02336d20cc3604fbd10c71c2210d1debe3c2b9 (commit)
via 4c56de88b3c0caee1d3d1242b71656a0297e9201 (commit)
via 8dc3de4337846cac6f5c2ac7460f2e21aff0f4fb (commit)
via 9bc63e72a72055b39cbe03c45f615b94522153fe (commit)
via 2790ab962a0c26430507f19ab0ff6b09b0274b26 (commit)
via dc1e1666b20f58c31081adaeec0f9e077d78dee3 (commit)
via c4244223b6f8049c3aeee10540d0477f496a728a (commit)
via 749c1514d34dc86d55220ab5238063d500a5b74c (commit)
from 04f8b9ad805277d48834db5618afeca9a1aa7c7b (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 -----------------------------------------------------------------
commit ac02336d20cc3604fbd10c71c2210d1debe3c2b9
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 19:11:34 2014 +0200
Use MonitorElement: remove a lot of SQL query from the HTML code.
diff --git a/src/common/docman/Document.class.php b/src/common/docman/Document.class.php
index 52eddfd..c57e42e 100644
--- a/src/common/docman/Document.class.php
+++ b/src/common/docman/Document.class.php
@@ -31,6 +31,36 @@ require_once $gfcommon.'docman/Parsedata.class.php';
require_once $gfcommon.'docman/DocumentManager.class.php';
require_once $gfcommon.'docman/DocumentGroup.class.php';
require_once $gfcommon.'docman/DocumentStorage.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
+
+$DOCUMENT_OBJ = array();
+
+/**
+ * document_get_object() - Get User object by user ID.
+ * document_get_object is useful so you can pool document objects/save database queries
+ * You should always use this instead of instantiating the object directly
+ *
+ * @param int $doc_id The ID of the document - required
+ * @param int|bool $res The result set handle ("SELECT * FROM docdata_vw WHERE docid=$1")
+ * @return Document a user object or false on failure
+ */
+function &document_get_object($doc_id, $res = false) {
+ global $DOCUMENT_OBJ;
+ if (!isset($DOCUMENT_OBJ["_".$doc_id."_"])) {
+ if ($res) {
+ //the db result handle was passed in
+ } else {
+ $res = db_query_params('SELECT * FROM docdata_vw WHERE docid = $1',
+ array($doc_id));
+ }
+ if (!$res || db_numrows($res) < 1) {
+ $DOCUMENT_OBJ["_".$doc_id."_"] = false;
+ } else {
+ $DOCUMENT_OBJ["_".$doc_id."_"] = new Document(group_get_object(db_result($res,0,'group_id')), $doc_id, db_fetch_array($res));
+ }
+ }
+ return $DOCUMENT_OBJ["_".$doc_id."_"];
+}
class Document extends Error {
@@ -536,22 +566,8 @@ class Document extends Error {
* @return string The list of emails comma separated
*/
function getMonitoredUserEmailAddress() {
- $result = db_query_params('select users.email from users,docdata_monitored_docman where users.user_id = docdata_monitored_docman.user_id and docdata_monitored_docman.doc_id = $1', array ($this->getID()));
- if (!$result || db_numrows($result) < 1) {
- return NULL;
- } else {
- $values = '';
- $comma = '';
- $i = 0;
- while ($arr = db_fetch_array($result)) {
- if ( $i > 0 )
- $comma = ',';
-
- $values .= $comma.$arr['email'];
- $i++;
- }
- }
- return $values;
+ $MonitorElementObject = new MonitorElement('docdata');
+ return $MonitorElementObject->getAllEmailsInCommatSeparated($this->getID());
}
/**
@@ -562,18 +578,12 @@ class Document extends Error {
* @return boolean true if monitored by this user
*/
function isMonitoredBy($userid = 'ALL') {
+ $MonitorElementObject = new MonitorElement('docdata');
if ( $userid == 'ALL' ) {
- $condition = '';
+ return $MonitorElementObject->isMonitoredByAny($this->getID());
} else {
- $condition = 'user_id='.$userid.' AND';
+ return $MonitorElementObject->isMonitoredByUserId($this->getID(), $userid);
}
- $result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE '.$condition.' doc_id=$1',
- array($this->getID()));
-
- if (!$result || db_numrows($result) < 1)
- return false;
-
- return true;
}
/**
@@ -583,11 +593,9 @@ class Document extends Error {
* @return boolean true if success
*/
function removeMonitoredBy($userid) {
- $result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id=$1 AND user_id=$2',
- array($this->getID(), $userid));
-
- if (!$result) {
- $this->setError(_('Unable To Remove Monitor')._(': ').db_error());
+ $MonitorElementObject = new MonitorElement('docdata');
+ if (!$MonitorElementObject->disableMonitoringByUserId($this->getID(), $userid)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
return false;
}
return true;
@@ -600,17 +608,10 @@ class Document extends Error {
* @return boolean true if success
*/
function addMonitoredBy($userid) {
- $result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE user_id=$1 AND doc_id=$2',
- array($userid, $this->getID()));
-
- if (!$result || db_numrows($result) < 1) {
- $result = db_query_params('INSERT INTO docdata_monitored_docman (doc_id,user_id) VALUES ($1,$2)',
- array($this->getID(), $userid));
-
- if (!$result) {
- $this->setError(_('Unable To Add Monitor')._(': ').db_error());
- return false;
- }
+ $MonitorElementObject = new MonitorElement('docdata');
+ if (!$MonitorElementObject->enableMonitoringByUserId($this->getID(), $userid)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
}
return true;
}
@@ -621,10 +622,9 @@ class Document extends Error {
* @return boolean true if success.
*/
function clearMonitor() {
- $result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id = $1',
- array($this->getID()));
- if (!$result) {
- $this->setError(_('Unable To Clear Monitor')._(': ').db_error());
+ $MonitorElementObject = new MonitorElement('docdata');
+ if (!$MonitorElementObject->clearMonitor($this->getID())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
return false;
}
return true;
@@ -933,7 +933,7 @@ class Document extends Error {
$subject="[" . forge_get_config('forge_name') ."] ".util_unconvert_htmlspecialchars($doc_name);
$body = "\n"._('A new document has been uploaded and waiting to be approved by you')._(': ').
"\n".util_make_url('/docman/?group_id='.$group_id.'&view=admin').
- "\nBy: " . $name . "\n";
+ "\n"._('by').(': ').$name."\n";
$sanitizer = new TextSanitizer();
$text = $desc;
diff --git a/src/common/docman/DocumentGroup.class.php b/src/common/docman/DocumentGroup.class.php
index 756c0a6..7c501c3 100644
--- a/src/common/docman/DocumentGroup.class.php
+++ b/src/common/docman/DocumentGroup.class.php
@@ -27,6 +27,7 @@
*/
require_once $gfcommon.'include/Error.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
class DocumentGroup extends Error {
@@ -356,22 +357,8 @@ class DocumentGroup extends Error {
* @return string The list of emails comma separated
*/
function getMonitoredUserEmailAddress() {
- $result = db_query_params('select users.email from users,docgroup_monitored_docman where users.user_id = docgroup_monitored_docman.user_id and docgroup_monitored_docman.docgroup_id = $1', array ($this->getID()));
- if (!$result || db_numrows($result) < 1) {
- return NULL;
- } else {
- $values = '';
- $comma = '';
- $i = 0;
- while ($arr = db_fetch_array($result)) {
- if ( $i > 0 )
- $comma = ',';
-
- $values .= $comma.$arr['email'];
- $i++;
- }
- }
- return $values;
+ $MonitorElementObject = new MonitorElement('docgroup');
+ return $MonitorElementObject->getAllEmailsInCommatSeparated($this->getID());
}
/**
@@ -382,18 +369,12 @@ class DocumentGroup extends Error {
* @return boolean true if monitored by this user
*/
function isMonitoredBy($userid = 'ALL') {
+ $MonitorElementObject = new MonitorElement('docgroup');
if ( $userid == 'ALL' ) {
- $condition = '';
+ return $MonitorElementObject->isMonitoredByAny($this->getID());
} else {
- $condition = 'user_id = '.$userid.' AND';
+ return $MonitorElementObject->isMonitoredByUserId($this->getID(), $userid);
}
- $result = db_query_params('SELECT * FROM docgroup_monitored_docman WHERE '.$condition.' docgroup_id = $1',
- array($this->getID()));
-
- if (!$result || db_numrows($result) < 1)
- return false;
-
- return true;
}
/**
@@ -403,11 +384,9 @@ class DocumentGroup extends Error {
* @return boolean true if success
*/
function removeMonitoredBy($userid) {
- $result = db_query_params('DELETE FROM docgroup_monitored_docman WHERE docgroup_id = $1 AND user_id = $2',
- array($this->getID(), $userid));
-
- if (!$result) {
- $this->setError(_('Unable To Remove Monitor')._(': ').db_error());
+ $MonitorElementObject = new MonitorElement('docgroup');
+ if (!$MonitorElementObject->disableMonitoringByUserId($this->getID(), $userid)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
return false;
}
return true;
@@ -420,17 +399,10 @@ class DocumentGroup extends Error {
* @return boolean true if success
*/
function addMonitoredBy($userid) {
- $result = db_query_params('SELECT * FROM docgroup_monitored_docman WHERE user_id=$1 AND docgroup_id = $2',
- array($userid, $this->getID()));
-
- if (!$result || db_numrows($result) < 1) {
- $result = db_query_params('INSERT INTO docgroup_monitored_docman (docgroup_id,user_id) VALUES ($1,$2)',
- array($this->getID(), $userid));
-
- if (!$result) {
- $this->setError(_('Unable To Add Monitor')._(': ').db_error());
- return false;
- }
+ $MonitorElementObject = new MonitorElement('docgroup');
+ if (!$MonitorElementObject->enableMonitoringByUserId($this->getID(), $userid)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
}
return true;
}
@@ -441,10 +413,9 @@ class DocumentGroup extends Error {
* @return boolean true if success.
*/
function clearMonitor() {
- $result = db_query_params('DELETE FROM docgroup_monitored_docman WHERE docgroup_id = $1',
- array($this->getID()));
- if (!$result) {
- $this->setError(_('Unable To Clear Monitor')._(': ').db_error());
+ $MonitorElementObject = new MonitorElement('docgroup');
+ if (!$MonitorElementObject->clearMonitor($this->getID())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
return false;
}
return true;
diff --git a/src/common/forum/Forum.class.php b/src/common/forum/Forum.class.php
index 43008fe..9fb89f8 100644
--- a/src/common/forum/Forum.class.php
+++ b/src/common/forum/Forum.class.php
@@ -6,7 +6,7 @@
* Copyright 2002, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013, Franck Villaume - TrivialDev
+ * Copyright 2013-2014 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
@@ -26,6 +26,8 @@
require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'forum/ForumMessage.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
+
// This string is used when sending the notification mail for identifying the
// user response
define('FORUM_MAIL_MARKER', '#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+');
@@ -401,9 +403,8 @@ class Forum extends Error {
* @return array The array of user_id's.
*/
function getMonitoringIDs() {
- $result = db_query_params('SELECT user_id FROM forum_monitored_forums WHERE forum_id=$1',
- array($this->getID()));
- return util_result_column_to_array($result);
+ $MonitorElementObject = new MonitorElement('forum');
+ return $MonitorElementObject->getMonitorUsersIdsInArray($this->getID());
}
/**
@@ -439,25 +440,12 @@ class Forum extends Error {
$this->setError(_('You can only monitor if you are logged in.'));
return false;
}
- $u = user_getid() ;
+ $u = user_getid();
}
- $result = db_query_params('SELECT * FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
- array($u,
- $this->getID()));
- if (!$result || db_numrows($result) < 1) {
- /*
- User is not already monitoring thread, so
- insert a row so monitoring can begin
- */
- $result = db_query_params('INSERT INTO forum_monitored_forums (forum_id,user_id) VALUES ($1,$2)',
- array($this->getID(),
- $u));
-
- if (!$result) {
- $this->setError(_('Unable To Add Monitor').' : '.db_error());
- return false;
- }
-
+ $MonitorElementObject = new MonitorElement('forum');
+ if (!$MonitorElementObject->enableMonitoringByUserId($this->getID(), $u)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
}
return true;
}
@@ -476,9 +464,12 @@ class Forum extends Error {
}
$u = user_getid();
}
- return db_query_params('DELETE FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
- array($u,
- $this->getID()));
+ $MonitorElementObject = new MonitorElement('forum');
+ if (!$MonitorElementObject->disableMonitoringByUserId($this->getID(), $u)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
+ }
+ return true;
}
/**
@@ -490,11 +481,8 @@ class Forum extends Error {
if (!session_loggedin()) {
return false;
}
- $result = db_query_params('SELECT count(*) AS count FROM forum_monitored_forums WHERE user_id=$1 AND forum_id=$2',
- array(user_getid(),
- $this->getID()));
- $row_count = db_fetch_array($result);
- return $result && $row_count['count'] > 0;
+ $MonitorElementObject = new MonitorElement('forum');
+ return $MonitorElementObject->isMonitoredByUserId($this->getID(), user_getid());
}
/**
@@ -634,8 +622,8 @@ class Forum extends Error {
return false;
}
- $result = db_query_params('DELETE FROM forum_monitored_forums WHERE forum_id=$1',
- array($this->getID()));
+ $MonitorElementObject = new MonitorElement('forum');
+ $result = $MonitorElementObject->clearMonitor($this->getID());
if (!$result) {
$this->setError(_('Error Deleting Forum')._(': ').db_error());
db_rollback();
diff --git a/src/common/frs/FRSPackage.class.php b/src/common/frs/FRSPackage.class.php
index a8ad328..b664d02 100644
--- a/src/common/frs/FRSPackage.class.php
+++ b/src/common/frs/FRSPackage.class.php
@@ -26,6 +26,7 @@
require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'frs/FRSRelease.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
/**
* get_frs_packages - get all FRS packages for a specific project
@@ -319,23 +320,10 @@ class FRSPackage extends Error {
$this->setError(_('You can only monitor if you are logged in.'));
return false;
}
- $result = db_query_params('SELECT * FROM filemodule_monitor WHERE user_id=$1 AND filemodule_id=$2',
- array (user_getid(), $this->getID()));
-
- if (!$result || db_numrows($result) < 1) {
- /*
- User is not already monitoring thread, so
- insert a row so monitoring can begin
- */
- $result = db_query_params ('INSERT INTO filemodule_monitor (filemodule_id,user_id) VALUES ($1,$2)',
- array ($this->getID(),
- user_getid()));
-
- if (!$result) {
- $this->setError(_('Unable To Add Monitor')._(': ').db_error());
- return false;
- }
-
+ $MonitorElementObject = new MonitorElement('frspackage');
+ if (!$MonitorElementObject->enableMonitoringByUserId($this->getID(), user_getid())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
}
return true;
}
@@ -350,9 +338,12 @@ class FRSPackage extends Error {
$this->setError(_('You can only monitor if you are logged in.'));
return false;
}
- return db_query_params ('DELETE FROM filemodule_monitor WHERE user_id=$1 AND filemodule_id=$2',
- array (user_getid(),
- $this->getID())) ;
+ $MonitorElementObject = new MonitorElement('frspackage');
+ if (!$MonitorElementObject->disableMonitoringByUserId($this->getID(), $userid)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
+ }
+ return true;
}
/**
@@ -361,13 +352,13 @@ class FRSPackage extends Error {
* @return int the count
*/
function getMonitorCount() {
- $res = db_result(db_query_params ('select count(*) as count from filemodule_monitor where filemodule_id=$1',
- array ($this->getID())), 0, 0);
- if ($res < 0) {
- $this->setError(_('Error On querying monitor count: ').db_error());
- return false;
+ $MonitorElementObject = new MonitorElement('frspackage');
+ $getMonitorCounterInteger = $MonitorElementObject->getMonitorCounterInteger($this->getID());
+ if ($getMonitorCounterInteger !== false) {
+ return $getMonitorCounterInteger;
}
- return $res;
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
}
/**
@@ -379,31 +370,16 @@ class FRSPackage extends Error {
if (!session_loggedin()) {
return false;
}
-
- $result = db_query_params ('SELECT * FROM filemodule_monitor WHERE user_id=$1 AND filemodule_id=$2',
- array (user_getid(),
- $this->getID())) ;
-
- if (!$result || db_numrows($result) < 1) {
- return false;
- } else {
- return true;
- }
+ return $this->isMonitoredBy(user_getid());
}
function isMonitoredBy($userid = 'ALL') {
+ $MonitorElementObject = new MonitorElement('frspackage');
if ( $userid == 'ALL' ) {
- $condition = '';
+ return $MonitorElementObject->isMonitoredByAny($this->getID());
} else {
- $condition = 'user_id='.$userid.' AND';
+ return $MonitorElementObject->isMonitoredByUserId($this->getID(), $userid);
}
- $result = db_query_params('SELECT * FROM filemodule_monitor WHERE '.$condition.' filemodule_id=$1',
- array($this->getID()));
-
- if (!$result || db_numrows($result) < 1)
- return false;
-
- return true;
}
/**
@@ -412,9 +388,8 @@ class FRSPackage extends Error {
* @return array The array of user_id's.
*/
function &getMonitorIDs() {
- $res = db_query_params ('SELECT user_id FROM filemodule_monitor WHERE filemodule_id=$1',
- array ($this->getID())) ;
- return util_result_column_to_array($res);
+ $MonitorElementObject = new MonitorElement('frspackage');
+ return $MonitorElementObject->getMonitorUsersIdsInArray($this->getID());
}
/**
@@ -660,22 +635,8 @@ class FRSPackage extends Error {
* @return string The list of emails comma separated
*/
function getMonitoredUserEmailAddress() {
- $result = db_query_params('select users.email from users,filemodule_monitor where users.user_id = filemodule_monitor.user_id and filemodule_monitor.file_id = $1', array ($this->getID()));
- if (!$result || db_numrows($result) < 1) {
- return NULL;
- } else {
- $values = '';
- $comma = '';
- $i = 0;
- while ($arr = db_fetch_array($result)) {
- if ( $i > 0 )
- $comma = ',';
-
- $values .= $comma.$arr['email'];
- $i++;
- }
- }
- return $values;
+ $MonitorElementObject = new MonitorElement('frspackage');
+ return $MonitorElementObject->getAllEmailsInCommatSeparated($this->getID());
}
}
diff --git a/src/common/include/User.class.php b/src/common/include/User.class.php
index 868364b..6f67826 100644
--- a/src/common/include/User.class.php
+++ b/src/common/include/User.class.php
@@ -273,28 +273,28 @@ class GFUser extends Error {
/**
* create() - Create a new user.
*
- * @param string $unix_name The unix username.
- * @param string $firstname The real firstname.
- * @param string $lastname The real lastname.
- * @param string $password1 The first password.
- * @param string $password2 The confirmation password.
- * @param string $email The users email address.
- * @param string $mail_site The users preferred default language.
- * @param string $mail_va The users preferred default timezone.
- * @param int $language_id The ID of the language preference.
- * @param string $timezone The users preferred default timezone.
- * @param string $dummy1 ignored (no longer used)
- * @param int $dummy2 ignored (no longer used)
- * @param int $theme_id The users theme_id.
- * @param string $unix_box The users unix_box.
- * @param string $address The users address.
- * @param string $address2 The users address part 2.
- * @param string $phone The users phone.
- * @param string $fax The users fax.
- * @param string $title The users title.
- * @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 string $unix_name The unix username.
+ * @param string $firstname The real firstname.
+ * @param string $lastname The real lastname.
+ * @param string $password1 The first password.
+ * @param string $password2 The confirmation password.
+ * @param string $email The users email address.
+ * @param string $mail_site The users preferred default language.
+ * @param string $mail_va The users preferred default timezone.
+ * @param int $language_id The ID of the language preference.
+ * @param string $timezone The users preferred default timezone.
+ * @param string $dummy1 ignored (no longer used)
+ * @param int $dummy2 ignored (no longer used)
+ * @param int $theme_id The users theme_id.
+ * @param string $unix_box The users unix_box.
+ * @param string $address The users address.
+ * @param string $address2 The users address part 2.
+ * @param string $phone The users phone.
+ * @param string $fax The users fax.
+ * @param string $title The users title.
+ * @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
* @return bool|int The newly created user ID
*
*/
@@ -524,37 +524,14 @@ Use one below, but make sure it is entered as the single line.)
db_begin();
- $res = db_query_params('DELETE FROM artifact_monitor WHERE user_id=$1',
- array($this->getID()));
- if (!$res) {
- $this->setError(_('Could Not Delete From artifact_monitor:') . ' '.db_error());
- db_rollback();
- return false;
- }
- $res = db_query_params('DELETE FROM artifact_type_monitor WHERE user_id=$1',
- array($this->getID()));
- if (!$res) {
- $this->setError(_('Could Not Delete From artifact_type_monitor:') . ' ' .db_error());
- db_rollback();
- return false;
- }
- $MonitorElementObject = new MonitorElement('forum');
- if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
- $this->setError($MonitorElementObject->getErrorMessage());
- db_rollback();
- return false;
- }
- $MonitorElementObject = new MonitorElement('docdata');
- if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
- $this->setError($MonitorElementObject->getErrorMessage());
- db_rollback();
- return false;
- }
- $MonitorElementObject = new MonitorElement('docgroup');
- if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
- $this->setError($MonitorElementObject->getErrorMessage());
- db_rollback();
- return false;
+ $monitorElementsArray = array('artifact', 'artifact_type', 'docdata', 'docgroup', 'forum');
+ foreach ($monitorElementsArray as $monitorElement) {
+ $MonitorElementObject = new MonitorElement($monitorElement);
+ if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ db_rollback();
+ return false;
+ }
}
$hook_params = array();
@@ -592,7 +569,7 @@ Use one below, but make sure it is entered as the single line.)
* @param string $ccode The users ccode.
* @param int $tooltips The users preference for tooltips.
* @param string $email The users email.
- * @return bool
+ * @return bool
*/
function update($firstname, $lastname, $language_id, $timezone, $mail_site, $mail_va, $use_ratings,
$dummy1, $dummy2, $theme_id, $address, $address2, $phone, $fax, $title,
@@ -680,8 +657,8 @@ Use one below, but make sure it is entered as the single line.)
*
* If an update occurred and you need to access the updated info.
*
- * @param int $user_id the User ID data to be fetched
- * @return boolean success;
+ * @param int $user_id the User ID data to be fetched
+ * @return boolean success;
*/
function fetchData($user_id) {
$res = db_query_params('SELECT * FROM users WHERE user_id=$1',
diff --git a/src/common/tracker/Artifact.class.php b/src/common/tracker/Artifact.class.php
index c845554..9f2b091 100644
--- a/src/common/tracker/Artifact.class.php
+++ b/src/common/tracker/Artifact.class.php
@@ -51,6 +51,7 @@ require_once $gfcommon.'tracker/ArtifactMessage.class.php';
require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
require_once $gfcommon.'tracker/ArtifactWorkflow.class.php';
require_once $gfcommon.'tracker/ArtifactStorage.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
// This string is used when sending the notification mail for identifying the
// user response
@@ -553,9 +554,8 @@ class Artifact extends Error {
ArtifactStorage::instance()->rollback();
return false;
}
- $res = db_query_params ('DELETE FROM artifact_monitor WHERE artifact_id=$1',
- array ($this->getID())) ;
- if (!$res) {
+ $MonitorElementObject = new MonitorElement('artifact');
+ if (!$MonitorElementObject->clearMonitor($this->getID())) {
$this->setError(_('Error deleting monitor: ').db_error());
db_rollback();
ArtifactStorage::instance()->rollback();
@@ -603,50 +603,39 @@ class Artifact extends Error {
* @return bool Always false - always use the getErrorMessage() for feedback
*/
function setMonitor() {
+ global $feedback;
if (session_loggedin()) {
- $user_id=user_getid();
+ $user_id = user_getid();
} else {
- $this->setError(_('Valid Email Address Required'));
+ $this->setError(_('You can only monitor if you are logged in.'));
return false;
}
- $res = db_query_params ('SELECT * FROM artifact_monitor WHERE artifact_id=$1 AND user_id=$2',
- array ($this->getID(),
- $user_id)) ;
-
- if (!$res || db_numrows($res) < 1) {
- //not yet monitoring
- $res = db_query_params ('INSERT INTO artifact_monitor (artifact_id,user_id) VALUES ($1,$2)',
- array ($this->getID(),
- $user_id)) ;
- if (!$res) {
- $this->setError(db_error());
- return false;
- } else {
- $this->setError(_('Monitoring Started'));
+ $MonitorElementObject = new MonitorElement('artifact');
+ if (!$this->isMonitoring()) {
+ if (!$MonitorElementObject->enableMonitoringByUserId($this->getID(), $user_id)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
return false;
}
+ $feedback = _('Monitoring Started');
+ return true;
} else {
- //already monitoring - remove their monitor
- db_query_params ('DELETE FROM artifact_monitor
- WHERE artifact_id=$1
- AND user_id=$2',
- array ($this->getID(),
- $user_id)) ;
- $this->setError(_('Monitoring Stopped'));
- return false;
+ if (!$MonitorElementObject->disableMonitoringByUserId($this->getID(), $user_id)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
+ }
+ $feedback = _('Monitoring Stopped');
+ return true;
}
+ return false;
}
function isMonitoring() {
if (!session_loggedin()) {
return false;
}
- $result = db_query_params ('SELECT count(*) AS count FROM artifact_monitor WHERE user_id=$1 AND artifact_id=$2',
- array (user_getid(),
- $this->getID())) ;
- $row_count = db_fetch_array($result);
- return $result && $row_count['count'] > 0;
+ $MonitorElementObject = new MonitorElement('artifact');
+ return $MonitorElementObject->isMonitoredByUserId($this->getID(), user_getid());
}
/**
@@ -655,9 +644,8 @@ class Artifact extends Error {
* @return array of email addresses monitoring this Artifact.
*/
function getMonitorIds() {
- $res = db_query_params ('SELECT user_id FROM artifact_monitor WHERE artifact_id=$1',
- array ($this->getID())) ;
- return array_unique(array_merge($this->ArtifactType->getMonitorIds(),util_result_column_to_array($res)));
+ $MonitorElementObject = new MonitorElement('artifact');
+ return $MonitorElementObject->getMonitorUsersIdsInArray($this->getID());
}
/**
diff --git a/src/common/tracker/ArtifactType.class.php b/src/common/tracker/ArtifactType.class.php
index ec6769a..2e2a7f4 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -28,6 +28,7 @@
require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'tracker/ArtifactExtraFieldElement.class.php';
require_once $gfcommon.'tracker/ArtifactStorage.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
/**
* Gets an ArtifactType object from the artifact type id
@@ -531,6 +532,7 @@ class ArtifactType extends Error {
* @return bool false - always false - always use the getErrorMessage() for feedback
*/
function setMonitor($user_id = -1) {
+ global $feedback;
if ($user_id == -1) {
if (!session_loggedin()) {
$this->setError(_('You can only monitor if you are logged in.'));
@@ -538,44 +540,31 @@ class ArtifactType extends Error {
}
$user_id = user_getid();
}
-
- $res = db_query_params('SELECT * FROM artifact_type_monitor WHERE group_artifact_id=$1 AND user_id=$2',
- array($this->getID(),
- $user_id));
- if (!$res || db_numrows($res) < 1) {
- //not yet monitoring
- $res = db_query_params('INSERT INTO artifact_type_monitor (group_artifact_id,user_id) VALUES ($1,$2)',
- array($this->getID(),
- $user_id));
- if (!$res) {
- $this->setError(db_error());
- return false;
- } else {
- $this->setError(_('Monitoring Started'));
+ $MonitorElementObject = new MonitorElement('artifact_type');
+ if (!$this->isMonitoring()) {
+ if (!$MonitorElementObject->enableMonitoringByUserId($this->getID(), $user_id)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
return false;
}
+ $feedback = _('Monitoring Started');
+ return true;
} else {
- //already monitoring - remove their monitor
- db_query_params('DELETE FROM artifact_type_monitor
- WHERE group_artifact_id=$1
- AND user_id=$2',
- array($this->getID(),
- $user_id));
- $this->setError(_('Monitoring Stopped'));
- return false;
+ if (!$MonitorElementObject->disableMonitoringByUserId($this->getID(), $user_id)) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ return false;
+ }
+ $feedback = _('Monitoring Stopped');
+ return true;
}
+ return false;
}
function isMonitoring() {
if (!session_loggedin()) {
return false;
}
- $result = db_query_params('SELECT count(*) AS count FROM artifact_type_monitor
- WHERE user_id=$1 AND group_artifact_id=$2',
- array(user_getid(),
- $this->getID()));
- $row_count = db_fetch_array($result);
- return $result && $row_count['count'] > 0;
+ $MonitorElementObject = new MonitorElement('artifact_type');
+ return $MonitorElementObject->isMonitoredByUserId($this->getID(), user_getid());
}
/**
@@ -584,9 +573,8 @@ class ArtifactType extends Error {
* @return array array of id of users monitoring this Artifact.
*/
function &getMonitorIds() {
- $res = db_query_params('SELECT user_id FROM artifact_type_monitor WHERE group_artifact_id=$1',
- array($this->getID()));
- return util_result_column_to_array($res);
+ $MonitorElementObject = new MonitorElement('artifact_type');
+ return $MonitorElementObject->getMonitorUsersIdsInArray($this->getID());
}
/**
@@ -884,6 +872,9 @@ class ArtifactType extends Error {
array($this->getID()));
//echo '11'.db_error();
+ $MonitorElementObject = new MonitorElement('artifact_type');
+ $MonitorElementObject->clearMonitor($this->getID());
+
db_commit();
ArtifactStorage::instance()->commit();
diff --git a/src/common/tracker/actions/tracker.php b/src/common/tracker/actions/tracker.php
index 4d17738..6e9a4a8 100644
--- a/src/common/tracker/actions/tracker.php
+++ b/src/common/tracker/actions/tracker.php
@@ -410,8 +410,8 @@ switch (getStringFromRequest('func')) {
if (!session_loggedin()) {
exit_permission_denied();
}
- $start = getIntFromRequest('start');
- $stop = getIntFromRequest('stop');
+ $start = getIntFromRequest('startmonitor');
+ $stop = getIntFromRequest('stopmonitor');
$artifact_id = getIntFromRequest('artifact_id');
// Fix to prevent collision with the start variable used in browse.
@@ -430,7 +430,6 @@ switch (getStringFromRequest('func')) {
$feedback = _('Monitoring Stopped');
else {
$ah->setMonitor();
- $error_msg = $ah->getErrorMessage();
}
include $gfcommon.'tracker/actions/browse.php';
}
@@ -447,7 +446,6 @@ switch (getStringFromRequest('func')) {
$feedback = _('Monitoring Deactivated');
else {
$at->setMonitor();
- $feedback=$at->getErrorMessage();
$at->clearError();
}
include $gfcommon.'tracker/actions/browse.php';
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 212d88a..db6dd5b 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -70,11 +70,11 @@ class ArtifactTypeHtml extends ArtifactType {
$attr[] = array('title' => _('Various graph about statistics.'));
if ($this->isMonitoring()) {
$labels[] = _('Stop Monitor');
- $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&stop=1';
+ $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&stopmonitor=1';
$attr[] = array('title' => _('Remove this tracker from your monitoring.'));
} else {
$labels[] = _('Monitor');
- $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&start=1';
+ $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&startmonitor=1';
$attr[] = array('title' => _('Add this tracker from your monitoring.'));
}
diff --git a/src/common/widget/Widget_MyMonitoredDocuments.class.php b/src/common/widget/Widget_MyMonitoredDocuments.class.php
index e661da7..b52877b 100644
--- a/src/common/widget/Widget_MyMonitoredDocuments.class.php
+++ b/src/common/widget/Widget_MyMonitoredDocuments.class.php
@@ -23,6 +23,7 @@
require_once 'Widget.class.php';
require_once $gfwww.'include/my_utils.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
/**
* Widget_MyMonitoredDocuments
@@ -42,26 +43,30 @@ class Widget_MyMonitoredDocuments extends Widget {
function getContent() {
global $HTML;
$html_my_monitored_documents = '';
- $result=db_query_params('select DISTINCT groups.group_name, docdata_vw.group_id from groups, docdata_vw, docdata_monitored_docman where docdata_monitored_docman.doc_id = docdata_vw.docid and groups.group_id = docdata_vw.group_id and docdata_monitored_docman.user_id = $1',array(user_getid()));
- $rows=db_numrows($result);
- if (!$result || $rows < 1) {
+ $monitorElementObject = new MonitorElement('docdata');
+ $distinctMonitorGroupIdsArray = $monitorElementObject->getMonitoredDistinctGroupIdsByUserIdInArray(user_getid());
+ if (!$distinctMonitorGroupIdsArray || count($distinctMonitorGroupIdsArray) < 1) {
$html_my_monitored_documents .= $HTML->warning_msg(_('You are not monitoring any documents.')).html_e('p', array(), _("If you monitor documents, you will be sent new update in the form of an email.")).html_e('p', array(), _("You can monitor documents by clicking on the appropriate icon action in the directory itself."));
} else {
- $request =& HTTPRequest::instance();
- $html_my_monitored_documents .= $HTML->listTableTop();
- $vItemId = new Valid_UInt('hide_item_id');
- $vItemId->required();
- if($request->valid($vItemId)) {
- $hide_item_id = $request->get('hide_item_id');
- } else {
- $hide_item_id = null;
+ $validDistinctMonitorGroupIdsArray = array();
+ foreach ($distinctMonitorGroupIdsArray as $distinctMonitorGroupId) {
+ if (forge_check_perm('docman', $distinctMonitorGroupId, 'read')) {
+ $validDistinctMonitorGroupIdsArray[] = $distinctMonitorGroupId;
+ } else {
+ // Oh ho! we found some monitored documents where user has no read access. Let's clean the situation
+ $monitorElementObject->disableMonitoringForGroupIdByUserId($distinctMonitorGroupId, user_getid());
+ }
}
- for ($j=0; $j<$rows; $j++) {
- $group_id = db_result($result,$j,'group_id');
- $sql2 = "select docdata_vw.docid, docdata_vw.doc_group, docdata_vw.filename, docdata_vw.filetype, docdata_vw.description from docdata_vw,docdata_monitored_docman where docdata_vw.docid = docdata_monitored_docman.doc_id and docdata_vw.group_id = $1 and docdata_monitored_docman.user_id = $2 limit 100";
- $result2 = db_query_params($sql2,array($group_id,user_getid()));
- $rows2 = db_numrows($result2);
-
+ if (count($validDistinctMonitorGroupIdsArray)) {
+ $request =& HTTPRequest::instance();
+ $html_my_monitored_documents .= $HTML->listTableTop();
+ $vItemId = new Valid_UInt('hide_item_id');
+ $vItemId->required();
+ if($request->valid($vItemId)) {
+ $hide_item_id = $request->get('hide_item_id');
+ } else {
+ $hide_item_id = null;
+ }
$vDocument = new Valid_WhiteList('hide_document', array(0, 1));
$vDocument->required();
if($request->valid($vDocument)) {
@@ -69,32 +74,37 @@ class Widget_MyMonitoredDocuments extends Widget {
} else {
$hide_document = null;
}
+ foreach ($distinctMonitorGroupIdsArray as $distinctMonitorGroupId) {
+ $groupObject = group_get_object($distinctMonitorGroupId);
+ $monitorElementIds = $monitorElementObject->getMonitoredIdsByGroupIdByUserIdInArray($distinctMonitorGroupId, user_getid());
- list($hide_now,$count_diff,$hide_url) = my_hide_url('document',$group_id,$hide_item_id,$rows2,$hide_document);
- $count_new = max(0, $count_diff);
- $cells = array();
- $cells[] = array($hide_url.util_make_link('/docman/?group_id='.$group_id, db_result($result,$j,'group_name')).' '.
- '['.$rows2.($count_new ? ', '.html_e('b', array(), sprintf(_('%s new'), $count_new)).']' : ']'), 'colspan' => 2);
- $html_hdr = $HTML->multiTableRow(array('class' => 'boxitem'), $cells);
- $html = '';
- for ($i = 0; $i < $rows2; $i++) {
+ list($hide_now, $count_diff, $hide_url) = my_hide_url('document', $distinctMonitorGroupId, $hide_item_id, count($monitorElementIds), $hide_document);
+ $count_new = max(0, $count_diff);
+ $cells = array();
+ $cells[] = array($hide_url.util_make_link('/docman/?group_id='.$distinctMonitorGroupId, $groupObject->getPublicName()).' '.
+ '['.count($monitorElementIds).($count_new ? ', '.html_e('b', array(), sprintf(_('%s new'), $count_new)).']' : ']'), 'colspan' => 2);
+ $html_hdr = $HTML->multiTableRow(array('class' => 'boxitem'), $cells);
+ $html = '';
if (!$hide_now) {
- $cells = array();
- $doc_group = db_result($result2,$i,'doc_group');
- $docid = db_result($result2,$i,'docid');
- $cells[] = array(' - '.util_make_link('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group, stripslashes(db_result($result2,$i,'filename'))), 'style' => 'width:99%');
- $cells[] = array(util_make_link('/docman/?group_id='.$group_id.'&action=monitorfile&option=stop&view=listfile&dirid='.$doc_group.'&fileid='.$docid,
- $HTML->getDeletePic(_('Stop Monitoring'), _('Stop Monitoring'), array('onClick' => 'return confirm("'._('Stop monitoring this document?').'")'))),
- 'class' => 'align-center');
- $html .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($i, true)), $cells);
+ foreach ($monitorElementIds as $key => $monitorElementId) {
+ $documentObject = document_get_object($monitorElementId);
+ $cells = array();
+ $cells[] = array(' - '.util_make_link('/docman/?group_id='.$distinctMonitorGroupId.'&view=listfile&dirid='.$documentObject->getDocGroupID(), stripslashes($documentObject->getFileName())), 'style' => 'width:99%');
+ $cells[] = array(util_make_link('/docman/?group_id='.$distinctMonitorGroupId.'&action=monitorfile&option=stop&view=listfile&dirid='.$documentObject->getDocGroupID().'&fileid='.$documentObject->getID(),
+ $HTML->getDeletePic(_('Stop Monitoring'), _('Stop Monitoring'), array('onClick' => 'return confirm("'._('Stop monitoring this document?').'")'))),
+ 'class' => 'align-center');
+ $html .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($key, true)), $cells);
+ }
}
- }
- $html_my_monitored_documents .= $html_hdr.$html;
+ $html_my_monitored_documents .= $html_hdr.$html;
+ }
+ $html_my_monitored_documents .= $HTML->listTableBottom();
+ } else {
+ $html_my_monitored_documents .= $HTML->warning_msg(_('You are not monitoring any documents.')).html_e('p', array(), _("If you monitor documents, you will be sent new update in the form of an email.")).html_e('p', array(), _("You can monitor documents by clicking on the appropriate icon action in the directory itself."));
}
- $html_my_monitored_documents .= $HTML->listTableBottom();
}
return $html_my_monitored_documents;
}
diff --git a/src/common/widget/Widget_MyMonitoredForums.class.php b/src/common/widget/Widget_MyMonitoredForums.class.php
index 8f5731a..17dd0d8 100644
--- a/src/common/widget/Widget_MyMonitoredForums.class.php
+++ b/src/common/widget/Widget_MyMonitoredForums.class.php
@@ -22,6 +22,7 @@
require_once 'Widget.class.php';
require_once $gfwww.'include/my_utils.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
/**
* Widget_MyMonitoredForums
@@ -41,57 +42,22 @@ class Widget_MyMonitoredForums extends Widget {
function getContent() {
global $HTML;
$html_my_monitored_forums = '';
- $sql = "SELECT DISTINCT groups.group_id, groups.group_name,
- forum_group_list.group_forum_id, forum_group_list.forum_name ".
- "FROM groups,forum_group_list,forum_monitored_forums ".
- "WHERE groups.group_id=forum_group_list.group_id ".
- "AND groups.status = 'A' ".
- "AND forum_group_list.group_forum_id=forum_monitored_forums.forum_id ".
- "AND forum_monitored_forums.user_id=$1 ";
- $um = UserManager::instance();
- $current_user = $um->getCurrentUser();
- if ($current_user->getStatus()=='S') {
- $projects = $current_user->getProjects();
- $sql .= "AND groups.group_id IN (". implode(',', $projects) .") ";
- }
- //$sql .= "GROUP BY groups.group_id ORDER BY groups.group_id ASC LIMIT 100";
- $sql .= "ORDER BY groups.group_id ASC LIMIT 100";
-
- $result = db_query_params($sql, array(user_getid()));
- $glist = array();
- while ($r = db_fetch_array($result)) {
- if (forge_check_perm('project', $r['group_id'], 'read')
- && forge_check_perm('forum', $r['group_forum_id'], 'read')) {
- $glist[] = serialize(array($r['group_id'], $r['group_name']));
- }
- }
- $glist = array_unique($glist);
- $rows = count($glist);
- if (!$result || $rows < 1) {
+ $monitorElementObject = new MonitorElement('forum');
+ $distinctMonitorGroupIdsArray = $monitorElementObject->getMonitoredDistinctGroupIdsByUserIdInArray(user_getid());
+ if (!$distinctMonitorGroupIdsArray || count($distinctMonitorGroupIdsArray) < 1) {
$html_my_monitored_forums .= $HTML->warning_msg(_('You are not monitoring any forums.')).html_e('p', array(), _("If you monitor forums, you will be sent new posts in the form of an email, with a link to the new message.")).html_e('p', array(), _("You can monitor forums by clicking on the appropriate menu item in the discussion forum itself."));
} else {
- $request =& HTTPRequest::instance();
- $html_my_monitored_forums .= $HTML->listTableTop();
- foreach ($glist as $group) {
- list($group_id, $group_name) = unserialize($group);
-
- $sql2="SELECT forum_group_list.group_forum_id,forum_group_list.forum_name ".
- "FROM groups,forum_group_list,forum_monitored_forums ".
- "WHERE groups.group_id=forum_group_list.group_id ".
- "AND groups.group_id=$1".
- "AND forum_group_list.group_forum_id=forum_monitored_forums.forum_id ".
- "AND forum_monitored_forums.user_id=$2 LIMIT 100";
-
- $result2 = db_query_params($sql2, array($group_id, user_getid()));
- $flist = array();
- while ($r = db_fetch_array($result2)) {
- if (forge_check_perm('forum', $r['group_forum_id'], 'read')) {
- $flist[] = $r;
- }
+ $validDistinctMonitorGroupIdsArray = array();
+ foreach ($distinctMonitorGroupIdsArray as $distinctMonitorGroupId) {
+ if (forge_check_perm('forum_admin', $distinctMonitorGroupId, 'read')) {
+ $validDistinctMonitorGroupIdsArray[] = $distinctMonitorGroupId;
+ } else {
+ // Oh ho! we found some monitored elements where user has no read access. Let's clean the situation
+ $monitorElementObject->disableMonitoringForGroupIdByUserId($distinctMonitorGroupId, user_getid());
}
-
- $rows2 = count($flist);
-
+ }
+ if (count($validDistinctMonitorGroupIdsArray)) {
+ $request =& HTTPRequest::instance();
$vItemId = new Valid_UInt('hide_item_id');
$vItemId->required();
if ($request->valid($vItemId)) {
@@ -99,7 +65,6 @@ class Widget_MyMonitoredForums extends Widget {
} else {
$hide_item_id = null;
}
-
$vForum = new Valid_WhiteList('hide_forum', array(0, 1));
$vForum->required();
if ($request->valid($vForum)) {
@@ -107,28 +72,53 @@ class Widget_MyMonitoredForums extends Widget {
} else {
$hide_forum = null;
}
-
- list($hide_now,$count_diff,$hide_url) = my_hide_url('forum',$group_id,$hide_item_id,$rows2,$hide_forum);
- $count_new = max(0, $count_diff);
- $cells = array();
- $cells[] = array($hide_url.util_make_link('/forum/?group_id='.$group_id, $group_name).' ['.$rows2.($count_new ? ', '.html_e('b', array(), sprintf(_('%s new'), $count_new)).']' : ']'),
- 'colspan' => 2);
- $html_hdr = $HTML->multiTableRow(array('class' => 'boxitem'), $cells);
- $html = '';
- for ($i=0; $i<$rows2; $i++) {
- if (!$hide_now) {
- $group_forum_id = $flist[$i]['group_forum_id'];
+ $setListTableTop = true;
+ foreach ($validDistinctMonitorGroupIdsArray as $validDistinctMonitorGroupId) {
+ $groupObject = group_get_object($validDistinctMonitorGroupId);
+ $monitoredForumIdsArray = $monitorElementObject->getMonitoredIdsByGroupIdByUserIdInArray($validDistinctMonitorGroupId, user_getid());
+ $validMonitoredForumIds = array();
+ foreach ($monitoredForumIdsArray as $monitoredForumId) {
+ if (forge_check_perm('forum', $monitoredForumId, 'read')) {
+ $validMonitoredForumIds[] = $monitoredForumId;
+ } else {
+ // Oh ho! we found some monitored elements where user has no read access. Let's clean the situation
+ $monitorElementObject->disableMonitoringByUserId($monitoredForumId, user_getid());
+ }
+ }
+ if (count($validMonitoredForumIds)) {
+ if ($setListTableTop) {
+ $html_my_monitored_forums .= $HTML->listTableTop();
+ $setListTableTop = false;
+ }
+
+ list($hide_now, $count_diff, $hide_url) = my_hide_url('forum', $validDistinctMonitorGroupId, $hide_item_id, count($validMonitoredForumIds), $hide_forum);
+ $count_new = max(0, $count_diff);
$cells = array();
- $cells[] = array(' - '.util_make_link('/forum/forum.php?forum_id='.$group_forum_id, $flist[$i]['forum_name']), 'style' => 'width:99%');
- $cells[] = array(util_make_link('/forum/monitor.php?forum_id='.$group_forum_id.'&group_id='.$group_id.'&stop=1',
+ $cells[] = array($hide_url.util_make_link('/forum/?group_id='.$validDistinctMonitorGroupId, $groupObject->getPublicName()).' ['.count($validMonitoredForumIds).($count_new ? ', '.html_e('b', array(), sprintf(_('%s new'), $count_new)).']' : ']'), 'colspan' => 2);
+ $html_hdr = $HTML->multiTableRow(array('class' => 'boxitem'), $cells);
+ $html = '';
+ if (!$hide_now) {
+ foreach ($validMonitoredForumIds as $key => $validMonitoredForumId) {
+ $forumObject = forum_get_object($validMonitoredForumId);
+ $cells = array();
+ $cells[] = array(' - '.util_make_link('/forum/forum.php?forum_id='.$validMonitoredForumId, $forumObject->getName()), 'style' => 'width:99%');
+ $cells[] = array(util_make_link('/forum/monitor.php?forum_id='.$validMonitoredForumId.'&group_id='.$groupObject->getID().'&stop=1',
$HTML->getDeletePic(_('Stop Monitoring'), _('Stop Monitoring'), array('onClick' => 'return confirm("'._('Stop monitoring this forum?').'")'))),
- 'class' => 'align-center');
- $html .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($i, true)), $cells);
+ 'class' => 'align-center');
+ $html .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($key, true)), $cells);
+ }
+ }
+ $html_my_monitored_forums .= $html_hdr.$html;
+ } else {
+ $html_my_monitored_forums .= $HTML->warning_msg(_('You are not monitoring any forums.')).html_e('p', array(), _("If you monitor forums, you will be sent new posts in the form of an email, with a link to the new message.")).html_e('p', array(), _("You can monitor forums by clicking on the appropriate menu item in the discussion forum itself."));
+ }
+ if (!$setListTableTop) {
+ $html_my_monitored_forums .= $HTML->listTableBottom();
}
}
- $html_my_monitored_forums .= $html_hdr.$html;
+ } else {
+ $html_my_monitored_forums .= $HTML->warning_msg(_('You are not monitoring any forums.')).html_e('p', array(), _("If you monitor forums, you will be sent new posts in the form of an email, with a link to the new message.")).html_e('p', array(), _("You can monitor forums by clicking on the appropriate menu item in the discussion forum itself."));
}
- $html_my_monitored_forums .= $HTML->listTableBottom();
}
return $html_my_monitored_forums;
}
diff --git a/src/common/widget/Widget_MyMonitoredFp.class.php b/src/common/widget/Widget_MyMonitoredFp.class.php
index 2dcca1e..c1ad3c4 100644
--- a/src/common/widget/Widget_MyMonitoredFp.class.php
+++ b/src/common/widget/Widget_MyMonitoredFp.class.php
@@ -20,6 +20,9 @@
*/
require_once 'Widget.class.php';
+require_once $gfwww.'include/my_utils.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
+
/**
* Widget_MyMonitoredFp
*
@@ -35,76 +38,83 @@ class Widget_MyMonitoredFp extends Widget {
function getContent() {
global $HTML;
$html_my_monitored_fp = '';
- $sql = "SELECT groups.group_name,groups.group_id ".
- "FROM groups,filemodule_monitor,frs_package ".
- "WHERE groups.group_id=frs_package.group_id ".
- "AND groups.status = 'A' ".
- "AND frs_package.package_id=filemodule_monitor.filemodule_id ".
- "AND filemodule_monitor.user_id=$1 ";
- $um = UserManager::instance();
- $current_user = $um->getCurrentUser();
- if ($current_user->getStatus()=='S') {
- $projects = $current_user->getProjects();
- $sql .= 'AND groups.group_id IN ('. implode(',', $projects) .') ';
- }
- $sql .= 'GROUP BY groups.group_id, groups.group_name ORDER BY groups.group_id ASC LIMIT 100';
-
- $result = db_query_params($sql,array(user_getid()));
- $rows = db_numrows($result);
- if (!$result || $rows < 1) {
+ $monitorElementObject = new MonitorElement('frspackage');
+ $distinctMonitorGroupIdsArray = $monitorElementObject->getMonitoredDistinctGroupIdsByUserIdInArray(user_getid());
+ if (!$distinctMonitorGroupIdsArray || count($distinctMonitorGroupIdsArray) < 1) {
$html_my_monitored_fp .= $HTML->warning_msg(_('You are not monitoring any files.')).html_e('p', array(), _('If you monitor files, you will be sent new release notices via email, with a link to the new file on our download server.')).html_e('p', array(), _("You can monitor files by visiting a project's “Summary Page” and clicking on the appropriate icon in the files section."));
} else {
- $html_my_monitored_fp .= $HTML->listTableTop();
- $request =& HTTPRequest::instance();
- for ($j = 0; $j < $rows; $j++) {
- $group_id = db_result($result, $j, 'group_id');
-
- $sql2="SELECT frs_package.name,filemodule_monitor.filemodule_id ".
- "FROM groups,filemodule_monitor,frs_package ".
- "WHERE groups.group_id=frs_package.group_id ".
- "AND groups.group_id=$1 ".
- "AND frs_package.package_id=filemodule_monitor.filemodule_id ".
- "AND filemodule_monitor.user_id=$2 LIMIT 100";
- $result2 = db_query_params($sql2, array($group_id, user_getid()));
- $rows2 = db_numrows($result2);
-
+ $validDistinctMonitorGroupIdsArray = array();
+ foreach ($distinctMonitorGroupIdsArray as $distinctMonitorGroupId) {
+ if (forge_check_perm('frs_admin', $distinctMonitorGroupId, 'read')) {
+ $validDistinctMonitorGroupIdsArray[] = $distinctMonitorGroupId;
+ } else {
+ // Oh ho! we found some monitored elements where user has no read access. Let's clean the situation
+ $monitorElementObject->disableMonitoringForGroupIdByUserId($distinctMonitorGroupId, user_getid());
+ }
+ }
+ if (count($validDistinctMonitorGroupIdsArray)) {
+ $request =& HTTPRequest::instance();
$vItemId = new Valid_UInt('hide_item_id');
$vItemId->required();
- if($request->valid($vItemId)) {
+ if ($request->valid($vItemId)) {
$hide_item_id = $request->get('hide_item_id');
} else {
$hide_item_id = null;
}
-
$vFrs = new Valid_WhiteList('hide_frs', array(0, 1));
$vFrs->required();
- if($request->valid($vFrs)) {
+ if ($request->valid($vFrs)) {
$hide_frs = $request->get('hide_frs');
} else {
$hide_frs = null;
}
-
- list($hide_now, $count_diff, $hide_url) = my_hide_url('frs', $group_id, $hide_item_id, $rows2, $hide_frs);
-
- $count_new = max(0, $count_diff);
- $cells = array();
- $cells[] = array($hide_url.util_make_link('/frs/?group_id='.$group_id, db_result($result,$j,'group_name')).my_item_count($rows2,$count_new), 'colspan' => 2);
- $html_hdr = $HTML->multiTableRow(array('class' => 'boxitem'), $cells);
- $html = '';
- for ($i = 0; $i < $rows2; $i++) {
- if (!$hide_now) {
+ $setListTableTop = true;
+ foreach ($validDistinctMonitorGroupIdsArray as $validDistinctMonitorGroupId) {
+ $groupObject = group_get_object($validDistinctMonitorGroupId);
+ $monitoredPackageIdsArray = $monitorElementObject->getMonitoredIdsByGroupIdByUserIdInArray($validDistinctMonitorGroupId, user_getid());
+ $validMonitoredPackageIds = array();
+ foreach ($monitoredPackageIdsArray as $monitoredPackageId) {
+ if (forge_check_perm('frs', $monitoredPackageId, 'read')) {
+ $validMonitoredPackageIds[] = $monitoredPackageId;
+ } else {
+ // Oh ho! we found some monitored elements where user has no read access. Let's clean the situation
+ $monitorElementObject->disableMonitoringByUserId($monitoredPackageId, user_getid());
+ }
+ }
+ if (count($validMonitoredPackageIds)) {
+ if ($setListTableTop) {
+ $html_my_monitored_fp .= $HTML->listTableTop();
+ $setListTableTop = false;
+ }
+ list($hide_now, $count_diff, $hide_url) = my_hide_url('frs', $validDistinctMonitorGroupId, $hide_item_id, count($validMonitoredPackageIds), $hide_frs);
+ $count_new = max(0, $count_diff);
$cells = array();
- $url = '/frs/?group_id='.$group_id.'&package_id='.db_result($result2,$i,'filemodule_id').'&action=monitor&status=0&ajax=0';
- $title = db_result($result2,$i,'name').' - '._('Stop monitoring this package');
- $package_monitor = util_make_link($url, $HTML->getDeletePic($title, $title, array('onClick' => 'return confirm("'._('Stop monitoring this package?').'")')));
- $cells[] = array(' - '.util_make_link('/frs/?group_id='.$group_id, db_result($result2,$i,'name')), 'width' => '99%');
- $cells[][] = $package_monitor;
- $html .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($i, true)), $cells);
+ $cells[] = array($hide_url.util_make_link('/frs/?group_id='.$validDistinctMonitorGroupId, $groupObject->getPublicName()).my_item_count(count($validMonitoredPackageIds),$count_new), 'colspan' => 2);
+ $html_hdr = $HTML->multiTableRow(array('class' => 'boxitem'), $cells);
+ $html = '';
+ if (!$hide_now) {
+ foreach ($validMonitoredPackageIds as $key => $validMonitoredPackageId) {
+ $frsPackageObject = frspackage_get_object($validMonitoredPackageId);
+ $cells = array();
+ $url = '/frs/?group_id='.$validDistinctMonitorGroupId.'&package_id='.$validMonitoredPackageId.'&action=monitor&status=0&ajax=0';
+ $title = $frsPackageObject->getName().' - '._('Stop monitoring this package');
+ $package_monitor = util_make_link($url, $HTML->getDeletePic($title, $title, array('onClick' => 'return confirm("'._('Stop monitoring this package?').'")')));
+ $cells[] = array(' - '.util_make_link('/frs/?group_id='.$validDistinctMonitorGroupId, $frsPackageObject->getName()), 'width' => '99%');
+ $cells[][] = $package_monitor;
+ $html .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($key, true)), $cells);
+ }
+ }
+ $html_my_monitored_fp .= $html_hdr .$html;
+ } else {
+ $html_my_monitored_fp .= $HTML->warning_msg(_('You are not monitoring any files.')).html_e('p', array(), _('If you monitor files, you will be sent new release notices via email, with a link to the new file on our download server.')).html_e('p', array(), _("You can monitor files by visiting a project's “Summary Page” and clicking on the appropriate icon in the files section."));
+ }
+ if (!$setListTableTop) {
+ $html_my_monitored_fp .= $HTML->listTableBottom();
}
}
- $html_my_monitored_fp .= $html_hdr .$html;
+ } else {
+ $html_my_monitored_fp .= $HTML->warning_msg(_('You are not monitoring any files.')).html_e('p', array(), _('If you monitor files, you will be sent new release notices via email, with a link to the new file on our download server.')).html_e('p', array(), _("You can monitor files by visiting a project's “Summary Page” and clicking on the appropriate icon in the files section."));
}
- $html_my_monitored_fp .= $HTML->listTableBottom();
}
return $html_my_monitored_fp;
}
@@ -121,6 +131,15 @@ class Widget_MyMonitoredFp extends Widget {
return true;
}
+ function getAjaxUrl($owner_id, $owner_type) {
+ $request =& HTTPRequest::instance();
+ $ajax_url = parent::getAjaxUrl($owner_id, $owner_type);
+ if ($request->exist('hide_item_id') || $request->exist('hide_frs')) {
+ $ajax_url .= '&hide_item_id='.$request->get('hide_item_id').'&hide_frs='.$request->get('hide_frs');
+ }
+ return $ajax_url;
+ }
+
function isAvailable() {
if (!forge_get_config('use_frs')) {
return false;
diff --git a/src/www/forum/admin/monitor.php b/src/www/forum/admin/monitor.php
index afae1de..3ec69a9 100644
--- a/src/www/forum/admin/monitor.php
+++ b/src/www/forum/admin/monitor.php
@@ -32,7 +32,8 @@ require_once $gfcommon.'forum/ForumAdmin.class.php';
require_once $gfcommon.'forum/ForumFactory.class.php';
require_once $gfcommon.'forum/ForumMessageFactory.class.php';
require_once $gfcommon.'forum/ForumMessage.class.php';
-require_once $gfcommon.'include/TextSanitizer.class.php'; // to make the HTML input by the user safe to store
+require_once $gfcommon.'include/MonitorElement.class.php';
+require_once $gfcommon.'include/User.class.php';
global $HTML;
@@ -50,12 +51,13 @@ session_require_perm('forum_admin', $f->Group->getID());
forum_header(array('title'=>sprintf(_('Forum %s Monitoring Users'), $f->getName())));
-$res = db_query_params('select users.user_id,users.user_name, users.email, users.realname from
- users,forum_monitored_forums fmf where fmf.user_id=users.user_id and
- fmf.forum_id =$1 order by users.user_id',
- array($group_forum_id));
-
-if ($res && db_numrows($res) == 0) {
+$MonitorElementObject = new MonitorElement('forum');
+$monitorUsersIdArray = $MonitorElementObject->getMonitorUsersIdsInArray($group_forum_id);
+if (!$monitorUsersIdArray) {
+ echo $HTML->error_msg($MonitorElementObject->getErrorMessage());
+ forum_footer();
+ exit;
+} elseif (count($monitorUsersIdArray) == 0) {
echo $HTML->information(_('No Monitoring Users'));
forum_footer();
exit;
@@ -64,11 +66,12 @@ if ($res && db_numrows($res) == 0) {
$tableHeaders = array(_('User'), _('Email'), _('Real Name'));
echo $HTML->listTableTop($tableHeaders);
-while ($arr = db_fetch_array($res)) {
+foreach ($monitorUsersIdArray as $monitorUsersId) {
+ $userObject = user_get_object($monitorUsersId);
$cells = array();
- $cells[][] = $arr['user_name'];
- $cells[][] = $arr['email'];
- $cells[][] = $arr['realname'];
+ $cells[][] = $userObject->getUnixName();
+ $cells[][] = $userObject->getEmail();
+ $cells[][] = $userObject->getRealName();
echo $HTML->multiTableRow(array(), $cells);
}
echo $HTML->listTableBottom();
diff --git a/src/www/forum/myforums.php b/src/www/forum/myforums.php
index f5fbca1..7653ad0 100644
--- a/src/www/forum/myforums.php
+++ b/src/www/forum/myforums.php
@@ -34,6 +34,7 @@ require_once $gfcommon.'forum/Forum.class.php';
require_once $gfcommon.'forum/ForumFactory.class.php';
require_once $gfcommon.'forum/ForumMessageFactory.class.php';
require_once $gfcommon.'forum/ForumMessage.class.php';
+require_once $gfcommon.'include/MonitorElement.class.php';
global $HTML;
@@ -50,27 +51,22 @@ if ($group_id) {
}
//get the user monitored forums
-$result = db_query_params ('SELECT mon.forum_id, fg.group_id FROM forum_monitored_forums mon,forum_group_list fg where mon.user_id=$1 and fg.group_forum_id=mon.forum_id',
- array ($user_id));
-if (!$result) {
- echo $HTML->error_msg(_('Database error :').db_error());
- forum_footer();
- exit;
-}
-if ( db_numrows($result) < 1) {
- echo $HTML->information(_('You have no monitored forums'));
- forum_footer();
- exit;
+$MonitorElementObject = new MonitorElement('forum');
+$monitoredForumsIdsArray = $MonitorElementObject->getMonitedByUserIdInArray($user_id);
+
+if (!$monitoredForumsIdsArray) {
+ echo $HTML->error_msg($MonitorElementObject->getErrorMessage());
+ forum_footer();
+ exit;
}
-//now, i need to create a forum object per each forum that the user is monitoring
-$monitored_forums = array();
-for ($i=0;$i<db_numrows($result);$i++) {
- $monitored_forums[$i] = db_fetch_array($result);
+if (count($monitoredForumsIdsArray) < 1) {
+ echo $HTML->information(_('You have no monitored forums'));
+ forum_footer();
+ exit;
}
-$tablearr=array(_('Project'),_('Forum'), _('Threads'),
- _('Posts'), _('Last Post'), _('New Content?'));
+$tablearr = array(_('Project'),_('Forum'), _('Threads'), _('Posts'), _('Last Post'), _('New Content?'));
echo $HTML->listTableTop($tablearr);
$i = 0;
@@ -78,89 +74,75 @@ $j = 0;
$f = array();
//CHECK : if we won't ever be needing to store each forum/fmf, etc for each pass, don't use an array and use the same variable like $fmf instead of $fmf[$i], etc
-for($i=0;$i<sizeof($monitored_forums);$i++) {
- $g = group_get_object($monitored_forums[$i]["group_id"]);
- if (!$g || !is_object($g) || $g->isError()) {
- exit_no_group();
- }
- $f = new Forum($g,$monitored_forums[$i]["forum_id"]);
- if (!$f || !is_object($f) || $f->isError()) {
- exit_error($f->isError(),'forums');
- }
- if (!is_object($f)) {
- //just skip it - this object should never have been placed here
- } elseif ($f->isError()) {
- echo $f->getErrorMessage();
- } else {
- //check if the forum has new content
-
- $fh = new ForumHTML($f);
- if (!$fh || !is_object($fh)) {
- exit_error(_('Error getting new ForumHTML'), 'forums');
- } elseif ($fh->isError()) {
- exit_error($fh->getErrorMessage(), 'forums');
- }
+for($i = 0; $i < sizeof($monitoredForumsIdsArray); $i++) {
+ if (forge_check_perm('forum', $monitoredForumsIdsArray[$i], 'read')) {
+ $forumObject = forum_get_object($monitoredForumsIdsArray[$i]);
+ if ($forumObject->isError()) {
+ echo $forumObject->getErrorMessage();
+ } else {
+ //check if the forum has new content
+
+ $fh = new ForumHTML($forumObject);
+ if (!$fh || !is_object($fh)) {
+ exit_error(_('Error getting new ForumHTML'), 'forums');
+ } elseif ($fh->isError()) {
+ exit_error($fh->getErrorMessage(), 'forums');
+ }
- $fmf = new ForumMessageFactory($f);
- if (!$fmf || !is_object($fmf)) {
- exit_error(_('Error getting new ForumMessageFactory'), 'forums');
- } elseif ($fmf->isError()) {
- exit_error($fmf->getErrorMessage(), 'forums');
- }
+ $fmf = new ForumMessageFactory($forumObject);
+ if (!$fmf || !is_object($fmf)) {
+ exit_error(_('Error getting new ForumMessageFactory'), 'forums');
+ } elseif ($fmf->isError()) {
+ exit_error($fmf->getErrorMessage(), 'forums');
+ }
- $fmf->setUp($offset,$style,$max_rows,$set);
- $style=$fmf->getStyle();
- $max_rows=$fmf->max_rows;
- $offset=$fmf->offset;
- $msg_arr = $fmf->nestArray($fmf->getNested());
- if ($fmf->isError()) {
- exit_error($fmf->getErrorMessage(), 'forums');
- }
- $rows=count($msg_arr[0]);
- $avail_rows=$fmf->fetched_rows;
- if ($rows > $max_rows) {
- $rows=$max_rows;
- }
+ $fmf->setUp($offset,$style,$max_rows,$set);
+ $style=$fmf->getStyle();
+ $max_rows=$fmf->max_rows;
+ $offset=$fmf->offset;
+ $msg_arr = $fmf->nestArray($fmf->getNested());
+ if ($fmf->isError()) {
+ exit_error($fmf->getErrorMessage(), 'forums');
+ }
+ $rows=count($msg_arr[0]);
+ $avail_rows=$fmf->fetched_rows;
+ if ($rows > $max_rows) {
+ $rows=$max_rows;
+ }
- $new_content = ' ';
- //this loops through every message AND followup, in search of new messages.
- //anything that's new ( new thread or followup) is considered to be a "new thing" and the forum
- //is considered to have new contents
- if (!empty($msg_arr)) {
- foreach ($msg_arr as $forum_msg_arr) {
- foreach ($forum_msg_arr as $forum_msg) {
- if ($f->getSavedDate() < $forum_msg->getPostDate()) {
- //we've got ourselves a new message or followup for this forum. note that, exit the search
- $new_content = html_image('ic/new.png','', '', array('alt' => 'new'));
+ $new_content = ' ';
+ //this loops through every message AND followup, in search of new messages.
+ //anything that's new ( new thread or followup) is considered to be a "new thing" and the forum
+ //is considered to have new contents
+ if (!empty($msg_arr)) {
+ foreach ($msg_arr as $forum_msg_arr) {
+ foreach ($forum_msg_arr as $forum_msg) {
+ if ($forumObject->getSavedDate() < $forum_msg->getPostDate()) {
+ //we've got ourselves a new message or followup for this forum. note that, exit the search
+ $new_content = html_image('ic/new.png','', '', array('alt' => 'new'));
+ break;
+ }
+ }
+ if ($new_content != ' ') {
break;
}
}
- if ($new_content != ' ') {
- break;
- }
}
+
+ $this_forum_group = $forumObject->getGroup();
+ $date = $forumObject->getMostRecentDate()? date(_('Y-m-d H:i'),$forumObject->getMostRecentDate()) : '';
+ $cells = array();
+ $cells[][] = $this_forum_group->getPublicName();
+ $cells[][] = util_make_link('/forum/forum.php?forum_id='.$forumObject->getID().'&group_id='.$this_forum_group->getID(), html_image('ic/forum20w.png').' '.$forumObject->getName());
+ $cells[] = array($forumObject->getThreadCount(), 'class' => 'align-center');
+ $cells[] = array($forumObject->getMessageCount(), 'class' => 'align-center');
+ $cells[] = array($date, 'class' => 'align-center');
+ $cells[] = array($new_content, 'class' => 'align-center');
+ echo $HTML->multiTableRow(array(), $cells);
}
- /*while (($j < $rows) && ($total_rows < $max_rows)) {
- $msg =& $msg_arr["0"][$j];
- $total_rows++;
- if ($f->getSavedDate() < $msg->getPostDate()) {
- //we've got ourselves a new message for this forum. note that, exit the search
- $new_content = "<center>" . html_image('ic/new.png','', '', array('alt' => 'new')) . "</center>";
- break;
- }
- $j++;
- }*/
-
- $this_forum_group = $f->getGroup();
- $date = $f->getMostRecentDate()? date(_('Y-m-d H:i'),$f->getMostRecentDate()) : '';
- $cells = array();
- $cells[][] = $this_forum_group->getPublicName();
- $cells[][] = util_make_link('/forum/forum.php?forum_id='.$f->getID().'&group_id='.$this_forum_group->getID(), html_image('ic/forum20w.png').' '.$f->getName());
- $cells[] = array($f->getThreadCount(), 'class' => 'align-center');
- $cells[] = array($f->getMessageCount(), 'class' => 'align-center');
- $cells[] = array($date, 'class' => 'align-center');
- $cells[] = array($new_content, 'class' => 'align-center');
- echo $HTML->multiTableRow(array(), $cells);
+ } else {
+ // Oh ho! we found some monitored elements where user has no read access. Let's clean the situation
+ $monitorElementObject->disableMonitoringByUserId($monitoredForumsIdsArray[$i], user_getid());
}
}
commit 4c56de88b3c0caee1d3d1242b71656a0297e9201
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 19:10:15 2014 +0200
Introduce MonitorElement object: helper to play with monitoring elements such as docs, forums, trackers, packages ...
diff --git a/src/common/include/MonitorElement.class.php b/src/common/include/MonitorElement.class.php
new file mode 100644
index 0000000..97b39a4
--- /dev/null
+++ b/src/common/include/MonitorElement.class.php
@@ -0,0 +1,328 @@
+<?php
+/**
+ * FusionForge MonitorElement Object
+ *
+ * Copyright 2014, 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
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+class MonitorElement extends Error {
+
+ var $_clearMonitorQuery = null;
+ var $_clearMonitorForUserIdQuery = null;
+ var $_disableMonitoringByUserIdQuery = null;
+ var $_disableMonitoringForGroupIdByUserIdQuery = null;
+ var $_enableMonitoringByUserIdQuery = null;
+ var $_getAllEmailsInArrayQuery = null;
+ var $_getMonitorCounterIntegerQuery = null;
+ var $_getMonitorUsersIdsInArrayQuery = null;
+ var $_getMonitoredByUserIdInArrayQuery = null;
+ var $_getMonitoredDistinctGroupIdsByUserIdInArrayQuery = null;
+ var $_getMonitoredIdsByGroupIdByUserIdInArrayQuery = null;
+ var $_isMonitoredByAnyQuery = null;
+ var $_isMonitoredByUserIdQuery = null;
+
+ function __construct($what) {
+ switch ($what) {
+ case 'docdata': {
+ $this->_clearMonitorQuery = 'delete from docdata_monitored_docman where doc_id = $1';
+ $this->_clearMonitorForUserIdQuery = 'delete from docdata_monitored_docman where user_id = $1';
+ $this->_disableMonitoringByUserIdQuery = 'delete from docdata_monitored_docman where doc_id = $1 and user_id = $2';
+ $this->_disableMonitoringForGroupIdByUserIdQuery = 'delete from docdata_monitored_docman where exists (select docdata_monitored_docman.doc_id from docdata_monitored_docman, doc_data where docdata_monitored_docman.doc_id = doc_data.docid and doc_data.group_id = $1 and docdata_monitored_docman.user_id = $2)';
+ $this->_enableMonitoringByUserIdQuery = 'insert into docdata_monitored_docman (doc_id, user_id) values ($1, $2)';
+ $this->_getAllEmailsInArrayQuery = 'select users.email from users, docdata_monitored_docman where users.user_id = docdata_monitored_docman.user_id and docdata_monitored_docman.doc_id = $1 and users.status = $2';
+ $this->_getMonitorCounterIntegerQuery = 'select count(docgroup_monitored_docman.user_id) as count from docdata_monitored_docman, users where users.user_id = docdata_monitored_docman.user_id and doc_id = $1 and users.status = $2';
+ $this->_getMonitorUsersIdsInArrayQuery = 'select docdata_monitored_docman.user_id from docdata_monitored_docman, users where users.user_id = docdata_monitored_docman.user_id and doc_id = $1 and users.status = $2';;
+ $this->_getMonitoredByUserIdInArrayQuery = 'select doc_id from docdata_monitored_docman where user_id = $1';
+ $this->_getMonitoredDistinctGroupIdsByUserIdInArrayQuery = 'select distinct doc_data.group_id from groups, doc_data, docdata_monitored_docman where docdata_monitored_docman.doc_id = doc_data.docid and groups.group_id = doc_data.group_id and docdata_monitored_docman.user_id = $1 and groups.status = $2';
+ $this->_getMonitoredIdsByGroupIdByUserIdInArrayQuery = 'select doc_data.docid from doc_data, docdata_monitored_docman where doc_data.docid = docdata_monitored_docman.doc_id and doc_data.group_id = $1 and docdata_monitored_docman.user_id = $2';
+ $this->_isMonitoredByAnyQuery = 'select doc_id, docdata_monitored_docman.user_id from docdata_monitored_docman, users where users.user_id = docdata_monitored_docman.user_id and doc_id = $1 and users.status = $2';
+ $this->_isMonitoredByUserIdQuery = 'select doc_id from docdata_monitored_docman where doc_id = $1 and user_id = $2';
+ break;
+ }
+ case 'docgroup': {
+ $this->_clearMonitorQuery = 'delete from docgroup_monitored_docman where docgroup_id = $1';
+ $this->_clearMonitorForUserIdQuery = 'delete from docgroup_monitored_docman where user_id = $1';
+ $this->_disableMonitoringByUserIdQuery = 'delete from docgroup_monitored_docman where docgroup_id = $1 and user_id = $2';
+ $this->_disableMonitoringForGroupIdByUserIdQuery = null; // not used by docgroup.
+ $this->_enableMonitoringByUserIdQuery = 'insert into docgroup_monitored_docman (docgroup_id, user_id) values ($1, $2)';
+ $this->_getAllEmailsInArrayQuery = 'select users.email from users, docgroup_monitored_docman where users.user_id = docgroup_monitored_docman.user_id and docgroup_monitored_docman.docgroup_id = $1 and users.status = $2';
+ $this->_getMonitorCounterIntegerQuery = 'select count(docgroup_monitored_docman.user_id) as count from docgroup_monitored_docman, users where users.user_id = docgroup_monitored_docman.user_id and docgroup_id = $1 and users.status = $2';
+ $this->_getMonitorUsersIdsInArrayQuery = 'select docgroup_monitored_docman.user_id from docgroup_monitored_docman, users where users.user_id = docgroup_monitored_docman.user_id and docgroup_id = $1 and users.status = $2';
+ $this->_getMonitoredByUserIdInArrayQuery = 'select docgroup_id from docgroup_monitored_docman where user_id = $1';
+ $this->_getMonitoredDistinctGroupIdsByUserIdInArrayQuery = 'select distinct doc_groups.group_id from groups, doc_groups, docgroup_monitored_docman where docgroup_monitored_docman.docgroup_id = doc_groups.doc_group and groups.group_id = doc_groups.group_id and docgroup_monitored_docman.user_id = $1';
+ $this->_getMonitoredIdsByGroupIdByUserIdInArrayQuery = 'select doc_groups.doc_group from doc_groups, docgroup_monitored_docman where doc_groups.doc_group = docgroup_monitored_docman.docgroup_id and doc_groups.group_id = $1 and docgroup_monitored_docman.user_id = $2';
+ $this->_isMonitoredByAnyQuery = 'select docgroup_id, docgroup_monitored_docman.user_id from docgroup_monitored_docman, users where users.user_id = docgroup_monitored_docman.user_id and docgroup_id = $1 and users.status = $2';
+ $this->_isMonitoredByUserIdQuery = 'select docgroup_id from docgroup_monitored_docman where docgroup_id = $1 and user_id = $2';
+ break;
+ }
+ case 'forum': {
+ $this->_clearMonitorQuery = 'delete from forum_monitored_forums where forum_id = $1';
+ $this->_clearMonitorForUserIdQuery = 'delete from forum_monitored_forums where user_id = $1';
+ $this->_disableMonitoringByUserIdQuery = 'delete from forum_monitored_forums where forum_id = $1 and user_id = $2';
+ $this->_disableMonitoringForGroupIdByUserIdQuery = 'delete from forum_monitored_forums where exists (select forum_monitored_forums.forum_id from forum_monitored_forums, forum_group_list where forum_monitored_forums.forum_id = forum_group_list.group_forum_id and forum_group_list.group_id = $1 and forum_monitored_forums.user_id = $2)';
+ $this->_enableMonitoringByUserIdQuery = 'insert into forum_monitored_forums (forum_id, user_id) values ($1, $2)';
+ $this->_getAllEmailsInArrayQuery = 'select users.email from users, forum_monitored_forums where users.user_id = forum_monitored_forums.user_id and forum_monitored_forums.forum_id = $1 and users.status = $2';
+ $this->_getMonitorCounterIntegerQuery = 'select count(forum_monitored_forums.user_id) as count from forum_monitored_forums, users where users.user_id = forum_monitored_forums.user_id and forum_monitored_forums.forum_id = $1 and users.status = $2';
+ $this->_getMonitorUsersIdsInArrayQuery = 'select forum_monitored_forums.user_id from forum_monitored_forums, users where users.user_id = forum_monitored_forums.user_id and forum_id = $1 and users.status = $2';
+ $this->_getMonitoredByUserIdInArrayQuery = 'select forum_id from forum_monitored_forums where user_id = $1';
+ $this->_getMonitoredDistinctGroupIdsByUserIdInArrayQuery = 'select distinct forum_group_list.group_id from groups, forum_group_list, forum_monitored_forums where groups.group_id = forum_group_list.group_id and forum_group_list.group_forum_id = forum_monitored_forums.forum_id and forum_monitored_forums.user_id = $1 and groups.status = $2';
+ $this->_getMonitoredIdsByGroupIdByUserIdInArrayQuery = 'select forum_group_list.group_forum_id from groups, forum_group_list,forum_monitored_forums where groups.group_id = forum_group_list.group_id and forum_group_list.group_forum_id = forum_monitored_forums.forum_id and groups.group_id = $1 and forum_monitored_forums.user_id= $2';
+ $this->_isMonitoredByAnyQuery = 'select forum_id, forum_monitored_forums.user_id from forum_monitored_forums, users where users.user_id = forum_monitored_forums.user_id and forum_monitored_forums.forum_id = $1 and users.status = $2';
+ $this->_isMonitoredByUserIdQuery = 'select forum_id from forum_monitored_forums where forum_id = $1 and user_id = $2';
+ break;
+ }
+ case 'artifact_type': {
+ $this->_clearMonitorQuery = 'delete from artifact_type_monitor where group_artifact_id = $1';
+ $this->_clearMonitorForUserIdQuery = 'delete from artifact_type_monitor where user_id = $1';
+ $this->_enableMonitoringByUserIdQuery = 'insert into artifact_type_monitor (group_artifact_id, user_id) values ($1, $2)';
+ $this->_disableMonitoringByUserIdQuery = 'delete from artifact_type_monitor where group_artifact_id = $1 and user_id = $2';
+ $this->_getMonitorUsersIdsInArrayQuery = 'select artifact_type_monitor.user_id from artifact_type_monitor, users where users.user_id = artifact_type_monitor.user_id and artifact_type_monitor.group_artifact_id = $1 and users.status = $2';
+ $this->_isMonitoredByUserIdQuery = 'select group_artifact_id from artifact_type_monitor where group_artifact_id = $1 and user_id = $2';
+ break;
+ }
+ case 'artifact': {
+ $this->_clearMonitorQuery = 'delete from artifact_monitor where artifact_id = $1';
+ $this->_clearMonitorForUserIdQuery = 'delete from artifact_monitor where user_id = $1';
+ $this->_enableMonitoringByUserIdQuery = 'insert into artifact_monitor (artifact_id, user_id) values ($1, $2)';
+ $this->_disableMonitoringByUserIdQuery = 'delete from artifact_monitor where artifact_id = $1 and user_id = $2';
+ $this->_getMonitorUsersIdsInArrayQuery = 'select artifact_monitor.user_id from artifact_monitor, users where users.user_id = artifact_monitor.user_id and artifact_monitor.artifact_id = $1 and users.status = $2';
+ $this->_isMonitoredByUserIdQuery = 'select artifact_id from artifact_monitor where artifact_id = $1 and user_id = $2';
+ break;
+ }
+ case 'frspackage': {
+ $this->_clearMonitorQuery = 'delete from filemodule_monitor where filemodule_id = $1';
+ $this->_clearMonitorForUserIdQuery = 'delete from filemodule_monitor where user_id = $1';
+ $this->_disableMonitoringByUserIdQuery = 'delete from filemodule_monitor where filemodule_id = $1 and user_id = $2';
+ $this->_disableMonitoringForGroupIdByUserIdQuery = 'delete from filemodule_monitor where exists (select filemodule_monitor.filemodule_id from filemodule_monitor, frs_package where filemodule_monitor.filemodule_id = frs_package.package_id and frs_package.group_id = $1 and filemodule_monitor.user_id = $2)';
+ $this->_enableMonitoringByUserIdQuery = 'insert into filemodule_monitor (filemodule_id, user_id) values ($1, $2)';
+ $this->_getAllEmailsInArrayQuery = 'select users.email from users, filemodule_monitor where users.user_id = filemodule_monitor.user_id and filemodule_monitor.filemodule_id = $1 and users.status = $2';
+ $this->_getMonitorCounterIntegerQuery = 'select count(filemodule_monitor.user_id) as count from filemodule_monitor, users where users.user_id = filemodule_monitor.user_id and filemodule_monitor.filemodule_id = $1 and users.status = $2';
+ $this->_getMonitorUsersIdsInArrayQuery = 'select filemodule_monitor.user_id from filemodule_monitor, users where users.user_id = filemodule_monitor.user_id and filemodule_monitor.filemodule_id = $1 and users.status = $2';
+ $this->_getMonitoredByUserIdInArrayQuery = 'select filemodule_id from filemodule_monitor where user_id = $1';
+ $this->_getMonitoredDistinctGroupIdsByUserIdInArrayQuery = 'select distinct frs_package.group_id from groups, frs_package, filemodule_monitor where filemodule_monitor.filemodule_id = frs_package.package_id and groups.group_id = frs_package.group_id and filemodule_monitor.user_id = $1 and groups.status = $2';
+ $this->_getMonitoredIdsByGroupIdByUserIdInArrayQuery = 'select filemodule_monitor.filemodule_id from groups,filemodule_monitor,frs_package where groups.group_id = frs_package.group_id and frs_package.package_id = filemodule_monitor.filemodule_id and groups.group_id=$1 and filemodule_monitor.user_id=$2';
+ $this->_isMonitoredByAnyQuery = 'select forum_id, filemodule_monitor.user_id from filemodule_monitor, users where users.user_id = filemodule_monitor.user_id and filemodule_monitor.filemodule_id = $1 and users.status = $2';
+ $this->_isMonitoredByUserIdQuery = 'select filemodule_id from filemodule_monitor where filemodule_id = $1 and user_id = $2';
+ break;
+ }
+ case 'frsrelease': {
+ break;
+ }
+ default: {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function clearMonitor($which = 0) {
+ if ($which && isset($this->_clearMonitorQuery)) {
+ $result = db_query_params($this->_clearMonitorQuery, array($which));
+ if (!$result) {
+ $this->setError(_('Unable to clear monitoring')._(': ').db_error());
+ return false;
+ }
+ return true;
+ }
+ $this->setError('clearMonitor:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function clearMonitorForUserId($who = 0) {
+ if ($who && isset($this->_clearMonitorForUserIdQuery)) {
+ $result = db_query_params($this->_clearMonitorForUserIdQuery, array($who));
+ if (!$result) {
+ $this->setError(_('Unable to clear monitoring for user')._(': ').db_error());
+ return false;
+ }
+ return true;
+ }
+ $this->setError('clearMonitor:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function disableMonitoringByUserId($which = 0, $who = 0) {
+ if ($which && $who && isset($this->_disableMonitoringByUserIdQuery)) {
+ if ($this->isMonitoredByUserId($which, $who)) {
+ $result = db_query_params($this->_disableMonitoringByUserIdQuery, array($which, $who));
+ if (!$result) {
+ $this->setError(_('Unable to remove monitor from db')._(': ').db_error());
+ return false;
+ }
+ }
+ return true;
+ }
+ $this->setError('disableMonitoringByUserId:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function disableMonitoringForGroupIdByUserId($where = 0, $who = 0) {
+ if ($where && $who && isset($this->_disableMonitoringForGroupIdByUserIdQuery)) {
+ $result = db_query_params($this->_disableMonitoringForGroupIdByUserIdQuery, array($where, $who));
+ if (!$result) {
+ $this->setError(_('Unable to remove monitor from db')._(': ').db_error());
+ return false;
+ }
+ return true;
+ }
+ $this->setError('disableMonitoringForGroupIdByUserId:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function enableMonitoringByUserId($which, $who) {
+ if ($which && $who && isset($this->_enableMonitoringByUserIdQuery)) {
+ if (!$this->isMonitoredByUserId($which, $who)) {
+ $result = db_query_params($this->_enableMonitoringByUserIdQuery, array($which, $who));
+ if (!$result) {
+ $this->setError(_('Unable to add monitor')._(': ').db_error());
+ return false;
+ }
+ }
+ return true;
+ }
+ $this->setError('enableMonitoringByUserId:: '._('Missing parameters values.'));
+ return true;
+ }
+
+ function getAllEmailsInArray($which = 0) {
+ if ($which && isset($this->_getAllEmailsInArrayQuery)) {
+ $result = db_query_params($this->_getAllEmailsInArrayQuery, array($which, 'A'));
+ if ($result || db_numrows($result) >= 0) {
+ return util_result_column_to_array($result);
+ }
+ $this->setError(_('Unable to get emails from db')._(': ').db_error());
+ return false;
+ }
+ $this->setError('getAllEmailsInArray:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function getAllEmailsInCommatSeparated($which = 0) {
+ if ($which) {
+ $getAllEmailsInCommatSeparatedArray = $this->getAllEmailsInArray($which);
+ if ($getAllEmailsInCommatSeparatedArray && is_array($getAllEmailsInCommatSeparatedArray)) {
+ $getAllEmailsInCommatSeparatedString = '';
+ $comma = '';
+ for ($i = 0; $i < count($getAllEmailsInCommatSeparatedArray); $i++) {
+ if ( $i > 0 )
+ $comma = ',';
+
+ $getAllEmailsInCommatSeparatedString .= $comma.$getAllEmailsInCommatSeparatedArray[$i];
+ }
+ return $getAllEmailsInCommatSeparatedString;
+ }
+ return false;
+ }
+ $this->setError('getAllEmailsInCommatSeparated:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function getMonitorUsersIdsInArray($which = 0) {
+ if ($which && isset($this->_getMonitorUsersIdsInArrayQuery)) {
+ $result = db_query_params($this->_getMonitorUsersIdsInArrayQuery, array($which, 'A'));
+ if ($result || db_numrows($result) >= 0) {
+ return util_result_column_to_array($result);
+ } else {
+ $this->setError(_('Unable to get ids from db')._(': ').db_error());
+ return false;
+ }
+ }
+ $this->setError('getMonitorUsersIdsInArray:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function getMonitorCounterInteger($which = 0) {
+ if ($which && isset($this->_getMonitorCounterIntegerQuery)) {
+ $result = db_query_params($this->_getMonitorCounterIntegerQuery, array($which, 'A'));
+ if ($result) {
+ return db_numrows($result);
+ } else {
+ $this->setError(_('Unable to get counter from db')._(': ').db_error());
+ return false;
+ }
+ }
+ $this->setError('getMonitorCounterInteger:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function getMonitedByUserIdInArray($who = 0) {
+ if ($who && isset($this->_getMonitoredByUserIdInArrayQuery)) {
+ $result = db_query_params($this->_getMonitoredByUserIdInArrayQuery, array($who));
+ if ($result || db_numrows($result) >= 0) {
+ return util_result_column_to_array($result);
+ } else {
+ $this->setError(_('Unable to get ids from db')._(': ').db_error());
+ return false;
+ }
+ }
+ $this->setError('getMonitedByUserId:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function getMonitoredDistinctGroupIdsByUserIdInArray($who = 0) {
+ if ($who && isset($this->_getMonitoredDistinctGroupIdsByUserIdInArrayQuery)) {
+ $result = db_query_params($this->_getMonitoredDistinctGroupIdsByUserIdInArrayQuery, array($who, 'A'));
+ if ($result || db_numrows($result) >= 0) {
+ return util_result_column_to_array($result);
+ } else {
+ $this->setError(_('Unable to get ids from db')._(': ').db_error());
+ return false;
+ }
+ }
+ $this->setError('getMonitoredDistinctGroupIdsByUserIdInArray:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function getMonitoredIdsByGroupIdByUserIdInArray($where = 0, $who = 0) {
+ if ($who && isset($this->_getMonitoredIdsByGroupIdByUserIdInArrayQuery)) {
+ $result = db_query_params($this->_getMonitoredIdsByGroupIdByUserIdInArrayQuery, array($where, $who));
+ if ($result || db_numrows($result) >= 0) {
+ return util_result_column_to_array($result);
+ } else {
+ $this->setError(_('Unable to get ids from db')._(': ').db_error());
+ return false;
+ }
+ }
+ $this->setError('getMonitoredIdsByGroupIdByUserIdInArray:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function isMonitoredByUserId($which = 0, $who = 0) {
+ if ($which && $who && isset($this->_isMonitoredByUserIdQuery)) {
+ $result = db_query_params($this->_isMonitoredByUserIdQuery, array($which, $who));
+ if ($result && db_numrows($result) == 1) {
+ return true;
+ }
+ return false;
+ }
+ $this->setError('isMonitoredByUserId:: '._('Missing parameters values.'));
+ return false;
+ }
+
+ function isMonitoredByAny($which = 0) {
+ if ($which && isset($this->_isMonitoredByAnyQuery)) {
+ $result = db_query_params($this->_isMonitoredByAnyQuery, array($which, 'A'));
+ if ($result && db_numrows($result) >= 1) {
+ return true;
+ }
+ return false;
+ }
+ $this->setError('isMonitoredByAny:: '._('Missing parameters values.'));
+ return false;
+ }
+}
commit 8dc3de4337846cac6f5c2ac7460f2e21aff0f4fb
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 19:06:10 2014 +0200
indent
diff --git a/src/www/include/my_utils.php b/src/www/include/my_utils.php
index 4a694c1..87e9b9f 100644
--- a/src/www/include/my_utils.php
+++ b/src/www/include/my_utils.php
@@ -5,7 +5,6 @@
* Originally written by Laurent Julliard 2001, 2002, Codendi Team, Xerox
* http://www.codendi.com
*
- *
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -46,49 +45,49 @@ Output:
function my_hide_url ($svc, $db_item_id, $item_id, $count, $hide) {
- $pref_name = 'my_hide_'.$svc.$db_item_id;
- $old_hide = $old_count = $old_pref_value = UserManager::instance()->getCurrentUser()->getPreference($pref_name);
- if ($old_pref_value) {
- list($old_hide,$old_count) = explode('|', $old_pref_value);
- }
-
- // Make sure they are both 0 if never set before
- if ($old_count == false) { $old_count = 0; }
- if ($old_hide == false) { $old_hide = 0; }
-
- if ($item_id == $db_item_id) {
- if (isset($hide)) {
- $pref_value = "$hide|$count";
- } else {
- $pref_value = "$old_hide|$count";
- $hide = $old_hide;
- }
- } else {
- if ($old_hide) {
- // if items are hidden keep the old count and keep pref as is
- $pref_value = $old_pref_value;
- } else {
- // only update the item count if the items are visible
- // if they are hidden keep reporting the old count
- $pref_value = "$old_hide|$count";
- }
- $hide = $old_hide;
- }
-
- // Update pref value if needed
- if ($old_pref_value != $pref_value) {
- UserManager::instance()->getCurrentUser()->setPreference($pref_name, $pref_value);
- }
-
- if ($hide) {
- $hide_url= util_make_link('/my/?hide_'.$svc.'=0&hide_item_id='.$db_item_id, html_image('pointer_right.png', 16, 16, array('title' => _('Expand'), 'alt' => _('Expand')))).' ';
- $hide_now = true;
- } else {
- $hide_url= util_make_link('/my/?hide_'.$svc.'=1&hide_item_id='.$db_item_id, html_image('pointer_down.png', 16, 16, array('title' => _('Collapse'), 'alt' => _('Collapse')))).' ';
- $hide_now = false;
- }
-
- return array($hide_now, $count-$old_count, $hide_url);
+ $pref_name = 'my_hide_'.$svc.$db_item_id;
+ $old_hide = $old_count = $old_pref_value = UserManager::instance()->getCurrentUser()->getPreference($pref_name);
+ if ($old_pref_value) {
+ list($old_hide,$old_count) = explode('|', $old_pref_value);
+ }
+
+ // Make sure they are both 0 if never set before
+ if ($old_count == false) { $old_count = 0; }
+ if ($old_hide == false) { $old_hide = 0; }
+
+ if ($item_id == $db_item_id) {
+ if (isset($hide)) {
+ $pref_value = "$hide|$count";
+ } else {
+ $pref_value = "$old_hide|$count";
+ $hide = $old_hide;
+ }
+ } else {
+ if ($old_hide) {
+ // if items are hidden keep the old count and keep pref as is
+ $pref_value = $old_pref_value;
+ } else {
+ // only update the item count if the items are visible
+ // if they are hidden keep reporting the old count
+ $pref_value = "$old_hide|$count";
+ }
+ $hide = $old_hide;
+ }
+
+ // Update pref value if needed
+ if ($old_pref_value != $pref_value) {
+ UserManager::instance()->getCurrentUser()->setPreference($pref_name, $pref_value);
+ }
+
+ if ($hide) {
+ $hide_url= util_make_link('/my/?hide_'.$svc.'=0&hide_item_id='.$db_item_id, html_image('pointer_right.png', 16, 16, array('title' => _('Expand'), 'alt' => _('Expand')))).' ';
+ $hide_now = true;
+ } else {
+ $hide_url= util_make_link('/my/?hide_'.$svc.'=1&hide_item_id='.$db_item_id, html_image('pointer_down.png', 16, 16, array('title' => _('Collapse'), 'alt' => _('Collapse')))).' ';
+ $hide_now = false;
+ }
+
+ return array($hide_now, $count-$old_count, $hide_url);
}
function my_hide($svc, $db_item_id, $item_id, $hide) {
@@ -104,47 +103,47 @@ function my_hide($svc, $db_item_id, $item_id, $hide) {
if ($old_hide == false) { $old_hide = 0; }
if ($item_id == $db_item_id) {
- if (!isset($hide)) {
+ if (!isset($hide)) {
$hide = $old_hide;
- }
+ }
} else {
- $hide = $old_hide;
+ $hide = $old_hide;
}
return $hide;
}
function my_format_as_flag($assigned_to, $submitted_by, $multi_assigned_to=null) {
- $AS_flag = '';
- if ($assigned_to == user_getid()) {
- $AS_flag = 'A';
- } elseif ($multi_assigned_to) {
- // For multiple assigned to
- for ($i=0; $i<count($multi_assigned_to); $i++) {
- if ($multi_assigned_to[$i]==user_getid()) {
- $AS_flag = 'A';
- }
- }
- }
- if ($submitted_by == user_getid()) {
- $AS_flag .= 'S';
- }
- if ($AS_flag) { $AS_flag = '[<b>'.$AS_flag.'</b>]'; }
-
- return $AS_flag;
+ $AS_flag = '';
+ if ($assigned_to == user_getid()) {
+ $AS_flag = 'A';
+ } elseif ($multi_assigned_to) {
+ // For multiple assigned to
+ for ($i=0; $i<count($multi_assigned_to); $i++) {
+ if ($multi_assigned_to[$i]==user_getid()) {
+ $AS_flag = 'A';
+ }
+ }
+ }
+ if ($submitted_by == user_getid()) {
+ $AS_flag .= 'S';
+ }
+ if ($AS_flag) { $AS_flag = '[<b>'.$AS_flag.'</b>]'; }
+
+ return $AS_flag;
}
/* second case */
function my_format_as_flag2($assignee, $submitter) {
- $AS_flag = '';
- if ($assignee) $AS_flag = 'A';
+ $AS_flag = '';
+ if ($assignee) $AS_flag = 'A';
- if ($submitter) $AS_flag .= 'S';
+ if ($submitter) $AS_flag .= 'S';
- if ($AS_flag != '') $AS_flag = '[<b>'.$AS_flag.'</b>]';
+ if ($AS_flag != '') $AS_flag = '[<b>'.$AS_flag.'</b>]';
- return $AS_flag;
+ return $AS_flag;
}
function my_item_count($total, $new) {
- return '['.$total.($new ? ", <b>".sprintf(ngettext('%d new item', '%d new items', $new), $new)."</b>]" : ']');
+ return '['.$total.($new ? ", <b>".sprintf(ngettext('%d new item', '%d new items', $new), $new)."</b>]" : ']');
}
commit 9bc63e72a72055b39cbe03c45f615b94522153fe
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 19:05:46 2014 +0200
Layout: use util_make_uri vs. util_make_url
diff --git a/src/www/include/Layout.class.php b/src/www/include/Layout.class.php
index 37a6b6d..d4f2e98 100644
--- a/src/www/include/Layout.class.php
+++ b/src/www/include/Layout.class.php
@@ -1367,7 +1367,7 @@ if (isset($params['group']) && $params['group']) {
echo '<script type="text/javascript">/* <![CDATA[ */'."
jQuery(document).ready(function() {
jQuery('#$element_id-ajax').html('".$spinner."');
- jQuery.ajax({url:'". util_make_url($widget->getAjaxUrl($owner_id, $owner_type)) ."',
+ jQuery.ajax({url:'". util_make_uri($widget->getAjaxUrl($owner_id, $owner_type)) ."',
success: function(result){jQuery('#$element_id-ajax').html(result)},
});
});
commit 2790ab962a0c26430507f19ab0ff6b09b0274b26
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 19:05:09 2014 +0200
remove obsolete requires
diff --git a/src/www/my/dashboard.php b/src/www/my/dashboard.php
index aa3a46e..18c15b7 100644
--- a/src/www/my/dashboard.php
+++ b/src/www/my/dashboard.php
@@ -32,7 +32,6 @@ require_once $gfcommon.'include/pre.php';
require_once $gfwww.'include/vote_function.php';
require_once $gfcommon.'tracker/ArtifactFactory.class.php';
require_once $gfcommon.'tracker/ArtifactsForUser.class.php';
-require_once $gfcommon.'forum/ForumsForUser.class.php';
require_once $gfcommon.'pm/ProjectTasksForUser.class.php';
global $HTML; // Layout object
@@ -101,7 +100,7 @@ if (!session_loggedin()) {
$cell_attrs = array('colspan' => (array_sum($display_col)+1), 'align' => 'left');
$cell_data = array(array_merge((array)$cell_text, $cell_attrs));
echo $HTML->multiTableRow(array(), $cell_data);
-
+
} else {
$atf = new ArtifactTypeFactory($p);
$at_arr = $atf->getArtifactTypes();
@@ -130,7 +129,7 @@ if (!session_loggedin()) {
$cell_data = array(array_merge((array)$cell_text, $cell_attrs));
echo $HTML->multiTableRow(array(), $cell_data);
$toggle=0;
-
+
foreach($art_arr as $art) {
$cell_data = array();
$row_attrs = array('class' => $HTML->boxGetAltRowStyle($toggle++, true));
@@ -208,7 +207,7 @@ if (!session_loggedin()) {
}
echo $HTML->boxBottom();
echo html_ac(html_ap()-2);
-
+
// priority colors
/*
echo html_ao('tr');
commit dc1e1666b20f58c31081adaeec0f9e077d78dee3
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 19:04:36 2014 +0200
my: remove unused requires
diff --git a/src/www/my/index.php b/src/www/my/index.php
index c0c80e8..5333163 100644
--- a/src/www/my/index.php
+++ b/src/www/my/index.php
@@ -27,9 +27,6 @@ require_once '../env.inc.php';
require_once $gfcommon.'include/pre.php';
require_once $gfwww.'include/my_utils.php';
require_once $gfwww.'include/vote_function.php';
-require_once $gfcommon.'tracker/ArtifactsForUser.class.php';
-require_once $gfcommon.'forum/ForumsForUser.class.php';
-require_once $gfcommon.'pm/ProjectTasksForUser.class.php';
require_once $gfcommon.'widget/WidgetLayoutManager.class.php';
if (!session_loggedin()) { // || $sf_user_hash) {
commit c4244223b6f8049c3aeee10540d0477f496a728a
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 11:25:25 2014 +0200
obsolete file
diff --git a/src/common/forum/ForumsForUser.class.php b/src/common/forum/ForumsForUser.class.php
deleted file mode 100644
index 66df513..0000000
--- a/src/common/forum/ForumsForUser.class.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * FusionForge forums
- *
- * Copyright 1999-2000, Tim Perdue/Sourceforge
- * Copyright 2002, Tim Perdue/GForge, LLC
- * Copyright 2009, Roland Mas
- *
- * This file is part of FusionForge. FusionForge is free software;
- * you can redistribute it and/or modify it under the terms of the
- * GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the Licence, or (at your option)
- * any later version.
- *
- * FusionForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with FusionForge; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-require_once $gfcommon.'include/Error.class.php';
-require_once $gfcommon.'forum/Forum.class.php';
-require_once $gfcommon.'include/User.class.php';
-
-class ForumsForUser extends Error {
-
- /**
- * The User object.
- *
- * @var object $User.
- */
- var $User;
-
- /**
- * Constructor.
- *
- * @param $user object The Group object to which this forum is associated.
- * @return bool
- */
- function ForumsForUser(&$user) {
- $this->User =& $user;
-
- return true;
- }
-
- /**
- * getMonitoredForums
- *
- * @return Forum[] The array of Forums
- *
- */
- function getMonitoredForums() {
- $forums = array();
- $result = db_query_params ('SELECT groups.group_name,groups.group_id,forum_group_list.group_forum_id,forum_group_list.forum_name
- FROM groups,forum_group_list,forum_monitored_forums
- WHERE groups.group_id=forum_group_list.group_id AND groups.status=$1
- AND forum_group_list.group_forum_id=forum_monitored_forums.forum_id
- AND forum_monitored_forums.user_id=$2
- ORDER BY group_name DESC',
- array ('A',
- $this->User->getID())) ;
- $rows=db_numrows($result);
- if ($rows < 1) {
- return $forums;
- }
- $last_group='';
- for ($i=0; $i<$rows; $i++) {
- $group_id = db_result($result,$i,'group_id');
- $forum_id = db_result($result,$i,'group_forum_id');
- $group = group_get_object($group_id);
- $forum = new Forum($group,$forum_id);
- if ($forum->isError()) {
- $this->setError($forum->getErrorMessage());
- } else {
- $forums[] = $forum;
- }
- }
- return $forums;
- }
-}
-
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End:
commit 749c1514d34dc86d55220ab5238063d500a5b74c
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Sep 14 11:24:58 2014 +0200
indent
diff --git a/src/common/include/User.class.php b/src/common/include/User.class.php
index d74528e..868364b 100644
--- a/src/common/include/User.class.php
+++ b/src/common/include/User.class.php
@@ -25,6 +25,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+require_once $gfcommon.'include/MonitorElement.class.php';
+
$USER_OBJ = array();
/**
@@ -293,7 +295,7 @@ class GFUser extends Error {
* @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
- * @return bool|int The newly created user ID
+ * @return bool|int The newly created user ID
*
*/
function create($unix_name, $firstname, $lastname, $password1, $password2, $email,
@@ -520,6 +522,7 @@ Use one below, but make sure it is entered as the single line.)
}
}
+
db_begin();
$res = db_query_params('DELETE FROM artifact_monitor WHERE user_id=$1',
array($this->getID()));
@@ -535,17 +538,21 @@ Use one below, but make sure it is entered as the single line.)
db_rollback();
return false;
}
- $res = db_query_params('DELETE FROM forum_monitored_forums WHERE user_id=$1',
- array($this->getID()));
- if (!$res) {
- $this->setError(_('Could Not Delete From forum_monitored_forums:') . ' '.db_error());
+ $MonitorElementObject = new MonitorElement('forum');
+ if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
db_rollback();
return false;
}
- $res = db_query_params('DELETE FROM filemodule_monitor WHERE user_id=$1',
- array($this->getID()));
- if (!$res) {
- $this->setError(_('Could Not Delete From filemodule_monitor:') . ' '.db_error());
+ $MonitorElementObject = new MonitorElement('docdata');
+ if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ $MonitorElementObject = new MonitorElement('docgroup');
+ if (!$MonitorElementObject->clearMonitorForUserId($this->getID())) {
+ $this->setError($MonitorElementObject->getErrorMessage());
db_rollback();
return false;
}
@@ -567,25 +574,25 @@ Use one below, but make sure it is entered as the single line.)
*
* Use specific setter to change other properties.
*
- * @param string $firstname The users first name.
- * @param string $lastname The users last name.
- * @param int $language_id The ID of the users language preference.
- * @param string $timezone The users timezone preference.
- * @param string $mail_site The users preference for receiving site updates by email.
- * @param string $mail_va The users preference for receiving community updates by email.
+ * @param string $firstname The users first name.
+ * @param string $lastname The users last name.
+ * @param int $language_id The ID of the users language preference.
+ * @param string $timezone The users timezone preference.
+ * @param string $mail_site The users preference for receiving site updates by email.
+ * @param string $mail_va The users preference for receiving community updates by email.
* @param string $use_ratings The users preference for being participating in "peer ratings".
- * @param string $dummy1 ignored (no longer used)
- * @param int $dummy2 ignored (no longer used)
- * @param int $theme_id The users theme_id preference.
- * @param string $address The users address.
- * @param string $address2 The users address2.
- * @param string $phone The users phone.
- * @param string $fax The users fax.
- * @param string $title The users title.
- * @param string $ccode The users ccode.
- * @param int $tooltips The users preference for tooltips.
- * @param string $email The users email.
- * @return bool
+ * @param string $dummy1 ignored (no longer used)
+ * @param int $dummy2 ignored (no longer used)
+ * @param int $theme_id The users theme_id preference.
+ * @param string $address The users address.
+ * @param string $address2 The users address2.
+ * @param string $phone The users phone.
+ * @param string $fax The users fax.
+ * @param string $title The users title.
+ * @param string $ccode The users ccode.
+ * @param int $tooltips The users preference for tooltips.
+ * @param string $email The users email.
+ * @return bool
*/
function update($firstname, $lastname, $language_id, $timezone, $mail_site, $mail_va, $use_ratings,
$dummy1, $dummy2, $theme_id, $address, $address2, $phone, $fax, $title,
@@ -723,8 +730,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* setStatus - set this user's status.
*
- * @param string $status Status - P, A, S, or D.
- * @return boolean success.
+ * @param string $status Status - P, A, S, or D.
+ * @return boolean success.
*/
function setStatus($status) {
@@ -772,7 +779,7 @@ Use one below, but make sure it is entered as the single line.)
*
* Database field status of 'A' returns true.
*
- * @return boolean is_active.
+ * @return boolean is_active.
*/
function isActive() {
if ($this->getStatus() == 'A') {
@@ -785,7 +792,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getUnixStatus - Status of activation of unix account.
*
- * @return string (N)one, (A)ctive, (S)uspended or (D)eleted
+ * @return string (N)one, (A)ctive, (S)uspended or (D)eleted
*/
function getUnixStatus() {
return $this->data_array['unix_status'];
@@ -838,7 +845,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getUnixName - the user's unix_name.
*
- * @return string This user's unix/login name.
+ * @return string This user's unix/login name.
*/
function getUnixName() {
return strtolower($this->data_array['user_name']);
@@ -847,7 +854,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getUnixPasswd - get the user's password.
*
- * @return string This user's unix crypted passwd.
+ * @return string This user's unix crypted passwd.
*/
function getUnixPasswd() {
return $this->data_array['unix_pw'];
@@ -856,7 +863,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getUnixBox - the hostname of the unix box this user has an account on.
*
- * @return string This user's shell login machine.
+ * @return string This user's shell login machine.
*/
function getUnixBox() {
return $this->data_array['unix_box'];
@@ -865,7 +872,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getMD5Passwd - the password.
*
- * @return string This user's MD5-crypted passwd.
+ * @return string This user's MD5-crypted passwd.
*/
function getMD5Passwd() {
return $this->data_array['user_pw'];
@@ -879,7 +886,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getConfirmHash - the confirm hash in the db.
*
- * @return string This user's confirmation hash.
+ * @return string This user's confirmation hash.
*/
function getConfirmHash() {
return $this->data_array['confirm_hash'];
@@ -888,7 +895,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getEmail - the user's email address.
*
- * @return string This user's email address.
+ * @return string This user's email address.
*/
function getEmail() {
return str_replace("\n", "", $this->data_array['email']);
@@ -897,7 +904,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getSha1Email - a SHA1 encoded hash of the email URI (including mailto: prefix)
*
- * @return string The SHA1 encoded value for the email
+ * @return string The SHA1 encoded value for the email
*/
function getSha1Email() {
return sha1('mailto:'.$this->getEmail());
@@ -908,7 +915,7 @@ Use one below, but make sure it is entered as the single line.)
*
* getNewEmail is a private operation for email change.
*
- * @return string This user's new (not yet confirmed) email address.
+ * @return string This user's new (not yet confirmed) email address.
* @private
*/
function getNewEmail() {
@@ -918,8 +925,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* setEmail - set a new email address, which must be confirmed.
*
- * @param string $email The email address.
- * @return boolean success.
+ * @param string $email The email address.
+ * @return boolean success.
*/
function setEmail($email) {
@@ -969,9 +976,9 @@ Use one below, but make sure it is entered as the single line.)
/**
* setNewEmailAndHash - setNewEmailAndHash is a private operation for email change.
*
- * @param string $email The email address.
- * @param string $hash The email hash.
- * @return boolean success.
+ * @param string $email The email address.
+ * @param string $hash The email hash.
+ * @return boolean success.
*/
function setNewEmailAndHash($email, $hash = '') {
@@ -1007,7 +1014,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getRealName - get the user's real name.
*
- * @return string This user's real name.
+ * @return string This user's real name.
*/
function getRealName() {
return $this->data_array['realname'];
@@ -1033,7 +1040,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getFirstName - get the user's first name.
*
- * @return string This user's first name.
+ * @return string This user's first name.
*/
function getFirstName() {
return $this->data_array['firstname'];
@@ -1042,7 +1049,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getLastName - get the user's last name.
*
- * @return string This user's last name.
+ * @return string This user's last name.
*/
function getLastName() {
return $this->data_array['lastname'];
@@ -1051,7 +1058,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getAddDate - this user's unix time when account was opened.
*
- * @return int This user's unix time when account was opened.
+ * @return int This user's unix time when account was opened.
*/
function getAddDate() {
return $this->data_array['add_date'];
@@ -1060,7 +1067,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getTimeZone - this user's timezone setting.
*
- * @return string This user's timezone setting.
+ * @return string This user's timezone setting.
*/
function getTimeZone() {
return $this->data_array['timezone'];
@@ -1069,7 +1076,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getCountryCode - this user's ccode setting.
*
- * @return string This user's ccode setting.
+ * @return string This user's ccode setting.
*/
function getCountryCode() {
return $this->data_array['ccode'];
@@ -1078,7 +1085,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getShell - this user's preferred shell.
*
- * @return string This user's preferred shell.
+ * @return string This user's preferred shell.
*/
function getShell() {
return $this->data_array['shell'];
@@ -1087,8 +1094,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* setShell - sets user's preferred shell.
*
- * @param string $shell The users preferred shell.
- * @return boolean success.
+ * @param string $shell The users preferred shell.
+ * @return boolean success.
*/
function setShell($shell) {
global $SYS;
@@ -1126,7 +1133,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getUnixUID() - Get the unix UID of the user
*
- * @return int This user's UID.
+ * @return int This user's UID.
*/
function getUnixUID() {
return $this->data_array['unix_uid'];
@@ -1135,7 +1142,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getUnixGID() - Get the unix GID of the user
*
- * @return int This user's GID.
+ * @return int This user's GID.
*/
function getUnixGID() {
return $this->data_array['unix_gid'];
@@ -1144,7 +1151,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getLanguage - this user's language_id from supported_languages table.
*
- * @return int This user's language_id.
+ * @return int This user's language_id.
*/
function getLanguage() {
return $this->data_array['language'];
@@ -1153,7 +1160,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getAddress - get this user's address.
*
- * @return text This user's address.
+ * @return text This user's address.
*/
function getAddress() {
return $this->data_array['address'];
@@ -1162,7 +1169,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getAddress2 - get this user's address2.
*
- * @return text This user's address2.
+ * @return text This user's address2.
*/
function getAddress2() {
return $this->data_array['address2'];
@@ -1171,7 +1178,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getPhone - get this person's phone number.
*
- * @return text This user's phone number.
+ * @return text This user's phone number.
*/
function getPhone() {
return $this->data_array['phone'];
@@ -1180,7 +1187,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getFax - get this person's fax number.
*
- * @return text This user's fax.
+ * @return text This user's fax.
*/
function getFax() {
return $this->data_array['fax'];
@@ -1189,7 +1196,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getTitle - get this person's title.
*
- * @return text This user's title.
+ * @return text This user's title.
*/
function getTitle() {
return $this->data_array['title'];
@@ -1198,8 +1205,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* getGroups - get an array of groups this user is a member of.
*
- * @param bool $onlylocal
- * @return array Array of groups.
+ * @param bool $onlylocal
+ * @return array Array of groups.
*/
function &getGroups($onlylocal = true) {
$ids = array();
@@ -1228,10 +1235,10 @@ Use one below, but make sure it is entered as the single line.)
}
/**
- * addAuthorizedKey - add the SSH authorized key for the user.
+ * addAuthorizedKey - add the SSH authorized key for the user.
*
- * @param string $key
- * @return boolean success.
+ * @param string $key
+ * @return boolean success.
*/
function addAuthorizedKey($key) {
$key = trim($key);
@@ -1287,7 +1294,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* setLoggedIn($val) - Really only used by session code.
*
- * @param boolean $val The session value.
+ * @param boolean $val The session value.
*/
function setLoggedIn($val = true) {
$this->is_logged_in = $val;
@@ -1300,7 +1307,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* isLoggedIn - only used by session code.
*
- * @return boolean is_logged_in.
+ * @return boolean is_logged_in.
*/
function isLoggedIn() {
return $this->is_logged_in;
@@ -1309,8 +1316,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* deletePreference - delete a preference for this user.
*
- * @param string $preference_name The unique field name for this preference.
- * @return boolean success.
+ * @param string $preference_name The unique field name for this preference.
+ * @return boolean success.
*/
function deletePreference($preference_name) {
$preference_name = strtolower(trim($preference_name));
@@ -1323,9 +1330,9 @@ Use one below, but make sure it is entered as the single line.)
/**
* setPreference - set a new preference for this user.
*
- * @param string $preference_name The unique field name for this preference.
- * @param string $value The value you are setting this preference to.
- * @return boolean success.
+ * @param string $preference_name The unique field name for this preference.
+ * @param string $value The value you are setting this preference to.
+ * @return boolean success.
*/
function setPreference($preference_name, $value) {
$preference_name = strtolower(trim($preference_name));
@@ -1356,8 +1363,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* getPreference - get a specific preference.
*
- * @param string $preference_name The unique field name for this preference.
- * @return string|bool the preference string or false on failure.
+ * @param string $preference_name The unique field name for this preference.
+ * @return string|bool the preference string or false on failure.
*/
function getPreference($preference_name) {
$preference_name = strtolower(trim($preference_name));
@@ -1402,8 +1409,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* setPasswd - Changes user's password.
*
- * @param string $passwd The plaintext password.
- * @return boolean success.
+ * @param string $passwd The plaintext password.
+ * @return boolean success.
*/
function setPasswd($passwd) {
global $SYS;
@@ -1448,8 +1455,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* setMD5Passwd - Changes user's MD5 password.
*
- * @param string $md5 The MD5-hashed password.
- * @return boolean success.
+ * @param string $md5 The MD5-hashed password.
+ * @return boolean success.
*/
function setMD5Passwd($md5) {
db_begin();
@@ -1470,8 +1477,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* setUnixPasswd - Changes user's Unix-hashed password.
*
- * @param string $unix The Unix-hashed password.
- * @return boolean success.
+ * @param string $unix The Unix-hashed password.
+ * @return boolean success.
*/
function setUnixPasswd($unix) {
global $SYS;
@@ -1504,7 +1511,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* usesRatings - whether user participates in rating system.
*
- * @return boolean success.
+ * @return boolean success.
*/
function usesRatings() {
return !$this->data_array['block_ratings'];
@@ -1513,7 +1520,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* usesTooltips - whether user enables or not tooltips.
*
- * @return boolean success.
+ * @return boolean success.
*/
function usesTooltips() {
return $this->data_array['tooltips'];
@@ -1522,7 +1529,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getPlugins - get a list of all available user plugins
*
- * @return array array containing plugin_id => plugin_name
+ * @return array array containing plugin_id => plugin_name
*/
function getPlugins() {
if (!isset($this->plugins_data)) {
@@ -1545,8 +1552,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* usesPlugin - returns true if the user uses a particular plugin
*
- * @param string $pluginname name of the plugin
- * @return boolean whether plugin is being used or not
+ * @param string $pluginname name of the plugin
+ * @return boolean whether plugin is being used or not
*/
function usesPlugin($pluginname) {
$plugins_data = $this->getPlugins();
@@ -1561,9 +1568,9 @@ Use one below, but make sure it is entered as the single line.)
/**
* setPluginUse - enables/disables plugins for the user
*
- * @param string $pluginname name of the plugin
- * @param boolean $val the new state
- * @return string database result
+ * @param string $pluginname name of the plugin
+ * @param boolean $val the new state
+ * @return string database result
*/
function setPluginUse($pluginname, $val = true) {
if ($val == $this->usesPlugin($pluginname)) {
@@ -1594,8 +1601,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* getMailingsPrefs - Get activity status for one of the site mailings.
*
- * @param string $mailing_id The id of mailing ('mail_va' for community mailings, 'mail_siteupdates' for site mailings)
- * @return boolean success.
+ * @param string $mailing_id The id of mailing ('mail_va' for community mailings, 'mail_siteupdates' for site mailings)
+ * @return boolean success.
*/
function getMailingsPrefs($mailing_id) {
if ($mailing_id == 'va') {
@@ -1610,8 +1617,8 @@ Use one below, but make sure it is entered as the single line.)
/**
* unsubscribeFromMailings - Disable email notifications for user.
*
- * @param boolean $all If false, disable general site mailings, else - all.
- * @return boolean success.
+ * @param boolean $all If false, disable general site mailings, else - all.
+ * @return boolean success.
*/
function unsubscribeFromMailings($all = false) {
$res2 = $res3 = true;
@@ -1630,7 +1637,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* getThemeID - get the theme_id for this user.
*
- * @return int The theme_id.
+ * @return int The theme_id.
*/
function getThemeID() {
return $this->data_array['theme_id'];
@@ -1639,7 +1646,7 @@ Use one below, but make sure it is entered as the single line.)
/**
* setUpTheme - get the theme path
*
- * @return string The theme path.
+ * @return string The theme path.
*/
function setUpTheme() {
//
-----------------------------------------------------------------------
Summary of changes:
src/common/docman/Document.class.php | 92 +++---
src/common/docman/DocumentGroup.class.php | 61 +---
src/common/forum/Forum.class.php | 52 ++--
src/common/forum/ForumsForUser.class.php | 89 ------
src/common/frs/FRSPackage.class.php | 89 ++----
src/common/include/MonitorElement.class.php | 328 ++++++++++++++++++++
src/common/include/User.class.php | 260 ++++++++--------
src/common/tracker/Artifact.class.php | 58 ++--
src/common/tracker/ArtifactType.class.php | 53 ++--
src/common/tracker/actions/tracker.php | 6 +-
.../tracker/include/ArtifactTypeHtml.class.php | 4 +-
.../widget/Widget_MyMonitoredDocuments.class.php | 82 ++---
.../widget/Widget_MyMonitoredForums.class.php | 122 ++++----
src/common/widget/Widget_MyMonitoredFp.class.php | 123 ++++----
src/www/forum/admin/monitor.php | 25 +-
src/www/forum/myforums.php | 166 +++++-----
src/www/include/Layout.class.php | 2 +-
src/www/include/my_utils.php | 139 ++++-----
src/www/my/dashboard.php | 7 +-
src/www/my/index.php | 3 -
20 files changed, 940 insertions(+), 821 deletions(-)
delete mode 100644 src/common/forum/ForumsForUser.class.php
create mode 100644 src/common/include/MonitorElement.class.php
hooks/post-receive
--
FusionForge
More information about the Fusionforge-commits
mailing list