コード例 #1
0
 function UpdateUserLastVisit($UserID, $VerificationKey = '')
 {
     $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
     $s->SetMainTable('User', 'u');
     $s->AddFieldNameValue('DateLastActive', MysqlDateTime());
     if ($VerificationKey) {
         $s->AddFieldNameValue('VerificationKey', $VerificationKey);
     }
     $s->AddFieldNameValue('CountVisit', 'CountVisit + 1', 0);
     $s->AddWhere('u', 'UserID', '', $UserID, '=');
     $this->Context->Database->Update($s, $this->Name, 'UpdateLastVisit', 'An error occurred while updating your profile.', false);
     // fail silently
 }
コード例 #2
0
 function UpdateWhisperCount($DiscussionID, $WhisperFromUserID, $WhisperToUserID, $MathOperator)
 {
     $Math = '+';
     if ($MathOperator != '+') {
         $Math = '-';
     }
     // 1. Update the whispercount for this discussion
     $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
     $s->SetMainTable('Discussion', 't');
     $s->AddFieldNameValue('TotalWhisperCount', 'TotalWhisperCount' . $Math . '1', 0);
     $s->AddWhere('t', 'DiscussionID', '', $DiscussionID, '=');
     $this->Context->Database->Update($s, $this->Name, 'UpdateWhisperCount', "An error occurred while manipulating the discussion's comment count.");
     // 2. Update the DiscussionUserWhisperFrom table
     $s->Clear();
     $s->SetMainTable('DiscussionUserWhisperFrom', 'tuwf');
     $s->AddFieldNameValue('CountWhispers', 'CountWhispers' . $Math . '1', 0);
     $s->AddWhere('tuwf', 'DiscussionID', '', $DiscussionID, '=');
     $s->AddWhere('tuwf', 'WhisperFromUserID', '', $WhisperFromUserID, '=');
     // If no rows were affected, make sure to insert the data
     if ($this->Context->Database->Update($s, $this->Name, 'UpdateWhisperCount', 'An error occurred while manipulating the whisper count for the user who sent the whisper.') == 0 && $Math == '+') {
         $s->Clear();
         $s->SetMainTable('DiscussionUserWhisperFrom', 'tuwf');
         $s->AddFieldNameValue('CountWhispers', '1');
         $s->AddFieldNameValue('DateLastActive', MysqlDateTime());
         $s->AddFieldNameValue('DiscussionID', $DiscussionID);
         $s->AddFieldNameValue('WhisperFromUserID', $WhisperFromUserID);
         $s->AddFieldNameValue('LastUserID', $WhisperFromUserID);
         $this->Context->Database->Insert($s, $this->Name, 'UpdateWhisperCount', "An error occurred while updating the discussion's comment summary.");
     }
     // 3. Update the DiscussionUserWhisperTo table
     // But only if the user was not whispering to him/herself (because this value is not incremented if that is the case)
     if ($WhisperToUserID != $WhisperFromUserID) {
         $s->Clear();
         $s->SetMainTable('DiscussionUserWhisperTo', 'tuwt');
         $s->AddFieldNameValue('CountWhispers', 'CountWhispers' . $Math . '1', 0);
         $s->AddWhere('tuwt', 'DiscussionID', '', $DiscussionID, '=');
         $s->AddWhere('tuwt', 'WhisperToUserID', '', $WhisperToUserID, '=');
         // If no rows were affected, make sure to insert the data
         if ($this->Context->Database->Update($s, $this->Name, 'UpdateWhisperCount', 'An error occurred while manipulating the whisper count for the user who received the whisper.') == 0 && $Math == '+') {
             $s->Clear();
             $s->SetMainTable('DiscussionUserWhisperTo', 'tuwt');
             $s->AddFieldNameValue('CountWhispers', '1');
             $s->AddFieldNameValue('DateLastActive', MysqlDateTime());
             $s->AddFieldNameValue('DiscussionID', $DiscussionID);
             $s->AddFieldNameValue('WhisperToUserID', $WhisperToUserID);
             $s->AddFieldNameValue('LastUserID', $WhisperFromUserID);
             $this->Context->Database->Insert($s, $this->Name, 'UpdateWhisperCount', "An error occurred while updating the discussion's comment summary.");
         }
     }
 }
コード例 #3
0
 function UpdateLastVisit($UserID, $VerificationKey)
 {
     $Query = "update LUM_User\n\t\t\tset DateLastActive = '" . MysqlDateTime() . "',\n\t\t\t\tVerificationKey = '" . $VerificationKey . "',\n\t\t\t\tCountVisit = CountVisit + 1\n\t\t\twhere UserID = " . $UserID;
     $this->Context->Database->Execute($Query, 'Authenticator', 'UpdateLastVisit', 'An error occurred while updating your profile.', false);
     // fail silently
 }
コード例 #4
0
 function UpdateWhisperCount($DiscussionID, $WhisperFromUserID, $WhisperToUserID, $MathOperator)
 {
     $Math = "+";
     if ($MathOperator != "+") {
         $Math = "-";
     }
     // 1. Update the whispercount for this discussion
     $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
     $s->SetMainTable("Discussion", "t");
     $s->AddFieldNameValue("TotalWhisperCount", "TotalWhisperCount" . $Math . "1", 0);
     $s->AddWhere("DiscussionID", $DiscussionID, "=");
     $this->Context->Database->Update($this->Context, $s, $this->Name, "UpdateWhisperCount", "An error occurred while manipulating the discussion's comment count.");
     // 2. Update the DiscussionUserWhisperFrom table
     $s->Clear();
     $s->SetMainTable("DiscussionUserWhisperFrom", "tuwf");
     $s->AddFieldNameValue("CountWhispers", "CountWhispers" . $Math . "1", 0);
     $s->AddWhere("DiscussionID", $DiscussionID, "=");
     $s->AddWhere("WhisperFromUserID", $WhisperFromUserID, "=");
     // If no rows were affected, make sure to insert the data
     if ($Math == "+" && $this->Context->Database->Update($this->Context, $s, $this->Name, "UpdateWhisperCount", "An error occurred while manipulating the whisper count for the user who sent the whisper.") == 0) {
         $s->Clear();
         $s->SetMainTable("DiscussionUserWhisperFrom", "tuwf");
         $s->AddFieldNameValue("CountWhispers", "1");
         $s->AddFieldNameValue("DateLastActive", MysqlDateTime());
         $s->AddFieldNameValue("DiscussionID", $DiscussionID);
         $s->AddFieldNameValue("WhisperFromUserID", $WhisperFromUserID);
         $s->AddFieldNameValue("LastUserID", $WhisperFromUserID);
         $this->Context->Database->Insert($this->Context, $s, $this->Name, "UpdateWhisperCount", "An error occurred while updating the discussion's comment summary.");
     }
     // 3. Update the DiscussionUserWhisperTo table
     // But only if the user was not whispering to him/herself (because this value is not incremented if that is the case)
     if ($WhisperToUserID != $WhisperFromUserID) {
         $s->Clear();
         $s->SetMainTable("DiscussionUserWhisperTo", "tuwt");
         $s->AddFieldNameValue("CountWhispers", "CountWhispers" . $Math . "1", 0);
         $s->AddWhere("DiscussionID", $DiscussionID, "=");
         $s->AddWhere("WhisperToUserID", $WhisperToUserID, "=");
         // If no rows were affected, make sure to insert the data
         if ($Math == "+" && $this->Context->Database->Update($this->Context, $s, $this->Name, "UpdateWhisperCount", "An error occurred while manipulating the whisper count for the user who received the whisper.") == 0) {
             $s->Clear();
             $s->SetMainTable("DiscussionUserWhisperTo", "tuwt");
             $s->AddFieldNameValue("CountWhispers", "1");
             $s->AddFieldNameValue("DateLastActive", MysqlDateTime());
             $s->AddFieldNameValue("DiscussionID", $DiscussionID);
             $s->AddFieldNameValue("WhisperToUserID", $WhisperToUserID);
             $s->AddFieldNameValue("LastUserID", $WhisperFromUserID);
             $this->Context->Database->Insert($this->Context, $s, $this->Name, "UpdateWhisperCount", "An error occurred while updating the discussion's comment summary.");
         }
     }
 }
コード例 #5
0
 function GetInactiveUsers($DaysOfMembership = "0")
 {
     $MembershipDate = SubtractDaysFromTimeStamp(mktime(), $DaysOfMembership);
     $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
     $s->SetMainTable("User", "u");
     $s->AddSelect("UserID", "u");
     $s->AddWhere("CountComments", "0", "=", "and", "", 0, 1);
     $s->AddWhere("CountComments", "0", "=", "or");
     $s->EndWhereGroup();
     $s->AddWhere("CountDiscussions", "0", "=", "and", "", 0, 1);
     $s->AddWhere("CountDiscussions", "0", "=", "or");
     $s->EndWhereGroup();
     if ($DaysOfMembership > 0) {
         $s->AddWhere("DateFirstVisit", MysqlDateTime($MembershipDate), "<");
     }
     $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve inactive user statistics.");
     $this->InactiveUsers = 0;
     $aInactiveUsers = array();
     while ($Row = $this->Context->Database->GetRow($Result)) {
         $aInactiveUsers[] = ForceInt($Row["UserID"], 0);
     }
     if (count($aInactiveUsers) > 0) {
         // Now (of these users), remove ones that have whispered
         $s->Clear();
         $s->SetMainTable("DiscussionUserWhisperFrom", "wf");
         $s->AddSelect("WhisperFromUserID", "wf");
         $s->AddWhere("WhisperFromUserID", "(" . implode(",", $aInactiveUsers) . ")", "in", "and", "", 0);
         $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve inactive user statistics.");
         $CurrentWhisperUserID = 0;
         while ($Row = $this->Context->Database->GetRow($Result)) {
             $CurrentWhisperUserID = ForceInt($Row["WhisperFromUserID"], 0);
             $Key = array_search($CurrentWhisperUserID, $aInactiveUsers);
             if ($Key !== false) {
                 array_splice($aInactiveUsers, $Key, 1);
             }
         }
     }
     if (count($aInactiveUsers) > 0) {
         // Now (of these users), remove ones that have received whispers
         $s->Clear();
         $s->SetMainTable("DiscussionUserWhisperTo", "wt");
         $s->AddSelect("WhisperToUserID", "wt");
         $s->AddWhere("WhisperToUserID", "(" . implode(",", $aInactiveUsers) . ")", "in", "and", "", 0);
         $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve inactive user statistics.");
         $CurrentWhisperUserID = 0;
         while ($Row = $this->Context->Database->GetRow($Result)) {
             $CurrentWhisperUserID = ForceInt($Row["WhisperToUserID"], 0);
             $Key = array_search($CurrentWhisperUserID, $aInactiveUsers);
             if ($Key !== false) {
                 array_splice($aInactiveUsers, $Key, 1);
             }
         }
     }
     return $aInactiveUsers;
 }
コード例 #6
0
 function SwitchCommentProperty($CommentID, $DiscussionID, $Switch)
 {
     $DiscussionID = ForceInt($DiscussionID, 0);
     $CommentID = ForceInt($CommentID, 0);
     if ($DiscussionID == 0) {
         $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrDiscussionID"));
     }
     if ($CommentID == 0) {
         $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrCommentID"));
     }
     if (!$this->Context->Session->User->AdminCategories) {
         $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrPermissionComments"));
     }
     if ($this->Context->WarningCollector->Count() == 0) {
         // Get some information about the comment being manipulated
         $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
         $s->SetMainTable("Comment", "m");
         $s->AddSelect(array("AuthUserID"), "m");
         $s->AddWhere("CommentID", $CommentID, "=");
         // Don't touch comments that are already switched to the selected status
         $s->AddWhere("Deleted", $Switch, "<>");
         $CommentData = $this->Context->Database->Select($this->Context, $s, $this->Name, "SwitchCommentProperty", "An error occurred while retrieving information about the comment.");
         $AuthUserID = 0;
         while ($Row = $this->Context->Database->GetRow($CommentData)) {
             $AuthUserID = ForceInt($Row["AuthUserID"], 0);
         }
         $MathOperator = $Switch == 0 ? "+" : "-";
         if ($AuthUserID > 0) {
             // Update the discussion table comment count
             $this->UpdateCommentCount($DiscussionID, $MathOperator);
         }
         // And finally, mark the comment as deleted
         $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
         $s->SetMainTable("Comment", "m");
         $s->AddFieldNameValue("Deleted", $Switch);
         if ($Switch == 1) {
             $s->AddFieldNameValue("DeleteUserID", $this->Context->Session->UserID);
             $s->AddFieldNameValue("DateDeleted", MysqlDateTime());
         }
         $s->AddWhere("CommentID", $CommentID, "=");
         $this->Context->Database->Update($this->Context, $s, $this->Name, "SwitchCommentProperty", "An error occurred while marking the comment as inactive.");
     }
     return $this->Context->WarningCollector->Iif();
 }
コード例 #7
0
 function SaveDiscussion($Discussion)
 {
     if (!$this->Context->Session->User->CanPostDiscussion) {
         $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrPermissionStartDiscussions"));
     } else {
         // If not editing, and the posted discussion count is less than the
         // user's current discussion count, silently skip the posting and
         // redirect as if everything is normal.
         if ($Discussion->DiscussionID == 0 && $Discussion->UserDiscussionCount < $this->Context->Session->User->CountDiscussions) {
             // Silently fail to post the data
             // Need to get the user's last posted discussionID and direct them to it
             $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
             $s->SetMainTable("Discussion", "d");
             $s->AddSelect("DiscussionID", "d");
             $s->AddWhere("AuthUserID", $this->Context->Session->UserID, "=");
             $s->AddOrderBy("DateCreated", "d", "desc");
             $s->AddLimit(0, 1);
             $LastDiscussionData = $this->Context->Database->Select($this->Context, $s, $this->Name, "SaveDiscussion", "An error occurred while retrieving your last discussion.");
             while ($Row = $this->Context->Database->GetRow($LastDiscussionData)) {
                 $Discussion->DiscussionID = ForceInt($Row["DiscussionID"], 0);
             }
             // Make sure we got it
             if ($Discussion->DiscussionID == 0) {
                 $this->Context->ErrorManager->AddError($this->Context, $this->Name, "SaveDiscussion", "Your last discussion could not be found.");
             }
         } else {
             $NewDiscussion = 0;
             $OldDiscussion = false;
             if ($Discussion->DiscussionID == 0) {
                 $NewDiscussion = 1;
             } else {
                 $OldDiscussion = $this->GetDiscussionById($Discussion->DiscussionID);
             }
             // Validate the Discussion topic
             $Name = FormatStringForDatabaseInput($Discussion->Name);
             Validate($this->Context->GetDefinition("DiscussionTopicLower"), 1, $Name, 100, "", $this->Context);
             if ($Discussion->CategoryID <= 0) {
                 $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrSelectCategory"));
             }
             // Validate first comment
             $Discussion->Comment->DiscussionID = $Discussion->DiscussionID;
             if ($OldDiscussion) {
                 $Discussion->Comment->CommentID = $OldDiscussion->FirstCommentID;
             } else {
                 $Discussion->Comment->CommentID = 0;
             }
             $CommentManager = $this->Context->ObjectFactory->NewContextObject($this->Context, "CommentManager");
             $CommentManager->ValidateComment($Discussion->Comment, 0);
             // If updating, validate that this is admin or the author
             if (!$NewDiscussion) {
                 if ($OldDiscussion->AuthUserID != $this->Context->Session->UserID && !$this->Context->Session->User->AdminCategories) {
                     $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrPermissionEditComments"));
                 }
             }
             // If validation was successful, then reset the properties to db safe values for saving
             if ($this->Context->WarningCollector->Count() == 0) {
                 $Discussion->Name = $Name;
             }
             if ($this->Context->WarningCollector->Iif()) {
                 $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
                 // Update the user info & check for spam
                 if ($NewDiscussion) {
                     $UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, "UserManager");
                     $UserManager->UpdateUserDiscussionCount($this->Context->Session->UserID);
                 }
                 // Proceed with the save if there are no warnings
                 if ($this->Context->WarningCollector->Count() == 0) {
                     $s->SetMainTable("Discussion");
                     $s->AddFieldNameValue("Name", $Discussion->Name);
                     $s->AddFieldNameValue("CategoryID", $Discussion->CategoryID);
                     if ($NewDiscussion) {
                         $s->AddFieldNameValue("AuthUserID", $this->Context->Session->UserID);
                         $s->AddFieldNameValue("DateCreated", MysqlDateTime());
                         $s->AddFieldNameValue("DateLastactive", MysqlDateTime());
                         $s->AddFieldNameValue("CountComments", 0);
                         $Discussion->DiscussionID = $this->Context->Database->Insert($this->Context, $s, $this->Name, "NewDiscussion", "An error occurred while creating a new discussion.");
                         $Discussion->Comment->DiscussionID = $Discussion->DiscussionID;
                         if ($this->Context->WarningCollector->Count() == 0) {
                             $n = $this->Context->ObjectFactory->NewContextObject($this->Context, "Notify");
                             $n->NotifyDiscussion($Discussion->DiscussionID, $this);
                         }
                     } else {
                         $s->AddWhere("DiscussionID", $Discussion->DiscussionID, "=");
                         $this->Context->Database->Update($this->Context, $s, $this->Name, "NewDiscussion", "An error occurred while updating the discussion.");
                     }
                 }
                 // Now save the associated Comment
                 if ($Discussion->Comment->DiscussionID > 0) {
                     $CommentManager->SaveComment($Discussion->Comment, 1);
                     // Now update the topic table so that we know what the first comment in the discussion was
                     if ($Discussion->Comment->CommentID > 0 && $NewDiscussion) {
                         $s->Clear();
                         $s->SetMainTable("Discussion", "d");
                         $s->AddFieldNameValue("FirstCommentID", $Discussion->Comment->CommentID);
                         $s->AddWhere("DiscussionID", $Discussion->Comment->DiscussionID, "=");
                         $this->Context->Database->Update($this->Context, $s, $this->Name, "NewDiscussion", "An error occurred while updating discussion properties.");
                     }
                 }
             }
         }
     }
     return $this->Context->WarningCollector->Iif($Discussion, false);
 }
コード例 #8
0
 function SaveDiscussion($Discussion)
 {
     if (!$this->Context->Session->User->Permission('PERMISSION_START_DISCUSSION')) {
         $this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrPermissionStartDiscussions'));
     } else {
         // If not editing, and the posted discussion count is less than the
         // user's current discussion count, silently skip the posting and
         // redirect as if everything is normal.
         if ($Discussion->DiscussionID == 0 && $Discussion->UserDiscussionCount < $this->Context->Session->User->CountDiscussions) {
             // Silently fail to post the data
             // Need to get the user's last posted discussionID and direct them to it
             $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
             $s->SetMainTable('Discussion', 'd');
             $s->AddSelect('DiscussionID', 'd');
             $s->AddWhere('c', 'AuthUserID', '', $this->Context->Session->UserID, '=');
             $s->AddOrderBy('DateCreated', 'd', 'desc');
             $s->AddLimit(0, 1);
             $LastDiscussionData = $this->Context->Database->Select($s, $this->Name, 'SaveDiscussion', 'An error occurred while retrieving your last discussion.');
             while ($Row = $this->Context->Database->GetRow($LastDiscussionData)) {
                 $Discussion->DiscussionID = ForceInt($Row['DiscussionID'], 0);
             }
             // Make sure we got it
             if ($Discussion->DiscussionID == 0) {
                 $this->Context->ErrorManager->AddError($this->Context, $this->Name, 'SaveDiscussion', 'Your last discussion could not be found.');
             }
         } else {
             $NewDiscussion = 0;
             $OldDiscussion = false;
             if ($Discussion->DiscussionID == 0) {
                 $NewDiscussion = 1;
             } else {
                 $OldDiscussion = $this->GetDiscussionById($Discussion->DiscussionID);
             }
             // Validate the Discussion topic
             $Name = FormatStringForDatabaseInput($Discussion->Name);
             Validate($this->Context->GetDefinition('DiscussionTopicLower'), 1, $Name, 100, '', $this->Context);
             //Validate the category ID and role
             $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
             $s->SetMainTable('Category', 'c');
             $s->AddSelect('CategoryID', 'c');
             $s->AddJoin('CategoryRoleBlock', 'crb', 'CategoryID', 'c', 'CategoryID', 'left join', ' and crb.' . $this->Context->DatabaseColumns['CategoryRoleBlock']['RoleID'] . ' = ' . $this->Context->Session->User->RoleID);
             $s->AddWhere('crb', 'Blocked', '', '0', '=', 'and', '', 1, 1);
             $s->AddWhere('crb', 'Blocked', '', '0', '=', 'or', '', 0, 0);
             $s->AddWhere('crb', 'Blocked', '', 'null', 'is', 'or', '', 0, 0);
             $s->AddWhere('c', 'CategoryID', '', $Discussion->CategoryID, '=', 'and');
             $s->EndWhereGroup();
             $CategoryAllowed = $this->Context->Database->Select($s, $this->Name, 'SaveDiscussion', 'An error occurred while validating category permissions.');
             if ($this->Context->Database->RowCount($CategoryAllowed) < 1) {
                 $Discussion->CategoryID = 0;
             }
             if ($Discussion->CategoryID <= 0) {
                 $this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrSelectCategory'));
             }
             // Validate first comment
             $Discussion->Comment->DiscussionID = $Discussion->DiscussionID;
             if ($OldDiscussion) {
                 $Discussion->Comment->CommentID = $OldDiscussion->FirstCommentID;
             } else {
                 $Discussion->Comment->CommentID = 0;
             }
             $CommentManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'CommentManager');
             $CommentManager->ValidateComment($Discussion->Comment, 0);
             // Validate the whisperusername
             $CommentManager->ValidateWhisperUsername($Discussion);
             // If updating, validate that this is admin or the author
             if (!$NewDiscussion) {
                 if ($OldDiscussion->AuthUserID != $this->Context->Session->UserID && !$this->Context->Session->User->Permission('PERMISSION_EDIT_DISCUSSIONS')) {
                     $this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrPermissionEditComments'));
                 }
             }
             // If validation was successful, then reset the properties to db safe values for saving
             if ($this->Context->WarningCollector->Count() == 0) {
                 $Discussion->Name = $Name;
             }
             if ($this->Context->WarningCollector->Iif()) {
                 $s->Clear();
                 // Update the user info & check for spam
                 if ($NewDiscussion) {
                     $UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager');
                     $UserManager->UpdateUserDiscussionCount($this->Context->Session->UserID);
                 }
                 // Proceed with the save if there are no warnings
                 if ($this->Context->WarningCollector->Count() == 0) {
                     $this->DelegateParameters['SqlBuilder'] =& $s;
                     $this->CallDelegate('PreSaveDiscussion');
                     $s->SetMainTable('Discussion', 'd');
                     $s->AddFieldNameValue('Name', $Discussion->Name);
                     $s->AddFieldNameValue('CategoryID', $Discussion->CategoryID);
                     if ($NewDiscussion) {
                         $s->AddFieldNameValue('AuthUserID', $this->Context->Session->UserID);
                         $s->AddFieldNameValue('DateCreated', MysqlDateTime());
                         $s->AddFieldNameValue('DateLastActive', MysqlDateTime());
                         $s->AddFieldNameValue('CountComments', 0);
                         $s->AddFieldNameValue('WhisperUserID', $Discussion->WhisperUserID);
                         if ($Discussion->WhisperUserID != '0') {
                             $s->AddFieldNameValue('DateLastWhisper', MysqlDateTime());
                         }
                         $Discussion->DiscussionID = $this->Context->Database->Insert($s, $this->Name, 'NewDiscussion', 'An error occurred while creating a new discussion.');
                         $Discussion->Comment->DiscussionID = $Discussion->DiscussionID;
                     } else {
                         $s->AddWhere('d', 'DiscussionID', '', $Discussion->DiscussionID, '=');
                         $this->Context->Database->Update($s, $this->Name, 'NewDiscussion', 'An error occurred while updating the discussion.');
                     }
                 }
                 // Now save the associated Comment
                 if ($Discussion->Comment->DiscussionID > 0) {
                     $CommentManager->SaveComment($Discussion->Comment, 1);
                     // Now update the topic table so that we know what the first comment in the discussion was
                     if ($Discussion->Comment->CommentID > 0 && $NewDiscussion) {
                         $s->Clear();
                         $s->SetMainTable('Discussion', 'd');
                         $s->AddFieldNameValue('FirstCommentID', $Discussion->Comment->CommentID);
                         $s->AddWhere('d', 'DiscussionID', '', $Discussion->Comment->DiscussionID, '=');
                         $this->Context->Database->Update($s, $this->Name, 'NewDiscussion', 'An error occurred while updating discussion properties.');
                     }
                 }
             }
         }
     }
     return $this->Context->WarningCollector->Iif($Discussion, false);
 }
コード例 #9
0
     $s->AddFieldNameValue("CountDiscussions", 0);
     $s->AddFieldNameValue("CountComments", 0);
     $s->AddFieldNameValue("RoleID", 6);
     $s->AddFieldNameValue("StyleID", 1);
     $s->AddFieldNameValue("UtilizeEmail", 0);
     $s->AddFieldNameValue("RemoteIP", GetRemoteIp(1));
     if (!@mysql_query($s->GetInsert(), $Connection)) {
         $WarningCollector->Add("Something bad happened when we were trying to create your administrative user account. Mysql said: " . mysql_error($Connection));
     } else {
         // Now insert the role history assignment
         $NewUserID = mysql_insert_id($Connection);
         $s->Clear();
         $s->SetMainTable("UserRoleHistory", "h");
         $s->AddFieldNameValue("UserID", $NewUserID);
         $s->AddFieldNameValue("RoleID", 6);
         $s->AddFieldNameValue("Date", MysqlDateTime());
         $s->AddFieldNameValue("AdminUserID", $NewUserID);
         $s->AddFieldNameValue("Notes", "Initial administrative account created");
         $s->AddFieldNameValue("RemoteIp", GetRemoteIp(1));
         // Fail silently on this one
         @mysql_query($s->GetInsert(), $Connection);
     }
 }
 // Close the database connection
 @mysql_close($Connection);
 // Save the application constants
 if ($WarningCollector->Count() == 0) {
     $ConstantsFile = $WorkingDirectory . "appg/settings.php";
     $ConstantManager = new ConstantManager($Context);
     $ConstantManager->DefineConstantsFromFile($ConstantsFile);
     // Set the constants to their new values
コード例 #10
0
 function UpdateUserDiscussionCount($UserID)
 {
     if ($this->Context->WarningCollector->Iif()) {
         $UserID = ForceInt($UserID, 0);
         if ($UserID == 0) {
             $this->Context->ErrorManager->AddError($this->Context, $this->Name, "UpdateUserDiscussionCount", "User identifier not supplied");
         }
         // Select the LastDiscussionPost, and DiscussionSpamCheck values from the user's profile
         $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
         $s->SetMainTable("User", "u");
         $s->AddSelect("(unix_timestamp('" . MysqlDateTime() . "')- unix_timestamp(LastDiscussionPost))", "", "DateDiff");
         $s->AddSelect("DiscussionSpamCheck");
         $s->AddWhere("UserID", $UserID, "=");
         $DateDiff = "";
         $DiscussionSpamCheck = 0;
         $result = $this->Context->Database->Select($this->Context, $s, $this->Name, "UpdateUserDiscussionCount", "An error occurred while retrieving user activity data.");
         while ($rows = $this->Context->Database->GetRow($result)) {
             $DateDiff = ForceString($rows['DateDiff'], "");
             $DiscussionSpamCheck = ForceInt($rows['DiscussionSpamCheck'], 0);
         }
         $SecondsSinceLastPost = ForceInt($DateDiff, 0);
         // If the LastDiscussionPost is less than 1 minute ago
         // and the DiscussionSpamCheck is greater than three, throw a warning
         if ($SecondsSinceLastPost < agDISCUSSION_THRESHOLD_PUNISHMENT && $DiscussionSpamCheck >= agDISCUSSION_POST_THRESHOLD && $DateDiff != "") {
             $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrSpamDiscussionsStart") . agDISCUSSION_POST_THRESHOLD . $this->Context->GetDefinition("ErrSpamDiscussionsMiddle1") . agDISCUSSION_TIME_THRESHOLD . $this->Context->GetDefinition("ErrSpamDiscussionsMiddle2") . agDISCUSSION_THRESHOLD_PUNISHMENT . $this->Context->GetDefinition("ErrSpamDiscussionsEnd"));
         }
         $s->Clear();
         $s->SetMainTable("User", "u");
         if ($this->Context->WarningCollector->Count() == 0) {
             $s->AddFieldNameValue("DateLastActive", MysqlDateTime());
             $s->AddFieldNameValue("CountDiscussions", "CountDiscussions+1", 0);
             // If the LastDiscussionPost is less than 1 minute ago
             // and the DiscussionSpamCheck is less than four,
             // update the user profile and add 1 to the DiscussionSpamCheck
             if ($SecondsSinceLastPost < agDISCUSSION_TIME_THRESHOLD && $DiscussionSpamCheck <= agDISCUSSION_POST_THRESHOLD && $DateDiff != "") {
                 $s->AddFieldNameValue("DiscussionSpamCheck", "DiscussionSpamCheck+1", 0);
             } else {
                 // If the LastDiscussionPost is more than 1 minute ago,
                 // set the DiscussionSpamCheck to 1, LastDiscussionPost to now(),
                 // and update the user profile
                 $s->AddFieldNameValue("DiscussionSpamCheck", 1);
                 $s->AddFieldNameValue("LastDiscussionPost", MysqlDateTime());
             }
             $s->AddWhere("UserID", $UserID, "=");
             $this->Context->Database->Update($this->Context, $s, $this->Name, "UpdateUserDiscussionCount", "An error occurred while updating the user profile.");
         } else {
             // Update the "Waiting period" every time they try to post again
             $s->AddFieldNameValue("DateLastActive", MysqlDateTime());
             $s->AddFieldNameValue("LastDiscussionPost", MysqlDateTime());
             $s->AddWhere("UserID", $UserID, "=");
             $this->Context->Database->Update($this->Context, $s, $this->Name, "UpdateUserCommentCount", "An error occurred while updating the user profile.");
         }
     }
     return $this->Context->WarningCollector->Iif();
 }
コード例 #11
0
ファイル: installer.php プロジェクト: laiello/lussumo-vanilla
     $s->AddFieldNameValue('CountDiscussions', 0);
     $s->AddFieldNameValue('CountComments', 0);
     $s->AddFieldNameValue('RoleID', 4);
     $s->AddFieldNameValue('StyleID', 1);
     $s->AddFieldNameValue('UtilizeEmail', 0);
     $s->AddFieldNameValue('RemoteIp', GetRemoteIp(1));
     if (!@mysql_query($s->GetInsert(), $Connection)) {
         $Context->WarningCollector->Add('Something bad happened when we were trying to create your administrative user account. Mysql said: ' . mysql_error($Connection));
     } else {
         // Now insert the role history assignment
         $NewUserID = mysql_insert_id($Connection);
         $s->Clear();
         $s->SetMainTable('UserRoleHistory', 'h');
         $s->AddFieldNameValue('UserID', $NewUserID);
         $s->AddFieldNameValue('RoleID', 4);
         $s->AddFieldNameValue('Date', MysqlDateTime());
         $s->AddFieldNameValue('AdminUserID', $NewUserID);
         $s->AddFieldNameValue('Notes', 'Initial administrative account created');
         $s->AddFieldNameValue('RemoteIp', GetRemoteIp(1));
         // Fail silently on this one
         @mysql_query($s->GetInsert(), $Connection);
     }
     // Create the default Vanilla style entry in the db
     $s->Clear();
     $s->SetMainTable('Style', 's');
     $s->AddFieldNameValue('Name', 'Vanilla');
     $s->AddFieldNameValue('Url', $ThemeDirectory . 'vanilla modern/styles/default/');
     @mysql_query($s->GetInsert(), $Connection);
 }
 // Close the database connection
 @mysql_close($Connection);
コード例 #12
0
 function UpdateUserDiscussionCount($UserID)
 {
     if ($this->Context->WarningCollector->Iif()) {
         $UserID = ForceInt($UserID, 0);
         if ($UserID == 0) {
             $this->Context->ErrorManager->AddError($this->Context, $this->Name, 'UpdateUserDiscussionCount', 'User identifier not supplied');
         }
         // Select the LastDiscussionPost, and DiscussionSpamCheck values from the user's profile
         $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
         $s->SetMainTable('User', 'u');
         $s->AddSelect(array('LastDiscussionPost', 'DiscussionSpamCheck'), 'u');
         $s->AddWhere('u', 'UserID', '', $UserID, '=');
         $DateDiff = '';
         $DiscussionSpamCheck = 0;
         $result = $this->Context->Database->Select($s, $this->Name, 'UpdateUserDiscussionCount', 'An error occurred while retrieving user activity data.');
         while ($rows = $this->Context->Database->GetRow($result)) {
             $LastDiscussionPost = UnixTimestamp($rows['LastDiscussionPost']);
             $DateDiff = mktime() - $LastDiscussionPost;
             $DiscussionSpamCheck = ForceInt($rows['DiscussionSpamCheck'], 0);
         }
         $SecondsSinceLastPost = ForceInt($DateDiff, 0);
         // If the LastDiscussionPost is less than 1 minute ago
         // and the DiscussionSpamCheck is greater than three, throw a warning
         if ($SecondsSinceLastPost < $this->Context->Configuration['DISCUSSION_THRESHOLD_PUNISHMENT'] && $DiscussionSpamCheck >= $this->Context->Configuration['DISCUSSION_POST_THRESHOLD'] && $DateDiff != '') {
             $this->Context->WarningCollector->Add(str_replace(array('//1', '//2', '//3'), array($this->Context->Configuration['DISCUSSION_POST_THRESHOLD'], $this->Context->Configuration['DISCUSSION_TIME_THRESHOLD'], $this->Context->Configuration['DISCUSSION_THRESHOLD_PUNISHMENT']), $this->Context->GetDefinition('ErrSpamDiscussions')));
         }
         $s->Clear();
         $s->SetMainTable('User', 'u');
         if ($this->Context->WarningCollector->Count() == 0) {
             $s->AddFieldNameValue('DateLastActive', MysqlDateTime());
             $s->AddFieldNameValue('CountDiscussions', $this->Context->DatabaseColumns['User']['CountDiscussions'] . '+1', 0);
             // If the LastDiscussionPost is less than 1 minute ago
             // and the DiscussionSpamCheck is less than four,
             // update the user profile and add 1 to the DiscussionSpamCheck
             if ($SecondsSinceLastPost < $this->Context->Configuration['DISCUSSION_TIME_THRESHOLD'] && $DiscussionSpamCheck <= $this->Context->Configuration['DISCUSSION_POST_THRESHOLD'] && $DateDiff != '') {
                 $s->AddFieldNameValue('DiscussionSpamCheck', $this->Context->DatabaseColumns['User']['DiscussionSpamCheck'] . '+1', 0);
             } else {
                 // If the LastDiscussionPost is more than 1 minute ago,
                 // set the DiscussionSpamCheck to 1, LastDiscussionPost to now(),
                 // and update the user profile
                 $s->AddFieldNameValue('DiscussionSpamCheck', 1);
                 $s->AddFieldNameValue('LastDiscussionPost', MysqlDateTime());
             }
             $s->AddWhere('u', 'UserID', '', $UserID, '=');
             $this->Context->Database->Update($s, $this->Name, 'UpdateUserDiscussionCount', 'An error occurred while updating the user profile.');
         } else {
             // Update the 'Waiting period' every time they try to post again
             $s->AddFieldNameValue('DateLastActive', MysqlDateTime());
             $s->AddFieldNameValue('LastDiscussionPost', MysqlDateTime());
             $s->AddWhere('u', 'UserID', '', $UserID, '=');
             $this->Context->Database->Update($s, $this->Name, 'UpdateUserCommentCount', 'An error occurred while updating the user profile.');
         }
     }
     return $this->Context->WarningCollector->Iif();
 }