public function toString() { if (!Gdn::session()->checkPermission('Garden.Activity.View')) { return ''; } if (stringIsNullOrEmpty($this->ActivityModuleTitle)) { $this->ActivityModuleTitle = t('Recent Activity'); } if (!$this->ActivityData) { $this->getData(); } $Data = $this->ActivityData; if (is_object($Data) && $Data->numRows() > 0) { return parent::toString(); } return ''; }
/** * Build the Message's Location property and add it. * * @param array|object $Message Message data. * @return array|object Message data with Location property/key added. */ public function defineLocation($Message) { $Controller = val('Controller', $Message); $Application = val('Application', $Message); $Method = val('Method', $Message); if (in_array($Controller, $this->_SpecialLocations)) { setValue('Location', $Message, $Controller); } else { setValue('Location', $Message, $Application); if (!stringIsNullOrEmpty($Controller)) { setValue('Location', $Message, val('Location', $Message) . '/' . $Controller); } if (!stringIsNullOrEmpty($Method)) { setValue('Location', $Message, val('Location', $Message) . '/' . $Method); } } return $Message; }
if (!defined('APPLICATION')) { exit; } // Get the information for displaying the connection information. if (!($ConnectName = $this->Form->getFormValue('FullName'))) { $ConnectName = $this->Form->getFormValue('Name'); } $ConnectPhoto = $this->Form->getFormValue('Photo'); if (!$ConnectPhoto) { $ConnectPhoto = '/applications/dashboard/design/images/usericon.gif'; } $ConnectSource = $this->Form->getFormValue('ProviderName'); ?> <div class="Connect"> <h1><?php echo stringIsNullOrEmpty($ConnectSource) ? t("Sign In") : sprintf(t('%s Connect'), $ConnectSource); ?> </h1> <div> <?php echo $this->Form->open(); echo $this->Form->errors(); if ($ConnectName || $ConnectPhoto) { ?> <div class="MeBox"> <?php if ($ConnectPhoto) { echo '<span class="PhotoWrap">', img($ConnectPhoto, array('alt' => t('Profile Picture'), 'class' => 'ProfilePhoto')), '</span>'; } echo '<div class="WhoIs">';
/** * Validate tags when saving a discussion. */ public function discussionModel_beforeSaveDiscussion_handler($Sender, $Args) { $FormPostValues = val('FormPostValues', $Args, array()); $TagsString = trim(strtolower(val('Tags', $FormPostValues, ''))); $NumTagsMax = c('Plugin.Tagging.Max', 5); // Tags can only contain unicode and the following ASCII: a-z 0-9 + # _ . if (stringIsNullOrEmpty($TagsString) && c('Plugins.Tagging.Required')) { $Sender->Validation->addValidationResult('Tags', 'You must specify at least one tag.'); } else { $Tags = TagModel::splitTags($TagsString); if (!TagModel::validateTags($Tags)) { $Sender->Validation->addValidationResult('Tags', '@' . t('ValidateTag', 'Tags cannot contain commas.')); } elseif (count($Tags) > $NumTagsMax) { $Sender->Validation->addValidationResult('Tags', '@' . sprintf(t('You can only specify up to %s tags.'), $NumTagsMax)); } else { } } }
/** * Returns an update statement for the specified table with the provided $Data. * * @param array $Tables The name of the table to updated data in. * @param array $Data An associative array of FieldName => Value pairs that should be inserted $Table. * @param mixed $Where A where clause (or array containing multiple where clauses) to be applied * to the where portion of the update statement. */ public function getUpdate($Tables, $Data, $Where) { if (!is_array($Data)) { trigger_error(errorMessage('The data provided is not in a proper format (Array).', 'MySQLDriver', '_GetUpdate'), E_USER_ERROR); } $Sets = array(); foreach ($Data as $Field => $Value) { $Sets[] = $Field . " = " . $Value; } $sql = 'update ' . ($this->options('Ignore') ? 'ignore ' : '') . $this->_fromTables($Tables); if (count($this->_Joins) > 0) { $sql .= "\n"; $Join = $this->_Joins[count($this->_Joins) - 1]; $sql .= implode("\n", $this->_Joins); } $sql .= "\nset " . implode(",\n ", $Sets); if (is_array($Where) && count($Where) > 0) { $sql .= "\nwhere " . implode("\n ", $Where); // Close any where groups that were left open. for ($i = 0; $i < $this->_OpenWhereGroupCount; ++$i) { $sql .= ')'; } $this->_OpenWhereGroupCount = 0; } elseif (is_string($Where) && !stringIsNullOrEmpty($Where)) { $sql .= ' where ' . $Where; } return $sql; }
if ($LastPhoto) { break; } } elseif (!$LastPhoto) { $LastPhoto = userPhoto($User); } } } $CssClass = 'Item'; $CssClass .= $Alt ? ' Alt' : ''; $CssClass .= $Conversation->CountNewMessages > 0 ? ' New' : ''; $CssClass .= $LastPhoto != '' ? ' HasPhoto' : ''; $CssClass .= ' ' . ($Conversation->CountNewMessages <= 0 ? 'Read' : 'Unread'); $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages; $Message = sliceString(Gdn_Format::plainText($Conversation->LastBody, $Conversation->LastFormat), 100); if (stringIsNullOrEmpty(trim($Message))) { $Message = t('Blank Message'); } $this->EventArguments['Conversation'] = $Conversation; ?> <li class="<?php echo $CssClass; ?> "> <?php $Names = ConversationModel::participantTitle($Conversation, false); ?> <div class="ItemContent Conversation"> <?php $Url = '/messages/' . $Conversation->ConversationID . '/#Item_' . $JumpToItem; echo '<h3 class="Users">';
/** * Validate tags when saving a discussion. */ public function discussionModel_beforeSaveDiscussion_handler($Sender, $Args) { $reservedTags = []; $Sender->EventArguments['ReservedTags'] =& $reservedTags; $Sender->FireEvent('ReservedTags'); $FormPostValues = val('FormPostValues', $Args, array()); $TagsString = trim(strtolower(val('Tags', $FormPostValues, ''))); $NumTagsMax = c('Plugin.Tagging.Max', 5); // Tags can only contain unicode and the following ASCII: a-z 0-9 + # _ . if (stringIsNullOrEmpty($TagsString) && c('Plugins.Tagging.Required')) { $Sender->Validation->addValidationResult('Tags', 'You must specify at least one tag.'); } else { $Tags = TagModel::splitTags($TagsString); // Handle upper/lowercase $Tags = array_map('strtolower', $Tags); $reservedTags = array_map('strtolower', $reservedTags); if ($reservedTags = array_intersect($Tags, $reservedTags)) { $names = implode(', ', $reservedTags); $Sender->Validation->addValidationResult('Tags', '@' . sprintf(t('These tags are reserved and cannot be used: %s'), $names)); } if (!TagModel::validateTags($Tags)) { $Sender->Validation->addValidationResult('Tags', '@' . t('ValidateTag', 'Tags cannot contain commas.')); } elseif (count($Tags) > $NumTagsMax) { $Sender->Validation->addValidationResult('Tags', '@' . sprintf(t('You can only specify up to %s tags.'), $NumTagsMax)); } else { } } }
/** * Validate tags when saving a discussion. * * @param DiscussionModel $Sender * @param array $Args */ public function discussionModel_beforeSaveDiscussion_handler($Sender, $Args) { // Allow an addon to set disallowed tag names. $reservedTags = []; $Sender->EventArguments['ReservedTags'] =& $reservedTags; $Sender->fireEvent('ReservedTags'); // Set some tagging requirements. $TagsString = trim(strtolower(valr('FormPostValues.Tags', $Args, ''))); if (stringIsNullOrEmpty($TagsString) && c('Plugins.Tagging.Required')) { $Sender->Validation->addValidationResult('Tags', 'You must specify at least one tag.'); } else { // Break apart our tags and lowercase them all for comparisons. $Tags = TagModel::splitTags($TagsString); $Tags = array_map('strtolower', $Tags); $reservedTags = array_map('strtolower', $reservedTags); $maxTags = c('Plugin.Tagging.Max', 5); // Validate our tags. if ($reservedTags = array_intersect($Tags, $reservedTags)) { $names = implode(', ', $reservedTags); $Sender->Validation->addValidationResult('Tags', '@' . sprintf(t('These tags are reserved and cannot be used: %s'), $names)); } if (!TagModel::validateTags($Tags)) { $Sender->Validation->addValidationResult('Tags', '@' . t('ValidateTag', 'Tags cannot contain commas.')); } if (count($Tags) > $maxTags) { $Sender->Validation->addValidationResult('Tags', '@' . sprintf(t('You can only specify up to %s tags.'), $maxTags)); } } }