iCommentId = $oRow->commentId; $this->iParentId = $oRow->parentId; if($oRow->appId) { $this->iAppId = $oRow->appId; } else { $oVersion = new version($this->iVersionId); $this->iAppId = $oApp->iAppId; } $this->iVersionId = $oRow->versionId; $this->sSubject = $oRow->subject; $this->sBody = $oRow->body; $this->sDateCreated = $oRow->time; $this->sHostname = $oRow->hostname; $this->oOwner = new User($oRow->userId); } } /* * Creates a new comment. * Informs interested people about the creation. * Returns true on success, false on failure */ function create() { $hResult = query_parameters("INSERT INTO appComments (parentId, versionId, subject, ". "body, userId, time, hostname) VALUES ('?', '?', '?', '?', '?', ?, '?')", $this->iParentId, $this->iVersionId, $this->sSubject, $this->sBody, $_SESSION['current']->iUserId, "NOW()", get_remote()); if($hResult) { $this->comment(query_appdb_insert_id()); $sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId); $sEmail .= $this->oOwner->sEmail." "; // fetches e-mails from parent comments, all parents are notified that a // comment was added to the thread $iParentId = $this->iParentId; while($iParentId) { $oParent = new Comment($iParentId); $sEmail .= $oParent->oOwner->sEmail." "; $iParentId = $oParent->iParentId; } if($sEmail) { $aEmailArray = explode(" ", $sEmail); /* break the long email string into parts by spaces */ $aEmailArray = array_unique($aEmailArray); /* remove duplicates */ /* build the single string of all emails up */ $sEmail = ""; foreach($aEmailArray as $key=>$value) { $sEmail.="$value "; } $sSubject = "Comment for '".Application::lookup_name($this->iAppId)." ".Version::lookup_name($this->iVersionId)."' added by ".$_SESSION['current']->sRealname; $sMsg = "To reply to this email please use the link provided below.\n"; $sMsg .= "DO NOT reply via your email client as it will not reach the person who wrote the comment\n"; $sMsg .= $this->objectMakeUrl()."\n"; $sMsg .= "\n"; $sMsg .= "Subject: ".$this->sSubject."\r\n"; $sMsg .= "\n"; $sMsg .= $this->sBody."\r\n"; mail_appdb($sEmail, $sSubject ,$sMsg); } addmsg("Comment created.", "green"); return true; } else { addmsg("Error while creating a new comment", "red"); return false; } } /** * Update comment. * FIXME: Informs interested people about the modification. * Returns true on success and false on failure. */ function update($sSubject=null, $sBody=null, $iParentId=null, $iVersionId=null) { if ($iParentId) { if (!query_parameters("UPDATE appComments SET parentId = '?' WHERE commentId = '?'", $iParentId, $this->iCommentId)) return false; $this->iParentId = $iParentId; } if ($iVersionId) { if (!query_parameters("UPDATE appComments SET versionId = '?' WHERE commentId = '?'", $iVersionId, $this->iCommentId)) return false; $this->iVersionId = $iVersionId; // FIXME: we need to refetch $this->iAppId. } if ($sSubject) { if (!query_parameters("UPDATE appComments SET subject = '?' WHERE commentId = '?'", $sSubject, $this->iCommentId)) return false; $this->sSubject = $sSubject; } if ($sBody) { if (!query_parameters("UPDATE appComments SET body = '?' WHERE commentId = '?'", $sBody, $this->iCommentId)) return false; $this->sBody = $sBody; } return true; } function purge() { return $this->delete(); } /** * Removes the current comment from the database. * Informs interested people about the deletion. * Returns true on success and false on failure. */ function delete() { $hResult = query_parameters("DELETE FROM appComments WHERE commentId = '?'", $this->iCommentId); if ($hResult) { /* fixup the child comments so the parentId points to a valid parent comment */ $hResult = query_parameters("UPDATE appComments set parentId = '?' WHERE parentId = '?'", $this->iParentId, $this->iCommentId); return true; } else { return false; } } function get_comment_count_for_versionid($iVersionId) { $sQuery = "SELECT count(*) as cnt from appComments where versionId = '?'"; $hResult = query_parameters($sQuery, $iVersionId); if(!$hResult) return 0; $oRow = query_fetch_object($hResult); return $oRow->cnt; } function getOutputEditorValues($aClean) { $this->sSubject = $aClean['sSubject']; $this->sBody = $aClean['sBody']; $this->iParentId = $aClean['iThread']; if($aClean['iVersionId']) $this->iVersionId = $aClean['iVersionId']; if(!$this->oOwner) $this->oOwner = $_SESSION['current']; if(!$this->sDateCreated) $this->sDateCreated = date("l F jS Y, H:i"); } /** * Displays the body of one comment. */ function view_comment_body($iCommentId) { $hResult = Comment::grab_comment($iCommentId); if ($hResult) { $oRow = query_fetch_object($hResult); Comment::view_app_comment($oRow); } } /** * display a single comment (in $oRow) */ function view_app_comment($oRow) { $oComment = new comment(null, $oRow); $oComment->display(); } function display() { echo html_frame_start('','98%'); echo '
| iCommentId.">\n";
echo " ".$this->sSubject." \n"; echo " by ".forum_lookup_user($this->oOwner->iUserId)." on ".$this->sDateCreated." \n"; echo " |
| \n";
// body
echo htmlify_urls($this->sBody), " \n"; $oVersion = new version($this->iVersionId); $oM = new objectManager("comment", "Post new comment"); $oM->setReturnTo($oVersion->objectMakeUrl()); // reply post buttons echo " [makeUrl("add")."&iVersionId=$this->iVersionId\">post new] \n"; echo " [makeUrl("add")."&iVersionId=$this->iVersionId". "&iThread=$this->iCommentId\">reply to this] \n"; echo " |
| \n"; echo " |
\n"; Comment::do_display_comments_nested($hResult2); echo "\n"; } } } function display_comments_nested($versionId, $threadId) { $hResult = Comment::grab_comments($versionId, $threadId); Comment::do_display_comments_nested($hResult); } /** * Generates the link to show the comment. */ function comment_link($oRow) { $sLink = "commentview.php?iAppId={$oRow->appId}&iVersionId=". "{$oRow->versionId}&iThreadId={$oRow->parentId}"; $sOnClick = "showComment('{$oRow->commentId}');"; /** * The return false line in the onClick is used to handle javascript * being disabled so we can fail gracefully to the old style. */ return "
\n"; Comment::do_display_comments_threaded($hResult2, 0); echo "\n"; } } if (!$is_main) echo "
|
The following comments are owned by whoever posted them. WineHQ is not responsible for what they say.
'."\n"; } //start comments echo '| ',"\n"; //hide or display depending on pref if ($_SESSION['current']->isLoggedIn()) $mode = $_SESSION['current']->getPref("comments:mode", "threaded"); else $mode = "threaded"; /* default non-logged in users to threaded comment display mode */ if ( isset($aClean['sMode']) && $aClean['sMode']=="nested") $mode = "nested"; switch ($mode) { case "flat": Comment::display_comments_flat($versionId); break; case "nested": Comment::display_comments_nested($versionId, $threadId); break; case "threaded": Comment::display_comments_threaded($versionId, $threadId); break; } echo ' |
Enter your comment in the box below."; echo "Please do not paste large terminal or debug outputs here.
"; echo html_frame_start($sMesTitle,500,"",0); echo '| From: | \n"; echo "".$_SESSION['current']->sRealname." |
| Subject: | \n"; echo "sSubject."\"> |