Example #1
0
 public static function Breadcrumbs($Data, $HomeLink = TRUE, $Options = array())
 {
     $Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
     $Result = '';
     if (!is_array($Data)) {
         $Data = array();
     }
     if ($HomeLink) {
         $HomeUrl = GetValue('HomeUrl', $Options);
         if (!$HomeUrl) {
             $HomeUrl = Url('/', TRUE);
         }
         $Row = array('Name' => $HomeLink, 'Url' => $HomeUrl, 'CssClass' => 'CrumbLabel HomeCrumb');
         if (!is_string($HomeLink)) {
             $Row['Name'] = T('Home');
         }
         array_unshift($Data, $Row);
     }
     if (GetValue('HideLast', $Options)) {
         // Remove the last item off the list.
         array_pop($Data);
     }
     $DefaultRoute = ltrim(GetValue('Destination', Gdn::Router()->GetRoute('DefaultController'), ''), '/');
     $Count = 0;
     $DataCount = 0;
     $HomeLinkFound = false;
     foreach ($Data as $Row) {
         $DataCount++;
         if ($HomeLinkFound && Gdn::Request()->UrlCompare($Row['Url'], $DefaultRoute) === 0) {
             continue;
             // don't show default route twice.
         } else {
             $HomeLinkFound = true;
         }
         // Add the breadcrumb wrapper.
         if ($Count > 0) {
             $Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
         }
         $Row['Url'] = Url($Row['Url']);
         $CssClass = 'CrumbLabel ' . GetValue('CssClass', $Row);
         if ($DataCount == count($Data)) {
             $CssClass .= ' Last';
         }
         $Label = '<span class="' . $CssClass . '">' . FormatString($Format, $Row) . '</span> ';
         $Result = ConcatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
         $Count++;
     }
     // Close the stack.
     for ($Count--; $Count > 0; $Count--) {
         $Result .= '</span>';
     }
     $Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
     return $Result;
 }
function GetPrice($symbol)
{
    //google finance can only handle up to 100 quotes at a time so split up query then merge results
    if (count($symbol) > 100) {
        $retArr = array();
        for ($j = 0; $j < count($symbol); $j += 100) {
            $arr = LookUpWithFormattedString(FormatString(array_slice($symbol, $j, 100)));
            $retArr = array_merge($retArr, $arr);
        }
        return $retArr;
    } else {
        return LookUpWithFormattedString(FormatString($symbol));
    }
}
 public static function connectButton($Provider, $Options = array())
 {
     if (!is_array($Provider)) {
         $Provider = self::getProvider($Provider);
     }
     $Url = htmlspecialchars(self::connectUrl($Provider));
     $Data = $Provider;
     $Target = Gdn::Request()->Get('Target');
     if (!$Target) {
         $Target = '/' . ltrim(Gdn::Request()->Path());
     }
     if (StringBeginsWith($Target, '/entry/signin')) {
         $Target = '/';
     }
     $ConnectQuery = array('client_id' => $Provider['AuthenticationKey'], 'Target' => $Target);
     $Data['Target'] = urlencode(Url('entry/jsconnect', TRUE) . '?' . http_build_query($ConnectQuery));
     $Data['Redirect'] = $Data['target'] = $Data['redirect'] = $Data['Target'];
     $SignInUrl = FormatString(GetValue('SignInUrl', $Provider, ''), $Data);
     $RegisterUrl = FormatString(GetValue('RegisterUrl', $Provider, ''), $Data);
     if ($RegisterUrl && !GetValue('NoRegister', $Options)) {
         $RegisterLink = ' ' . Anchor(sprintf(T('Register with %s', 'Register'), $Provider['Name']), $RegisterUrl, 'Button RegisterLink');
     } else {
         $RegisterLink = '';
     }
     if (IsMobile()) {
         $PopupWindow = '';
     } else {
         $PopupWindow = 'PopupWindow';
     }
     if (GetValue('NoConnectLabel', $Options)) {
         $ConnectLabel = '';
     } else {
         $ConnectLabel = '<span class="Username"></span><div class="ConnectLabel TextColor">' . sprintf(T('Sign In with %s'), $Provider['Name']) . '</div>';
     }
     if (!C('Plugins.JsConnect.NoGuestCheck')) {
         $Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="' . $Url . '">';
         if (!GetValue('IsDefault', $Provider)) {
             $Result .= '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
         }
         $Result .= '<div class="JsConnect-Connect"><a class="ConnectLink">' . Img('https://cd8ba0b44a15c10065fd-24461f391e20b7336331d5789078af53.ssl.cf1.rackcdn.com/images/usericon_50.png', array('class' => 'ProfilePhotoSmall UserPhoto')) . $ConnectLabel . '</a></div>';
         $Result .= '</div>';
     } else {
         if (!GetValue('IsDefault', $Provider)) {
             $Result = '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
         }
     }
     return $Result;
 }
   public static function Breadcrumbs($Data, $Format, $HomeLink = TRUE) {
      $Result = '';

      if ($HomeLink) {
         if (!is_string($HomeLink))
            $HomeLink = T('Home');
            $Result .= '<span class="Label"><a href="'.Url('/').'">'.$HomeLink.'</a></span>';
      }

      foreach ($Data as $Row) {
         $Label = '<span class="Label">'.FormatString($Format, $Row).'</span>';
         $Result = ConcatSep('<span class="Crumb">'.T('Breadcrumbs Crumb', '&raquo;').'</span>', $Result, $Label);
      }

      $Result ='<span class="BreadCrumbs">'.$Result.'</span>';
      return $Result;
   }
 protected function DrawEdited($Sender)
 {
     $Record = $Sender->Data('Discussion');
     if (!$Record) {
         $Record = $Sender->Data('Record');
     }
     if (!$Record) {
         return;
     }
     $PermissionCategoryID = GetValue('PermissionCategoryID', $Record);
     $Data = $Record;
     $RecordType = 'discussion';
     $RecordID = GetValue('DiscussionID', $Data);
     // But override if comment
     if (isset($Sender->EventArguments['Comment']) || GetValue('RecordType', $Record) == 'comment') {
         $Data = $Sender->EventArguments['Comment'];
         $RecordType = 'comment';
         $RecordID = GetValue('CommentID', $Data);
     }
     $UserCanEdit = Gdn::Session()->CheckPermission('Vanilla.' . ucfirst($RecordType) . 's.Edit', TRUE, 'Category', $PermissionCategoryID);
     if (is_null($Data->DateUpdated)) {
         return;
     }
     if (Gdn_Format::ToTimestamp($Data->DateUpdated) <= Gdn_Format::ToTimestamp($Data->DateInserted)) {
         return;
     }
     $SourceUserID = $Data->InsertUserID;
     $UpdatedUserID = $Data->UpdateUserID;
     $UserData = Gdn::UserModel()->GetID($UpdatedUserID);
     $Edited = array('EditUser' => GetValue('Name', $UserData, T('Unknown User')), 'EditDate' => Gdn_Format::Date($Data->DateUpdated, 'html'), 'EditLogUrl' => Url("/log/record/{$RecordType}/{$RecordID}"), 'EditWord' => 'at');
     $DateUpdateTime = Gdn_Format::ToTimestamp($Data->DateUpdated);
     if (date('ymd', $DateUpdateTime) != date('ymd')) {
         $Edited['EditWord'] = 'on';
     }
     $Format = T('PostEdited.Plain', 'Post edited by {EditUser} {EditWord} {EditDate}');
     if ($UserCanEdit) {
         $Format = T('PostEdited.Log', 'Post edited by {EditUser} {EditWord} {EditDate} (<a href="{EditLogUrl}">log</a>)');
     }
     $Display = '<div class="PostEdited">' . FormatString($Format, $Edited) . '</div>';
     echo $Display;
 }
Example #6
0
 public static function Breadcrumbs($Data, $HomeLink = TRUE)
 {
     $Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
     $Result = '';
     if (!is_array($Data)) {
         $Data = array();
     }
     if ($HomeLink) {
         $Row = array('Name' => $HomeLink, 'Url' => Url('/', TRUE), 'CssClass' => 'CrumbLabel HomeCrumb');
         if (!is_string($HomeLink)) {
             $Row['Name'] = T('Home');
         }
         array_unshift($Data, $Row);
     }
     $DefaultRoute = ltrim(GetValue('Destination', Gdn::Router()->GetRoute('DefaultController'), ''), '/');
     $Count = 0;
     foreach ($Data as $Row) {
         if (ltrim($Row['Url'], '/') == $DefaultRoute && $HomeLink) {
             continue;
         }
         // don't show default route twice.
         // Add the breadcrumb wrapper.
         if ($Count > 0) {
             $Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
         }
         $Row['Url'] = Url($Row['Url']);
         $CssClass = GetValue('CssClass', $Row, 'CrumbLabel');
         $Label = '<span class="' . $CssClass . '">' . FormatString($Format, $Row) . '</span> ';
         $Result = ConcatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
         $Count++;
     }
     // Close the stack.
     for ($Count--; $Count > 0; $Count--) {
         $Result .= '</span>';
     }
     $Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
     return $Result;
 }
 /**
  * Delete cached data for user
  * 
  * @param type $UserID
  * @return type 
  */
 public function ClearCache($UserID, $CacheTypesToClear = NULL)
 {
     if (is_null($UserID) || !$UserID) {
         return FALSE;
     }
     if (is_null($CacheTypesToClear)) {
         $CacheTypesToClear = array('user', 'roles', 'permissions');
     }
     if (in_array('user', $CacheTypesToClear)) {
         $UserKey = FormatString(self::USERID_KEY, array('UserID' => $UserID));
         Gdn::Cache()->Remove($UserKey);
     }
     if (in_array('roles', $CacheTypesToClear)) {
         $UserRolesKey = FormatString(self::USERROLES_KEY, array('UserID' => $UserID));
         Gdn::Cache()->Remove($UserRolesKey);
     }
     if (in_array('permissions', $CacheTypesToClear)) {
         Gdn::SQL()->Put('User', array('Permissions' => ''), array('UserID' => $UserID));
         $PermissionsIncrement = $this->GetPermissionsIncrement();
         $UserPermissionsKey = FormatString(self::USERPERMISSIONS_KEY, array('UserID' => $UserID, 'PermissionsIncrement' => $PermissionsIncrement));
         Gdn::Cache()->Remove($UserPermissionsKey);
     }
     return TRUE;
 }
 function GetRecord($RecordType, $ID, $ThrowError = FALSE)
 {
     $Row = FALSE;
     switch (strtolower($RecordType)) {
         case 'discussion':
             $Model = new DiscussionModel();
             $Row = $Model->GetID($ID);
             $Row->Url = DiscussionUrl($Row);
             $Row->ShareUrl = $Row->Url;
             if ($Row) {
                 return (array) $Row;
             }
             break;
         case 'comment':
             $Model = new CommentModel();
             $Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Url'] = Url("/discussion/comment/{$ID}#Comment_{$ID}", TRUE);
                 $Model = new DiscussionModel();
                 $Discussion = $Model->GetID($Row['DiscussionID']);
                 if ($Discussion) {
                     $Discussion->Url = DiscussionUrl($Discussion);
                     $Row['ShareUrl'] = $Discussion->Url;
                     $Row['Name'] = $Discussion->Name;
                     $Row['Discussion'] = (array) $Discussion;
                 }
                 return $Row;
             }
             break;
         case 'activity':
             $Model = new ActivityModel();
             $Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Name'] = FormatString($Row['HeadlineFormat'], $Row);
                 $Row['Body'] = $Row['Story'];
                 return $Row;
             }
         default:
             throw new Gdn_UserException(sprintf("I don't know what a %s is.", strtolower($RecordType)));
     }
     if ($ThrowError) {
         throw NotFoundException($RecordType);
     } else {
         return FALSE;
     }
 }
 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         $RedirectLink = $Sender->Form->GetFormValue('RedirectLink');
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             $DiscussionModel->DefineSchema();
             $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     if ($RedirectLink) {
                         // The discussion needs to be changed to a moved link.
                         $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => FormatString(T('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
                         $DiscussionModel->SetField($Discussion['DiscussionID'], $RedirectDiscussion);
                         $CommentModel->UpdateCommentCount($Discussion['DiscussionID']);
                         $CommentModel->RemovePageCache($Discussion['DiscussionID']);
                     } else {
                         // Delete discussion that was merged.
                         $DiscussionModel->Delete($Discussion['DiscussionID']);
                     }
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->JsonTarget('', '', 'Refresh');
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
 public function setSignatureRules(&$Sender)
 {
     $rules = array();
     $rulesParams = array();
     $imagesAllowed = true;
     if (C('Plugins.Signatures.MaxNumberImages', 'Unlimited') !== 'Unlimited') {
         if (C('Plugins.Signatures.MaxNumberImages') === 'None') {
             $rules[] = T('Images not allowed.');
             $imagesAllowed = false;
         } else {
             $rulesParams['maxImages'] = C('Plugins.Signatures.MaxNumberImages');
             $rules[] = FormatString(T('Use up to {maxImages,plural,%s image, %s images}.'), $rulesParams);
         }
     }
     if ($imagesAllowed && C('Plugins.Signatures.MaxImageHeight') && C('Plugins.Signatures.MaxImageHeight') > 0) {
         $rulesParams['maxImageHeight'] = C('Plugins.Signatures.MaxImageHeight');
         $rules[] = FormatString(T('Images will be scaled to a maximum height of {maxImageHeight}px.'), $rulesParams);
     }
     if (C('Plugins.Signatures.MaxLength') && C('Plugins.Signatures.MaxLength') > 0) {
         $rulesParams['maxLength'] = C('Plugins.Signatures.MaxLength');
         $rules[] = FormatString(T('Signatures can be up to {maxLength} characters long.'), $rulesParams);
     }
     $Sender->SetData('SignatureRules', implode(' ', $rules));
 }
Example #11
0
<?php

if (!defined('APPLICATION')) {
    return;
}
?>
<h1><?php 
echo $this->Data('Title');
?>
</h1>
<div class="Wrap">
<?php 
echo $this->Form->Open();
echo $this->Form->Errors();
?>

<div class="DismissMessage WarningMessage">
   <?php 
echo FormatString(T('You are about to unban {User.UserID,user}.'), $this->Data);
?>
</div>
   
<?php 
if ($LogID = $this->Data('User.Attributes.BanLogID')) {
    echo '<div class="P">', $this->Form->CheckBox('RestoreContent', "Restore deleted content."), '</div>';
}
echo '<div class="Buttons P">', $this->Form->Button('Unban'), '</div>';
echo $this->Form->Close();
?>
</div>
Example #12
0
 /**
  * Create or update a comment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique ID to add the comment to. If blank, this method will throw an error.
  */
 public function Comment($DiscussionID = '')
 {
     // Get $DiscussionID from RequestArgs if valid
     if ($DiscussionID == '' && count($this->RequestArgs)) {
         if (is_numeric($this->RequestArgs[0])) {
             $DiscussionID = $this->RequestArgs[0];
         }
     }
     // If invalid $DiscussionID, get from form.
     $this->Form->SetModel($this->CommentModel);
     $DiscussionID = is_numeric($DiscussionID) ? $DiscussionID : $this->Form->GetFormValue('DiscussionID', 0);
     // Set discussion data
     $this->DiscussionID = $DiscussionID;
     $this->Discussion = $Discussion = $this->DiscussionModel->GetID($DiscussionID);
     // Is this an embedded comment being posted to a discussion that doesn't exist yet?
     $vanilla_type = $this->Form->GetFormValue('vanilla_type', '');
     $vanilla_url = $this->Form->GetFormValue('vanilla_url', '');
     $vanilla_category_id = $this->Form->GetFormValue('vanilla_category_id', '');
     $Attributes = array('ForeignUrl' => $vanilla_url);
     $vanilla_identifier = $this->Form->GetFormValue('vanilla_identifier', '');
     // Only allow vanilla identifiers of 32 chars or less - md5 if larger
     if (strlen($vanilla_identifier) > 32) {
         $Attributes['vanilla_identifier'] = $vanilla_identifier;
         $vanilla_identifier = md5($vanilla_identifier);
     }
     if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
         $Discussion = $Discussion = $this->DiscussionModel->GetForeignID($vanilla_identifier, $vanilla_type);
         if ($Discussion) {
             $this->DiscussionID = $DiscussionID = $Discussion->DiscussionID;
             $this->Form->SetValue('DiscussionID', $DiscussionID);
         }
     }
     // If so, create it!
     if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
         // Add these values back to the form if they exist!
         $this->Form->AddHidden('vanilla_identifier', $vanilla_identifier);
         $this->Form->AddHidden('vanilla_type', $vanilla_type);
         $this->Form->AddHidden('vanilla_url', $vanilla_url);
         $this->Form->AddHidden('vanilla_category_id', $vanilla_category_id);
         $PageInfo = FetchPageInfo($vanilla_url);
         if (!($Title = $this->Form->GetFormValue('Name'))) {
             $Title = GetValue('Title', $PageInfo, '');
             if ($Title == '') {
                 $Title = T('Undefined discussion subject.');
             }
         }
         $Description = GetValue('Description', $PageInfo, '');
         $Images = GetValue('Images', $PageInfo, array());
         $LinkText = T('EmbededDiscussionLinkText', 'Read the full story here');
         if (!$Description && count($Images) == 0) {
             $Body = FormatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
         } else {
             $Body = FormatString('
         <div class="EmbeddedContent">{Image}<strong>{Title}</strong>
            <p>{Excerpt}</p>
            <p><a href="{Url}">{LinkText}</a></p>
            <div class="ClearFix"></div>
         </div>', array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? Img(GetValue(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $vanilla_url, 'LinkText' => $LinkText));
         }
         if ($Body == '') {
             $Body = $vanilla_url;
         }
         if ($Body == '') {
             $Body = T('Undefined discussion body.');
         }
         // Validate the CategoryID for inserting.
         $Category = CategoryModel::Categories($vanilla_category_id);
         if (!$Category) {
             $vanilla_category_id = C('Vanilla.Embed.DefaultCategoryID', 0);
             if ($vanilla_category_id <= 0) {
                 // No default category defined, so grab the first non-root category and use that.
                 $vanilla_category_id = $this->DiscussionModel->SQL->Select('CategoryID')->From('Category')->Where('CategoryID >', 0)->Get()->FirstRow()->CategoryID;
                 // No categories in the db? default to 0
                 if (!$vanilla_category_id) {
                     $vanilla_category_id = 0;
                 }
             }
         } else {
             $vanilla_category_id = $Category['CategoryID'];
         }
         $EmbedUserID = C('Garden.Embed.UserID');
         if ($EmbedUserID) {
             $EmbedUser = Gdn::UserModel()->GetID($EmbedUserID);
         }
         if (!$EmbedUserID || !$EmbedUser) {
             $EmbedUserID = Gdn::UserModel()->GetSystemUserID();
         }
         $EmbeddedDiscussionData = array('InsertUserID' => $EmbedUserID, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'CategoryID' => $vanilla_category_id, 'ForeignID' => $vanilla_identifier, 'Type' => $vanilla_type, 'Name' => $Title, 'Body' => $Body, 'Format' => 'Html', 'Attributes' => serialize($Attributes));
         $this->EventArguments['Discussion'] = $EmbeddedDiscussionData;
         $this->FireEvent('BeforeEmbedDiscussion');
         $DiscussionID = $this->DiscussionModel->SQL->Insert('Discussion', $EmbeddedDiscussionData);
         $ValidationResults = $this->DiscussionModel->ValidationResults();
         if (count($ValidationResults) == 0 && $DiscussionID > 0) {
             $this->Form->AddHidden('DiscussionID', $DiscussionID);
             // Put this in the form so reposts won't cause new discussions.
             $this->Form->SetFormValue('DiscussionID', $DiscussionID);
             // Put this in the form values so it is used when saving comments.
             $this->SetJson('DiscussionID', $DiscussionID);
             $this->Discussion = $Discussion = $this->DiscussionModel->GetID($DiscussionID, DATASET_TYPE_OBJECT, array('Slave' => FALSE));
             // Update the category discussion count
             if ($vanilla_category_id > 0) {
                 $this->DiscussionModel->UpdateDiscussionCount($vanilla_category_id, $DiscussionID);
             }
         }
     }
     // If no discussion was found, error out
     if (!$Discussion) {
         $this->Form->AddError(T('Failed to find discussion for commenting.'));
     }
     $PermissionCategoryID = GetValue('PermissionCategoryID', $Discussion);
     // Setup head
     $this->AddJsFile('jquery.autosize.min.js');
     $this->AddJsFile('post.js');
     $this->AddJsFile('autosave.js');
     // Setup comment model, $CommentID, $DraftID
     $Session = Gdn::Session();
     $CommentID = isset($this->Comment) && property_exists($this->Comment, 'CommentID') ? $this->Comment->CommentID : '';
     $DraftID = isset($this->Comment) && property_exists($this->Comment, 'DraftID') ? $this->Comment->DraftID : '';
     $this->EventArguments['CommentID'] = $CommentID;
     $this->EventArguments['DraftID'] = $DraftID;
     // Determine whether we are editing
     $Editing = $CommentID > 0 || $DraftID > 0;
     $this->EventArguments['Editing'] = $Editing;
     // If closed, cancel & go to discussion
     if ($Discussion && $Discussion->Closed == 1 && !$Editing && !$Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID)) {
         Redirect(DiscussionUrl($Discussion));
     }
     // Add hidden IDs to form
     $this->Form->AddHidden('DiscussionID', $DiscussionID);
     $this->Form->AddHidden('CommentID', $CommentID);
     $this->Form->AddHidden('DraftID', $DraftID, TRUE);
     // Check permissions
     if ($Discussion && $Editing) {
         // Permisssion to edit
         if ($this->Comment->InsertUserID != $Session->UserID) {
             $this->Permission('Vanilla.Comments.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
         }
         // Make sure that content can (still) be edited.
         $EditContentTimeout = C('Garden.EditContentTimeout', -1);
         $CanEdit = $EditContentTimeout == -1 || strtotime($this->Comment->DateInserted) + $EditContentTimeout > time();
         if (!$CanEdit) {
             $this->Permission('Vanilla.Comments.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
         }
         // Make sure only moderators can edit closed things
         if ($Discussion->Closed) {
             $this->Permission('Vanilla.Comments.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
         }
         $this->Form->SetFormValue('CommentID', $CommentID);
     } else {
         if ($Discussion) {
             // Permission to add
             $this->Permission('Vanilla.Comments.Add', TRUE, 'Category', $Discussion->PermissionCategoryID);
         }
     }
     if (!$this->Form->IsPostBack()) {
         // Form was validly submitted
         if (isset($this->Comment)) {
             $this->Form->SetData((array) $this->Comment);
         }
     } else {
         // Save as a draft?
         $FormValues = $this->Form->FormValues();
         $FormValues = $this->CommentModel->FilterForm($FormValues);
         if ($DraftID == 0) {
             $DraftID = $this->Form->GetFormValue('DraftID', 0);
         }
         $Type = GetIncomingValue('Type');
         $Draft = $Type == 'Draft';
         $this->EventArguments['Draft'] = $Draft;
         $Preview = $Type == 'Preview';
         if ($Draft) {
             $DraftID = $this->DraftModel->Save($FormValues);
             $this->Form->AddHidden('DraftID', $DraftID, TRUE);
             $this->Form->SetValidationResults($this->DraftModel->ValidationResults());
         } else {
             if (!$Preview) {
                 // Fix an undefined title if we can.
                 if ($this->Form->GetFormValue('Name') && GetValue('Name', $Discussion) == T('Undefined discussion subject.')) {
                     $Set = array('Name' => $this->Form->GetFormValue('Name'));
                     if (isset($vanilla_url) && $vanilla_url && strpos(GetValue('Body', $Discussion), T('Undefined discussion subject.')) !== FALSE) {
                         $LinkText = T('EmbededDiscussionLinkText', 'Read the full story here');
                         $Set['Body'] = FormatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
                     }
                     $this->DiscussionModel->SetField(GetValue('DiscussionID', $Discussion), $Set);
                 }
                 $Inserted = !$CommentID;
                 $CommentID = $this->CommentModel->Save($FormValues);
                 // The comment is now half-saved.
                 if (is_numeric($CommentID) && $CommentID > 0) {
                     if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                         $this->CommentModel->Save2($CommentID, $Inserted, TRUE, TRUE);
                     } else {
                         $this->JsonTarget('', Url("/vanilla/post/comment2.json?commentid={$CommentID}&inserted={$Inserted}"), 'Ajax');
                     }
                     // $Discussion = $this->DiscussionModel->GetID($DiscussionID);
                     $Comment = $this->CommentModel->GetID($CommentID, DATASET_TYPE_OBJECT, array('Slave' => FALSE));
                     $this->EventArguments['Discussion'] = $Discussion;
                     $this->EventArguments['Comment'] = $Comment;
                     $this->FireEvent('AfterCommentSave');
                 } elseif ($CommentID === SPAM || $CommentID === UNAPPROVED) {
                     $this->StatusMessage = T('CommentRequiresApprovalStatus', 'Your comment will appear after it is approved.');
                 }
                 $this->Form->SetValidationResults($this->CommentModel->ValidationResults());
                 if ($CommentID > 0 && $DraftID > 0) {
                     $this->DraftModel->Delete($DraftID);
                 }
             }
         }
         // Handle non-ajax requests first:
         if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
             if ($this->Form->ErrorCount() == 0) {
                 // Make sure that this form knows what comment we are editing.
                 if ($CommentID > 0) {
                     $this->Form->AddHidden('CommentID', $CommentID);
                 }
                 // If the comment was not a draft
                 if (!$Draft) {
                     // Redirect to the new comment.
                     if ($CommentID > 0) {
                         Redirect("discussion/comment/{$CommentID}/#Comment_{$CommentID}");
                     } elseif ($CommentID == SPAM) {
                         $this->SetData('DiscussionUrl', DiscussionUrl($Discussion));
                         $this->View = 'Spam';
                     }
                 } elseif ($Preview) {
                     // If this was a preview click, create a comment shell with the values for this comment
                     $this->Comment = new stdClass();
                     $this->Comment->InsertUserID = $Session->User->UserID;
                     $this->Comment->InsertName = $Session->User->Name;
                     $this->Comment->InsertPhoto = $Session->User->Photo;
                     $this->Comment->DateInserted = Gdn_Format::Date();
                     $this->Comment->Body = ArrayValue('Body', $FormValues, '');
                     $this->Comment->Format = GetValue('Format', $FormValues, C('Garden.InputFormatter'));
                     $this->AddAsset('Content', $this->FetchView('preview'));
                 } else {
                     // If this was a draft save, notify the user about the save
                     $this->InformMessage(sprintf(T('Draft saved at %s'), Gdn_Format::Date()));
                 }
             }
         } else {
             // Handle ajax-based requests
             if ($this->Form->ErrorCount() > 0) {
                 // Return the form errors
                 $this->ErrorMessage($this->Form->Errors());
             } else {
                 // Make sure that the ajax request form knows about the newly created comment or draft id
                 $this->SetJson('CommentID', $CommentID);
                 $this->SetJson('DraftID', $DraftID);
                 if ($Preview) {
                     // If this was a preview click, create a comment shell with the values for this comment
                     $this->Comment = new stdClass();
                     $this->Comment->InsertUserID = $Session->User->UserID;
                     $this->Comment->InsertName = $Session->User->Name;
                     $this->Comment->InsertPhoto = $Session->User->Photo;
                     $this->Comment->DateInserted = Gdn_Format::Date();
                     $this->Comment->Body = ArrayValue('Body', $FormValues, '');
                     $this->View = 'preview';
                 } elseif (!$Draft) {
                     // If the comment was not a draft
                     // If Editing a comment
                     if ($Editing) {
                         // Just reload the comment in question
                         $this->Offset = 1;
                         $Comments = $this->CommentModel->GetIDData($CommentID, array('Slave' => FALSE));
                         $this->SetData('Comments', $Comments);
                         $this->SetData('Discussion', $Discussion);
                         // Load the discussion
                         $this->ControllerName = 'discussion';
                         $this->View = 'comments';
                         // Also define the discussion url in case this request came from the post screen and needs to be redirected to the discussion
                         $this->SetJson('DiscussionUrl', DiscussionUrl($this->Discussion) . '#Comment_' . $CommentID);
                     } else {
                         // If the comment model isn't sorted by DateInserted or CommentID then we can't do any fancy loading of comments.
                         $OrderBy = GetValueR('0.0', $this->CommentModel->OrderBy());
                         //                     $Redirect = !in_array($OrderBy, array('c.DateInserted', 'c.CommentID'));
                         //							$DisplayNewCommentOnly = $this->Form->GetFormValue('DisplayNewCommentOnly');
                         //                     if (!$Redirect) {
                         //                        // Otherwise load all new comments that the user hasn't seen yet
                         //                        $LastCommentID = $this->Form->GetFormValue('LastCommentID');
                         //                        if (!is_numeric($LastCommentID))
                         //                           $LastCommentID = $CommentID - 1; // Failsafe back to this new comment if the lastcommentid was not defined properly
                         //
                         //                        // Don't reload the first comment if this new comment is the first one.
                         //                        $this->Offset = $LastCommentID == 0 ? 1 : $this->CommentModel->GetOffset($LastCommentID);
                         //                        // Do not load more than a single page of data...
                         //                        $Limit = C('Vanilla.Comments.PerPage', 30);
                         //
                         //                        // Redirect if the new new comment isn't on the same page.
                         //                        $Redirect |= !$DisplayNewCommentOnly && PageNumber($this->Offset, $Limit) != PageNumber($Discussion->CountComments - 1, $Limit);
                         //                     }
                         //                     if ($Redirect) {
                         //                        // The user posted a comment on a page other than the last one, so just redirect to the last page.
                         //                        $this->RedirectUrl = Gdn::Request()->Url("discussion/comment/$CommentID/#Comment_$CommentID", TRUE);
                         //                     } else {
                         //                        // Make sure to load all new comments since the page was last loaded by this user
                         //								if ($DisplayNewCommentOnly)
                         $this->Offset = $this->CommentModel->GetOffset($CommentID);
                         $Comments = $this->CommentModel->GetIDData($CommentID, array('Slave' => FALSE));
                         $this->SetData('Comments', $Comments);
                         $this->SetData('NewComments', TRUE);
                         $this->ClassName = 'DiscussionController';
                         $this->ControllerName = 'discussion';
                         $this->View = 'comments';
                         //                     }
                         // Make sure to set the user's discussion watch records
                         $CountComments = $this->CommentModel->GetCount($DiscussionID);
                         $Limit = is_object($this->Data('Comments')) ? $this->Data('Comments')->NumRows() : $Discussion->CountComments;
                         $Offset = $CountComments - $Limit;
                         $this->CommentModel->SetWatch($this->Discussion, $Limit, $Offset, $CountComments);
                     }
                 } else {
                     // If this was a draft save, notify the user about the save
                     $this->InformMessage(sprintf(T('Draft saved at %s'), Gdn_Format::Date()));
                 }
                 // And update the draft count
                 $UserModel = Gdn::UserModel();
                 $CountDrafts = $UserModel->GetAttribute($Session->UserID, 'CountDrafts', 0);
                 $this->SetJson('MyDrafts', T('My Drafts'));
                 $this->SetJson('CountDrafts', $CountDrafts);
             }
         }
     }
     // Include data for FireEvent
     if (property_exists($this, 'Discussion')) {
         $this->EventArguments['Discussion'] = $this->Discussion;
     }
     if (property_exists($this, 'Comment')) {
         $this->EventArguments['Comment'] = $this->Comment;
     }
     $this->FireEvent('BeforeCommentRender');
     if ($this->DeliveryType() == DELIVERY_TYPE_DATA) {
         $Comment = $this->Data('Comments')->FirstRow(DATASET_TYPE_ARRAY);
         if ($Comment) {
             $Photo = $Comment['InsertPhoto'];
             if (strpos($Photo, '//') === FALSE) {
                 $Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
             }
             $Comment['InsertPhoto'] = $Photo;
         }
         $this->Data = array('Comment' => $Comment);
         $this->RenderData($this->Data);
     } else {
         require_once $this->FetchViewLocation('helper_functions', 'Discussion');
         // Render default view.
         $this->Render();
     }
 }
Example #13
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>

<h1><?php 
echo $this->Data('Title');
?>
</h1>
   <?php 
echo $this->Form->Open();
echo $this->Form->Errors();
echo Wrap(FormatString(T("ConfirmDeleteProfileField", "You are about to delete the profile field &ldquo;{Field.Label}&rdquo; from all users."), $this->Data), 'p');
echo '<div class="Buttons Buttons-Confirm">';
echo $this->Form->Button('Delete Field');
echo $this->Form->Button('Cancel', array('type' => 'button', 'class' => 'Button Close Cancel'));
echo '</div>';
echo $this->Form->Close();
Example #14
0
 /**
  *
  * @param Gdn_Controller $Sender
  */
 public function Base_Render_Before($Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         if ($PreviewThemeName != '') {
             $Sender->Theme = $PreviewThemeName;
             $Sender->InformMessage(sprintf(T('You are previewing the %s theme.'), Wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . Anchor(T('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->TransientKey(), 'PreviewThemeButton') . ' ' . Anchor(T('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->IsValid()) {
         $ConfirmEmail = C('Garden.Registration.ConfirmEmail', false);
         $Confirmed = GetValue('Confirmed', Gdn::Session()->User, true);
         if ($ConfirmEmail && !$Confirmed) {
             $Message = FormatString(T('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->InformMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     // 2011-09-09 - mosullivan - No longer allowing messages in dashboard
     //		if ($Sender->MasterView == 'admin')
     //			$Exceptions[] = '[Admin]';
     //		else if (in_array($Sender->MasterView, array('', 'default')))
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->DeliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->Data('_NoMessages') && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions, $Sender->Data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->AddModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::Factory('Statistics');
         $Gdn_Statistics->Check($Sender);
     }
     // Allow forum embedding
     if ($Embed = C('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = C('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 SaveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->AddDefinition('RemoteUrl', $RemoteUrl);
         }
         // Force embedding?
         if (!IsSearchEngine() && !IsMobile() && strtolower($Sender->ControllerName) != 'entry') {
             $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
             $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->AddDefinition('Path', Gdn::Request()->Path());
         // $Sender->AddDefinition('MasterView', $Sender->MasterView);
         $Sender->AddDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->AddJsFile('vanilla.embed.local.js');
         } else {
             $Sender->AddJsFile('embed_local.js');
         }
     } else {
         $Sender->SetHeader('X-Frame-Options', 'SAMEORIGIN');
     }
     // Allow return to mobile site
     $ForceNoMobile = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile');
     if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) {
         $Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
 }
function AddKrit($Array, $kriterium, $wert, $Tags)
{
    $kriterium = addslashes(FormatString($kriterium, "StripSpaces"));
    $kriterium = addslashes(FormatString($kriterium, "StripSpaces"));
    $Table = constant("DBTab" . $Array);
    if (!isset($_SESSION[$Array]) or !is_array($_SESSION[$Array])) {
        $_SESSION[$Array] = array();
    }
    $Vorhanden = DBQ("SELECT * FROM " . $Table . " WHERE Kriterium='" . $kriterium . "' AND Wert='" . $wert . "' AND Tags='" . $Tags . "'");
    if (count($Vorhanden) == 1) {
        // Wenn kein Fehler in der Query und kein Ergebniswert zurückgegeben wurde ...
        $ID = generateContentID($Table);
        if (strlen($Tags)) {
            $Tags = explode(",", $Tags);
            $InsertTagsID = array();
            $InsertTags = array();
            foreach ($Tags as $Tag) {
                $InsertTagsID[count($InsertTagsID)] = GenerateContentID(DBTabTags);
                $InsertTags[count($InsertTags)] = $Tag;
            }
        }
        DBIN($Table, "ID,Kriterium,Wert,Tags", "'" . $ID . "','" . $kriterium . "','" . $wert . "','" . $Tags . "'");
        // TODO Dies wird später erst erledigt, wenn die Hardware tatsächlich hinzugefügt wird.
    }
    $x = count($_SESSION[$Array]);
    $_SESSION[$Array][$x]['kriterium'] = $kriterium;
    $_SESSION[$Array][$x]['wert'] = $wert;
    $o = PrintKrits($_SESSION[$Array]);
    return $o;
}
 public function Entitled($CollaborativeTitle) {
    $this->CollaborativeTitle = $CollaborativeTitle;
    
    // Figure out how much space we have for the title
    $MaxLength = 90;
    $Stripped = FormatString($CollaborativeTitle,array(
       'RegardingTitle'     => ''
    ));
    $UsedLength = strlen($Stripped);
    $AvailableLength = $MaxLength - $UsedLength;
    
    // Check if the SourceElement contains a 'Name'
    $Name = GetValue('Name', $this->SourceElement, FALSE);
    
    // If not...
    if ($Name === FALSE) {
       // ...and we have a parent element...
       if (!is_null($this->ParentElement)) {
          // ...try to get a 'Name' from the parent
          $Name = GetValue('Name', $this->ParentElement, FALSE);
       }
    }
    
    // If all that failed, use the 'Body' of the source
    if ($Name === FALSE)
       $Name = GetValue('Body', $this->SourceElement, '');
    
    // Trim it if it is too long
    if (strlen($Name) > $AvailableLength)
       $Name = substr($Name, 0, $AvailableLength-3).'...';
    
    $CollaborativeTitle = FormatString($CollaborativeTitle,array(
       'RegardingTitle'     => $Name
    ));
    
    $this->CollaborativeTitle = $CollaborativeTitle;
    return $this;
 }
Example #17
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     Trace(FormatString($message, $context), 'FormattedMessage');
     Trace($context, 'context');
 }
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>

<h1><?php 
echo $this->Data('Title');
?>
</h1>
<div class="Wrap">
<?php 
echo $this->Form->Open();
echo $this->Form->Errors();
?>

<div class="Warning">
   <?php 
echo FormatString(T("You are about to delete all of a user's content.", "You are about to delete all of the content for {User.UserID,user}."), $this->Data);
?>
</div>
<?php 
echo '<div class="Buttons Buttons-Confirm">';
echo $this->Form->Button('Yes');
echo $this->Form->Button('No', array('type' => 'button', 'class' => 'Button Close'));
echo '</div>';
echo $this->Form->Close();
?>
   
</div>
Example #19
0
 public function FetchPageInfo($Url, $ThrowError = FALSE)
 {
     $PageInfo = FetchPageInfo($Url, 3, $ThrowError);
     $Title = GetValue('Title', $PageInfo, '');
     if ($Title == '') {
         if ($ThrowError) {
             throw new Gdn_UserException(T("The page didn't contain any information."));
         }
         $Title = FormatString(T('Undefined discussion subject.'), array('Url' => $Url));
     } else {
         if ($Strip = C('Vanilla.Embed.StripPrefix')) {
             $Title = StringBeginsWith($Title, $Strip, TRUE, TRUE);
         }
         if ($Strip = C('Vanilla.Embed.StripSuffix')) {
             $Title = StringEndsWith($Title, $Strip, TRUE, TRUE);
         }
     }
     $Title = trim($Title);
     $Description = GetValue('Description', $PageInfo, '');
     $Images = GetValue('Images', $PageInfo, array());
     $Body = FormatString(T('EmbeddedDiscussionFormat'), array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? Img(GetValue(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $Url));
     if ($Body == '') {
         $Body = $ForeignUrl;
     }
     if ($Body == '') {
         $Body = FormatString(T('EmbeddedNoBodyFormat.'), array('Url' => $Url));
     }
     $Result = array('Name' => $Title, 'Body' => $Body, 'Format' => 'Html');
     return $Result;
 }
Example #20
0
<div class="RegardingEvent">
   <span class="InformSprite Skull"/>&nbsp;</span> <?php 
echo FormatString(T("{ReportingUser} reported this {EntityType} written by {ReportedUser}"), array('ReportingUser' => UserAnchor(GetValue('ReportingUser', $this->Data('ReportInfo')), 'ReportingUser'), 'EntityType' => GetValue('EntityType', $this->Data('ReportInfo')), 'ReportedUser' => UserAnchor(GetValue('ReportedUser', $this->Data('ReportInfo')), 'ReportedUser')));
?>
   <div class="RegardingTime"><?php 
$ReportedDate = GetValue('ReportedTime', $this->Data('ReportInfo'));
echo Gdn_Format::FuzzyTime($ReportedDate);
?>
</div>
   <?php 
$ReportedReason = GetValue('ReportedReason', $this->Data('ReportInfo'), NULL);
if (!is_null($ReportedReason)) {
    ?>
         <div class="ReportedReason">"<?php 
    echo $ReportedReason;
    ?>
"</div>
         <?php 
}
?>
</div>
<div class="RegardingActions">
   <?php 
$ForeignURL = GetValue('ForeignURL', $this->Data('RegardingData'), NULL);
if (!is_null($ForeignURL)) {
    ?>
<div class="ActionButton"><a href="<?php 
    echo $ForeignURL;
    ?>
" title="<?php 
    echo T("Visit reported content location");
Example #21
0
 public function SaveActivity($User, $Level, $Reason)
 {
     $UserID = $User->UserID;
     $UserName = $User->Name;
     $HeadlineMods = $Level && $Level != 'None' ? T('Warning.HeadlineMods') : T('Warning.HeadlineModsClear');
     $HeadlineUser = $Level && $Level != 'None' ? T('Warning.HeadlineUser') : T('Warning.HeadlineUserClear');
     $StoryMod = $Level && $Level != 'None' ? T('Warning.NotifyModsMsg') : T('Warning.NotifyModsClearMsg');
     $StoryUser = $Level && $Level != 'None' ? T('Warning.NotifyUserMsg') : T('Warning.NotifyUserClearMsg');
     $ActivityModel = new ActivityModel();
     $Activity = array('ActivityType' => 'Warn', 'ActivityUserID' => Gdn::Session()->UserID, 'RegardingUserID' => $UserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'Story' => $StoryMod, 'RecordType' => 'Warn', 'Notified' => ActivityModel::SENT_PENDING, 'Emailed' => ActivityModel::SENT_PENDING, 'Data' => array('Level' => $Level), 'Level' => $Level, 'Name' => $UserName, 'Reason' => $Reason, 'HeadlineFormat' => $HeadlineMods, 'Route' => 'profile/' . $UserID . '/' . rawurlencode($UserName));
     $UserActivity = $Activity;
     $Activity['Story'] = FormatString($UserActivity['Story'], $Activity);
     $Activity['HeadlineFormat'] = FormatString($Activity['HeadlineFormat'], $Activity);
     $UserActivity['NotifyUserID'] = $UserID;
     $UserActivity['Story'] = FormatString($StoryUser, $Activity);
     $UserActivity['HeadlineFormat'] = FormatString($HeadlineUser, $Activity);
     // Mod Activity
     $ActivityModel->Save($Activity, FALSE, array('Force' => TRUE));
     // User Activity
     $ActivityModel->Save($UserActivity, FALSE, array('Force' => TRUE));
 }
 public static function SetUserRoles(&$Users, $UserIDColumn = 'UserID', $RolesColumn = 'Roles')
 {
     $UserIDs = array_unique(ConsolidateArrayValuesByKey($Users, $UserIDColumn));
     // Try and get all of the mappings from the cache.
     $Keys = array();
     foreach ($UserIDs as $UserID) {
         $Keys[$UserID] = FormatString(UserModel::USERROLES_KEY, array('UserID' => $UserID));
     }
     $UserRoles = Gdn::Cache()->Get($Keys);
     if (!is_array($UserRoles)) {
         $UserRoles = array();
     }
     // Grab all of the data that doesn't exist from the DB.
     $MissingIDs = array();
     foreach ($Keys as $UserID => $Key) {
         if (!array_key_exists($Key, $UserRoles)) {
             $MissingIDs[$UserID] = $Key;
         }
     }
     if (count($MissingIDs) > 0) {
         $DbUserRoles = Gdn::SQL()->Select('ur.*')->From('UserRole ur')->WhereIn('ur.UserID', array_keys($MissingIDs))->Get()->ResultArray();
         $DbUserRoles = Gdn_DataSet::Index($DbUserRoles, 'UserID', array('Unique' => FALSE));
         // Store the user role mappings.
         foreach ($DbUserRoles as $UserID => $Rows) {
             $RoleIDs = ConsolidateArrayValuesByKey($Rows, 'RoleID');
             $Key = $Keys[$UserID];
             Gdn::Cache()->Store($Key, $RoleIDs);
             $UserRoles[$Key] = $RoleIDs;
         }
     }
     $AllRoles = self::Roles();
     // roles indexed by role id.
     // Skip personal info roles
     if (!CheckPermission('Garden.PersonalInfo.View')) {
         $AllRoles = array_filter($AllRoles, 'self::FilterPersonalInfo');
     }
     // Join the users.
     foreach ($Users as &$User) {
         $UserID = GetValue($UserIDColumn, $User);
         $Key = $Keys[$UserID];
         $RoleIDs = GetValue($Key, $UserRoles, array());
         $Roles = array();
         foreach ($RoleIDs as $RoleID) {
             if (!array_key_exists($RoleID, $AllRoles)) {
                 continue;
             }
             $Roles[$RoleID] = $AllRoles[$RoleID]['Name'];
         }
         SetValue($RolesColumn, $User, $Roles);
     }
 }
Example #23
0
 public function Email(&$Activity, $NoDelete = FALSE)
 {
     if (is_numeric($Activity)) {
         $ActivityID = $Activity;
         $Activity = $this->GetID($ActivityID);
     } else {
         $ActivityID = GetValue('ActivityID', $Activity);
     }
     if (!$Activity) {
         return FALSE;
     }
     $Activity = (array) $Activity;
     $User = Gdn::UserModel()->GetID($Activity['NotifyUserID'], DATASET_TYPE_ARRAY);
     if (!$User) {
         return FALSE;
     }
     // Format the activity headline based on the user being emailed.
     if (GetValue('HeadlineFormat', $Activity)) {
         $SessionUserID = Gdn::Session()->UserID;
         Gdn::Session()->UserID = $User['UserID'];
         $Activity['Headline'] = FormatString($Activity['HeadlineFormat'], $Activity);
         Gdn::Session()->UserID = $SessionUserID;
     } else {
         if (!isset($Activity['ActivityGender'])) {
             $AT = self::GetActivityType($Activity['ActivityType']);
             $Data = array($Activity);
             self::JoinUsers($Data);
             $Activity = $Data[0];
             $Activity['RouteCode'] = GetValue('RouteCode', $AT);
             $Activity['FullHeadline'] = GetValue('FullHeadline', $AT);
             $Activity['ProfileHeadline'] = GetValue('ProfileHeadline', $AT);
         }
         $Activity['Headline'] = Gdn_Format::ActivityHeadline($Activity, '', $User['UserID']);
     }
     // Build the email to send.
     $Email = new Gdn_Email();
     $Email->Subject(sprintf(T('[%1$s] %2$s'), C('Garden.Title'), Gdn_Format::PlainText($Activity['Headline'])));
     $Email->To($User);
     $Url = ExternalUrl($Activity['Route'] == '' ? '/' : $Activity['Route']);
     if ($Activity['Story']) {
         $Message = sprintf(T('EmailStoryNotification', "%3\$s\n\n%2\$s"), Gdn_Format::PlainText($Activity['Headline']), $Url, Gdn_Format::PlainText($Activity['Story']));
     } else {
         $Message = sprintf(T('EmailNotification', "%1\$s\n\n%2\$s"), Gdn_Format::PlainText($Activity['Headline']), $Url);
     }
     $Email->Message($Message);
     // Fire an event for the notification.
     $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity['Route'], 'Story' => $Activity['Story'], 'Headline' => $Activity['Headline'], 'Activity' => $Activity);
     $this->EventArguments = $Notification;
     $this->FireEvent('BeforeSendNotification');
     // Send the email.
     try {
         // Only send if the user is not banned
         if (!GetValue('Banned', $User)) {
             $Email->Send();
         }
         $Emailed = self::SENT_OK;
         // Delete the activity now that it has been emailed.
         if (!$NoDelete && !$Activity['Notified']) {
             if (GetValue('ActivityID', $Activity)) {
                 $this->Delete($Activity['ActivityID']);
             } else {
                 $Activity['_Delete'] = TRUE;
             }
         }
     } catch (phpmailerException $pex) {
         if ($pex->getCode() == PHPMailer::STOP_CRITICAL) {
             $Emailed = self::SENT_FAIL;
         } else {
             $Emailed = self::SENT_ERROR;
         }
     } catch (Exception $ex) {
         $Emailed = self::SENT_FAIL;
         // similar to http 5xx
     }
     $Activity['Emailed'] = $Emailed;
     if ($ActivityID) {
         // Save the emailed flag back to the activity.
         $this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $ActivityID));
     }
 }
 /**
  * Form to ask for the destination of the move, confirmation and permission check.
  */
 public function ConfirmDiscussionMoves($DiscussionID = NULL)
 {
     $Session = Gdn::Session();
     $this->Form = new Gdn_Form();
     $DiscussionModel = new DiscussionModel();
     $this->Title(T('Confirm'));
     if ($DiscussionID) {
         $CheckedDiscussions = (array) $DiscussionID;
         $ClearSelection = FALSE;
     } else {
         $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
         if (!is_array($CheckedDiscussions)) {
             $CheckedDiscussions = array();
         }
         $ClearSelection = TRUE;
     }
     $DiscussionIDs = $CheckedDiscussions;
     $CountCheckedDiscussions = count($DiscussionIDs);
     $this->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     // Check for edit permissions on each discussion
     $AllowedDiscussions = array();
     $DiscussionData = $DiscussionModel->SQL->Select('DiscussionID, Name, DateLastComment, CategoryID')->From('Discussion')->WhereIn('DiscussionID', $DiscussionIDs)->Get();
     $DiscussionData = Gdn_DataSet::Index($DiscussionData->ResultArray(), array('DiscussionID'));
     foreach ($DiscussionData as $DiscussionID => $Discussion) {
         $Category = CategoryModel::Categories($Discussion['CategoryID']);
         if ($Category && $Category['PermsDiscussionsEdit']) {
             $AllowedDiscussions[] = $DiscussionID;
         }
     }
     $this->SetData('CountAllowed', count($AllowedDiscussions));
     $CountNotAllowed = $CountCheckedDiscussions - count($AllowedDiscussions);
     $this->SetData('CountNotAllowed', $CountNotAllowed);
     if ($this->Form->AuthenticatedPostBack()) {
         // Retrieve the category id
         $CategoryID = $this->Form->GetFormValue('CategoryID');
         $Category = CategoryModel::Categories($CategoryID);
         $RedirectLink = $this->Form->GetFormValue('RedirectLink');
         // User must have add permission on the target category
         if (!$Category['PermsDiscussionsAdd']) {
             throw ForbiddenException('@' . T('You do not have permission to add discussions to this category.'));
         }
         // Iterate and move.
         foreach ($AllowedDiscussions as $DiscussionID) {
             // Create the shadow redirect.
             if ($RedirectLink) {
                 $Discussion = GetValue($DiscussionID, $DiscussionData);
                 $DiscussionModel->DefineSchema();
                 $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
                 $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Moved: %s'), $Discussion['Name']), $MaxNameLength), 'DateInserted' => $Discussion['DateLastComment'], 'Type' => 'redirect', 'CategoryID' => $Discussion['CategoryID'], 'Body' => FormatString(T('This discussion has been <a href="{url,html}">moved</a>.'), array('url' => DiscussionUrl($Discussion))), 'Format' => 'Html', 'Closed' => TRUE);
                 $RedirectID = $DiscussionModel->Save($RedirectDiscussion);
                 if (!$RedirectID) {
                     $this->Form->SetValidationResults($DiscussionModel->ValidationResults());
                     break;
                 }
             }
             $DiscussionModel->SetField($DiscussionID, 'CategoryID', $CategoryID);
         }
         // Clear selections.
         if ($ClearSelection) {
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($this);
         }
         if ($this->Form->ErrorCount() == 0) {
             $this->JsonTarget('', '', 'Refresh');
         }
     }
     $this->Render();
 }
 /**
  * Delete a Tag
  *
  * @param Gdn_Controller $Sender
  */
 public function Controller_Delete($Sender)
 {
     $Sender->Permission('Garden.Settings.Manage');
     $TagID = GetValue(1, $Sender->RequestArgs);
     $TagModel = new TagModel();
     $Tag = $TagModel->GetID($TagID, DATASET_TYPE_ARRAY);
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Delete tag & tag relations.
         $SQL = Gdn::SQL();
         $SQL->Delete('TagDiscussion', array('TagID' => $TagID));
         $SQL->Delete('Tag', array('TagID' => $TagID));
         $Sender->InformMessage(FormatString(T('<b>{Name}</b> deleted.'), $Tag));
         $Sender->JsonTarget("#Tag_{$Tag['TagID']}", NULL, 'Remove');
     }
     $Sender->SetData('Title', T('Delete Tag'));
     $Sender->Render('delete', '', 'plugins/Tagging');
 }
Example #26
0
    function WriteCommentForm()
    {
        $Session = Gdn::Session();
        $Controller = Gdn::Controller();
        $Discussion = $Controller->Data('Discussion');
        $PermissionCategoryID = GetValue('PermissionCategoryID', $Discussion);
        $UserCanClose = $Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID);
        $UserCanComment = $Session->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $PermissionCategoryID);
        // Closed notification
        if ($Discussion->Closed == '1') {
            ?>
		<div class="Foot Closed">
			<div class="Note Closed"><?php 
            echo T('This discussion has been closed.');
            ?>
</div>
			<?php 
            //echo Anchor(T('All Discussions'), 'discussions', 'TabLink');
            ?>
		</div>
		<?php 
        } else {
            if (!$UserCanComment) {
                if (!Gdn::Session()->IsValid()) {
                    ?>
		<div class="Foot Closed">
			<div class="Note Closed"><?php 
                    $Popup = C('Garden.SignIn.Popup') ? ' class="Popup"' : '';
                    echo FormatString(T('Sign In or Register to Comment.', '<a href="{SignInUrl,html}"{Popup}>Sign In</a> or <a href="{RegisterUrl,html}">Register</a> to comment.'), array('SignInUrl' => Url(SignInUrl(Url(''))), 'RegisterUrl' => Url(RegisterUrl(Url(''))), 'Popup' => $Popup));
                    ?>
         </div>
			<?php 
                    //echo Anchor(T('All Discussions'), 'discussions', 'TabLink');
                    ?>
		</div>
		<?php 
                }
            }
        }
        if ($Discussion->Closed == '1' && $UserCanClose || $Discussion->Closed == '0' && $UserCanComment) {
            echo $Controller->FetchView('comment', 'post');
        }
    }
Example #27
0
 /**
  * Send welcome email to user.
  *
  * @param $UserID
  * @param $Password
  * @param string $RegisterType
  * @param null $AdditionalData
  * @throws Exception
  */
 public function sendWelcomeEmail($UserID, $Password, $RegisterType = 'Add', $AdditionalData = null)
 {
     $Session = Gdn::session();
     $Sender = $this->getID($Session->UserID);
     $User = $this->getID($UserID);
     if (!ValidateEmail($User->Email)) {
         return;
     }
     $AppTitle = Gdn::config('Garden.Title');
     $Email = new Gdn_Email();
     $Email->subject(sprintf(t('[%s] Welcome Aboard!'), $AppTitle));
     $Email->to($User->Email);
     $Data = array();
     $Data['User'] = arrayTranslate((array) $User, array('UserID', 'Name', 'Email'));
     $Data['Sender'] = arrayTranslate((array) $Sender, array('Name', 'Email'));
     $Data['Title'] = $AppTitle;
     if (is_array($AdditionalData)) {
         $Data = array_merge($Data, $AdditionalData);
     }
     $Data['EmailKey'] = valr('Attributes.EmailKey', $User);
     // Check for the new email format.
     if (($EmailFormat = t("EmailWelcome{$RegisterType}", '#')) != '#') {
         $Message = formatString($EmailFormat, $Data);
     } else {
         $Message = sprintf(t('EmailWelcome'), $User->Name, $Sender->Name, $AppTitle, ExternalUrl('/'), $Password, $User->Email);
     }
     // Add the email confirmation key.
     if ($Data['EmailKey']) {
         $Message .= "\n\n" . FormatString(t('EmailConfirmEmail', self::DEFAULT_CONFIRM_EMAIL), $Data);
     }
     $Message = $this->_addEmailHeaderFooter($Message, $Data);
     $Email->message($Message);
     $Email->send();
 }
Example #28
0
 function DetalleOrden($header, $TurnId, $OrdId, $tbl_name)
 {
     $_db = new MySQL();
     $_db->connect();
     /* Consulto los Examenes - Nuevo Esquema para generar el Menu */
     $ex = array();
     $_sql = "SELECT CASE\r\n\t\t\t\t\tWHEN TestPadrePadre!='' THEN TestPadrePadre\r\n\t\t\t\t\tWHEN TestPadreDescripcion!='' THEN TestPadreDescripcion\r\n\t\t\t\t\tEND AS test\r\n\t\t\t\t FROM {$tbl_name} WHERE EstadoProcesa='V' GROUP BY test ORDER BY test";
     $_db->prepare($_sql);
     //echo $_sql;
     $_result = $_db->execute();
     while (@($data = $_db->fetch_array($_result))) {
         $ex[] = $data["test"];
     }
     $_db->free($_result);
     //Verifico elementos repetidos en el array
     $exams = array_unique($ex);
     /* Barro Todos los Test Padres */
     $np = 0;
     foreach ($exams as $key => $value) {
         // Test Descripcion
         $this->Ln();
         $this->SetFont('Arial', 'B', 10);
         $this->Cell(10, 10, ucwords(strtolower(str_replace(":", " ", $value))), '', 0, 'L', false);
         $this->Ln();
         // Colores, ancho de linea y fuente en negrita
         $this->SetFillColor(101, 101, 101);
         $this->SetTextColor(255);
         $this->SetDrawColor(80, 80, 80);
         $this->SetLineWidth(0.3);
         $this->SetFont('Arial', '', 9);
         // Cabecera
         $w = array(60, 50, 25, 60);
         for ($i = 0; $i < count($header); $i++) {
             $this->Cell($w[$i], 6, $header[$i], 1, 0, 'C', true);
         }
         $this->Ln();
         // Consulto Resultados
         //$this->SetFont('Arial','',9);
         $fill = false;
         $test = trim(str_replace(":", " ", $value));
         $resultados = array();
         $_sql = "SELECT OrdId, OrdTurno, OrdFecha, CONCAT(PacNombre,' ',PacApellido) as Paciente, \r\n\t\t\t\t\t  CONCAT(MedNombre,' ',MedApellido)as Medico, TestDescripcion, Resultado, Unidad, \r\n\t\t\t\t\t  RanValInf, RanValSup, RanMultiple, TestPadre, TestPadreDescripcion, EmpId, EmpDescripcion,\r\n\t\t\t\t\t  TestNivel, TestPadrePadre, '' AS TestPadrePadrePadre, OrdDiagnostico\r\n\t\t\t\t\tFROM `{$tbl_name}` \r\n\t\t\t\t\tWHERE OrdTurno='{$TurnId}' AND OrdId='{$OrdId}' AND EstadoProcesa='V'  \r\n\t\t\t\t\t  AND (TestPadreDescripcion like '%{$test}%' Or TestPadrePadre like '%{$test}%') ";
         if ($test == 'BACTERIOLOGIA') {
             //$_sql .= " ORDER BY TestNivel, TestSubNivel, TestPadreDescripcion ";
             $_sql .= " ORDER BY TestPadre, TestNivel, TestSubNivel ";
         } else {
             if ($test == 'ORINA') {
                 $_sql .= " ORDER BY TestNivel ";
             } else {
                 $_sql .= " ORDER BY TestPadreDescripcion, TestNivel, TestSubNivel ";
             }
         }
         //echo $_sql;
         $_db->prepare($_sql);
         $_result = $_db->execute();
         while (@($data = $_db->fetch_array($_result))) {
             $resultados[] = $data;
         }
         $_db->free($_result);
         /* Muestra los Resultados */
         $i = 1;
         $j = 1;
         $limite = 26;
         foreach ($resultados as $k => $val) {
             $nivel = $val["TestNivel"];
             //Nivel del Examen
             if ($val["TestPadreDescripcion"] != $desc) {
                 $i = 1;
                 //Inicializo i
                 $j = 1;
                 //Inicializo j
             }
             /* Seteo el Formato drl Texto en las cabeceras de los Resultados */
             $this->SetFillColor(255, 255, 255);
             $this->SetTextColor(0);
             $this->SetFont('Arial', 'B', 9);
             if ($nivel > 1) {
                 switch ($nivel) {
                     case "2":
                         if ($i == 1) {
                             $this->Cell($w[0], 6, ucwords(strtolower(str_replace(":", " ", $val["TestPadreDescripcion"]))), '', 0, 'L', false);
                             $this->Ln();
                             //Salto de Linea
                         }
                         $i++;
                         break;
                     case "3":
                         if ($i == 1) {
                             if ($tpp != $val["TestPadrePadre"]) {
                                 $this->Cell($w[0], 6, ucwords(strtolower(str_replace(":", " ", $val["TestPadrePadre"]))), '', 0, 'L', false);
                                 $this->Ln();
                                 //Salto de Linea
                             }
                         }
                         if ($j == 1) {
                             $this->Cell($w[0], 6, ucwords(strtolower(str_replace(":", " ", $val["TestPadreDescripcion"]))), '', 0, 'L', false);
                             $this->Ln();
                             //Salto de Linea
                         }
                         $i++;
                         $j++;
                         break;
                 }
             }
             // Restauracion de colores y fuentes
             $this->SetFillColor(224, 235, 255);
             $this->SetTextColor(0);
             $this->SetFont('Arial', '', 9);
             /* Presenta los Resultados */
             $flag = false;
             $exa = "";
             $resul = "";
             $rango = "";
             # Verifica la Longitud del Examen
             if (strlen($val["TestDescripcion"]) >= $limite) {
                 if (strstr($val["TestDescripcion"], '<br>')) {
                     $exa = $val["TestDescripcion"];
                 } else {
                     $exa = FormatString($val["TestDescripcion"], $limite);
                     $flag = true;
                 }
             } else {
                 $exa = $val["TestDescripcion"];
             }
             # Verifica la Longitud del Resultado
             if (strlen($val["Resultado"]) >= $limite) {
                 if (strstr($val["Resultado"], '<br>')) {
                     $resul = $val["Resultado"];
                 } else {
                     $resul = FormatString($val["Resultado"], $limite);
                     $flag = true;
                 }
             } else {
                 $resul = $val["Resultado"];
             }
             # Verifica los rangos referenciales
             if (!empty($val["RanValInf"]) || !empty($val["RanValSup"])) {
                 $rango = $val["RanValInf"] . " - " . $val["RanValSup"];
             } else {
                 if (!empty($val["RanMultiple"])) {
                     $rango = str_replace("<br>", "\n", $val["RanMultiple"]);
                     $flag = true;
                 }
             }
             if (!$flag) {
                 $this->Cell($w[0], 6, $exa, 'LR', 0, 'L', $fill);
                 // Nombre del Examen
                 $this->Cell($w[1], 6, $resul, 'LR', 0, 'C', $fill);
                 // Resultado
                 $this->Cell($w[2], 6, $val["Unidad"], 'LR', 0, 'C', $fill);
                 // Unidad
                 $this->Cell($w[3], 6, $rango, 'LR', 0, 'C', $fill);
                 // Rango Minimo - Rango Maximo
             } else {
                 $this->SetFont('Arial', '', 9);
                 $this->SetWidths(array(60, 50, 25, 60));
                 if (strlen($rango) < $limite) {
                     $this->SetAligns(array('L', 'C', 'C', 'C'));
                 } else {
                     $this->SetAligns(array('L', 'C', 'C', 'L'));
                 }
                 $this->Row(array(utf8_decode(str_replace("<br/>", "\n", $exa)), utf8_decode(str_replace("<br/>", "\n", $resul)), utf8_decode($val["Unidad"]), $rango));
             }
             $this->Ln();
             $fill = !$fill;
             $desc = $val["TestPadreDescripcion"];
             // Guardo El Test Anterior - TestPadreDescripcion
             $tpp = $val["TestPadrePadre"];
             // TestPadrePadre
             $diagnostico = $val["OrdDiagnostico"];
             // Diagnostico
         }
         $this->Cell(array_sum($w), 0, '', 'T');
         $this->Ln();
         $this->Cell(200, 10, '* Sin valor legal, para ese efecto acerquese al Laboratorio Principal', 0, 0, 'C');
         $np++;
         if (count($exams) - $np != 0) {
             $this->AddPage();
         }
     }
     # Imprimo el Diagnostico
     if (!empty($diagnostico)) {
         $this->Ln(20);
         $this->SetFont('Arial', 'B', 10);
         $this->Cell(80, 6, "Observaciones y Comentarios a la Solicitud:", '', 'L', $fill);
         $this->SetFont('Arial', '', 10);
         $this->Cell(120, 6, $diagnostico, '', 'L', $fill);
     }
     $_db->close();
 }
 /**
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function NotificationsController_BeforeInformNotifications_Handler($Sender, $Args)
 {
     $Path = trim($Sender->Request->GetValue('Path'), '/');
     if (preg_match('`^(vanilla/)?discussion[^s]`i', $Path)) {
         return;
     }
     // Check to see if the user has answered questions.
     $Count = Gdn::SQL()->GetCount('Discussion', array('Type' => 'Question', 'InsertUserID' => Gdn::Session()->UserID, 'QnA' => 'Answered'));
     if ($Count > 0) {
         $Sender->InformMessage(FormatString(T("You've asked questions that have now been answered", "<a href=\"{/discussions/mine?qna=Answered,url}\">You've asked questions that now have answers</a>. Make sure you accept/reject the answers.")), 'Dismissable');
     }
 }
Example #30
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 
}