本文整理汇总了PHP中CommentModel::GetID方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::GetID方法的具体用法?PHP CommentModel::GetID怎么用?PHP CommentModel::GetID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommentModel
的用法示例。
在下文中一共展示了CommentModel::GetID方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddReplyButton
protected function AddReplyButton($Sender)
{
if (!Gdn::Session()->UserID) {
return;
}
if (isset($Sender->EventArguments['Comment'])) {
$Model = new CommentModel();
$Data = $Model->GetID($Sender->EventArguments['Comment']->CommentID);
} else {
$Model = new DiscussionModel();
$Data = $Model->GetID($Sender->Data['Discussion']->DiscussionID);
}
$ReplyURL = "#" . "{$Data->InsertName}";
$ReplyText = T('Reply');
echo <<<QUOTE
<span class="CommentReply"><a href="{$ReplyURL}">{$ReplyText}</a></span>
QUOTE;
}
示例2: Gdn_Statistics_Tick_Handler
public function Gdn_Statistics_Tick_Handler($Sender, $Args)
{
$Path = Gdn::Request()->Post('Path');
$Args = Gdn::Request()->Post('Args');
parse_str($Args, $Args);
$ResolvedPath = trim(Gdn::Request()->Post('ResolvedPath'), '/');
$ResolvedArgs = @json_decode(Gdn::Request()->Post('ResolvedArgs'));
$DiscussionID = NULL;
$DiscussionModel = new DiscussionModel();
// Gdn::Controller()->SetData('Path', $Path);
// Gdn::Controller()->SetData('Args', $Args);
// Gdn::Controller()->SetData('ResolvedPath', $ResolvedPath);
// Gdn::Controller()->SetData('ResolvedArgs', $ResolvedArgs);
// Comment permalink
if ($ResolvedPath == 'vanilla/discussion/comment') {
$CommentID = GetValue('CommentID', $ResolvedArgs);
$CommentModel = new CommentModel();
$Comment = $CommentModel->GetID($CommentID);
$DiscussionID = GetValue('DiscussionID', $Comment);
} elseif ($ResolvedPath == 'vanilla/discussion/index') {
$DiscussionID = GetValue('DiscussionID', $ResolvedArgs, NULL);
} elseif ($ResolvedPath == 'vanilla/discussion/embed') {
$ForeignID = GetValue('vanilla_identifier', $Args);
if ($ForeignID) {
// This will be hit a lot so let's try caching it...
$Key = "DiscussionID.ForeignID.page.{$ForeignID}";
$DiscussionID = Gdn::Cache()->Get($Key);
if (!$DiscussionID) {
$Discussion = $DiscussionModel->GetForeignID($ForeignID, 'page');
$DiscussionID = GetValue('DiscussionID', $Discussion);
Gdn::Cache()->Store($Key, $DiscussionID, array(Gdn_Cache::FEATURE_EXPIRY, 1800));
}
}
}
if ($DiscussionID) {
$DiscussionModel->AddView($DiscussionID);
}
}
示例3: DiscussionController_CommentOptions_Handler
public function DiscussionController_CommentOptions_Handler($Sender)
{
$Session = Gdn::Session();
$User = $Session->User;
$UID = $User->UserID;
$DiscussionModel = new DiscussionModel();
$CommentModel = new CommentModel();
$Discussion = $DiscussionModel->GetID($DiscussionID);
if ($Sender->EventArguments['Type'] == 'Discussion') {
$DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID;
if ($Sender->Data['Comments'] instanceof Gdn_DataSet) {
$this->LikeModel->PreloadLikes($Sender->Data['Comments']);
}
$ID = $DiscussionID;
$Model = new DiscussionModel();
$Data = $Model->GetID($ID);
$Likes = $this->LikeModel->GetDiscussionLikes($ID);
$Url = $DiscussionID;
} else {
$DiscussionID = $Sender->EventArguments['Object']->DiscussionID;
$ID = $Sender->EventArguments['Object']->CommentID;
$Model = new CommentModel();
$Data = $Model->GetID($ID);
$Likes = $this->LikeModel->GetCommentLikes($ID);
$Url = $DiscussionID . '/comment/' . $ID;
}
$InsertID = $Data->InsertUserID;
if ($InsertID == $UID) {
$Self = TRUE;
} else {
$Self = FALSE;
}
// Check for permission.
if (!Gdn::Session()->UserID) {
$Self = TRUE;
}
if (!CheckPermission('Plugins.LikeThis.AllowedToLike')) {
$Self = TRUE;
}
$LikeDisplay = $this->FormatLikes($Likes, $Url, $UID, $Self);
echo '<span class="Like">' . $LikeDisplay . '</span>';
}
示例4: Gdn_Statistics_Tick_Handler
public function Gdn_Statistics_Tick_Handler($Sender, $Args)
{
$Path = GetValue('Path', $Args);
if (preg_match('`discussion\\/(\\d+)`i', $Path, $Matches)) {
$DiscussionID = $Matches[1];
} elseif (preg_match('`discussion\\/comment\\/(\\d+)`i', $Path, $Matches)) {
$CommentID = $Matches[1];
$CommentModel = new CommentModel();
$Comment = $CommentModel->GetID($CommentID);
$DiscussionID = GetValue('DiscussionID', $Comment);
}
if (isset($DiscussionID)) {
$DiscussionModel = new DiscussionModel();
$Discussion = $DiscussionModel->GetID($DiscussionID);
$DiscussionModel->AddView($DiscussionID, GetValue('CountViews', $Discussion));
}
}
示例5: RecordActivity
public function RecordActivity($ReplyCommentID, $ActivityUserID, $CommentID)
{
// Get the author of the discussion
$CommentModel = new CommentModel();
$Comment = $CommentModel->GetID($ReplyCommentID);
if ($ActivityUserID != $Comment->InsertUserID) {
AddActivity($ActivityUserID, 'CommentReply', '', $Comment->InsertUserID, 'discussion/reply/' . $CommentID . '/#Comment_' . $ReplyCommentID);
}
}
示例6: GetRecord
function GetRecord($RecordType, $ID, $ThrowError = FALSE)
{
$Row = FALSE;
switch (strtolower($RecordType)) {
case 'discussion':
$Model = new DiscussionModel();
$Row = $Model->GetID($ID);
$Row->Url = DiscussionUrl($Row);
$Row->ShareUrl = $Row->Url;
if ($Row) {
return (array) $Row;
}
break;
case 'comment':
$Model = new CommentModel();
$Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
if ($Row) {
$Row['Url'] = Url("/discussion/comment/{$ID}#Comment_{$ID}", TRUE);
$Model = new DiscussionModel();
$Discussion = $Model->GetID($Row['DiscussionID']);
if ($Discussion) {
$Discussion->Url = DiscussionUrl($Discussion);
$Row['ShareUrl'] = $Discussion->Url;
$Row['Name'] = $Discussion->Name;
$Row['Discussion'] = (array) $Discussion;
}
return $Row;
}
break;
case 'activity':
$Model = new ActivityModel();
$Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
if ($Row) {
$Row['Name'] = FormatString($Row['HeadlineFormat'], $Row);
$Row['Body'] = $Row['Story'];
return $Row;
}
default:
throw new Gdn_UserException(sprintf("I don't know what a %s is.", strtolower($RecordType)));
}
if ($ThrowError) {
throw NotFoundException($RecordType);
} else {
return FALSE;
}
}
示例7: DiscussionController_VoteComment_Create
/**
* Increment/decrement comment scores
*/
public function DiscussionController_VoteComment_Create($Sender)
{
// if (!C('Plugins.Voting.Enabled'))
// return;
$CommentID = GetValue(0, $Sender->RequestArgs, 0);
$VoteType = GetValue(1, $Sender->RequestArgs);
$TransientKey = GetValue(2, $Sender->RequestArgs);
$Session = Gdn::Session();
$FinalVote = 0;
$Total = 0;
if ($Session->IsValid() && $Session->ValidateTransientKey($TransientKey) && $CommentID > 0) {
$CommentModel = new CommentModel();
$OldUserVote = $CommentModel->GetUserScore($CommentID, $Session->UserID);
$NewUserVote = $VoteType == 'voteup' ? 1 : -1;
$FinalVote = intval($OldUserVote) + intval($NewUserVote);
// Allow admins to vote unlimited.
$AllowVote = $Session->CheckPermission('Garden.Moderation.Manage');
// Only allow users to vote up or down by 1.
if (!$AllowVote) {
$AllowVote = $FinalVote > -2 && $FinalVote < 2;
}
if ($AllowVote) {
$Total = $CommentModel->SetUserScore($CommentID, $Session->UserID, $FinalVote);
}
// Move the comment into or out of moderation.
if (class_exists('LogModel')) {
$Moderate = FALSE;
if ($Total <= C('Plugins.Voting.ModThreshold1', -10)) {
$LogOptions = array('GroupBy' => array('RecordID'));
// Get the comment row.
$Data = $CommentModel->GetID($CommentID, DATASET_TYPE_ARRAY);
if ($Data) {
// Get the users that voted the comment down.
$OtherUserIDs = $CommentModel->SQL->Select('UserID')->From('UserComment')->Where('CommentID', $CommentID)->Where('Score <', 0)->Get()->ResultArray();
$OtherUserIDs = array_column($OtherUserIDs, 'UserID');
$LogOptions['OtherUserIDs'] = $OtherUserIDs;
// Add the comment to moderation.
if ($Total > C('Plugins.Voting.ModThreshold2', -20)) {
LogModel::Insert('Moderate', 'Comment', $Data, $LogOptions);
}
}
$Moderate = TRUE;
}
if ($Total <= C('Plugins.Voting.ModThreshold2', -20)) {
// Remove the comment.
$CommentModel->Delete($CommentID, array('Log' => 'Moderate'));
$Sender->InformMessage(sprintf(T('The %s has been removed for moderation.'), T('comment')));
} elseif ($Moderate) {
$Sender->InformMessage(sprintf(T('The %s has been flagged for moderation.'), T('comment')));
}
}
}
$Sender->DeliveryType(DELIVERY_TYPE_BOOL);
$Sender->SetJson('TotalScore', $Total);
$Sender->SetJson('FinalVote', $FinalVote);
$Sender->Render();
}
示例8: GetRecord
function GetRecord($RecordType, $ID)
{
switch (strtolower($RecordType)) {
case 'discussion':
$Model = new DiscussionModel();
$Row = $Model->GetID($ID);
$Row->Url = DiscussionUrl($Row);
$Row->ShareUrl = $Row->Url;
return (array) $Row;
case 'comment':
$Model = new CommentModel();
$Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
$Row['Url'] = Url("/discussion/comment/{$ID}#Comment_{$ID}", TRUE);
$Model = new DiscussionModel();
$Discussion = $Model->GetID($Row['DiscussionID']);
$Discussion->Url = DiscussionUrl($Discussion);
$Row['ShareUrl'] = $Discussion->Url;
$Row['Name'] = $Discussion->Name;
$Row['Discussion'] = (array) $Discussion;
return $Row;
default:
throw new Gdn_UserException(sprintf("I don't know what a %s is.", strtolower($RecordType)));
}
}
示例9: filenameRedirect
/**
*
*
* @param $Filename
* @param $Get
* @return bool|string
*/
public function filenameRedirect($Filename, $Get)
{
trace(['Filename' => $Filename, 'Get' => $Get], 'Testing');
$Filename = strtolower($Filename);
array_change_key_case($Get);
if (!isset(self::$Files[$Filename])) {
return false;
}
$Row = self::$Files[$Filename];
if (is_callable($Row)) {
// Use a callback to determine the translation.
$Row = call_user_func_array($Row, [&$Get]);
}
trace($Get, 'New Get');
// Translate all of the get parameters into new parameters.
$Vars = array();
foreach ($Get as $Key => $Value) {
if (!isset($Row[$Key])) {
continue;
}
$Opts = (array) $Row[$Key];
if (isset($Opts['Filter'])) {
// Call the filter function to change the value.
$R = call_user_func($Opts['Filter'], $Value, $Opts[0]);
if (is_array($R)) {
if (isset($R[0])) {
// The filter can change the column name too.
$Opts[0] = $R[0];
$Value = $R[1];
} else {
// The filter can return return other variables too.
$Vars = array_merge($Vars, $R);
$Value = null;
}
} else {
$Value = $R;
}
}
if ($Value !== null) {
$Vars[$Opts[0]] = $Value;
}
}
trace($Vars, 'Translated Arguments');
// Now let's see what kind of record we have.
// We'll check the various primary keys in order of importance.
$Result = false;
if (isset($Vars['CommentID'])) {
trace("Looking up comment {$Vars['CommentID']}.");
$CommentModel = new CommentModel();
// If a legacy slug is provided (assigned during a merge), attempt to lookup the comment using it
if (isset($Get['legacy']) && Gdn::Structure()->Table('Comment')->ColumnExists('ForeignID')) {
$Comment = $CommentModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CommentID']])->FirstRow();
} else {
$Comment = $CommentModel->GetID($Vars['CommentID']);
}
if ($Comment) {
$Result = CommentUrl($Comment, '//');
}
} elseif (isset($Vars['DiscussionID'])) {
trace("Looking up discussion {$Vars['DiscussionID']}.");
$DiscussionModel = new DiscussionModel();
$DiscussionID = $Vars['DiscussionID'];
$Discussion = false;
if (is_numeric($DiscussionID)) {
// If a legacy slug is provided (assigned during a merge), attempt to lookup the discussion using it
if (isset($Get['legacy']) && Gdn::Structure()->Table('Discussion')->ColumnExists('ForeignID')) {
$Discussion = $DiscussionModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $DiscussionID])->FirstRow();
} else {
$Discussion = $DiscussionModel->GetID($Vars['DiscussionID']);
}
} else {
// This is a slug style discussion ID. Let's see if there is a UrlCode column in the discussion table.
$DiscussionModel->DefineSchema();
if ($DiscussionModel->Schema->FieldExists('Discussion', 'UrlCode')) {
$Discussion = $DiscussionModel->GetWhere(['UrlCode' => $DiscussionID])->FirstRow();
}
}
if ($Discussion) {
$Result = DiscussionUrl($Discussion, self::pageNumber($Vars, 'Vanilla.Comments.PerPage'), '//');
}
} elseif (isset($Vars['UserID'])) {
trace("Looking up user {$Vars['UserID']}.");
$User = Gdn::UserModel()->GetID($Vars['UserID']);
if ($User) {
$Result = Url(UserUrl($User), '//');
}
} elseif (isset($Vars['TagID'])) {
$Tag = TagModel::instance()->GetID($Vars['TagID']);
if ($Tag) {
$Result = TagUrl($Tag, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//');
}
} elseif (isset($Vars['CategoryID'])) {
trace("Looking up category {$Vars['CategoryID']}.");
//.........这里部分代码省略.........