/**
  * Handle awesome actions
  *
  * @param mixed $Sender
  */
 public function Controller_Awesome($Sender)
 {
     if (!($UserID = Gdn::Session()->UserID)) {
         throw new Exception(T('Cannot report content while not logged in.'));
     }
     $UserName = Gdn::Session()->User->Name;
     $Arguments = $Sender->RequestArgs;
     if (sizeof($Arguments) != 4) {
         throw new Exception(sprintf(T("Incorrect arg-count. Doesn't look like a legit request. Got %s arguments, expected 4."), sizeof($Arguments)));
     }
     list($EventType, $Context, $ElementID, $EncodedURL) = $Arguments;
     $URL = base64_decode(str_replace('-', '=', $EncodedURL));
     $ReportElementModelName = ucfirst($Context) . 'Model';
     if (!class_exists($ReportElementModelName)) {
         throw new Exception(T('Cannot report on an entity with no model.'));
     }
     // Ok we're good to go for sure now
     $ReportElementModel = new $ReportElementModelName();
     $ReportElement = $ReportElementModel->GetID($ElementID);
     $ElementTitle = Gdn_Format::Text(GetValue('Name', $ReportElement, NULL), FALSE);
     $ElementExcerpt = Gdn_Format::Text(GetValue('Body', $ReportElement, NULL), FALSE);
     if (!is_null($ElementExcerpt)) {
         $Original = strlen($ElementExcerpt);
         $ElementExcerpt = substr($ElementExcerpt, 0, 140);
         if ($Original > strlen($ElementExcerpt)) {
             $ElementExcerpt .= "...";
         }
     }
     if (is_null($ElementTitle)) {
         $ElementTitle = $ElementExcerpt;
     }
     $ElementShortTitle = strlen($ElementTitle) <= 143 ? $ElementTitle : substr($ElementTitle, 0, 140) . '...';
     $ElementAuthorID = GetValue('InsertUserID', $ReportElement);
     $ElementAuthor = Gdn::UserModel()->GetID($ElementAuthorID);
     $ElementAuthorName = GetValue('Name', $ElementAuthor);
     $ReportingData = array('Context' => $Context, 'ElementID' => $ElementID, 'ElementTitle' => $ElementTitle, 'ElementExcerpt' => $ElementExcerpt, 'ElementAuthor' => $ElementAuthor, 'URL' => $URL, 'UserID' => $UserID, 'UserName' => $UserName);
     $RegardingAction = C('Plugins.Reporting.AwesomeAction', FALSE);
     $RegardingActionSupplement = C('Plugins.Reporting.AwesomeActionSupplement', FALSE);
     if ($Sender->Form->AuthenticatedPostBack()) {
         $RegardingTitle = sprintf(T("Awesome: '{RegardingTitle}' by %s"), $ElementAuthorName);
         $Regarding = Gdn::Regarding()->That($Context, $ElementID, $ReportElement)->ItsAwesome()->ForCollaboration($RegardingAction, $RegardingActionSupplement)->Entitled($RegardingTitle)->From(Gdn::Session()->UserID)->Because($Sender->Form->GetValue('Plugin.Reporting.Reason'))->Located(TRUE)->Commit();
         $Sender->InformMessage('<span class="InformSprite Heart"></span>' . T('Your suggestion has been registered. Thankyou!'), 'HasSprite Dismissable AutoDismiss');
     }
     $Sender->SetData('Plugin.Reporting.Data', $ReportingData);
     $Sender->Render($this->GetView('awesome.php'));
 }
Exemple #2
0
Gdn::FactoryInstall(Gdn::AliasSession, 'Gdn_Session');
Gdn::FactoryInstall(Gdn::AliasAuthenticator, 'Gdn_Auth');
// Dispatcher.
Gdn::FactoryInstall(Gdn::AliasRouter, 'Gdn_Router');
Gdn::FactoryInstall(Gdn::AliasDispatcher, 'Gdn_Dispatcher');
// Smarty Templating Engine
Gdn::FactoryInstall('Smarty', 'Smarty', PATH_LIBRARY . '/vendors/Smarty-2.6.25/libs/Smarty.class.php');
Gdn::FactoryInstall('ViewHandler.tpl', 'Gdn_Smarty');
// Slice handler
Gdn::FactoryInstall(Gdn::AliasSlice, 'Gdn_Slice');
// Remote Statistics
Gdn::FactoryInstall('Statistics', 'Gdn_Statistics', NULL, Gdn::FactorySingleton);
Gdn::Statistics();
// Regarding
Gdn::FactoryInstall('Regarding', 'Gdn_Regarding', NULL, Gdn::FactorySingleton);
Gdn::Regarding();
// Other objects.
Gdn::FactoryInstall('Dummy', 'Gdn_Dummy');
/**
 * Extension Startup
 *
 * Allow installed Extensions (Applications, Themes, Plugins) to execute startup
 * and bootstrap procedures that they may have, here.
 */
// Applications startup
foreach (Gdn::ApplicationManager()->EnabledApplicationFolders() as $ApplicationName => $ApplicationFolder) {
    // Include the application's bootstrap.
    $Gdn_Path = PATH_APPLICATIONS . "/{$ApplicationFolder}/settings/bootstrap.php";
    if (file_exists($Gdn_Path)) {
        include_once $Gdn_Path;
    }