function GetPropertiesFromDataSet($DataSet) { $this->UserID = ForceInt(@$DataSet['UserID'], 0); $this->Username = ForceString(@$DataSet['Username'], ''); $this->FullName = ForceString(@$DataSet['FullName'], ''); $this->RoleID = ForceInt(@$DataSet['RoleID'], 0); $this->Role = ForceString(@$DataSet['Role'], ''); $this->RoleDescription = ForceString(@$DataSet['RoleDescription'], ''); $this->RoleIcon = ForceString(@$DataSet['RoleIcon'], ''); $this->AdminUserID = ForceInt(@$DataSet['AdminUserID'], 0); $this->AdminUsername = ForceString(@$DataSet['AdminUsername'], ''); $this->AdminFullName = ForceString(@$DataSet['AdminFullName'], ''); $this->Notes = ForceString(@$DataSet['Notes'], ''); $this->Date = UnixTimestamp(@$DataSet['Date']); }
function get_body(&$Context, $CommentID) { if (!isset($_GET['FullComment'])) { $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("Comment", "m"); $s->AddSelect(array("Body", "DateCreated"), "m"); $s->AddSelect("DiscussionID", "d"); $s->AddSelect("account_firstname", "a", "AuthFullName", "concat", "' ',a.account_lastname"); $s->AddJoin("Discussion", "d", "DiscussionID", "m", "DiscussionID", "left join"); $s->AddJoin("categories", "c", "cat_id", "d", "CategoryID", "left join", "phpgw_"); $s->AddJoin("accounts", "a", "account_id", "m", "AuthUserID", "left join", "phpgw_"); $s->AddWhere("CommentID", $CommentID, "="); $s->AddWhere("c.cat_owner", "(" . implode(",", array_keys($this->Context->Session->GetVariable("UserGroups", "Array"))) . ")", "IN", "and", "", 0); $result = $this->Context->Database->Select($this->Context, $s, $this->Name, "GetCommentBodyById", "An error occurred while attempting to retrieve the requested comment."); if ($this->Context->Database->RowCount($result) == 0) { $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrCommentNotFound")); } while ($rows = $this->Context->Database->GetRow($result)) { $CommentBody = $rows['Body']; $CommentDate = $rows['DateCreated']; $CommentAuthor = $rows['AuthFullName']; $CommentDiscussionID = $rows['DiscussionID']; } if (isset($CommentBody)) { if (isset($_GET['quote']) && $_GET['quote'] == "1") { return '<div class="quote"><p><em class="SmallText"><b>' . $CommentAuthor . " " . $this->Context->GetDefinition("Wrote") . " " . TimeDiff(UnixTimestamp($CommentDate)) . '</b>' . '</em><br/>' . $CommentBody . '</div></p><div><br/></div>'; } else { return $CommentBody . "<br/><input type=\"button\" onclick=\"addQuoteToCommentBody(" . $CommentID . ")\" class=\"Button QuoteButton\" id=\"CommentQuote_" . $CommentID . "\" value=\"" . $this->Context->GetDefinition("Quote") . "\" />"; } } else { return '<p><font color="red"><b>Access to comment denied, or comment not found</b></font></p>'; } } elseif (isset($_GET['FullComment'])) { return $this->FullComment($CommentID); } }
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(); }
function GetPropertiesFromDataSet($DataSet, $UserID) { $this->CommentID = ForceInt(@$DataSet["CommentID"], 0); $this->DiscussionID = ForceInt(@$DataSet["DiscussionID"], 0); $this->DiscussionWhisperUserID = ForceInt(@$DataSet["DiscussionWhisperUserID"], 0); $this->Discussion = ForceString(@$DataSet["Discussion"], ""); $this->CategoryID = ForceInt(@$DataSet["CategoryID"], 0); $this->Category = ForceString(@$DataSet["Category"], ""); $this->AuthUserID = ForceInt(@$DataSet["AuthUserID"], 0); $this->AuthFullName = ForceString(@$DataSet["AuthFullName"], ""); $this->AuthUsername = ForceString(@$DataSet["AuthUsername"], ""); $this->AuthIcon = ForceString(@$DataSet["AuthIcon"], ""); $this->AuthRoleID = ForceInt(@$DataSet["AuthRoleID"], 0); $this->AuthRole = ForceString(@$DataSet["AuthRole"], ""); $this->AuthRoleIcon = ForceString(@$DataSet["AuthRoleIcon"], ""); $this->AuthRoleDesc = ForceString(@$DataSet["AuthRoleDesc"], ""); $this->AuthCanPostHtml = ForceBool(@$DataSet["AuthCanPostHtml"], 0); $this->AuthBlocked = ForceBool(@$DataSet["AuthBlocked"], 0); $this->CommentBlocked = ForceBool(@$DataSet["CommentBlocked"], 0); $this->EditUserID = ForceInt(@$DataSet["EditUserID"], 0); $this->EditFullName = ForceString(@$DataSet["EditFullName"], ""); $this->EditUsername = ForceString(@$DataSet["EditUsername"], ""); $this->DateCreated = UnixTimestamp(@$DataSet["DateCreated"]); $this->DateEdited = UnixTimestamp(@$DataSet["DateEdited"]); $this->WhisperUserID = ForceInt(@$DataSet["WhisperUserID"], 0); $this->WhisperUsername = ForceString(@$DataSet["WhisperUsername"], ""); $this->Body = ForceString(@$DataSet["Body"], ""); $this->FormatType = ForceString(@$DataSet["FormatType"], "Text"); $this->Deleted = ForceBool(@$DataSet["Deleted"], 0); $this->DateDeleted = UnixTimestamp(@$DataSet["DateDeleted"]); $this->DeleteUserID = ForceInt(@$DataSet["DeleteUserID"], 0); $this->DeleteFullName = ForceString(@$DataSet["DeleteFullName"], ""); $this->DeleteUsername = ForceString(@$DataSet["DeleteUsername"], ""); $this->RemoteIp = ForceString(@$DataSet["RemoteIp"], ""); $this->Status = $this->GetStatus($UserID); if ($this->AuthRoleIcon != "") { $this->AuthIcon = $this->AuthRoleIcon; } }
function GetPropertiesFromDataSet($DataSet) { $this->DiscussionID = @$DataSet['DiscussionID']; $this->FirstCommentID = @$DataSet['FirstCommentID']; $this->CategoryID = @$DataSet['CategoryID']; $this->Category = @$DataSet['Category']; $this->AuthUserID = @$DataSet['AuthUserID']; $this->AuthUsername = @$DataSet['AuthUsername']; $this->LastUserID = @$DataSet['LastUserID']; $this->LastUsername = @$DataSet['LastUsername']; $this->Active = @$DataSet['Active']; $this->Closed = @$DataSet['Closed']; $this->Sticky = @$DataSet['Sticky']; $this->Bookmarked = @$DataSet['Bookmarked']; $this->Sink = @$DataSet['Sink']; $this->Name = @$DataSet['Name']; $this->DateCreated = UnixTimestamp(@$DataSet['DateCreated']); $this->DateLastActive = UnixTimestamp(@$DataSet['DateLastActive']); $this->CountComments = @$DataSet['CountComments']; if ($this->Context->Configuration['ENABLE_WHISPERS']) { $this->WhisperUserID = @$DataSet['WhisperUserID']; $this->WhisperUsername = @$DataSet['WhisperUsername']; $WhisperFromDateLastActive = UnixTimestamp(@$DataSet['WhisperFromDateLastActive']); $WhisperFromLastUserID = @$DataSet['WhisperFromLastUserID']; $WhisperFromLastFullName = @$DataSet['WhisperFromLastFullName']; $WhisperFromLastUsername = @$DataSet['WhisperFromLastUsername']; $this->CountWhispersFrom = @$DataSet['CountWhispersFrom']; $WhisperToDateLastActive = UnixTimestamp(@$DataSet['WhisperToDateLastActive']); $WhisperToLastUserID = @$DataSet['WhisperToLastUserID']; $WhisperToLastFullName = @$DataSet['WhisperToLastFullName']; $WhisperToLastUsername = @$DataSet['WhisperToLastUsername']; $this->CountWhispersTo = @$DataSet['CountWhispersTo']; $this->CountComments += $this->CountWhispersFrom; $this->CountComments += $this->CountWhispersTo; $this->CountReplies = $this->CountComments - 1; if ($this->CountReplies < 0) { $this->CountReplies = 0; } if ($WhisperFromDateLastActive != '') { if ($this->DateLastActive < $WhisperFromDateLastActive) { $this->DateLastActive = $WhisperFromDateLastActive; $this->LastUserID = $WhisperFromLastUserID; $this->LastFullName = $WhisperFromLastFullName; $this->LastUsername = $WhisperFromLastUsername; } } if ($WhisperToDateLastActive != '') { if ($this->DateLastActive < $WhisperToDateLastActive) { $this->DateLastActive = $WhisperToDateLastActive; $this->LastUserID = $WhisperToLastUserID; $this->LastFullName = $WhisperToLastFullName; $this->LastUsername = $WhisperToLastUsername; } } } $this->CountReplies = $this->CountComments - 1; if ($this->CountReplies < 0) { $this->CountReplies = 0; } $this->LastViewed = UnixTimestamp(@$DataSet['LastViewed']); $this->LastViewCountComments = @$DataSet['LastViewCountComments']; if ($this->LastViewed != '') { $this->NewComments = $this->CountComments - $this->LastViewCountComments; if ($this->NewComments < 0) { $this->NewComments = 0; } } else { $this->NewComments = $this->CountComments; } $this->Status = $this->GetStatus(); // Define the last page $this->CallDelegate('PreDefineLastPage'); $TmpCount = $this->CountComments / $this->Context->Configuration['COMMENTS_PER_PAGE']; $RoundedCount = intval($TmpCount); if ($TmpCount > 1) { if ($TmpCount > $RoundedCount) { $this->LastPage = $RoundedCount + 1; } else { $this->LastPage = $RoundedCount; } } else { $this->LastPage = 1; } $this->DelegateParameters['DataSet'] =& $DataSet; $this->CallDelegate('PostGetPropertiesFromDataSet'); }
function GetPropertiesFromDataSet($DataSet, $UserID) { $this->CommentID = ForceInt(@$DataSet['CommentID'], 0); $this->DiscussionID = ForceInt(@$DataSet['DiscussionID'], 0); $this->Discussion = ForceString(@$DataSet['Discussion'], ''); $this->CategoryID = ForceInt(@$DataSet['CategoryID'], 0); $this->Category = ForceString(@$DataSet['Category'], ''); $this->AuthUserID = ForceInt(@$DataSet['AuthUserID'], 0); $this->AuthUsername = ForceString(@$DataSet['AuthUsername'], ''); $this->AuthIcon = ForceString(@$DataSet['AuthIcon'], ''); $this->AuthRoleID = ForceInt(@$DataSet['AuthRoleID'], 0); $this->AuthRole = ForceString(@$DataSet['AuthRole'], ''); $this->AuthRoleIcon = ForceString(@$DataSet['AuthRoleIcon'], ''); $this->AuthRoleDesc = ForceString(@$DataSet['AuthRoleDesc'], ''); $this->AuthCanPostHtml = ForceBool(@$DataSet['AuthCanPostHtml'], 0); $this->AuthBlocked = ForceBool(@$DataSet['AuthBlocked'], 0); $this->CommentBlocked = ForceBool(@$DataSet['CommentBlocked'], 0); $this->EditUserID = ForceInt(@$DataSet['EditUserID'], 0); $this->EditUsername = ForceString(@$DataSet['EditUsername'], ''); $this->DateCreated = UnixTimestamp(@$DataSet['DateCreated']); $this->DateEdited = UnixTimestamp(@$DataSet['DateEdited']); $this->Body = ForceString(@$DataSet['Body'], ''); $this->FormatType = ForceString(@$DataSet['FormatType'], $this->Context->Configuration['DEFAULT_FORMAT_TYPE']); if (!in_array($this->FormatType, $this->Context->Configuration['FORMAT_TYPES'])) { $this->FormatType = $this->Context->Configuration['DEFAULT_FORMAT_TYPE']; } $this->Deleted = ForceBool(@$DataSet['Deleted'], 0); $this->DateDeleted = UnixTimestamp(@$DataSet['DateDeleted']); $this->DeleteUserID = ForceInt(@$DataSet['DeleteUserID'], 0); $this->DeleteUsername = ForceString(@$DataSet['DeleteUsername'], ''); $this->RemoteIp = ForceString(@$DataSet['RemoteIp'], ''); $this->WhisperUserID = ForceInt(@$DataSet['WhisperUserID'], 0); $this->WhisperUsername = ForceString(@$DataSet['WhisperUsername'], ''); $this->DiscussionWhisperUserID = ForceInt(@$DataSet['DiscussionWhisperUserID'], 0); $this->Status = $this->GetStatus($UserID); if ($this->AuthRoleIcon != '') { $this->AuthIcon = $this->AuthRoleIcon; } }
function GetPropertiesFromDataSet($DataSet) { $this->DiscussionID = ForceInt(@$DataSet["DiscussionID"], 0); $this->FirstCommentID = ForceInt(@$DataSet["FirstCommentID"], 0); $this->CategoryID = ForceInt(@$DataSet["CategoryID"], 0); $this->Category = ForceString(@$DataSet["Category"], ""); $this->AuthUserID = ForceInt(@$DataSet["AuthUserID"], 0); $this->AuthFullName = ForceString(@$DataSet["AuthFullName"], ""); $this->AuthUsername = ForceString(@$DataSet["AuthUsername"], ""); $this->LastUserID = ForceInt(@$DataSet["LastUserID"], 0); $this->LastFullName = ForceString(@$DataSet["LastFullName"], ""); $this->LastUsername = ForceString(@$DataSet["LastUsername"], ""); $this->Active = ForceBool(@$DataSet["Active"], 0); $this->Closed = ForceBool(@$DataSet["Closed"], 0); $this->Sticky = ForceBool(@$DataSet["Sticky"], 0); $this->Bookmarked = ForceBool(@$DataSet["Bookmarked"], 0); $this->Name = ForceString(@$DataSet["Name"], ""); $this->DateCreated = UnixTimestamp(@$DataSet["DateCreated"]); $this->DateLastActive = UnixTimestamp(@$DataSet["DateLastActive"]); $this->CountComments = ForceInt(@$DataSet["CountComments"], 0); $this->CountReplies = $this->CountComments - 1; if ($this->CountReplies < 0) { $this->CountReplies = 0; } $this->LastViewed = UnixTimestamp(@$DataSet["LastViewed"]); $this->LastViewCountComments = ForceInt(@$DataSet["LastViewCountComments"], 0); if ($this->LastViewed != "") { $this->NewComments = $this->CountComments - $this->LastViewCountComments; if ($this->NewComments < 0) { $this->NewComments = 0; } } else { $this->NewComments = $this->CountComments; } $this->Status = $this->GetStatus(); // Define the last page $this->LastPage = CalculateNumberOfPages($this->CountComments, agCOMMENTS_PER_PAGE); }
function GetPropertiesFromDataSet($DataSet) { $this->UserID = ForceInt(@$DataSet['UserID'], 0); $this->RoleID = ForceInt(@$DataSet['RoleID'], 0); $this->Role = ForceString(@$DataSet['Role'], ''); if ($this->RoleID == 0 && $this->Context) { $this->Role = $this->Context->GetDefinition('Applicant'); } $this->RoleIcon = ForceString(@$DataSet['RoleIcon'], ''); $this->RoleDescription = ForceString(@$DataSet['RoleDescription'], ''); $this->StyleID = ForceInt(@$DataSet['StyleID'], 0); $this->Style = ForceString(@$DataSet['Style'], ''); $this->StyleUrl = ForceString(@$DataSet['StyleUrl'], ''); $this->CustomStyle = ForceString(@$DataSet['CustomStyle'], ''); $this->Name = ForceString(@$DataSet['Name'], ''); $this->FirstName = ForceString(@$DataSet['FirstName'], ''); $this->LastName = ForceString(@$DataSet['LastName'], ''); $this->FullName = trim($this->FirstName . ' ' . $this->LastName); $this->ShowName = ForceBool(@$DataSet['ShowName'], 0); $this->Email = ForceString(@$DataSet['Email'], ''); $this->UtilizeEmail = ForceBool(@$DataSet['UtilizeEmail'], 0); $this->Icon = ForceString(@$DataSet['Icon'], ''); $this->Picture = ForceString(@$DataSet['Picture'], ''); $this->Discovery = ForceString(@$DataSet['Discovery'], ''); $this->Attributes = ''; $this->Attributes = ForceString(@$DataSet['Attributes'], ''); $this->Attributes = UnserializeArray($this->Attributes); $this->SendNewApplicantNotifications = ForceBool(@$DataSet['SendNewApplicantNotifications'], 0); if ($this->RoleIcon != '') { $this->DisplayIcon = $this->RoleIcon; } else { $this->DisplayIcon = $this->Icon; } $this->Preferences = ''; $this->Preferences = ForceString(@$DataSet['Preferences'], ''); $this->Preferences = UnserializeAssociativeArray($this->Preferences); $this->DateFirstVisit = UnixTimestamp(@$DataSet['DateFirstVisit']); $this->DateLastActive = UnixTimestamp(@$DataSet['DateLastActive']); $this->CountVisit = ForceInt(@$DataSet['CountVisit'], 0); $this->CountDiscussions = ForceInt(@$DataSet['CountDiscussions'], 0); $this->CountComments = ForceInt(@$DataSet['CountComments'], 0); $this->RemoteIp = ForceString(@$DataSet['RemoteIp'], ''); $this->BlocksCategories = ForceBool(@$DataSet['UserBlocksCategories'], 0); $this->DefaultFormatType = ForceString(@$DataSet['DefaultFormatType'], $this->Context->Configuration['DEFAULT_FORMAT_TYPE']); // User Role Permissions $this->PERMISSION_SIGN_IN = ForceBool(@$DataSet['PERMISSION_SIGN_IN'], $this->Context->Configuration['PERMISSION_SIGN_IN']); $this->PERMISSION_HTML_ALLOWED = ForceBool(@$DataSet['PERMISSION_HTML_ALLOWED'], $this->Context->Configuration['PERMISSION_HTML_ALLOWED']); $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION = ForceBool(@$DataSet['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'], $this->Context->Configuration['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION']); $this->Permissions = ''; $this->Permissions = ForceString(@$DataSet['Permissions'], ''); $this->Permissions = UnserializeAssociativeArray($this->Permissions); $this->Permissions['PERMISSION_SIGN_IN'] = $this->PERMISSION_SIGN_IN; $this->Permissions['PERMISSION_HTML_ALLOWED'] = $this->PERMISSION_HTML_ALLOWED; $this->Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'] = $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION; // If this user doesn't have permission to do things, force their preferences to abide. if (!$this->Permission('PERMISSION_VIEW_HIDDEN_DISCUSSIONS')) { $this->Setting['ShowDeletedDiscussions'] = 0; } if (!$this->Permission('PERMISSION_VIEW_HIDDEN_COMMENTS')) { $this->Setting['ShowDeletedComments'] = 0; } if (!$this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION) { $this->SendNewApplicantNotifications = 0; } // change the user's style if they've selected no style if ($this->StyleID == 0) { $this->Style = 'Custom'; $this->StyleUrl = ForceString($this->CustomStyle, $this->Context->Configuration['DEFAULT_STYLE']); } $this->Password = ForceString(@$DataSet['Password'], '*'); $this->VerificationKey = ForceString(@$DataSet['VerificationKey'], ''); }
function FixDate($Date = "") { if ($Date == "") { $NewDate = date(DATE_FORMAT, mktime()); } else { $NewDate = date(DATE_FORMAT, UnixTimestamp($Date)); } // Dates that look like this: // 2005-07-23T18:44:53-0400 // Need to look like this: // 2005-07-23T18:44:53-04:00 if (strlen($NewDate) != 24) { return $NewDate; } else { return substr($NewDate, 0, 22) . ":" . substr($NewDate, 22); } }