• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP touchValue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中touchValue函数的典型用法代码示例。如果您正苦于以下问题:PHP touchValue函数的具体用法?PHP touchValue怎么用?PHP touchValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了touchValue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: isSpam

 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function isSpam($RecordType, $Data, $Options = array())
 {
     if (self::$Disabled) {
         return false;
     }
     // Set some information about the user in the data.
     if ($RecordType == 'Registration') {
         touchValue('Username', $Data, $Data['Name']);
     } else {
         touchValue('InsertUserID', $Data, Gdn::session()->UserID);
         $User = Gdn::userModel()->getID(val('InsertUserID', $Data), DATASET_TYPE_ARRAY);
         if ($User) {
             if (val('Verified', $User)) {
                 // The user has been verified and isn't a spammer.
                 return false;
             }
             touchValue('Username', $Data, $User['Name']);
             touchValue('Email', $Data, $User['Email']);
             touchValue('IPAddress', $Data, $User['LastIPAddress']);
         }
     }
     if (!isset($Data['Body']) && isset($Data['Story'])) {
         $Data['Body'] = $Data['Story'];
     }
     touchValue('IPAddress', $Data, Gdn::request()->ipAddress());
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = false;
     $Sp->fireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && val('Log', $Options, true)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
             case 'Activity':
             case 'ActivityComment':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:60,代码来源:class.spammodel.php


示例2: addItem

 /**
  * Add an item to the items array.
  *
  * @param string $type The type of the item: link, group or divider.
  * @param array $item The item to add to the array.
  * @throws Exception
  */
 protected function addItem($type, $item)
 {
     $this->touchKey($item);
     if (!is_array(val('key', $item))) {
         $item['key'] = explode('.', val('key', $item));
     } else {
         $item['key'] = array_values(val('key', $item));
     }
     $item = (array) $item;
     // Make sure the link has its type.
     $item['type'] = $type;
     // Walk into the items list to set the item.
     $items =& $this->items;
     foreach (val('key', $item) as $i => $key_part) {
         if ($i === count(val('key', $item)) - 1) {
             // Add the item here.
             if (array_key_exists($key_part, $items)) {
                 // The item is already here so merge this one on top of it.
                 if ($items[$key_part]['type'] !== $type) {
                     throw new \Exception(val('key', $item) . " of type {$type} does not match existing type {$items[$key_part]['type']}.", 500);
                 }
                 $items[$key_part] = array_merge($items[$key_part], $item);
             } else {
                 // The item is new so just add it here.
                 touchValue('_sort', $item, count($items));
                 $items[$key_part] = $item;
             }
         } else {
             // This is a group.
             if (!array_key_exists($key_part, $items)) {
                 // The group doesn't exist so lazy-create it.
                 $items[$key_part] = array('type' => 'group', 'text' => '', 'items' => [], '_sort' => count($items));
             } elseif ($items[$key_part]['type'] !== 'group') {
                 throw new \Exception("{$key_part} is not a group", 500);
             } elseif (!array_key_exists('items', $items[$key_part])) {
                 // Lazy create the items array.
                 $items[$key_part]['items'] = [];
             }
             $items =& $items[$key_part]['items'];
         }
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:49,代码来源:class.nestedcollection.php


示例3: discussion

 /**
  * Create or update a discussion.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $CategoryID Unique ID of the category to add the discussion to.
  */
 public function discussion($CategoryUrlCode = '')
 {
     // Override CategoryID if categories are disabled
     $UseCategories = $this->ShowCategorySelector = (bool) c('Vanilla.Categories.Use');
     if (!$UseCategories) {
         $CategoryUrlCode = '';
     }
     // Setup head
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('autosave.js');
     $this->addJsFile('post.js');
     $Session = Gdn::session();
     Gdn_Theme::section('PostDiscussion');
     // Set discussion, draft, and category data
     $DiscussionID = isset($this->Discussion) ? $this->Discussion->DiscussionID : '';
     $DraftID = isset($this->Draft) ? $this->Draft->DraftID : 0;
     $Category = false;
     $CategoryModel = new CategoryModel();
     if (isset($this->Discussion)) {
         $this->CategoryID = $this->Discussion->CategoryID;
         $Category = CategoryModel::categories($this->CategoryID);
     } elseif ($CategoryUrlCode != '') {
         $Category = CategoryModel::categories($CategoryUrlCode);
         if ($Category) {
             $this->CategoryID = val('CategoryID', $Category);
         }
     }
     if ($Category) {
         $this->Category = (object) $Category;
         $this->setData('Category', $Category);
         $this->Form->addHidden('CategoryID', $this->Category->CategoryID);
         if (val('DisplayAs', $this->Category) == 'Discussions' && !$DraftID) {
             $this->ShowCategorySelector = false;
         } else {
             // Get all our subcategories to add to the category if we are in a Header or Categories category.
             $this->Context = CategoryModel::getSubtree($this->CategoryID);
         }
     } else {
         $this->CategoryID = 0;
         $this->Category = null;
     }
     $CategoryData = $this->ShowCategorySelector ? CategoryModel::categories() : false;
     // Check permission
     if (isset($this->Discussion)) {
         // Make sure that content can (still) be edited.
         $CanEdit = DiscussionModel::canEdit($this->Discussion);
         if (!$CanEdit) {
             throw permissionException('Vanilla.Discussions.Edit');
         }
         // Make sure only moderators can edit closed things
         if ($this->Discussion->Closed) {
             $this->permission('Vanilla.Discussions.Edit', true, 'Category', $this->Category->PermissionCategoryID);
         }
         $this->Form->setFormValue('DiscussionID', $this->Discussion->DiscussionID);
         $this->title(t('Edit Discussion'));
         if ($this->Discussion->Type) {
             $this->setData('Type', $this->Discussion->Type);
         } else {
             $this->setData('Type', 'Discussion');
         }
     } else {
         // Permission to add.
         if ($this->Category) {
             $this->permission('Vanilla.Discussions.Add', true, 'Category', $this->Category->PermissionCategoryID);
         } else {
             $this->permission('Vanilla.Discussions.Add');
         }
         $this->title(t('New Discussion'));
     }
     touchValue('Type', $this->Data, 'Discussion');
     // See if we should hide the category dropdown.
     if ($this->ShowCategorySelector) {
         $AllowedCategories = CategoryModel::getByPermission('Discussions.Add', $this->Form->getValue('CategoryID', $this->CategoryID), ['Archived' => 0, 'AllowDiscussions' => 1], ['AllowedDiscussionTypes' => $this->Data['Type']]);
         if (count($AllowedCategories) == 1) {
             $AllowedCategory = array_pop($AllowedCategories);
             $this->ShowCategorySelector = false;
             $this->Form->addHidden('CategoryID', $AllowedCategory['CategoryID']);
             if ($this->Form->isPostBack() && !$this->Form->getFormValue('CategoryID')) {
                 $this->Form->setFormValue('CategoryID', $AllowedCategory['CategoryID']);
             }
         }
     }
     // Set the model on the form
     $this->Form->setModel($this->DiscussionModel);
     if (!$this->Form->isPostBack()) {
         // Prep form with current data for editing
         if (isset($this->Discussion)) {
             $this->Form->setData($this->Discussion);
         } elseif (isset($this->Draft)) {
             $this->Form->setData($this->Draft);
         } else {
             if ($this->Category !== null) {
//.........这里部分代码省略.........
开发者ID:vanilla,项目名称:vanilla,代码行数:101,代码来源:class.postcontroller.php


示例4: renderAdventureNav

    function renderAdventureNav($items)
    {
        foreach ($items as $item) {
            if (val('type', $item) == 'group') {
                $heading = val('text', $item);
                if (!$heading) {
                    touchValue('cssClass', $item, '');
                    $item['cssClass'] .= ' nav-group-noheading';
                }
                ?>
                <div type="group" class="nav-group <?php 
                echo val('cssClass', $item);
                ?>
">
                <?php 
                if ($heading) {
                    echo '<h3>' . val('text', $item) . '</h3>';
                }
                if (val('items', $item)) {
                    renderAdventureNav(val('items', $item));
                }
                echo '</div>';
            }
            if (val('type', $item) == 'link') {
                ?>
                <div class="nav-item">
                    <a role="menuitem" class="nav-link <?php 
                echo val('cssClass', $item);
                ?>
" tabindex="-1"
                        href="<?php 
                echo url(val('url', $item));
                ?>
">
                        <div class="nav-item-icon"><?php 
                echo icon(val('icon', $item));
                ?>
</div>
                        <div class="nav-item-content">
                            <div class="nav-item-title"><?php 
                echo val('text', $item);
                ?>
</div>
                            <div class="nav-item-description">
                                <?php 
                echo val('description', $item);
                ?>
                            </div>
                        </div>
                        <div class="nav-item-arrow"><?php 
                echo dashboardSymbol('chevron-right');
                ?>
</div>
                    </a>
                </div>
                <?php 
            }
            if (val('type', $item) == 'divider') {
                echo '<hr/>';
            }
        }
    }
开发者ID:vanilla,项目名称:vanilla,代码行数:62,代码来源:nav-adventure.php


示例5: joinRecentPosts

 /**
  *
  *
  * @param $Data
  * @param null $CategoryID
  * @return bool
  */
 public static function joinRecentPosts(&$Data, $CategoryID = null)
 {
     $DiscussionIDs = array();
     $CommentIDs = array();
     $Joined = false;
     foreach ($Data as &$Row) {
         if (!is_null($CategoryID) && $Row['CategoryID'] != $CategoryID) {
             continue;
         }
         if (isset($Row['LastTitle']) && $Row['LastTitle']) {
             continue;
         }
         if ($Row['LastDiscussionID']) {
             $DiscussionIDs[] = $Row['LastDiscussionID'];
         }
         if ($Row['LastCommentID']) {
             $CommentIDs[] = $Row['LastCommentID'];
         }
         $Joined = true;
     }
     // Create a fresh copy of the Sql object so as not to pollute.
     $Sql = clone Gdn::sql();
     $Sql->reset();
     $Discussions = null;
     // Grab the discussions.
     if (count($DiscussionIDs) > 0) {
         $Discussions = $Sql->whereIn('DiscussionID', $DiscussionIDs)->get('Discussion')->resultArray();
         $Discussions = Gdn_DataSet::Index($Discussions, array('DiscussionID'));
     }
     if (count($CommentIDs) > 0) {
         $Comments = $Sql->whereIn('CommentID', $CommentIDs)->get('Comment')->resultArray();
         $Comments = Gdn_DataSet::Index($Comments, array('CommentID'));
     }
     foreach ($Data as &$Row) {
         if (!is_null($CategoryID) && $Row['CategoryID'] != $CategoryID) {
             continue;
         }
         $Discussion = val($Row['LastDiscussionID'], $Discussions);
         $NameUrl = 'x';
         if ($Discussion) {
             $Row['LastTitle'] = Gdn_Format::text($Discussion['Name']);
             $Row['LastUserID'] = $Discussion['InsertUserID'];
             $Row['LastDiscussionUserID'] = $Discussion['InsertUserID'];
             $Row['LastDateInserted'] = $Discussion['DateInserted'];
             $NameUrl = Gdn_Format::text($Discussion['Name'], true);
             $Row['LastUrl'] = DiscussionUrl($Discussion, false, '/') . '#latest';
         }
         if (!empty($Comments) && ($Comment = val($Row['LastCommentID'], $Comments))) {
             $Row['LastUserID'] = $Comment['InsertUserID'];
             $Row['LastDateInserted'] = $Comment['DateInserted'];
             $Row['DateLastComment'] = $Comment['DateInserted'];
         } else {
             $Row['NoComment'] = true;
         }
         touchValue('LastTitle', $Row, '');
         touchValue('LastUserID', $Row, null);
         touchValue('LastDiscussionUserID', $Row, null);
         touchValue('LastDateInserted', $Row, null);
         touchValue('LastUrl', $Row, null);
     }
     return $Joined;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:69,代码来源:class.categorymodel.php


示例6: save

 /**
  * Save message from form submission.
  *
  * @since 2.0.0
  * @access public
  *
  * @param array $FormPostValues Values submitted via form.
  * @return int Unique ID of message created or updated.
  */
 public function save($FormPostValues, $Conversation = null, $Options = array())
 {
     $Session = Gdn::session();
     // Define the primary key in this model's table.
     $this->defineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->applyRule('Body', 'Required');
     $this->addInsertFields($FormPostValues);
     $this->EventArguments['FormPostValues'] = $FormPostValues;
     $this->fireEvent('BeforeSaveValidation');
     // Determine if spam check should be skipped.
     $SkipSpamCheck = !empty($Options['NewConversation']);
     // Validate the form posted values
     $MessageID = false;
     if ($this->validate($FormPostValues) && !$this->checkForSpam('ConversationMessage', $SkipSpamCheck)) {
         $Fields = $this->Validation->schemaValidationFields();
         // All fields on the form that relate to the schema
         touchValue('Format', $Fields, c('Garden.InputFormatter', 'Html'));
         $this->EventArguments['Fields'] = $Fields;
         $this->fireEvent('BeforeSave');
         $MessageID = $this->SQL->insert($this->Name, $Fields);
         $this->LastMessageID = $MessageID;
         $ConversationID = val('ConversationID', $Fields, 0);
         if (!$Conversation) {
             $Conversation = $this->SQL->getWhere('Conversation', array('ConversationID' => $ConversationID))->firstRow(DATASET_TYPE_ARRAY);
         }
         $Message = $this->getID($MessageID);
         $this->EventArguments['Conversation'] = $Conversation;
         $this->EventArguments['Message'] = $Message;
         $this->fireEvent('AfterSave');
         // Get the new message count for the conversation.
         $SQLR = $this->SQL->select('MessageID', 'count', 'CountMessages')->select('MessageID', 'max', 'LastMessageID')->from('ConversationMessage')->where('ConversationID', $ConversationID)->get()->firstRow(DATASET_TYPE_ARRAY);
         if (sizeof($SQLR)) {
             list($CountMessages, $LastMessageID) = array_values($SQLR);
         } else {
             return;
         }
         // Update the conversation's DateUpdated field.
         $DateUpdated = Gdn_Format::toDateTime();
         $this->SQL->update('Conversation c')->set('CountMessages', $CountMessages)->set('LastMessageID', $LastMessageID)->set('UpdateUserID', Gdn::session()->UserID)->set('DateUpdated', $DateUpdated)->where('ConversationID', $ConversationID)->put();
         // Update the last message of the users that were previously up-to-date on their read messages.
         $this->SQL->update('UserConversation uc')->set('uc.LastMessageID', $MessageID)->set('uc.DateConversationUpdated', $DateUpdated)->where('uc.ConversationID', $ConversationID)->where('uc.Deleted', '0')->where('uc.CountReadMessages', $CountMessages - 1)->where('uc.UserID <>', $Session->UserID)->put();
         // Update the date updated of the users that were not up-to-date.
         $this->SQL->update('UserConversation uc')->set('uc.DateConversationUpdated', $DateUpdated)->where('uc.ConversationID', $ConversationID)->where('uc.Deleted', '0')->where('uc.CountReadMessages <>', $CountMessages - 1)->where('uc.UserID <>', $Session->UserID)->put();
         // Update the sending user.
         $this->SQL->update('UserConversation uc')->set('uc.CountReadMessages', $CountMessages)->set('Deleted', 0)->set('uc.DateConversationUpdated', $DateUpdated)->where('ConversationID', $ConversationID)->where('UserID', $Session->UserID)->put();
         // Find users involved in this conversation
         $UserData = $this->SQL->select('UserID')->select('LastMessageID')->select('Deleted')->from('UserConversation')->where('ConversationID', $ConversationID)->get()->result(DATASET_TYPE_ARRAY);
         $UpdateCountUserIDs = array();
         $NotifyUserIDs = array();
         // Collapse for call to UpdateUserCache and ActivityModel.
         $InsertUserFound = false;
         foreach ($UserData as $UpdateUser) {
             $LastMessageID = val('LastMessageID', $UpdateUser);
             $UserID = val('UserID', $UpdateUser);
             $Deleted = val('Deleted', $UpdateUser);
             if ($UserID == val('InsertUserID', $Fields)) {
                 $InsertUserFound = true;
                 if ($Deleted) {
                     $this->SQL->put('UserConversation', array('Deleted' => 0, 'DateConversationUpdated' => $DateUpdated), array('ConversationID' => $ConversationID, 'UserID' => $UserID));
                 }
             }
             // Update unread for users that were up to date
             if ($LastMessageID == $MessageID) {
                 $UpdateCountUserIDs[] = $UserID;
             }
             // Send activities to users that have not deleted the conversation
             if (!$Deleted) {
                 $NotifyUserIDs[] = $UserID;
             }
         }
         if (!$InsertUserFound) {
             $UserConversation = array('UserID' => val('InsertUserID', $Fields), 'ConversationID' => $ConversationID, 'LastMessageID' => $LastMessageID, 'CountReadMessages' => $CountMessages, 'DateConversationUpdated' => $DateUpdated);
             $this->SQL->insert('UserConversation', $UserConversation);
         }
         if (sizeof($UpdateCountUserIDs)) {
             $ConversationModel = new ConversationModel();
             $ConversationModel->updateUserUnreadCount($UpdateCountUserIDs, true);
         }
         $this->fireEvent('AfterAdd');
         $activityModel = new ActivityModel();
         foreach ($NotifyUserIDs as $notifyUserID) {
             if ($Session->UserID == $notifyUserID) {
                 continue;
                 // don't notify self.
             }
             // Notify the users of the new message.
             $activity = array('ActivityType' => 'ConversationMessage', 'ActivityUserID' => val('InsertUserID', $Fields), 'NotifyUserID' => $notifyUserID, 'HeadlineFormat' => t('HeadlineFormat.ConversationMessage', '{ActivityUserID,user} sent you a <a href="{Url,html}">message</a>'), 'RecordType' => 'Conversation', 'RecordID' => $ConversationID, 'Story' => val('Body', $Fields, ''), 'Format' => val('Format', $Fields, c('Garden.InputFormatter')), 'Route' => "/messages/{$ConversationID}#{$MessageID}");
             if (c('Conversations.Subjects.Visible') && val('Subject', $Conversation, '')) {
                 $activity['HeadlineFormat'] = val('Subject', $Conversation, '');
             }
//.........这里部分代码省略.........
开发者ID:caidongyun,项目名称:vanilla,代码行数:101,代码来源:class.conversationmessagemodel.php


示例7: addInsertFields

 /**
  * Parent override.
  *
  * @param array &$Fields
  */
 public function addInsertFields(&$Fields)
 {
     $this->defineSchema();
     // Set the hour offset based on the client's clock.
     $ClientHour = val('ClientHour', $Fields, '');
     if (is_numeric($ClientHour) && $ClientHour >= 0 && $ClientHour < 24) {
         $HourOffset = $ClientHour - date('G', time());
         $Fields['HourOffset'] = $HourOffset;
     }
     // Set some required dates.
     $Now = Gdn_Format::toDateTime();
     $Fields[$this->DateInserted] = $Now;
     touchValue('DateFirstVisit', $Fields, $Now);
     $Fields['DateLastActive'] = $Now;
     $Fields['InsertIPAddress'] = ipEncode(Gdn::request()->ipAddress());
     $Fields['LastIPAddress'] = ipEncode(Gdn::request()->ipAddress());
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:22,代码来源:class.usermodel.php


示例8: resolveStaticResources


//.........这里部分代码省略.........
                 }
                 // Garden-wide theme override
                 $testPaths[] = paths(PATH_THEMES, $controllerTheme, $stub, $resourceFile);
             }
             // Application or plugin
             $isPluginFolder = stringBeginsWith(trim($appFolder, '/'), 'plugins/', true, false);
             if ($isPluginFolder) {
                 $pluginFolder = stringBeginsWith(trim($appFolder, '/'), 'plugins/', true, true);
             }
             if (in_array('plugins', $checkLocations) && $isPluginFolder) {
                 // Plugin
                 $testPaths[] = paths(PATH_PLUGINS, $pluginFolder, $stub, $resourceFile);
                 $testPaths[] = paths(PATH_PLUGINS, $pluginFolder, $resourceFile);
             }
             if (in_array('applications', $checkLocations) && !$isPluginFolder) {
                 // Application
                 if ($appFolder) {
                     $testPaths[] = paths(PATH_APPLICATIONS, $appFolder, $stub, $resourceFile);
                 }
                 // Dashboard app is added by default
                 if ($appFolder != 'dashboard') {
                     $testPaths[] = paths(PATH_APPLICATIONS, 'dashboard', $stub, $resourceFile);
                 }
             }
             if (in_array('global', $checkLocations)) {
                 // Global folder. eg. root/js/
                 $testPaths[] = paths(PATH_ROOT, $stub, $resourceFile);
                 if ($checkGlobalLibrary) {
                     // Global library folder. eg. root/js/library/
                     $testPaths[] = paths(PATH_ROOT, $stub, 'library', $resourceFile);
                 }
             }
         }
         // Find the first file that matches the path.
         $resourcePath = false;
         if (!$skipFileCheck) {
             foreach ($testPaths as $glob) {
                 $paths = safeGlob($glob);
                 if (is_array($paths) && count($paths) > 0) {
                     $resourcePath = $paths[0];
                     break;
                 }
             }
             // Get version
             $version = val('Version', $resourceInfo, false);
             // If a path was matched, make sure it has a version
             if ($resourcePath && !$version && $autoDetectVersion) {
                 // Theme file
                 if (!$version && preg_match('`themes/([^/]+)/`i', $resourcePath, $matches)) {
                     $themeName = $matches[1];
                     $themeInfo = Gdn::themeManager()->getThemeInfo($themeName);
                     $version = val('Version', $themeInfo);
                     $versionSource = "theme {$themeName}";
                 }
                 // Plugin file
                 if (!$version && preg_match('`plugins/([^/]+)/`i', $resourcePath, $matches)) {
                     $pluginName = $matches[1];
                     $pluginInfo = Gdn::pluginManager()->getPluginInfo($pluginName, Gdn_PluginManager::ACCESS_PLUGINNAME);
                     $version = val('Version', $pluginInfo);
                     $versionSource = "plugin {$pluginName}";
                 }
                 // Application file
                 if (!$version && preg_match('`applications/([^/]+)/`i', $resourcePath, $matches)) {
                     $applicationName = $matches[1];
                     $applicationInfo = Gdn::applicationManager()->getApplicationInfo($applicationName);
                     $version = val('Version', $applicationInfo);
                     $versionSource = "app {$applicationName}";
                 }
             }
         } else {
             $version = null;
         }
         // Global file
         if (!$version) {
             $version = APPLICATION_VERSION;
         }
         // If a path was succesfully matched
         if ($resourcePath !== false || $skipFileCheck) {
             // We enact SkipFileCheck for virtual paths, targeting controllers
             // perhaps, or full URLs from the CDN resolver.
             if ($skipFileCheck) {
                 $resourcePath = array_pop($testPaths);
             }
             // Strip PATH_ROOT from absolute path
             $resourceResolved = $resourcePath;
             if ($stripRoot) {
                 $resourceResolved = str_replace(array(PATH_ROOT, DS), array('', '/'), $resourcePath);
             }
             // Bring options into response structure
             $resource = array('path' => $resourcePath);
             $resourceOptions = (array) val('Options', $resourceInfo, array());
             touchValue('version', $resource, $version);
             if ($resourceOptions) {
                 touchValue('options', $resource, $resourceOptions);
             }
             $fileList[$resourceResolved] = $resource;
         }
     }
     return $fileList;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:101,代码来源:class.mustache.php


示例9: settings_addEdit

 /**
  * @param SettingsController $sender
  * @param array $Args
  */
 protected function settings_addEdit($sender, $Args)
 {
     $client_id = $sender->Request->Get('client_id');
     Gdn::Locale()->SetTranslation('AuthenticationKey', 'Client ID');
     Gdn::Locale()->SetTranslation('AssociationSecret', 'Secret');
     Gdn::Locale()->SetTranslation('AuthenticateUrl', 'Authentication Url');
     /* @var Gdn_Form $form */
     $form = $sender->Form;
     $model = new Gdn_AuthenticationProviderModel();
     $form->setModel($model);
     if ($form->authenticatedPostBack()) {
         if ($form->getFormValue('Generate') || $sender->Request->post('Generate')) {
             $form->setFormValue('AuthenticationKey', mt_rand());
             $form->setFormValue('AssociationSecret', md5(mt_rand()));
             $sender->setFormSaved(FALSE);
         } else {
             $form->validateRule('AuthenticationKey', 'ValidateRequired');
             $form->validateRule('AuthenticationKey', 'regex:`^[a-z0-9_-]+$`i', T('The client id must contain only letters, numbers and dashes.'));
             $form->validateRule('AssociationSecret', 'ValidateRequired');
             $form->validateRule('AuthenticateUrl', 'ValidateRequired');
             $form->setFormValue('AuthenticationSchemeAlias', 'jsconnect');
             if ($form->save(['ID' => $client_id])) {
                 $sender->RedirectUrl = url('/settings/jsconnect');
             }
         }
     } else {
         if ($client_id) {
             $provider = self::getProvider($client_id);
             touchValue('Trusted', $provider, 1);
         } else {
             $provider = array();
         }
         $form->setData($provider);
     }
     // Set up the form controls for editing the connection.
     $hashTypes = hash_algos();
     $hashTypes = array_combine($hashTypes, $hashTypes);
     $controls = ['AuthenticationKey' => ['LabelCode' => 'Client ID', 'Description' => T('The client ID uniquely identifies the site.', 'The client ID uniquely identifies the site. You can generate a new ID with the button at the bottom of this page.')], 'AssociationSecret' => ['LabelCode' => 'Secret', 'Description' => T('The secret secures the sign in process.', 'The secret secures the sign in process. Do <b>NOT</b> give the secret out to anyone.')], 'Name' => ['LabelCode' => 'Site Name', 'Description' => T('Enter a short name for the site.', 'Enter a short name for the site. This is displayed on the signin buttons.')], 'AuthenticateUrl' => ['LabelCode' => 'Authentication URL', 'Description' => T('The location of the JSONP formatted authentication data.'), 'Options' => ['class' => 'InputBox BigInput']], 'SignInUrl' => ['LabelCode' => 'Sign In URL', 'Description' => T('The url that users use to sign in.') . ' ' . T('Use {target} to specify a redirect.'), 'Options' => ['class' => 'InputBox BigInput']], 'RegisterUrl' => ['LabelCode' => 'Registration URL', 'Description' => T('The url that users use to register for a new account.'), 'Options' => ['class' => 'InputBox BigInput']], 'SignOutUrl' => ['LabelCode' => 'Sign Out URL', 'Description' => T('The url that users use to sign out of your site.'), 'Options' => ['class' => 'InputBox BigInput']], 'Trusted' => ['Control' => 'checkbox', 'LabelCode' => 'This is trusted connection and can sync roles & permissions.'], 'IsDefault' => ['Control' => 'checkbox', 'LabelCode' => 'Make this connection your default signin method.'], 'Advanced' => ['Control' => 'callback', 'Callback' => function ($form) {
         return '<h2>' . T('Advanced') . '</h2>';
     }], 'HashType' => ['Control' => 'dropdown', 'LabelCode' => 'Hash Algorithm', 'Items' => $hashTypes, 'Description' => T('Choose md5 if you\'re not sure what to choose.', "You can select a custom hash algorithm to sign your requests. The hash algorithm must also be used in your client library. Choose md5 if you're not sure what to choose."), 'Options' => ['Default' => 'md5']], 'TestMode' => ['Control' => 'checkbox', 'LabelCode' => 'This connection is in test-mode.']];
     $sender->setData('_Controls', $controls);
     $sender->setData('Title', sprintf(T($client_id ? 'Edit %s' : 'Add %s'), T('Connection')));
     // Throw a render event as this plugin so that handlers can call our methods.
     Gdn::pluginManager()->callEventHandlers($this, __CLASS__, 'addedit', 'render');
     $sender->render('Settings_AddEdit', '', 'plugins/jsconnect');
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:50,代码来源:class.jsconnect.plugin.php


示例10: isSpam

 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function isSpam($RecordType, $Data, $Options = array())
 {
     if (self::$Disabled) {
         return false;
     }
     // Set some information about the user in the data.
     if ($RecordType == 'Registration') {
         touchValue('Username', $Data, $Data['Name']);
     } else {
         touchValue('InsertUserID', $Data, Gdn::session()->UserID);
         $User = Gdn::userModel()->getID(val('InsertUserID', $Data), DATASET_TYPE_ARRAY);
         if ($User) {
             if (val('Verified', $User)) {
                 // The user has been verified and isn't a spammer.
                 return false;
             }
             touchValue('Username', $Data, $User['Name']);
             touchValue('Email', $Data, $User['Email']);
             touchValue('IPAddress', $Data, $User['LastIPAddress']);
         }
     }
     if (!isset($Data['Body']) && isset($Data['Story'])) {
         $Data['Body'] = $Data['Story'];
     }
     // Make sure all IP addresses are unpacked.
     $Data = ipDecodeRecursive($Data);
     touchValue('IPAddress', $Data, Gdn::request()->ipAddress());
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = false;
     $Sp->fireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && val('Log', $Options, true)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
             case 'Activity':
             case 'ActivityComment':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         // If this is a discussion or a comment, it needs some special handling.
         if ($RecordType == 'Comment' || $RecordType == 'Discussion') {
             // Grab the record ID, if available.
             $recordID = intval(val("{$RecordType}ID", $Data));
             /**
              * If we have a valid record ID, run it through flagForReview.  This will allow us to purge existing
              * discussions and comments that have been flagged as SPAM after being edited.  If there's no valid ID,
              * just treat it with regular SPAM logging.
              */
             if ($recordID) {
                 self::flagForReview($RecordType, $recordID, $Data);
             } else {
                 LogModel::insert('Spam', $RecordType, $Data, $LogOptions);
             }
         } else {
             LogModel::insert('Spam', $RecordType, $Data, $LogOptions);
         }
     }
     return $Spam;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:78,代码来源:class.spammodel.php


示例11: connections

 /**
  * Lists the connections to other sites.
  *
  * @param int|string $UserReference
  * @param string $Username
  * @since 2.1
  */
 public function connections($UserReference = '', $Username = '')
 {
     $this->permission('Garden.SignIn.Allow');
     $this->getUserInfo($UserReference, $Username, '', true);
     $UserID = valr('User.UserID', $this);
     $this->_setBreadcrumbs(t('Social'), userUrl($this->User, '', 'connections'));
     $PModel = new Gdn_AuthenticationProviderModel();
     $Providers = $PModel->getProviders();
     $this->setData('_Providers', $Providers);
     $this->setData('Connections', array());
     $this->EventArguments['User'] = $this->User;
     $this->fireEvent('GetConnections');
     // Add some connection information.
     foreach ($this->Data['Connections'] as &$Row) {
         $Provider = val($Row['ProviderKey'], $Providers, array());
         touchValue('Connected', $Row, !is_null(val('UniqueID', $Provider, null)));
     }
     $this->canonicalUrl(userUrl($this->User, '', 'connections'));
     $this->title(t('Social'));
     require_once $this->fetchViewLocation('connection_functions');
     $this->render();
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:29,代码来源:class.profilecontroller.php


示例12: renderMaster


//.........这里部分代码省略.........
                     if ($this->Theme) {
                         // 1. Application-specific js. eg. root/themes/theme_name/app_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                         // 2. Garden-wide theme view. eg. root/themes/theme_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'js' . DS . $JsFile;
                     }
                     // 3. The application or plugin folder.
                     if (stringBeginsWith(trim($AppFolder, '/'), 'plugins/')) {
                         $JsPaths[] = PATH_PLUGINS . strstr($AppFolder, '/') . "/js/{$JsFile}";
                         $JsPaths[] = PATH_PLUGINS . strstr($AppFolder, '/') . "/{$JsFile}";
                     } else {
                         $JsPaths[] = PATH_APPLICATIONS . "/{$AppFolder}/js/{$JsFile}";
                     }
                     // 4. Global JS folder. eg. root/js/
                     $JsPaths[] = PATH_ROOT . DS . 'js' . DS . $JsFile;
                     // 5. Global JS library folder. eg. root/js/library/
                     $JsPaths[] = PATH_ROOT . DS . 'js' . DS . 'library' . DS . $JsFile;
                 }
                 // Find the first file that matches the path.
                 $JsPath = false;
                 foreach ($JsPaths as $Glob) {
                     $Paths = safeGlob($Glob);
                     if (is_array($Paths) && count($Paths) > 0) {
                         $JsPath = $Paths[0];
                         break;
                     }
                 }
                 if ($JsPath !== false) {
                     $JsSrc = str_replace(array(PATH_ROOT, DS), array('', '/'), $JsPath);
                     $Options = (array) $JsInfo['Options'];
                     $Options['path'] = $JsPath;
                     $Version = val('Version', $JsInfo);
                     if ($Version) {
                         touchValue('version', $Options, $Version);
                     }
                     $this->Head->addScript($JsSrc, 'text/javascript', $Options);
                 }
             }
         }
         // Add the favicon.
         $Favicon = C('Garden.FavIcon');
         if ($Favicon) {
             $this->Head->setFavIcon(Gdn_Upload::url($Favicon));
         }
         // Make sure the head module gets passed into the assets collection.
         $this->addModule('Head');
     }
     // Master views come from one of four places:
     $MasterViewPaths = array();
     $MasterViewPath2 = viewLocation($this->masterView() . '.master', '', $this->ApplicationFolder);
     if (strpos($this->MasterView, '/') !== false) {
         $MasterViewPaths[] = combinePaths(array(PATH_ROOT, str_replace('/', DS, $this->MasterView) . '.master*'));
     } else {
         if ($this->Theme) {
             // 1. Application-specific theme view. eg. root/themes/theme_name/app_name/views/
             $MasterViewPaths[] = combinePaths(array(PATH_THEMES, $this->Theme, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
             // 2. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/
             $MasterViewPaths[] = combinePaths(array(PATH_THEMES, $this->Theme, 'views', $this->MasterView . '.master*'));
         }
         // 3. Application default. eg. root/app_name/views/
         $MasterViewPaths[] = combinePaths(array(PATH_APPLICATIONS, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
         // 4. Garden default. eg. root/dashboard/views/
         $MasterViewPaths[] = combinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', $this->MasterView . '.master*'));
     }
     // Find the first file that matches the path.
     $MasterViewPath = false;
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:67,代码来源:class.controller.php


示例13: schema

 /**
  * Set the data definition to load/save from the config.
  *
  * @param array $Def A list of fields from the config that this form will use.
  */
 public function schema($Def = null)
 {
     if ($Def !== null) {
         $Schema = array();
         foreach ($Def as $Key => $Value) {
             $Row = array('Name' => '', 'Type' => 'string', 'Control' => 'TextBox', 'Options' => array());
             if (is_numeric($Key)) {
                 $Row['Name'] = $Value;
             } elseif (is_string($Value)) {
                 $Row['Name'] = $Key;
                 $Row['Type'] = $Value;
             } elseif (is_array($Value)) {
                 $Row['Name'] = $Key;
                 $Row = array_merge($Row, $Value);
             } else {
                 $Row['Name'] = $Key;
             }
             touchValue('Config', $Row, $Row['Name']);
             $Schema[] = $Row;
         }
         $this->_Schema = $Schema;
     }
     return $this->_Schema;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:29,代码来源:class.configurationmodule.php


示例14: _touch

 /**
  *
  *
  * @param $Data
  */
 protected function _touch(&$Data)
 {
     touchValue('ActivityType', $Data, 'Default');
     touchValue('ActivityUserID', $Data, Gdn::session()->UserID);
     touchValue('NotifyUserID', $Data, self::NOTIFY_PUBLIC);
     touchValue('Headline', $Data, null);
     touchValue('Story', $Data, null);
     touchValue('Notified', $Data, 0);
     touchValue('Emailed', $Data, 0);
     touchValue('Photo', $Data, null);
     touchValue('Route', $Data, null);
     if (!isset($Data['Data']) || !is_array($Data['Data'])) {
         $Data['Data'] = array();
     }
 }
开发者ID:bahill,项目名称:vanilla,代码行数:20,代码来源:class.activitymodel.php


示例15: simple

 /**
  * Generates a multi-field form from a schema.
  *
  * @param array $Schema An array where each item of the array is a row that identifies a form field with the following information:
  *  - Name: The name of the form field.
  *  - Control: The type of control used for the field. This is one of the control methods on the Gdn_Form object.
  *  - LabelCode: The translation code for the label. Optional.
  *  - Description: An optional description for the field.
  *  - Items: If the control is a list control then its items are specified here.
  *  - Options: Additional options to be passed into the control.
  * @param type $Options Additional options to pass into the form.
  *  - Wrap: A two item array specifying the text to wrap the form in.
  *  - ItemWrap: A two item array specifying the text to wrap each form item in.
  */
 public function simple($Schema, $Options = array())
 {
     $Result = valr('Wrap.0', $Options, '<ul>');
     $ItemWrap = val('ItemWrap', $Options, array("<li>\n  ", "\n</li>\n"));
     foreach ($Schema as $Index => $Row) {
         if (is_string($Row)) {
             $Row = array('Name' => $Index, 'Control' => $Row);
         }
         if (!isset($Row['Name'])) {
             $Row['Name'] = $Index;
         }
         if (!isset($Row['Options'])) {
             $Row['Options'] = array();
         }
         $Result .= $ItemWrap[0];
         $LabelCode = self::labelCode($Row);
         $Description = val('Description', $Row, '');
         if ($Description) {
             $Description = '<div class="Info">' . $Description . '</div>';
         }
        

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP touch_time函数代码示例发布时间:2022-05-23
下一篇:
PHP touch函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap