Ejemplo n.º 1
0
 /**
  * Format the content of a log file.
  *
  * @param $Log
  * @return array|string
  */
 public function formatContent($Log)
 {
     $Data = $Log['Data'];
     // TODO: Check for a custom log type handler.
     switch ($Log['RecordType']) {
         case 'Activity':
             $Result = $this->FormatKey('Story', $Data);
             break;
         case 'Discussion':
             $Result = '<b>' . $this->FormatKey('Name', $Data) . '</b><br />' . $this->FormatKey('Body', $Data);
             break;
         case 'ActivityComment':
         case 'Comment':
             $Result = $this->FormatKey('Body', $Data);
             break;
         case 'Configuration':
             $Result = $this->FormatConfiguration($Data);
             break;
         case 'Registration':
         case 'User':
             $Result = $this->FormatRecord(array('Email', 'Name'), $Data);
             if ($DiscoveryText = val('DiscoveryText', $Data)) {
                 $Result .= '<br /><b>' . t('Why do you want to join?') . '</b><br />' . Gdn_Format::Display($DiscoveryText);
             }
             if (val('Banned', $Data)) {
                 $Result .= "<br />" . t('Banned');
             }
             break;
         default:
             $Result = '';
     }
     return $Result;
 }
Ejemplo n.º 2
0
 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload. 
  *
  * @since 2.0.18
  * @access public
  *
  * @param Gdn_Controller $Sender The object calling this method.
  */
 public static function InformNotifications($Sender)
 {
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     $ActivityModel = new ActivityModel();
     // Get five pending notifications.
     $Where = array('NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
     // If we're in the middle of a visit only get very recent notifications.
     $Where['DateUpdated >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes'));
     $Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray();
     $ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID');
     $ActivityModel->SetNotified($ActivityIDs);
     foreach ($Activities as $Activity) {
         if ($Activity['Photo']) {
             $UserPhoto = Anchor(Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
         } else {
             $UserPhoto = '';
         }
         $Excerpt = Gdn_Format::Display($Activity['Story']);
         $ActivityClass = ' Activity-' . $Activity['ActivityType'];
         $Sender->InformMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
     }
 }
 public function Format($String)
 {
     try {
         $Result = parse_bbc($String);
     } catch (Exception $Ex) {
         $Result = '<!-- Error: ' . htmlspecialchars($Ex->getMessage()) . '-->' . Gdn_Format::Display($String);
     }
     return $Result;
 }
Ejemplo n.º 4
0
function WriteActivityComment($Comment, &$Sender, &$Session)
{
    $Author = UserBuilder($Comment, 'Activity');
    $PhotoAnchor = UserPhoto($Author, 'Photo');
    $CssClass = 'Item ActivityComment Condensed ' . $Comment->ActivityType;
    if ($PhotoAnchor != '') {
        $CssClass .= ' HasPhoto';
    }
    ?>
<li id="Activity_<?php 
    echo $Comment->ActivityID;
    ?>
" class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if ($PhotoAnchor != '') {
        ?>
   <div class="Author Photo"><?php 
        echo $PhotoAnchor;
        ?>
</div>
   <?php 
    }
    ?>
   <div class="ItemContent ActivityComment">
      <?php 
    echo UserAnchor($Author, 'Title Name');
    ?>
      <div class="Excerpt"><?php 
    echo Gdn_Format::Display($Comment->Story);
    ?>
</div>
      <div class="Meta">
         <span class="DateCreated"><?php 
    echo Gdn_Format::Date($Comment->DateInserted);
    ?>
</span>
         <?php 
    if ($Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete')) {
        echo Anchor(T('Delete'), 'dashboard/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request()), 'DeleteComment');
    }
    ?>
      </div>
   </div>
</li>
<?php 
}
Ejemplo n.º 5
0
$Alt = FALSE;
foreach ($this->AvailablePlugins as $PluginName => $PluginInfo) {
    // Skip Hidden & Trigger plugins
    if (isset($PluginInfo['Hidden']) && $PluginInfo['Hidden'] === TRUE) {
        continue;
    }
    if (isset($PluginInfo['Trigger']) && $PluginInfo['Trigger'] == TRUE) {
        // Any 'true' value.
        continue;
    }
    $Css = array_key_exists($PluginName, $this->EnabledPlugins) ? 'Enabled' : 'Disabled';
    $State = strtolower($Css);
    if ($this->Filter == 'all' || $this->Filter == $State) {
        $Alt = $Alt ? FALSE : TRUE;
        $Version = Gdn_Format::Display(val('Version', $PluginInfo, ''));
        $ScreenName = Gdn_Format::Display(val('Name', $PluginInfo, $PluginName));
        $SettingsUrl = $State == 'enabled' ? arrayValue('SettingsUrl', $PluginInfo, '') : '';
        $PluginUrl = arrayValue('PluginUrl', $PluginInfo, '');
        $Author = arrayValue('Author', $PluginInfo, '');
        $AuthorUrl = arrayValue('AuthorUrl', $PluginInfo, '');
        $NewVersion = arrayValue('NewVersion', $PluginInfo, '');
        $Upgrade = $NewVersion != '' && version_compare($NewVersion, $Version, '>');
        $RowClass = $Css;
        if ($Alt) {
            $RowClass .= ' Alt';
        }
        $IconPath = '/plugins/' . GetValue('Folder', $PluginInfo, '') . '/icon.png';
        $IconPath = file_exists(PATH_ROOT . $IconPath) ? $IconPath : 'applications/dashboard/design/images/plugin-icon.png';
        ?>
            <tr <?php 
        echo 'id="' . Gdn_Format::url(strtolower($PluginName)) . '-plugin"', ' class="More ' . $RowClass . '"';
Ejemplo n.º 6
0
</th>
      </tr>
   </thead>
   <tbody>
<?php 
$Alt = FALSE;
foreach ($this->AvailablePlugins as $PluginName => $PluginInfo) {
    if (isset($PluginInfo['Hidden']) && $PluginInfo['Hidden'] === TRUE) {
        continue;
    }
    $Css = array_key_exists($PluginName, $this->EnabledPlugins) ? 'Enabled' : 'Disabled';
    $State = strtolower($Css);
    if ($this->Filter == 'all' || $this->Filter == $State) {
        $Alt = $Alt ? FALSE : TRUE;
        $Version = Gdn_Format::Display(GetValue('Version', $PluginInfo, ''));
        $ScreenName = Gdn_Format::Display(GetValue('Name', $PluginInfo, $PluginName));
        $SettingsUrl = $State == 'enabled' ? ArrayValue('SettingsUrl', $PluginInfo, '') : '';
        $PluginUrl = ArrayValue('PluginUrl', $PluginInfo, '');
        $Author = ArrayValue('Author', $PluginInfo, '');
        $AuthorUrl = ArrayValue('AuthorUrl', $PluginInfo, '');
        $NewVersion = ArrayValue('NewVersion', $PluginInfo, '');
        $Upgrade = $NewVersion != '' && version_compare($NewVersion, $Version, '>');
        $RowClass = $Css;
        if ($Alt) {
            $RowClass .= ' Alt';
        }
        $IconPath = '/plugins/' . GetValue('Folder', $PluginInfo, '') . '/icon.png';
        $IconPath = file_exists(PATH_ROOT . $IconPath) ? $IconPath : 'applications/dashboard/design/images/plugin-icon.png';
        ?>
      <tr <?php 
        echo 'id="' . Gdn_Format::Url(strtolower($PluginName)) . '-plugin"', ' class="More ' . $RowClass . '"';
Ejemplo n.º 7
0
 /**
  * Format a string using Markdown syntax. Also purifies the output html.
  *
  * @param mixed $Mixed An object, array, or string to be formatted.
  * @return string
  */
 public static function Markdown($Mixed)
 {
     if (!is_string($Mixed)) {
         return self::To($Mixed, 'Markdown');
     } else {
         $Formatter = Gdn::Factory('HtmlFormatter');
         if (is_null($Formatter)) {
             return Gdn_Format::Display($Mixed);
         } else {
             require_once PATH_LIBRARY . DS . 'vendors' . DS . 'markdown' . DS . 'markdown.php';
             $Mixed = Markdown($Mixed);
             $Mixed = Gdn_Format::Links($Mixed);
             $Mixed = Gdn_Format::Mentions($Mixed);
             return $Formatter->Format($Mixed);
         }
     }
 }
Ejemplo n.º 8
0
      <?php 
$Data = $this->ActivityData;
foreach ($Data->Result() as $Activity) {
    echo '<li class="Activity ' . $Activity->ActivityType . '">';
    // If this was a status update or a wall comment, don't bother with activity strings
    $ActivityType = explode(' ', $Activity->ActivityType);
    // Make sure you strip out any extra css classes munged in here
    $ActivityType = $ActivityType[0];
    $Author = UserBuilder($Activity, 'Activity');
    if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
        echo UserAnchor($Author, 'Name');
        if ($Activity->ActivityType == 'WallComment' && $Activity->RegardingUserID > 0) {
            $Author = UserBuilder($Activity, 'Regarding');
            echo '<span>&rarr;</span>' . UserAnchor($Author, 'Name');
        }
        echo ' ' . Gdn_Format::Display($Activity->Story) . ' ';
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
    } else {
        echo Gdn_Format::ActivityHeadline($Activity);
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
        if ($Activity->Story != '') {
            echo '<div class="Story">';
            echo $Activity->Story;
            echo '</div>';
        }
    }
    echo '</li>';
}
?>
      <li class="ShowAll"><?php 
echo Anchor(T('↳ Show All'), 'activity/' . implode(',', $this->_RoleID));
Ejemplo n.º 9
0
 /**
  * Format a string using Markdown syntax. Also purifies the output html.
  *
  * @param mixed $Mixed An object, array, or string to be formatted.
  * @return string
  */
 public static function Markdown($Mixed)
 {
     if (!is_string($Mixed)) {
         return self::To($Mixed, 'Markdown');
     } else {
         $Formatter = Gdn::Factory('HtmlFormatter');
         if (is_null($Formatter)) {
             return Gdn_Format::Display($Mixed);
         } else {
             require_once PATH_LIBRARY . '/vendors/markdown/markdown.php';
             $Mixed = Markdown($Mixed);
             $Mixed = $Formatter->Format($Mixed);
             $Mixed = Gdn_Format::Links($Mixed);
             $Mixed = Gdn_Format::Mentions($Mixed);
             $Mixed = Emoji::instance()->translateToHtml($Mixed);
             return $Mixed;
         }
     }
 }
Ejemplo n.º 10
0
<div class="User" itemscope itemtype="http://schema.org/Person">
    <h1 class="H"><?php 
echo htmlspecialchars($this->User->Name);
echo '<span class="Gloss">';
Gdn_Theme::BulletRow();
if ($this->User->Title) {
    echo Gdn_Theme::BulletItem('Title');
    echo ' ' . Bullet() . ' ' . Wrap(htmlspecialchars($this->User->Title), 'span', array('class' => 'User-Title'));
}
$this->fireEvent('UsernameMeta');
echo '</span>';
?>
</h1>
    <?php 
if ($this->User->Admin == 2) {
    echo '<div class="DismissMessage InfoMessage">', t('This is a system account and does not represent a real person.'), '</div>';
}
if ($this->User->About != '') {
    echo '<div id="Status" itemprop="description">' . Wrap(Gdn_Format::Display($this->User->About));
    if ($this->User->About != '' && ($Session->UserID == $this->User->UserID || $Session->checkPermission('Garden.Users.Edit'))) {
        echo ' - ' . anchor(t('clear'), '/profile/clear/' . $this->User->UserID, 'Hijack');
    }
    echo '</div>';
}
echo Gdn_Theme::Module('UserBanModule', array('UserID' => $this->User->UserID));
$this->fireEvent('BeforeUserInfo');
echo Gdn_Theme::Module('UserInfoModule');
$this->fireEvent('AfterUserInfo');
?>
</div>
Ejemplo n.º 11
0
function WriteActivity($Activity, &$Sender, &$Session)
{
    $Activity = (object) $Activity;
    // If this was a status update or a wall comment, don't bother with activity strings
    $ActivityType = explode(' ', $Activity->ActivityType);
    // Make sure you strip out any extra css classes munged in here
    $ActivityType = $ActivityType[0];
    $Author = UserBuilder($Activity, 'Activity');
    $PhotoAnchor = Anchor(Img($Activity->Photo, array('class' => 'ProfilePhoto ProfilePhotoMedium')), $Activity->PhotoUrl, 'PhotoWrap');
    $CssClass = 'Item Activity Activity-' . $ActivityType;
    if ($PhotoAnchor != '') {
        $CssClass .= ' HasPhoto';
    }
    $Format = GetValue('Format', $Activity);
    $Title = '';
    $Excerpt = $Activity->Story;
    if ($Format) {
        $Excerpt = Gdn_Format::To($Excerpt, $Format);
    }
    if (!in_array($ActivityType, array('WallComment', 'WallPost', 'AboutUpdate'))) {
        $Title = '<div class="Title">' . GetValue('Headline', $Activity) . '</div>';
    } else {
        if ($ActivityType == 'WallPost') {
            $RegardingUser = UserBuilder($Activity, 'Regarding');
            $PhotoAnchor = UserPhoto($RegardingUser);
            $Title = '<div class="Title">' . UserAnchor($RegardingUser, 'Name') . ' <span>&rarr;</span> ' . UserAnchor($Author, 'Name') . '</div>';
            if (!$Format) {
                $Excerpt = Gdn_Format::Display($Excerpt);
            }
        } else {
            $Title = UserAnchor($Author, 'Name');
            if (!$Format) {
                $Excerpt = Gdn_Format::Display($Excerpt);
            }
        }
    }
    $Sender->EventArguments['Activity'] =& $Activity;
    $Sender->EventArguments['CssClass'] =& $CssClass;
    $Sender->FireEvent('BeforeActivity');
    ?>
<li id="Activity_<?php 
    echo $Activity->ActivityID;
    ?>
" class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if ($Session->IsValid() && ($Session->UserID == $Activity->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete'))) {
        echo '<div class="Options">' . Anchor('×', 'dashboard/activity/delete/' . $Activity->ActivityID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'Delete') . '</div>';
    }
    if ($PhotoAnchor != '') {
        ?>
   <div class="Author Photo"><?php 
        echo $PhotoAnchor;
        ?>
</div>
   <?php 
    }
    ?>
   <div class="ItemContent Activity">
      <?php 
    echo $Title;
    ?>
      <div class="Excerpt"><?php 
    echo $Excerpt;
    ?>
</div>
      <?php 
    $Sender->EventArguments['Activity'] = $Activity;
    $Sender->FireAs('ActivityController')->FireEvent('AfterActivityBody');
    ?>
      <div class="Meta">
         <span class="MItem DateCreated"><?php 
    echo Gdn_Format::Date($Activity->DateUpdated);
    ?>
</span>
         <?php 
    $SharedString = FALSE;
    $ID = GetValue('SharedNotifyUserID', $Activity->Data);
    if (!$ID) {
        $ID = GetValue('CommentNotifyUserID', $Activity->Data);
    }
    if ($ID) {
        $SharedString = FormatString(T('Comments are between {UserID,you}.'), array('UserID' => array($Activity->NotifyUserID, $ID)));
    }
    $AllowComments = $Activity->NotifyUserID < 0 || $SharedString;
    if ($AllowComments && $Session->CheckPermission('Garden.Profiles.Edit')) {
        echo '<span class="MItem AddComment">' . Anchor(T('Activity.Comment', 'Comment'), '#CommentForm_' . $Activity->ActivityID, 'CommentOption');
    }
    if ($SharedString) {
        echo ' <span class="MItem"><i>' . $SharedString . '</i></span>';
    }
    echo '</span>';
    $Sender->FireEvent('AfterMeta');
    ?>
      </div>
   </div>
   <?php 
    $Comments = GetValue('Comments', $Activity, array());
    if (count($Comments) > 0) {
        echo '<ul class="DataList ActivityComments">';
        foreach ($Comments as $Comment) {
            WriteActivityComment($Comment, $Sender, $Session);
        }
    } else {
        echo '<ul class="DataList ActivityComments Hidden">';
    }
    if ($Session->CheckPermission('Garden.Profiles.Edit')) {
        ?>
      <li class="CommentForm">
      <?php 
        echo Anchor(T('Write a comment'), '/dashboard/activity/comment/' . $Activity->ActivityID, 'CommentLink');
        $CommentForm = Gdn::Factory('Form');
        $CommentForm->SetModel($Sender->ActivityModel);
        $CommentForm->AddHidden('ActivityID', $Activity->ActivityID);
        $CommentForm->AddHidden('Return', Gdn_Url::Request());
        echo $CommentForm->Open(array('action' => Url('/dashboard/activity/comment'), 'class' => 'Hidden'));
        echo '<div class="TextBoxWrapper">' . $CommentForm->TextBox('Body', array('MultiLine' => TRUE, 'value' => '')) . '</div>';
        echo $CommentForm->Close('Comment');
        ?>
</li>
   <?php 
    }
    echo '</ul>';
    ?>
</li>
<?php 
}
 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload. 
  *
  * @since 2.0.18
  * @access public
  *
  * @param object $Sender The object calling this method.
  */
 public static function InformNotifications($Sender)
 {
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     // Set the user's DateLastInform attribute to now. This value can be used
     // by addons to determine if their inform messages have already been sent.
     $InformLastActivityID = $Session->GetAttribute('Notifications.InformLastActivityID', 0);
     // Allow pluggability
     $Sender->EventArguments['InformLastActivityID'] =& $InformLastActivityID;
     $Sender->FireEvent('BeforeInformNotifications');
     // Retrieve default preferences
     $Preferences = array();
     $DefaultPreferences = C('Preferences.Popup', array());
     foreach ($DefaultPreferences as $Preference => $Val) {
         if ($Val) {
             $Preferences[] = $Preference;
         }
     }
     //		$User = Gdn::Database()->SQL()->Select('Preferences')->From('User')->Where('UserID', $Session->UserID)->Get()->FirstRow();
     //      if ($User) {
     //         $PrefData = Gdn_Format::Unserialize($User->Preferences);
     //			foreach ($PrefData as $Pref => $Val) {
     //				if (substr($Pref, 0, 6) == 'Popup.') {
     //					$Pref = substr($Pref, 6);
     //					if ($Val) {
     //						$Preferences[] = $Pref;
     //					} else {
     //						if (in_array($Pref, $Preferences))
     //							unset($Preferences[array_search($Pref, $Preferences)]);
     //					}
     //				}
     //			}
     //		}
     //		if (count($Preferences) > 0) {
     // Grab the activity type ids for the desired notification prefs.
     $ActivityTypeIDs = array();
     //         $ActivityTypes = array();
     $Data = Gdn::Database()->SQL()->GetWhere('ActivityType', array('Notify' => TRUE))->ResultArray();
     //  ->WhereIn('Name', $Preferences)->Get();
     foreach ($Data as $ActivityType) {
         if (Gdn::Session()->GetPreference("Popup.{$ActivityType['Name']}", C("Preferences.Popup.{$ActivityType['Name']}", TRUE))) {
             $ActivityTypeIDs[] = $ActivityType['ActivityTypeID'];
             //               $ActivityTypes[] = $ActivityType['Name'];
         }
     }
     if (count($ActivityTypeIDs) > 0) {
         // Retrieve new notifications
         $ActivityModel = new ActivityModel();
         $NotificationData = $ActivityModel->GetNotificationsSince($Session->UserID, $InformLastActivityID, $ActivityTypeIDs);
         $InformLastActivityID = -1;
         // Add (no more than 5) notifications to the inform stack
         foreach ($NotificationData->Result() as $Notification) {
             // Make sure the user wants to be notified of this
             //					if (!in_array($Notification->ActivityType, $Preferences)) {
             //                  continue;
             //               }
             $UserPhoto = UserPhoto(UserBuilder($Notification, 'Activity'), 'Icon');
             $ActivityType = explode(' ', $Notification->ActivityType);
             $ActivityType = $ActivityType[0];
             $Excerpt = $Notification->Story;
             if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
                 $Excerpt = Gdn_Format::Display($Excerpt);
             }
             // Inform the user of new messages
             $Sender->InformMessage($UserPhoto . Wrap(Gdn_Format::ActivityHeadline($Notification, $Session->UserID), 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . ($UserPhoto == '' ? '' : ' HasIcon'));
             // Assign the most recent activity id
             if ($InformLastActivityID == -1) {
                 $InformLastActivityID = $Notification->ActivityID;
             }
         }
     }
     //		}
     if ($InformLastActivityID > 0) {
         Gdn::UserModel()->SaveAttribute($Session->UserID, 'Notifications.InformLastActivityID', $InformLastActivityID);
     }
 }
Ejemplo n.º 13
0
   <ul class="PanelActivity">
      <?php 
foreach ($this->_ActivityData->Result() as $Activity) {
    echo '<li class="Activity ' . $Activity->ActivityType . '">';
    // If this was a status update or a wall comment, don't bother with activity strings
    $ActivityType = explode(' ', $Activity->ActivityType);
    // Make sure you strip out any extra css classes munged in here
    $ActivityType = $ActivityType[0];
    $Author = UserBuilder($Activity, 'Activity');
    if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
        echo UserAnchor($Author, 'Name');
        if ($Activity->ActivityType == 'WallComment' && $Activity->RegardingUserID > 0) {
            $Author = UserBuilder($Activity, 'Regarding');
            echo '<span>&rarr;</span>' . UserAnchor($Author, 'Name');
        }
        echo Gdn_Format::Display($Activity->Story);
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
    } else {
        echo Gdn_Format::ActivityHeadline($Activity);
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
        if ($Activity->Story != '') {
            echo '<div class="Story">';
            echo $Activity->Story;
            echo '</div>';
        }
    }
    echo '</li>';
}
?>
      <li class="ShowAll"><?php 
echo Anchor(T('↳ Show All'), 'activity');
Ejemplo n.º 14
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
$Session = Gdn::Session();
?>
<div class="User">
   <h1><?php 
echo $this->User->Name;
?>
 <a onclick="parent.location='//<?php 
echo DOMAIN;
?>
/account/<?php 
echo $this->User->UserID;
?>
'">(View muzombies.org Profile)</a></h1>
   <?php 
if ($this->User->About != '') {
    echo '<div id="Status">' . Gdn_Format::Display($this->User->About);
    if ($this->User->About != '' && ($Session->UserID == $this->User->UserID || $Session->CheckPermission('Garden.Users.Edit'))) {
        echo ' - ' . Anchor(T('Clear'), '/profile/clear/' . $this->User->UserID . '/' . $Session->TransientKey(), 'Change');
    }
    echo '</div>';
}
?>
</div>
Ejemplo n.º 15
0
 public function Post($Notify = FALSE, $UserID = FALSE)
 {
     if (is_numeric($Notify)) {
         $UserID = $Notify;
         $Notify = FALSE;
     }
     if (!$UserID) {
         $UserID = Gdn::Session()->UserID;
     }
     switch ($Notify) {
         case 'mods':
             $this->Permission('Garden.Moderation.Manage');
             $NotifyUserID = ActivityModel::NOTIFY_MODS;
             break;
         case 'admins':
             $this->Permission('Garden.Settings.Manage');
             $NotifyUserID = ActivityModel::NOTIFY_ADMINS;
             break;
         default:
             $this->Permission('Garden.Profiles.Edit');
             $NotifyUserID = ActivityModel::NOTIFY_PUBLIC;
             break;
     }
     $Activities = array();
     if ($this->Form->IsPostBack()) {
         $Data = $this->Form->FormValues();
         $Data = $this->ActivityModel->FilterForm($Data);
         $Data['Format'] = C('Garden.InputFormatter');
         if ($UserID != Gdn::Session()->UserID) {
             // This is a wall post.
             $Activity = array('ActivityType' => 'WallPost', 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::Session()->UserID, 'HeadlineFormat' => T('HeadlineFormat.WallPost', '{RegardingUserID,you} &rarr; {ActivityUserID,you}'), 'Story' => $Data['Comment'], 'Format' => $Data['Format']);
         } else {
             // This is a status update.
             $Activity = array('ActivityType' => 'Status', 'HeadlineFormat' => T('HeadlineFormat.Status', '{ActivityUserID,user}'), 'Story' => $Data['Comment'], 'Format' => $Data['Format'], 'NotifyUserID' => $NotifyUserID);
             $this->SetJson('StatusMessage', Gdn_Format::Display($Data['Comment']));
         }
         $Activity = $this->ActivityModel->Save($Activity, FALSE, array('CheckSpam' => TRUE));
         if ($Activity == SPAM) {
             $this->StatusMessage = T('Your post has been flagged for moderation.');
             $this->Render('Blank', 'Utility');
             return;
         }
         if ($Activity) {
             if ($UserID == Gdn::Session()->UserID && $NotifyUserID == ActivityModel::NOTIFY_PUBLIC) {
                 Gdn::UserModel()->SetField(Gdn::Session()->UserID, 'About', Gdn_Format::PlainText($Activity['Story'], $Activity['Format']));
             }
             $Activities = array($Activity);
             ActivityModel::JoinUsers($Activities);
             $this->ActivityModel->CalculateData($Activities);
         }
     }
     if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
         Redirect($this->Request->Get('Target', '/activity'));
     }
     $this->SetData('Activities', $Activities);
     $this->Render('Activities');
 }