Example #1
0
    public function SettingsController_Render_Before(&$Sender)
    {
        // Save the action if editing registration settings
        if (strcasecmp($Sender->RequestMethod, 'registration') == 0 && $Sender->Form->AuthenticatedPostBack() === TRUE) {
            $this->SaveStep('Plugins.GettingStarted.Registration');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'plugins') == 0) {
            $this->SaveStep('Plugins.GettingStarted.Plugins');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'managecategories') == 0) {
            $this->SaveStep('Plugins.GettingStarted.Categories');
        }
        // Add messages & their css on dashboard
        if (strcasecmp($Sender->RequestMethod, 'index') == 0) {
            $Sender->AddCssFile(DS . 'plugins' . DS . 'GettingStarted' . DS . 'style.css');
            $Session = Gdn::Session();
            $WelcomeMessage = '<div class="GettingStarted">' . Anchor('×', '/garden/plugin/dismissgettingstarted/' . $Session->TransientKey(), 'Dismiss') . "<p>Here's how to get started:</p>" . '<ul>
      <li class="One' . (Gdn::Config('Plugins.GettingStarted.Registration', '0') == '1' ? ' Done' : '') . '">' . Anchor(Gdn::Translate('Define how users register for your forum'), '/settings/registration') . '</li>
      <li class="Two' . (Gdn::Config('Plugins.GettingStarted.Plugins', '0') == '1' ? ' Done' : '') . '">' . Anchor(Gdn::Translate('Manage your plugins'), 'settings/plugins') . '</li>
      <li class="Three' . (Gdn::Config('Plugins.GettingStarted.Categories', '0') == '1' ? ' Done' : '') . '">' . Anchor(Gdn::Translate('Organize your discussion categories'), 'vanilla/settings/managecategories') . '</li>
      <li class="Four' . (Gdn::Config('Plugins.GettingStarted.Profile', '0') == '1' ? ' Done' : '') . '">' . Anchor(Gdn::Translate('Customize your profile'), 'profile') . '</li>
      <li class="Five' . (Gdn::Config('Plugins.GettingStarted.Discussion', '0') == '1' ? ' Done' : '') . '">' . Anchor(Gdn::Translate('Start your first discussion'), 'post/discussion') . '</li>
   </ul>
</div>';
            $Sender->AddAsset('Messages', $WelcomeMessage, 'WelcomeMessage');
        }
    }
Example #2
0
 public function Base_Render_Before(&$Sender)
 {
     // Add menu items.
     $Session = Gdn::Session();
     if ($Sender->Menu) {
         $Sender->Menu->AddLink('Dashboard', 'Dashboard', '/garden/settings', array('Garden.Settings.Manage'));
         $Sender->Menu->AddLink('Dashboard', 'Users', '/user/browse', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
         $Sender->Menu->AddLink('Activity', 'Activity', '/activity');
         $Authenticator = Gdn::Authenticator();
         if ($Session->IsValid()) {
             $Sender->Menu->AddLink('SignOut', 'Sign Out', '/entry/leave/{Session_TransientKey}', FALSE, array('class' => 'NonTab'));
             $Notifications = Gdn::Translate('Notifications');
             $CountNotifications = $Session->User->CountNotifications;
             if (is_numeric($CountNotifications) && $CountNotifications > 0) {
                 $Notifications .= '<span>' . $CountNotifications . '</span>';
             }
             $Sender->Menu->AddLink('User', '{Username}', '/profile/{Username}', array('Garden.SignIn.Allow'));
             $Sender->Menu->AddLink('User', '\\' . $Notifications, 'profile/notifications/{Username}');
         } else {
             $Sender->Menu->AddLink('Entry', 'Sign In', $Authenticator->SignInUrl());
         }
     }
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewTheme = $Session->GetPreference('PreviewTheme', '');
         if ($PreviewTheme != '') {
             $Sender->Theme = $PreviewTheme;
         }
     }
 }
Example #3
0
 public function Edit($MessageID = '')
 {
     $this->AddJsFile('js/library/jquery.autogrow.js');
     $this->AddJsFile('messages.js');
     $this->Permission('Garden.Messages.Manage');
     $this->AddSideMenu('garden/message');
     // Generate some Controller & Asset data arrays
     $this->LocationData = $this->_GetLocationData();
     $this->AssetData = $this->_GetAssetData();
     // Set the model on the form.
     $this->Form->SetModel($this->MessageModel);
     $this->Message = $this->MessageModel->GetID($MessageID);
     // Make sure the form knows which item we are editing.
     if (is_numeric($MessageID) && $MessageID > 0) {
         $this->Form->AddHidden('MessageID', $MessageID);
     }
     // If seeing the form for the first time...
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         $this->Form->SetData($this->Message);
     } else {
         if ($MessageID = $this->Form->Save()) {
             // Reset the message cache
             $this->MessageModel->SetMessageCache();
             // Redirect
             $this->StatusMessage = Gdn::Translate('Your changes have been saved.');
             $this->RedirectUrl = Url('garden/message');
         }
     }
     $this->Render();
 }
    public function ToString()
    {
        $String = '';
        ob_start();
        ?>
      <div class="Box">
         <h4><?php 
        echo Gdn::Translate('In this Discussion');
        ?>
</h4>
         <ul class="PanelInfo">
         <?php 
        foreach ($this->_UserData->Result() as $User) {
            ?>
            <li>
               <strong><?php 
            echo Anchor($User->Name, '/profile/' . urlencode($User->Name), 'UserLink');
            ?>
</strong>
               <?php 
            echo Format::Date($User->DateLastActive);
            ?>
            </li>
            <?php 
        }
        ?>
         </ul>
      </div>
      <?php 
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
    }
 public function __construct(&$Sender = '')
 {
     $Session = Gdn::Session();
     if (property_exists($Sender, 'Conversation')) {
         $this->Conversation = $Sender->Conversation;
     }
     $this->Form = Gdn::Factory('Form', 'AddPeople');
     // $this->Form->Action = $Sender->SelfUrl;
     // If the form was posted back, check for people to add to the conversation
     if ($this->Form->AuthenticatedPostBack()) {
         $NewRecipientUserIDs = array();
         $NewRecipients = explode(',', $this->Form->GetFormValue('AddPeople', ''));
         $UserModel = Gdn::Factory("UserModel");
         foreach ($NewRecipients as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->Get(trim($Name));
                 if (is_object($User)) {
                     $NewRecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         $Sender->ConversationModel->AddUserToConversation($this->Conversation->ConversationID, $NewRecipientUserIDs);
         // if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL)
         //    Redirect('/messages/'.$this->Conversation->ConversationID);
         $Sender->StatusMessage = Gdn::Translate('Your changes were saved.');
         $Sender->RedirectUrl = Url('/messages/' . $this->Conversation->ConversationID);
     }
     $this->_ApplicationFolder = $Sender->Application;
     $this->_ThemeFolder = $Sender->Theme;
 }
Example #6
0
 /**
  * Checks to see if the user is spamming. Returns TRUE if the user is spamming.
  */
 public function CheckForSpam($Type)
 {
     $Spam = FALSE;
     if (!in_array($Type, array('Comment', 'Discussion'))) {
         trigger_error(ErrorMessage(sprintf('Spam check type unknown: %s', $Type), 'VanillaModel', 'CheckForSpam'), E_USER_ERROR);
     }
     $Session = Gdn::Session();
     $CountSpamCheck = $Session->GetAttribute('Count' . $Type . 'SpamCheck', 0);
     $DateSpamCheck = $Session->GetAttribute('Date' . $Type . 'SpamCheck', 0);
     $SecondsSinceSpamCheck = time() - Format::ToTimestamp($DateSpamCheck);
     $SpamCount = Gdn::Config('Vanilla.' . $Type . '.SpamCount');
     if (!is_numeric($SpamCount) || $SpamCount < 2) {
         $SpamCount = 2;
     }
     // 2 spam minimum
     $SpamTime = Gdn::Config('Vanilla.' . $Type . '.SpamTime');
     if (!is_numeric($SpamTime) || $SpamTime < 0) {
         $SpamTime = 30;
     }
     // 30 second minimum spam span
     $SpamLock = Gdn::Config('Vanilla.' . $Type . '.SpamLock');
     if (!is_numeric($SpamLock) || $SpamLock < 30) {
         $SpamLock = 30;
     }
     // 30 second minimum lockout
     // Definition:
     // Users cannot post more than $SpamCount comments within $SpamTime
     // seconds or their account will be locked for $SpamLock seconds.
     // Apply a spam lock if necessary
     $Attributes = array();
     if ($SecondsSinceSpamCheck < $SpamLock && $CountSpamCheck >= $SpamCount && $DateSpamCheck !== FALSE) {
         // TODO: REMOVE DEBUGGING INFO AFTER THIS IS WORKING PROPERLY
         /*
         echo '<div>SecondsSinceSpamCheck: '.$SecondsSinceSpamCheck.'</div>';
         echo '<div>SpamLock: '.$SpamLock.'</div>';
         echo '<div>CountSpamCheck: '.$CountSpamCheck.'</div>';
         echo '<div>SpamCount: '.$SpamCount.'</div>';
         echo '<div>DateSpamCheck: '.$DateSpamCheck.'</div>';
         echo '<div>SpamTime: '.$SpamTime.'</div>';
         */
         $Spam = TRUE;
         $this->Validation->AddValidationResult('Body', sprintf(Gdn::Translate('You have posted %1$s times within %2$s seconds. A spam block is now in effect on your account. You must wait at least %3$s seconds before attempting to post again.'), $SpamCount, $SpamTime, $SpamLock));
         // Update the 'waiting period' every time they try to post again
         $Attributes['Date' . $Type . 'SpamCheck'] = Format::ToDateTime();
     } else {
         if ($SecondsSinceSpamCheck > $SpamTime) {
             $Attributes['Count' . $Type . 'SpamCheck'] = 1;
             $Attributes['Date' . $Type . 'SpamCheck'] = Format::ToDateTime();
         } else {
             $Attributes['Count' . $Type . 'SpamCheck'] = $CountSpamCheck + 1;
         }
     }
     // Update the user profile after every comment
     $UserModel = Gdn::UserModel();
     $UserModel->SaveAttribute($Session->UserID, $Attributes);
     return $Spam;
 }
Example #7
0
    public function ToString()
    {
        $String = '';
        $Session = Gdn::Session();
        ob_start();
        //Hide the top poster box id there's no post greater than 0
        if ($this->_TopPosters->NumRows() > 0) {
            ?>
		
			<div id="TopPosters" class="Box">
				<h4><?php 
            echo Gdn::Translate("Top Posters");
            ?>
</h4>
				<ul class="PanelInfo">
				<?php 
            $i = 1;
            foreach ($this->_TopPosters->Result() as $User) {
                ?>
					<li>
						<?php 
                echo $User->AllPosted;
                ?>
						<?php 
                if (Gdn::Config('TopPosters.Show.Medal') == "both" || Gdn::Config('TopPosters.Show.Medal') == "side") {
                    ?>
						<img src="<?php 
                    echo str_replace("index.php?p=", "", Url('/plugins/TopPosters/badges/' . (file_exists('plugins/TopPosters/badges/' . $i . '.png') ? $i . '.png' : 'medal-icon.png')));
                    ?>
">
						<?php 
                }
                ?>
		 				<strong>
		    				<?php 
                echo UserAnchor($User);
                ?>
		 				</strong>
		 				
					</li>
				<?php 
                $i++;
            }
            ?>
			</ul>
		</div>
		<?php 
        }
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
    }
Example #8
0
 public function ProfileController_AddProfileTabs_Handler(&$Sender)
 {
     if (is_object($Sender->User) && $Sender->User->UserID > 0 && $Sender->User->CountDiscussions > 0) {
         // Add the discussion tab
         $Sender->AddProfileTab(Gdn::Translate('Discussions'));
         // Add the discussion tab's css
         $Sender->AddCssFile('vanillaprofile.css', 'vanilla');
         if ($Sender->Head) {
             $Sender->Head->AddScript('/js/library/jquery.gardenmorepager.js');
             $Sender->Head->AddScript('/applications/vanilla/js/discussions.js');
         }
     }
 }
Example #9
0
 public function Check($Type = '', $Name = '')
 {
     if ($Type != '' && $Name != '') {
         $this->AddItem($Type, $Name);
     }
     if (count($this->_Items) > 0) {
         // TODO: Use garden update check url instead of this:
         $UpdateUrl = Url('/lussumo/update', TRUE, TRUE);
         $Host = Gdn_Url::Host();
         $Path = CombinePaths(array(Gdn_Url::WebRoot(), 'lussumo', 'update'), '/');
         $Port = 80;
         /*
         $UpdateUrl = Gdn::Config('Garden.UpdateCheckUrl', '');
         $UpdateUrl = parse_url($UpdateUrl);
         $Host = ArrayValue('host', $UpdateUrl, 'www.lussumo.com');
         $Path = ArrayValue('path', $UpdateUrl, '/');
         $Port = ArrayValue('port', $UpdateUrl, '80');
         */
         $Path .= '?Check=' . urlencode(Format::Serialize($this->_Items));
         $Locale = Gdn::Config('Garden.Locale', 'Undefined');
         $Referer = Gdn_Url::WebRoot(TRUE);
         if ($Referer === FALSE) {
             $Referer = 'Undefined';
         }
         $Timeout = 10;
         $Response = '';
         // Connect to the update server.
         $Pointer = @fsockopen($Host, '80', $ErrorNumber, $Error, $Timeout);
         if (!$Pointer) {
             throw new Exception(sprintf(Gdn::Translate('Encountered an error when attempting to connect to the update server (%1$s): [%2$s] %3$s'), $UpdateUrl, $ErrorNumber, $Error));
         } else {
             // send the necessary headers to get the file
             fputs($Pointer, "GET {$Path} HTTP/1.0\r\n" . "Host: {$Host}\r\n" . "User-Agent: Lussumo Garden/1.0\r\n" . "Accept: */*\r\n" . "Accept-Language: " . $Locale . "\r\n" . "Accept-Charset: utf-8;\r\n" . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: {$Referer}\r\n\r\n");
             // Retrieve the response from the remote server
             while ($Line = fread($Pointer, 4096)) {
                 $Response .= $Line;
             }
             fclose($Pointer);
             // Remove response headers
             $Response = substr($Response, strpos($Response, "\r\n\r\n") + 4);
         }
         $Result = Format::Unserialize($Response);
         // print_r($Result);
         if (is_array($Result)) {
             $this->_Items = $Result;
         } else {
             $Result = FALSE;
         }
         return $Result;
     }
 }
Example #10
0
 public function Base_Render_Before(&$Sender)
 {
     // Add the menu options for conversations
     $Session = Gdn::Session();
     if ($Sender->Menu && $Session->IsValid()) {
         $Inbox = Gdn::Translate('Inbox');
         $CountUnreadConversations = $Session->User->CountUnreadConversations;
         if (is_numeric($CountUnreadConversations) && $CountUnreadConversations > 0) {
             $Inbox .= '<span>' . $CountUnreadConversations . '</span>';
         }
         $Sender->Menu->AddLink('Conversations', $Inbox, '/messages/all', FALSE);
         $Sender->Menu->AddLink('Conversations', Gdn::Translate('New Conversation'), '/messages/add', FALSE);
     }
 }
Example #11
0
 public static function ErrorHandler($Error, $Message = '', $File = '', $Line = '')
 {
     if (error_reporting() == 0) {
         return False;
     }
     $Object = 'PHP';
     $Method = 'Function';
     if (is_object($Error)) {
         $Info = False;
         foreach ($Error->GetTrace() as $Info) {
             break;
         }
         $Method = ArrayValue('function', $Info, $Method);
         $Object = ArrayValue('class', $Info, $Object);
         $Message = $Error->GetMessage();
         $File = $Error->GetFile();
         $Line = $Error->GetLine();
         $Error = -1;
     }
     $File = str_replace(PATH_ROOT . DS, '', $File);
     switch ($Error) {
         case E_NOTICE:
             $Code = 'NOTICE';
             break;
         case E_WARNING:
             $Code = 'WARNING';
             break;
         case -1:
             $Code = 'UNCAUGHT EXCEPTION';
             break;
         default:
             $Code = 'ERROR';
     }
     $Message = strip_tags($Message);
     self::Message('%s: %s in %s on line %s', $Code, $Message, $File, $Line);
     self::Message($Message);
     LogMessage($File, $Line, $Object, $Method, $Message, $Code);
     // send error to email
     $To = Gdn::Config('Plugins.UsefulFunctions.Console.ErrorsEmailToAddress');
     if (self::Check() && $To != False) {
         $Text = sprintf(Gdn::Translate('Error in console script %1$s %2$s %3$s %4$s'), $Code, $Message, $File, $Line);
         if (!class_exists('Gdn_Email')) {
             return error_log("Error ({$Code})", 1, $To, $Text);
         }
         $Email = new Gdn_Email();
         $Email->To($To)->Message($Text)->Subject("Error ({$Code})")->Send('ErrorInConsoleScript');
     }
     exit;
 }
    public function ToString()
    {
        $String = '';
        $Session = Gdn::Session();
        ob_start();
        $LatestOrMost = Gdn::Config('LatestComment.Show.LatestComment');
        //Hide the top poster box id there's no post greater than 0
        if ($this->_LatestComments->NumRows() > 0) {
            ?>
		
			<div id="LatestComment" class="Box BoxLatestComment">
				<h4><?php 
            if ($LatestOrMost == "YES") {
                echo Gdn::Translate("Latest Commented");
            } else {
                echo Gdn::Translate("Most Commented");
            }
            ?>
</h4>
				<ul class="PanelInfo PanelLatestComment">
				<?php 
            $i = 1;
            foreach ($this->_LatestComments->Result() as $Discussion) {
                ?>
					<li><span><strong>
		    			<a href="/Discussion/<?php 
                echo $Discussion->DiscussionID;
                ?>
/<?php 
                echo str_replace(" ", "-", $Discussion->Name);
                ?>
"><?php 
                echo $Discussion->Name;
                ?>
</a>
					</span></strong></li>
				<?php 
                $i++;
            }
            ?>
			</ul>
		</div>
		<?php 
        }
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
    }
Example #13
0
 public function Delete($Category, $ReplacementCategoryID)
 {
     // Don't do anything if the required category object & properties are not defined.
     if (!is_object($Category) || !property_exists($Category, 'CategoryID') || !property_exists($Category, 'ParentCategoryID') || !property_exists($Category, 'AllowDiscussions') || !property_exists($Category, 'Name') || $Category->CategoryID <= 0) {
         throw new Exception(Gdn::Translate('Invalid category for deletion.'));
     } else {
         // Remove permissions.
         $PermissionModel = Gdn::PermissionModel();
         $PermissionModel->Delete(NULL, 'Category', 'CategoryID', $Category->CategoryID);
         // If there is a replacement category...
         if ($ReplacementCategoryID > 0) {
             // Update children categories
             $this->SQL->Update('Category')->Set('ParentCategoryID', $ReplacementCategoryID)->Where('ParentCategoryID', $Category->CategoryID)->Put();
             // Update discussions
             $this->SQL->Update('Discussion')->Set('CategoryID', $ReplacementCategoryID)->Where('CategoryID', $Category->CategoryID)->Put();
             // Update the discussion count
             $Count = $this->SQL->Select('DiscussionID', 'count', 'DiscussionCount')->From('Discussion')->Where('CategoryID', $ReplacementCategoryID)->Get()->FirstRow()->DiscussionCount;
             if (!is_numeric($Count)) {
                 $Count = 0;
             }
             $this->SQL->Update('Category')->Set('CountDiscussions', $Count)->Where('CategoryID', $ReplacementCategoryID)->Put();
         } else {
             // Delete comments in this category
             $this->SQL->From('Comment')->Join('Discussion d', 'c.DiscussionID = d.DiscussionID')->Delete('Comment c', array('d.CategoryID' => $Category->CategoryID));
             // Delete discussions in this category
             $this->SQL->Delete('Discussion', array('CategoryID' => $Category->CategoryID));
         }
         // Delete the category
         $this->SQL->Delete('Category', array('CategoryID' => $Category->CategoryID));
         // If there are no parent categories left, make sure that all other
         // categories are not assigned
         if ($this->SQL->Select('CategoryID')->From('Category')->Where('AllowDiscussions', '0')->Get()->NumRows() == 0) {
             $this->SQL->Update('Category')->Set('ParentCategoryID', 'null', FALSE)->Put();
         }
         // If there is only one category, make sure that Categories are not used
         $CountCategories = $this->Get()->NumRows();
         $Config = Gdn::Factory(Gdn::AliasConfig);
         $Config->Load(PATH_CONF . DS . 'config.php', 'Save');
         $Config->Set('Vanilla.Categories.Use', $CountCategories > 1, TRUE, 'ForSave');
         $Config->Save();
     }
     // Make sure to reorganize the categories after deletes
     $this->Organize();
 }
Example #14
0
 public function Base_Render_Before(&$Sender)
 {
     // Add menu items.
     $Session = Gdn::Session();
     if ($Sender->Menu) {
         $Sender->Menu->AddLink('Dashboard', 'Dashboard', '/garden/settings', array('Garden.Settings.Manage'));
         $Sender->Menu->AddLink('Dashboard', 'Users', '/user/browse', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
         $Sender->Menu->AddLink('Activity', 'Activity', '/activity');
         $Authenticator = Gdn::Authenticator();
         if ($Session->IsValid()) {
             $Sender->Menu->AddLink('SignOut', 'Sign Out', '/entry/leave/{Session_TransientKey}', FALSE, array('class' => 'NonTab'));
             $Notifications = Gdn::Translate('Notifications');
             $CountNotifications = $Session->User->CountNotifications;
             if (is_numeric($CountNotifications) && $CountNotifications > 0) {
                 $Notifications .= '<span>' . $CountNotifications . '</span>';
             }
             $Sender->Menu->AddLink('User', '{Username}', '/profile/{Username}', array('Garden.SignIn.Allow'));
             $Sender->Menu->AddLink('User', '\\' . $Notifications, 'profile/notifications/{Username}');
         } else {
             $Sender->Menu->AddLink('Entry', 'Sign In', $Authenticator->SignInUrl());
         }
     }
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewTheme = $Session->GetPreference('PreviewTheme', '');
         if ($PreviewTheme != '') {
             $Sender->Theme = $PreviewTheme;
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     if (in_array('Base', $MessageCache) || InArrayI($Location, $MessageCache)) {
         $MessageModel = new Gdn_MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location);
         foreach ($MessageData as $Message) {
             $MessageModule = new Gdn_MessageModule($Sender, $Message);
             $Sender->AddModule($MessageModule);
         }
     }
 }
Example #15
0
 public function Base_GetAppSettingsMenuItems_Handler(&$Sender)
 {
     $Menu =& $Sender->EventArguments['SideMenu'];
     $Menu->AddItem('Dashboard', Gdn::Translate('Dashboard'));
     $Menu->AddLink('Dashboard', Gdn::Translate('Dashboard'), 'garden/settings', 'Garden.Settings.Manage');
     $Menu->AddItem('Site Settings', Gdn::Translate('Site Settings'));
     $Menu->AddLink('Site Settings', Gdn::Translate('General'), 'garden/settings/configure', 'Garden.Settings.Manage');
     $Menu->AddLink('Site Settings', Gdn::Translate('Routes'), 'garden/routes', 'Garden.Routes.Manage');
     $Menu->AddLink('Site Settings', Gdn::Translate('Messages'), 'garden/message', 'Garden.Messages.Manage');
     $Menu->AddItem('Add-ons', Gdn::Translate('Add-ons'));
     $Menu->AddLink('Add-ons', Gdn::Translate('Applications'), 'garden/settings/applications', 'Garden.Applications.Manage');
     $Menu->AddLink('Add-ons', Gdn::Translate('Plugins'), 'garden/settings/plugins', 'Garden.Applications.Manage');
     $Menu->AddLink('Add-ons', Gdn::Translate('Themes'), 'garden/settings/themes', 'Garden.Themes.Manage');
     $Menu->AddItem('Users', Gdn::Translate('Users'));
     $Menu->AddLink('Users', Gdn::Translate('Users'), 'garden/user', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
     $Menu->AddLink('Users', Gdn::Translate('Roles & Permissions'), 'garden/role', 'Garden.Roles.Manage');
     $Menu->AddLink('Users', Gdn::Translate('Registration'), 'garden/settings/registration', 'Garden.Registration.Manage');
     if (Gdn::Config('Garden.Registration.Method') == 'Approval') {
         $Menu->AddLink('Users', Gdn::Translate('Applicants'), 'garden/user/applicants', 'Garden.Applicants.Manage');
     }
 }
Example #16
0
 public function SettingsController_DashboardData_Handler(&$Sender)
 {
     $DiscussionModel = new Gdn_DiscussionModel();
     // Number of Discussions
     $CountDiscussions = $DiscussionModel->GetCount();
     $Sender->AddDefinition('CountDiscussions', $CountDiscussions);
     $Sender->BuzzData[Gdn::Translate('Discussions')] = number_format($CountDiscussions);
     // Number of New Discussions in the last day
     $Sender->BuzzData[Translate('New discussions in the last day')] = number_format($DiscussionModel->GetCount(array('d.DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Number of New Discussions in the last week
     $Sender->BuzzData[Translate('New discussions in the last week')] = number_format($DiscussionModel->GetCount(array('d.DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
     $CommentModel = new Gdn_CommentModel();
     // Number of Comments
     $CountComments = $CommentModel->GetCountWhere();
     $Sender->AddDefinition('CountComments', $CountComments);
     $Sender->BuzzData[Gdn::Translate('Comments')] = number_format($CountComments);
     // Number of New Comments in the last day
     $Sender->BuzzData[Translate('New comments in the last day')] = number_format($CommentModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Number of New Comments in the last week
     $Sender->BuzzData[Translate('New comments in the last week')] = number_format($CommentModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
 }
Example #17
0
 public function SettingsController_DashboardData_Handler(&$Sender)
 {
     $ConversationModel = new Gdn_ConversationModel();
     // Number of Conversations
     $CountConversations = $ConversationModel->GetCountWhere();
     $Sender->AddDefinition('CountConversations', $CountConversations);
     $Sender->BuzzData[Gdn::Translate('Conversations')] = number_format($CountConversations);
     // Number of New Conversations in the last day
     $Sender->BuzzData[Translate('New conversations in the last day')] = number_format($ConversationModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Number of New Conversations in the last week
     $Sender->BuzzData[Translate('New conversations in the last week')] = number_format($ConversationModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
     $ConversationMessageModel = new Gdn_ConversationMessageModel();
     // Number of Messages
     $CountMessages = $ConversationMessageModel->GetCountWhere();
     $Sender->AddDefinition('CountConversationMessages', $CountMessages);
     $Sender->BuzzData[Gdn::Translate('Conversation Messages')] = number_format($CountMessages);
     // Number of New Messages in the last day
     $Sender->BuzzData[Translate('New messages in the last day')] = number_format($ConversationMessageModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Number of New Messages in the last week
     $Sender->BuzzData[Translate('New messages in the last week')] = number_format($ConversationMessageModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
 }
 public function SettingsController_tInfoBar_Create(&$Sender)
 {
     $Sender->PluginName = $this->ClassName;
     $Sender->AddSideMenu('plugin/' . $this->ClassName);
     $Sender->Form = new Gdn_Form();
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $Sender->Form->SetModel($ConfigurationModel);
     if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         $Sender->Form->SetData($ConfigurationModel->Data);
     } else {
         $Data = $Sender->Form->FormValues();
         $ConfigurationModel->SetField(array_keys($Data));
         if ($Sender->Form->Save() !== FALSE) {
             $Sender->StatusMessage = Gdn::Translate("Your settings have been saved.");
         }
     }
     // creates the page for the plugin options such as display options
     $Sender->View = dirname(__FILE__) . DS . 'views' . DS . 'dashboard.php';
     $Sender->Render();
 }
Example #19
0
 public function PluginController_TopPosters_Create(&$Sender)
 {
     $Sender->AddSideMenu('plugin/topposters');
     $Sender->Form = new Gdn_Form();
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('TopPosters.Location.Show', 'TopPosters.Limit', 'TopPosters.Excluded', 'TopPosters.Show.Medal'));
     $Sender->Form->SetModel($ConfigurationModel);
     if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         $Sender->Form->SetData($ConfigurationModel->Data);
     } else {
         $Data = $Sender->Form->FormValues();
         $ConfigurationModel->Validation->ApplyRule('TopPosters.Limit', array('Required', 'Integer'));
         $ConfigurationModel->Validation->ApplyRule('TopPosters.Location.Show', 'Required');
         if ($Sender->Form->Save() !== FALSE) {
             $Sender->StatusMessage = Gdn::Translate("Your settings have been saved.");
         }
     }
     $TopPostersModule = new TopPostersModule($Sender);
     $Sender->AllUsers = $TopPostersModule->GetAllUsers();
     $Sender->Render($this->GetView('topposters.php'));
 }
Example #20
0
 public function PluginController_LatestComment_Create(&$Sender)
 {
     $Sender->AddSideMenu('plugin/latestcomment');
     $Sender->Form = new Gdn_Form();
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('LatestComment.Show.LatestComment', 'LatestComment.Location.Show', 'LatestComment.Limit', 'LatestComment.Show.User'));
     $Sender->Form->SetModel($ConfigurationModel);
     if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         $Sender->Form->SetData($ConfigurationModel->Data);
     } else {
         $Data = $Sender->Form->FormValues();
         $ConfigurationModel->Validation->ApplyRule('LatestComment.Show.LatestComment', 'Required');
         $ConfigurationModel->Validation->ApplyRule('LatestComment.Location.Show', 'Required');
         $ConfigurationModel->Validation->ApplyRule('LatestComment.Limit', array('Required', 'Integer'));
         //$ConfigurationModel->Validation->ApplyRule('LatestComment.Location.Show', 'Required');
         if ($Sender->Form->Save() !== FALSE) {
             $Sender->StatusMessage = Gdn::Translate("Your settings have been saved.");
         }
     }
     $LatestCommentModule = new LatestCommentModule($Sender);
     $Sender->AllDiscussions = $LatestCommentModule->GetAllDiscussion();
     $Sender->Render($this->GetView('latestcomment.php'));
 }
Example #21
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="Box GuestBox">
   <h4><?php 
echo Gdn::Translate('Howdy, Stranger!');
?>
</h4>
   <p><?php 
echo Translate($this->MessageCode);
?>
</p>
   <p>
      <?php 
echo Anchor(Gdn::Translate('Sign In'), Gdn::Authenticator()->SignInUrl($this->_Sender->SelfUrl), 'Button' . (Gdn::Config('Garden.SignIn.Popup') ? ' SignInPopup' : ''));
?>
 
      <?php 
$Url = Gdn::Authenticator()->RegisterUrl($this->_Sender->SelfUrl);
if (!empty($Url)) {
    echo Anchor(Gdn::Translate('Apply for Membership'), $Url, 'Button');
}
?>
   </p>
</div>
Example #22
0
?>
   </li>
   <li id="InvitationSettings">
      <div class="Info"><?php 
echo Gdn::Translate('Choose who can send out invitations to new members:');
?>
</div>
      <table class="Label AltColumns">
         <thead>
            <tr>
               <th><?php 
echo Gdn::Translate('Role');
?>
</th>
               <th class="Alt"><?php 
echo Gdn::Translate('Invitations per month');
?>
</th>
            </tr>
         </thead>
         <tbody>
         <?php 
$i = 0;
$Count = $this->RoleData->NumRows();
$Alt = FALSE;
foreach ($this->RoleData->Result() as $Role) {
    $Alt = $Alt ? FALSE : TRUE;
    $CssClass = $Alt ? 'Alt' : '';
    ++$i;
    if ($Count == $i) {
        $CssClass .= ' Last';
Example #23
0
 /**
  * Translates a code into the selected locale's definition.
  *
  * @param string $Code The code related to the language-specific definition.
  *   Codes thst begin with an '@' symbol are treated as literals and not translated.
  * @param string $Default The default value to be displayed if the translation code is not found.
  * @return string The translated string or $Code if there is no value in $Default.
  * @see Gdn::Translate()
  */
 function T($Code, $Default = FALSE)
 {
     return Gdn::Translate($Code, $Default);
 }
Example #24
0
    echo Gdn::Translate('Just you!');
} else {
    if ($this->RecipientData->NumRows() == 2) {
        foreach ($this->RecipientData->Result() as $User) {
            if ($User->UserID != $Session->UserID) {
                echo sprintf(Gdn::Translate('%s and you'), UserAnchor($User));
            }
        }
    } else {
        $Users = array();
        foreach ($this->RecipientData->Result() as $User) {
            if ($User->UserID != $Session->UserID) {
                $Users[] = UserAnchor($User);
            }
        }
        echo sprintf(Gdn::Translate('%s, and you'), implode(', ', $Users));
    }
}
?>
</h2>
<?php 
echo $this->Pager->ToString('less');
?>
<ul id="Conversation">
   <?php 
$MessagesViewLocation = $this->FetchViewLocation('messages');
include $MessagesViewLocation;
?>
</ul>
<?php 
echo $this->Pager->ToString();
Example #25
0
 public function CheckBoxGridGroup($GroupName, $Data, $FieldName)
 {
     // Get the column and row info.
     $Columns = $Data['_Columns'];
     ksort($Columns);
     $Rows = $Data['_Rows'];
     ksort($Rows);
     unset($Data['_Columns'], $Data['_Rows']);
     if (array_key_exists('_Info', $Data)) {
         $GroupName = $Data['_Info']['Name'];
         unset($Data['_Info']);
     }
     $Result = '<table class="CheckBoxGrid">';
     // Append the header.
     $Result .= '<thead><tr><th>' . Gdn::Translate($GroupName) . '</th>';
     $Alt = TRUE;
     foreach ($Columns as $ColumnName => $X) {
         $Result .= '<td' . ($Alt ? ' class="Alt"' : '') . '>' . Gdn::Translate($ColumnName) . '</td>';
         $Alt = !$Alt;
     }
     $Result . '</tr></thead>';
     // Append the rows.
     $Result .= '<tbody>';
     foreach ($Rows as $RowName => $X) {
         $Result .= '<tr><th>';
         // If the row name is still seperated by dots then put those in spans.
         $RowNames = explode('.', $RowName);
         for ($i = 0; $i < count($RowNames) - 1; ++$i) {
             $Result .= '<span class="Parent">' . Gdn::Translate($RowNames[$i]) . '</span>';
         }
         $Result .= Gdn::Translate($RowNames[count($RowNames) - 1]) . '</th>';
         // Append the columns within the rows.
         $Alt = TRUE;
         foreach ($Columns as $ColumnName => $Y) {
             $Result .= '<td' . ($Alt ? ' class="Alt"' : '') . '>';
             // Check to see if there is a row corresponding to this area.
             if (array_key_exists($RowName . '.' . $ColumnName, $Data)) {
                 $CheckBox = $Data[$RowName . '.' . $ColumnName];
                 $Attributes = array('value' => $CheckBox['PostValue']);
                 if ($CheckBox['Value']) {
                     $Attributes['checked'] = 'checked';
                 }
                 $Result .= $this->CheckBox($FieldName . '[]', '', $Attributes);
             } else {
                 $Result .= ' ';
             }
             $Result .= '</td>';
             $Alt = !$Alt;
         }
         $Result .= '</tr>';
     }
     $Result .= '</tbody></table>';
     return $Result;
 }
Example #26
0
 public function EditCategory($CategoryID = '')
 {
     $this->Permission('Vanilla.Categories.Manage');
     $RoleModel = new Gdn_RoleModel();
     $PermissionModel = Gdn::PermissionModel();
     $this->Form->SetModel($this->CategoryModel);
     $this->Category = $this->CategoryModel->GetID($CategoryID);
     $this->AddJsFile('/js/library/jquery.gardencheckboxgrid.js');
     $this->Title(Translate('Edit Category'));
     $this->AddSideMenu('vanilla/settings/managecategories');
     // Make sure the form knows which item we are editing.
     $this->Form->AddHidden('CategoryID', $CategoryID);
     // Load all roles with editable permissions
     $this->RoleArray = $RoleModel->GetArray();
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         $this->Form->SetData($this->Category);
     } else {
         if ($this->Form->Save()) {
             // Report success
             $this->StatusMessage = Gdn::Translate('The category was saved successfully.');
             $this->RedirectUrl = Url('vanilla/settings/managecategories');
         }
     }
     // Get all of the currently selected role/permission combinations for this junction
     $Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => $CategoryID), 'Category');
     $Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
     $this->SetData('PermissionData', $Permissions, TRUE);
     $this->Render();
 }
Example #27
0
 /**
  * Translates a code into the selected locale's definition.
  *
  * @param string $Code The code related to the language-specific definition.
  * @param string $Default The default value to be displayed if the translation code is not found.
  * @return string The translated string or $Code if there is no value in $Default.
  * @deprecated
  * @see Gdn::Translate()
  */
 function Translate($Code, $Default = '')
 {
     $Result = Gdn::Translate($Code, $Default);
     return $Result;
 }
Example #28
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<h2><?php 
echo Gdn::Translate('Conversations');
?>
</h2>
<ul id="Conversations">
   <?php 
if ($this->ConversationData->NumRows() == 0) {
    ?>
   <li class="Empty"><?php 
    echo Gdn::Translate('You do not have any conversations.');
    ?>
</li>
   <?php 
} else {
    $ViewLocation = $this->FetchViewLocation('conversations');
    include $ViewLocation;
}
?>
</ul>
<?php 
echo $this->Pager->ToString();
Example #29
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
$Session = Gdn::Session();
?>
<h2><?php 
echo Gdn::Translate('Notifications');
?>
</h2>
<?php 
if ($this->NotificationData->NumRows() > 0) {
    ?>
<ul class="Activities">
   <?php 
    foreach ($this->NotificationData->Result() as $Activity) {
        ?>
      <li id="Activity_<?php 
        echo $Activity->ActivityID;
        ?>
" class="Activity<?php 
        echo ' ' . $Activity->ActivityType;
        ?>
"><?php 
        if ($Activity->ActivityPhoto != '' && $Activity->ShowIcon == '1') {
            if ($Activity->InsertUserID == $Session->UserID) {
                echo '<a href="' . Url('/garden/profile/' . urlencode($Activity->ActivityName)) . '">' . $this->Html->Image('uploads/n' . $Activity->ActivityPhoto) . '</a>';
            } else {
                echo $this->Html->Image('uploads/n' . $Activity->ActivityPhoto);
            }
Example #30
0
 public function UnInvite($InvitationID = '', $PostBackKey = '')
 {
     $this->Permission('Garden.SignIn.Allow');
     $InvitationModel = new InvitationModel();
     $Session = Gdn::Session();
     if ($Session->ValidateTransientKey($PostBackKey)) {
         try {
             $InvitationModel->Delete($InvitationID, $this->UserModel);
         } catch (Exception $ex) {
             $this->Form->AddError(strip_tags($ex->getMessage()));
         }
         if ($this->Form->ErrorCount() == 0) {
             $this->StatusMessage = Gdn::Translate('The invitation was removed successfully.');
         }
     }
     $this->View = 'Invitations';
     $this->Invitations();
 }