function Render()
 {
     if ($this->Context->WarningCollector->Count() == 0 && $this->PostBackAction == "") {
         if ($this->User->RoleID == 0 && $this->User->Discovery != "" && $this->Context->Session->User->AdminUsers) {
             $this->Context->Writer->Add("<div class=\"Discovery\">\r\n\t\t\t\t\t<h1>" . $this->Context->GetDefinition("Discovery") . "</h1>\r\n\t\t\t\t\t<blockquote>" . FormatHtmlStringInline($this->User->Discovery) . "</blockquote>\r\n\t\t\t\t</div>");
         }
     }
 }
示例#2
0
 function GetPropertiesFromDataSet($DataSet, &$Context)
 {
     $this->Title = FormatHtmlStringInline(ForceString($DataSet["Name"], ""));
     $this->Link = PrependString("http://", AppendFolder(agDOMAIN, "comments.php?DiscussionID=" . ForceInt($DataSet["DiscussionID"], 0)));
     $this->Id = $this->Link;
     $this->Published = FixDate(@$DataSet["DateCreated"]);
     $this->Updated = FixDate(@$DataSet["DateLastActive"]);
     $this->AuthorName = FormatHtmlStringInline(ForceString($DataSet["AuthUsername"], ""));
     $this->AuthorUrl = PrependString("http://", AppendFolder(agDOMAIN, "account.php?u=" . ForceInt($DataSet["AuthUserID"], 0)));
     $this->Content = $this->RemoveHtml(ForceString(@$DataSet["Body"], ""));
     $this->Summary = SliceString($this->Content, 200);
     $this->Summary = str_replace("\r\n", " ", $this->Content);
     $this->Content = str_replace("\r\n", "<br />", $this->Content);
     if (agUSE_CATEGORIES) {
         $this->Category = FormatStringForDisplay(ForceString($DataSet["Category"], ""), true);
         $this->CategoryLink = "http://" . AppendFolder(agDOMAIN, "?CategoryID=" . ForceInt($DataSet["CategoryID"], 0));
     }
 }
 function FormatPropertiesForSafeDisplay()
 {
     $this->AuthFullName = FormatStringForDisplay($this->AuthFullName);
     $this->AuthUsername = FormatStringForDisplay($this->AuthUsername);
     $this->EditFullName = FormatStringForDisplay($this->EditFullName);
     $this->EditUsername = FormatStringForDisplay($this->EditUsername);
     $this->DeleteFullName = FormatStringForDisplay($this->DeleteFullName);
     $this->DeleteUsername = FormatStringForDisplay($this->DeleteUsername);
     $this->WhisperUsername = FormatStringForDisplay($this->WhisperUsername);
     $this->Discussion = FormatStringForDisplay($this->Discussion);
     $this->Category = FormatStringForDisplay($this->Category);
     $this->Body = FormatHtmlStringInline($this->Body);
     $this->AuthIcon = FormatStringForDisplay($this->AuthIcon);
 }
 function FormatPropertiesForSafeDisplay()
 {
     // Make sure to pass the body through global string formatters
     $this->Body = $this->Context->StringManipulator->GlobalParse($this->Body, $this, FORMAT_STRING_FOR_DISPLAY);
     $this->AuthUsername = FormatStringForDisplay($this->AuthUsername);
     $this->EditUsername = FormatStringForDisplay($this->EditUsername);
     $this->DeleteUsername = FormatStringForDisplay($this->DeleteUsername);
     $this->WhisperUsername = FormatStringForDisplay($this->WhisperUsername);
     $this->Discussion = FormatStringForDisplay($this->Discussion);
     $this->Category = FormatStringForDisplay($this->Category);
     $this->Body = FormatHtmlStringInline($this->Body, 0, 1);
     $this->AuthIcon = FormatStringForDisplay($this->AuthIcon, 1, 0);
     $this->CallDelegate('PostFormatPropertiesForSafeDisplay');
 }
 function CreateUser($User)
 {
     $User->FormatPropertiesForDatabaseInput();
     //                 echo "<!--validation starting-->\n";
     // Instantiate a new validator for each field
     Validate($this->Context->GetDefinition("FirstNameLower"), 1, $User->FirstName, 50, "", $this->Context);
     Validate($this->Context->GetDefinition("LastNameLower"), 1, $User->LastName, 50, "", $this->Context);
     Validate($this->Context->GetDefinition("EmailLower"), 1, $User->Email, 200, "(.+)@(.+)\\.(.+)", $this->Context);
     Validate($this->Context->GetDefinition("UsernameLower"), 1, $User->Name, 20, "", $this->Context);
     //Validate($this->Context->GetDefinition("PasswordLower"), 1, $User->NewPassword, 50, "", $this->Context);
     // 		echo "<!--validation successful-->\n";
     //if ($User->Discovery == "") $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrDiscovery"));
     //if ($User->NewPassword != $User->ConfirmPassword) $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrPasswordsMatchBad"));
     //if (!$User->AgreeToTerms) $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrAgreeTOS"));
     //if (!$User->ReadTerms) $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrReadTOS"));
     // Ensure the username isn't taken already
     $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
     $s->SetMainTable("User", "u");
     $s->AddSelect("UserID", "u");
     $s->AddWhere("Name", $User->Name, "=");
     $MatchCount = 0;
     $result = $this->Context->Database->Select($this->Context, $s, $this->Name, "CreateUser", "A fatal error occurred while validating your input.");
     $MatchCount = $this->Context->Database->RowCount($result);
     if ($MatchCount > 0) {
         $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrUsernameTaken"));
     }
     // 		echo "<!--validation successful again [".$this->Context->WarningCollector->Count()."] -->\n";
     // If validation was successful
     if ($this->Context->WarningCollector->Count() == 0) {
         $s->Clear();
         $s->SetMainTable("User", "u");
         $s->AddFieldNameValue("UserID", $User->UserID);
         $s->AddFieldNameValue("FirstName", $User->FirstName);
         $s->AddFieldNameValue("LastName", $User->LastName);
         $s->AddFieldNameValue("Name", $User->Name);
         $s->AddFieldNameValue("Email", $User->Email);
         $s->AddFieldNameValue("Password", $User->NewPassword, 1, "md5");
         $s->AddFieldNameValue("Discovery", $User->Discovery);
         $s->AddFieldNameValue("DateFirstVisit", MysqlDateTime());
         $s->AddFieldNameValue("DateLastActive", MysqlDateTime());
         $s->AddFieldNameValue("CountVisit", 0);
         $s->AddFieldNameValue("CountDiscussions", 0);
         $s->AddFieldNameValue("CountComments", 0);
         $s->AddFieldNameValue("RoleID", agDEFAULT_ROLE);
         $s->AddFieldNameValue("StyleID", 1);
         $s->AddFieldNameValue("UtilizeEmail", 0);
         $s->AddFieldNameValue("RemoteIP", GetRemoteIp(1));
         $User->UserID = $this->Context->Database->Insert($this->Context, $s, $this->Name, "CreateUser", "An error occurred while creating a new user.");
         // 			echo "<!--inserted successfuly -->\n";
         $Urh = $this->Context->ObjectFactory->NewObject($this->Context, "UserRoleHistory");
         $Urh->UserID = $User->UserID;
         $Urh->AdminUserID = 0;
         $Urh->RoleID = agDEFAULT_ROLE;
         if (agALLOW_IMMEDIATE_ACCESS) {
             $Urh->Notes = $this->Context->GetDefinition("RegistrationAccepted");
         } else {
             $Urh->Notes = $this->Context->GetDefinition("RegistrationPendingApproval");
         }
         $this->AssignRole($Urh, 1);
         // Notify user administrators
         if (!agALLOW_IMMEDIATE_ACCESS) {
             $s->Clear();
             $s->SetMainTable("User", "u");
             $s->AddJoin("Role", "r", "RoleID", "u", "RoleID", "inner join");
             $s->AddWhere("r.AdminUsers", 1, "=");
             $s->AddWhere("u.SendNewApplicantNotifications", 1, "=");
             $s->AddSelect(array("Name", "Email"), "u");
             $Administrators = $this->Context->Database->Select($this->Context, $s, $this->Name, "CreateUser", "An error occurred while retrieving administrator email addresses.", 0);
             // Fail silently if an error occurs while notifying administrators
             if ($Administrators) {
                 if ($this->Context->Database->RowCount($Administrators) > 0) {
                     $e = $this->Context->ObjectFactory->NewContextObject($this->Context, "Email");
                     $e->HtmlOn = 0;
                     $e->ErrorManager =& $this->Context->ErrorManager;
                     $e->WarningCollector =& $this->Context->WarningCollector;
                     $e->AddFrom(agSUPPORT_EMAIL, agSUPPORT_NAME);
                     $AdminEmail = "";
                     $AdminName = "";
                     while ($Row = $this->Context->Database->GetRow($Administrators)) {
                         $AdminEmail = ForceString($Row["Email"], "");
                         $AdminName = ForceString($Row["Name"], "");
                         if ($AdminEmail != "") {
                             $e->AddRecipient($AdminEmail, $AdminName);
                         }
                     }
                     $e->Subject = $this->Context->GetDefinition("NewCaps") . " " . agAPPLICATION_TITLE . " " . $this->Context->GetDefinition("Applicant");
                     $e->BodyText = $this->Context->GetDefinition("ApplicationCompletedBy") . " " . $User->Name . " " . $this->Context->GetDefinition("For") . " " . agAPPLICATION_TITLE . $this->Context->GetDefinition("ApplicantSuppliedInformation") . FormatHtmlStringInline($User->Discovery, 1) . $this->Context->GetDefinition("ReviewApplication") . "http://" . agDOMAIN;
                     @$e->Send();
                 }
             }
         }
     }
     return $this->Context->WarningCollector->Iif();
 }