当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn::structure方法代码示例

本文整理汇总了PHP中Gdn::structure方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::structure方法的具体用法?PHP Gdn::structure怎么用?PHP Gdn::structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn的用法示例。


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

示例1: structure

 /**
  * Apply database structure updates
  */
 public function structure()
 {
     $PM = new PermissionModel();
     $PM->define(array('Plugins.PostUrl.Allow' => 'Plugins.PostUrl.Allow'));
     $Structure = Gdn::structure();
     $Structure->table('PostUrl')->column('DiscussionID', 'int(11)', false, 'unique')->column('PostUrlValue', 'int(11)')->column('DateInserted', 'datetime')->set(false, false);
 }
开发者ID:xjtdy888,项目名称:vanilla-posturl,代码行数:10,代码来源:class.posturl.plugin.php

示例2: updateCounts

 /**
  *
  *
  * @return bool
  */
 public function updateCounts()
 {
     // This option could take a while so set the timeout.
     set_time_limit(60 * 5);
     // Define the necessary SQL.
     $Sqls = array();
     if (!$this->importExists('Discussion', 'LastCommentID')) {
         $Sqls['Discussion.LastCommentID'] = $this->GetCountSQL('max', 'Discussion', 'Comment');
     }
     if (!$this->importExists('Discussion', 'DateLastComment')) {
         $Sqls['Discussion.DateLastComment'] = "update :_Discussion d\n         left join :_Comment c\n            on d.LastCommentID = c.CommentID\n         set d.DateLastComment = coalesce(c.DateInserted, d.DateInserted)";
     }
     if (!$this->importExists('Discussion', 'LastCommentUserID')) {
         $Sqls['Discussion.LastCommentUseID'] = "update :_Discussion d\n         join :_Comment c\n            on d.LastCommentID = c.CommentID\n         set d.LastCommentUserID = c.InsertUserID";
     }
     if (!$this->importExists('Discussion', 'Body')) {
         // Update the body of the discussion if it isn't there.
         if (!$this->importExists('Discussion', 'FirstCommentID')) {
             $Sqls['Discussion.FirstCommentID'] = $this->GetCountSQL('min', 'Discussion', 'Comment', 'FirstCommentID', 'CommentID');
         }
         $Sqls['Discussion.Body'] = "update :_Discussion d\n         join :_Comment c\n            on d.FirstCommentID = c.CommentID\n         set d.Body = c.Body, d.Format = c.Format";
         if ($this->importExists('Media') && Gdn::structure()->TableExists('Media')) {
             // Comment Media has to go onto the discussion.
             $Sqls['Media.Foreign'] = "update :_Media m\n            join :_Discussion d\n               on d.FirstCommentID = m.ForeignID and m.ForeignTable = 'comment'\n            set m.ForeignID = d.DiscussionID, m.ForeignTable = 'discussion'";
         }
         $Sqls['Comment.FirstComment.Delete'] = "delete c.*\n         from :_Comment c\n         inner join :_Discussion d\n           on d.FirstCommentID = c.CommentID";
     }
     if (!$this->importExists('Discussion', 'CountComments')) {
         $Sqls['Discussion.CountComments'] = $this->GetCountSQL('count', 'Discussion', 'Comment');
     }
     if ($this->importExists('UserDiscussion') && !$this->importExists('UserDiscussion', 'CountComments') && $this->importExists('UserDiscussion', 'DateLastViewed')) {
         $Sqls['UserDiscussuion.CountComments'] = "update :_UserDiscussion ud\n         set CountComments = (\n           select count(c.CommentID)\n           from :_Comment c\n           where c.DiscussionID = ud.DiscussionID\n             and c.DateInserted <= ud.DateLastViewed)";
     }
     if ($this->importExists('Tag') && $this->importExists('TagDiscussion')) {
         $Sqls['Tag.CoundDiscussions'] = $this->GetCountSQL('count', 'Tag', 'TagDiscussion', 'CountDiscussions', 'TagID');
     }
     if ($this->importExists('Poll') && Gdn::structure()->TableExists('Poll')) {
         $Sqls['PollOption.CountVotes'] = $this->GetCountSQL('count', 'PollOption', 'PollVote', 'CountVotes', 'PollOptionID');
         $Sqls['Poll.CountOptions'] = $this->GetCountSQL('count', 'Poll', 'PollOption', 'CountOptions', 'PollID');
         $Sqls['Poll.CountVotes'] = $this->GetCountSQL('sum', 'Poll', 'PollOption', 'CountVotes', 'CountVotes', 'PollID');
     }
     if ($this->importExists('Activity', 'ActivityType')) {
         $Sqls['Activity.ActivityTypeID'] = "\n            update :_Activity a\n            join :_ActivityType t\n               on a.ActivityType = t.Name\n            set a.ActivityTypeID = t.ActivityTypeID";
     }
     if ($this->importExists('Tag') && $this->importExists('TagDiscussion')) {
         $Sqls['Tag.CoundDiscussions'] = $this->GetCountSQL('count', 'Tag', 'TagDiscussion', 'CountDiscussions', 'TagID');
     }
     $Sqls['Category.CountDiscussions'] = $this->GetCountSQL('count', 'Category', 'Discussion');
     $Sqls['Category.CountComments'] = $this->GetCountSQL('sum', 'Category', 'Discussion', 'CountComments', 'CountComments');
     if (!$this->importExists('Category', 'PermissionCategoryID')) {
         $Sqls['Category.PermissionCategoryID'] = "update :_Category set PermissionCategoryID = -1";
     }
     if ($this->importExists('Conversation') && $this->importExists('ConversationMessage')) {
         $Sqls['Conversation.FirstMessageID'] = $this->GetCountSQL('min', 'Conversation', 'ConversationMessage', 'FirstMessageID', 'MessageID');
         if (!$this->importExists('Conversation', 'CountMessages')) {
             $Sqls['Conversation.CountMessages'] = $this->GetCountSQL('count', 'Conversation', 'ConversationMessage', 'CountMessages', 'MessageID');
         }
         if (!$this->importExists('Conversation', 'LastMessageID')) {
             $Sqls['Conversation.LastMessageID'] = $this->GetCountSQL('max', 'Conversation', 'ConversationMessage', 'LastMessageID', 'MessageID');
         }
         if (!$this->importExists('Conversation', 'DateUpdated')) {
             $Sqls['Converstation.DateUpdated'] = "update :_Conversation c join :_ConversationMessage m on c.LastMessageID = m.MessageID set c.DateUpdated = m.DateInserted";
         }
         if ($this->importExists('UserConversation')) {
             if (!$this->importExists('UserConversation', 'LastMessageID')) {
                 if ($this->importExists('UserConversation', 'DateLastViewed')) {
                     // Get the value from the DateLastViewed.
                     $Sqls['UserConversation.LastMessageID'] = "update :_UserConversation uc\n                     set LastMessageID = (\n                       select max(MessageID)\n                       from :_ConversationMessage m\n                       where m.ConversationID = uc.ConversationID\n                         and m.DateInserted >= uc.DateLastViewed)";
                 } else {
                     // Get the value from the conversation.
                     // In this case just mark all of the messages read.
                     $Sqls['UserConversation.LastMessageID'] = "update :_UserConversation uc\n                     join :_Conversation c\n                       on c.ConversationID = uc.ConversationID\n                     set uc.CountReadMessages = c.CountMessages,\n                       uc.LastMessageID = c.LastMessageID";
                 }
             } elseif (!$this->importExists('UserConversation', 'DateLastViewed')) {
                 // We have the last message so grab the date from that.
                 $Sqls['UserConversation.DateLastViewed'] = "update :_UserConversation uc\n                     join :_ConversationMessage m\n                       on m.ConversationID = uc.ConversationID\n                         and m.MessageID = uc.LastMessageID\n                     set uc.DateLastViewed = m.DateInserted";
             }
         }
     }
     // User counts.
     if (!$this->importExists('User', 'DateFirstVisit')) {
         $Sqls['User.DateFirstVisit'] = 'update :_User set DateFirstVisit = DateInserted';
     }
     if (!$this->importExists('User', 'CountDiscussions')) {
         $Sqls['User.CountDiscussions'] = $this->GetCountSQL('count', 'User', 'Discussion', 'CountDiscussions', 'DiscussionID', 'UserID', 'InsertUserID');
     }
     if (!$this->importExists('User', 'CountComments')) {
         $Sqls['User.CountComments'] = $this->GetCountSQL('count', 'User', 'Comment', 'CountComments', 'CommentID', 'UserID', 'InsertUserID');
     }
     if (!$this->importExists('User', 'CountBookmarks')) {
         $Sqls['User.CountBookmarks'] = "update :_User u\n            set CountBookmarks = (\n               select count(ud.DiscussionID)\n               from :_UserDiscussion ud\n               where ud.Bookmarked = 1\n                  and ud.UserID = u.UserID\n            )";
     }
     //      if (!$this->importExists('User', 'CountUnreadConversations')) {
     //         $Sqls['User.CountUnreadConversations'] =
     //            'update :_User u
//.........这里部分代码省略.........
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:101,代码来源:class.importmodel.php

示例3: structure

 /**
  * Database update.
  *
  * @throws Exception
  */
 public function structure()
 {
     Gdn::structure()->table('Media')->primaryKey('MediaID')->column('Name', 'varchar(255)')->column('Type', 'varchar(128)')->column('Size', 'int(11)')->column('ImageWidth', 'usmallint', null)->column('ImageHeight', 'usmallint', null)->column('StorageMethod', 'varchar(24)', 'local')->column('Path', 'varchar(255)')->column('ThumbWidth', 'usmallint', null)->column('ThumbHeight', 'usmallint', null)->column('ThumbPath', 'varchar(255)', null)->column('InsertUserID', 'int(11)')->column('DateInserted', 'datetime')->column('ForeignID', 'int(11)', true)->column('ForeignTable', 'varchar(24)', true)->set();
     Gdn::structure()->table('Category')->column('AllowFileUploads', 'tinyint(1)', '1')->set();
 }
开发者ID:vanilla,项目名称:addons,代码行数:10,代码来源:class.fileupload.plugin.php

示例4: structure

 /**
  * Plugin structure method.
  *
  * Add 'Resolved' columns to the Discussion table.
  *
  * @return void
  */
 public function structure()
 {
     Gdn::structure()->table('Discussion')->column('Resolved', 'int', '0')->column('DateResolved', 'datetime', true)->column('ResolvedUserID', 'int', true)->set();
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:11,代码来源:class.resolved.plugin.php

示例5: runStructure

 /**
  * Run the structure for all addons.
  *
  * The structure runs the addons in priority order so that higher priority addons override lower priority ones.
  *
  * @param bool $captureOnly Run the structure or just capture the SQL changes.
  * @throws Exception Throws an exception if in debug mode and something goes wrong.
  */
 public function runStructure($captureOnly = false)
 {
     $addons = array_reverse(Gdn::addonManager()->getEnabled());
     // These variables are required for included structure files.
     $Database = Gdn::database();
     $SQL = $this->SQL;
     $SQL->CaptureModifications = $captureOnly;
     $Structure = Gdn::structure();
     $Structure->CaptureOnly = $captureOnly;
     /* @var Addon $addon */
     foreach ($addons as $addon) {
         // Look for a structure file.
         if ($structure = $addon->getSpecial('structure')) {
             Logger::event('addon_structure', Logger::INFO, "Executing structure for {addonKey}.", ['addonKey' => $addon->getKey(), 'structureType' => 'file']);
             try {
                 include $addon->path($structure);
             } catch (\Exception $ex) {
                 if (debug()) {
                     throw $ex;
                 }
             }
         }
         // Look for a structure method on the plugin.
         if ($addon->getPluginClass()) {
             $plugin = Gdn::pluginManager()->getPluginInstance($addon->getPluginClass(), Gdn_PluginManager::ACCESS_CLASSNAME);
             if (is_object($plugin) && method_exists($plugin, 'structure')) {
                 Logger::event('addon_structure', Logger::INFO, "Executing structure for {addonKey}.", ['addonKey' => $addon->getKey(), 'structureType' => 'method']);
                 try {
                     call_user_func([$plugin, 'structure']);
                 } catch (\Exception $ex) {
                     if (debug()) {
                         throw $ex;
                     }
                 }
             }
         }
         // Register permissions.
         $permissions = $addon->getInfoValue('registerPermissions');
         if (!empty($permissions)) {
             Logger::event('addon_permissions', Logger::INFO, "Defining permissions for {addonKey}.", ['addonKey' => $addon->getKey(), 'permissions' => $permissions]);
             Gdn::permissionModel()->define($permissions);
         }
     }
     $this->fireEvent('AfterStructure');
     if ($captureOnly && property_exists($Structure->Database, 'CapturedSql')) {
         return $Structure->Database->CapturedSql;
     }
     return [];
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:57,代码来源:class.updatemodel.php

示例6: loadTableInsert

 /**
  * Import a table from a CSV using SQL insert statements.
  *
  * @param string $Tablename The name of the table to import to.
  * @param string $Path The path to the CSV.
  * @param bool $skipHeader Whether the CSV contains a header row.
  * @param int $chunk The number of records to chunk the imports to.
  * @return bool
  */
 public function loadTableInsert($Tablename, $Path, $skipHeader = true, $chunk = 100)
 {
     // Get the column count of the table.
     $St = Gdn::structure();
     $St->get(self::TABLE_PREFIX . $Tablename);
     $ColumnCount = count($St->Columns());
     $St->reset();
     ini_set('auto_detect_line_endings', true);
     $fp = fopen($Path, 'rb');
     // Figure out the current position.
     $fPosition = val('CurrentLoadPosition', $this->Data, 0);
     if ($fPosition == 0 && $skipHeader) {
         // Skip the header row.
         $Row = self::FGetCSV2($fp);
     }
     if ($fPosition == 0) {
         $Px = Gdn::database()->DatabasePrefix . self::TABLE_PREFIX;
         Gdn::database()->query("truncate table {$Px}{$Tablename}");
     } else {
         fseek($fp, $fPosition);
     }
     $PDO = Gdn::database()->connection();
     $PxTablename = Gdn::database()->DatabasePrefix . self::TABLE_PREFIX . $Tablename;
     $Inserts = '';
     $Count = 0;
     while ($Row = self::FGetCSV2($fp)) {
         ++$Count;
         $Row = array_map('trim', $Row);
         // Quote the values in the row.
         $Row = array_map(array($PDO, 'quote'), $Row);
         // Add any extra columns to the row.
         while (count($Row) < $ColumnCount) {
             $Row[] = 'null';
         }
         // Add the insert values to the sql.
         if (strlen($Inserts) > 0) {
             $Inserts .= ',';
         }
         $Inserts .= '(' . implode(',', $Row) . ')';
         if ($Count >= $chunk) {
             // Insert in chunks.
             $Sql = "insert {$PxTablename} values {$Inserts}";
             $this->Database->query($Sql);
             $Count = 0;
             $Inserts = '';
             // Check for a timeout.
             if ($this->Timer->ElapsedTime() > $this->MaxStepTime) {
                 // The step's taken too long. Save the file position.
                 $Pos = ftell($fp);
                 $this->Data['CurrentLoadPosition'] = $Pos;
                 $Filesize = filesize($Path);
                 if ($Filesize > 0) {
                     $PercentComplete = $Pos / filesize($Path);
                     $this->Data['CurrentStepMessage'] = $Tablename . ' (' . round($PercentComplete * 100.0) . '%)';
                 }
                 fclose($fp);
                 return 0;
             }
         }
     }
     fclose($fp);
     if (strlen($Inserts) > 0) {
         $Sql = "insert {$PxTablename} values {$Inserts}";
         $this->query($Sql);
     }
     return $Count;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:76,代码来源:class.importmodel.php

示例7: structure

 /**
  * Runs on utility/update.
  *
  * @throws Exception
  */
 public function structure()
 {
     // Pocket class isn't autoloaded on Enable.
     require_once 'library/class.pocket.php';
     $St = Gdn::structure();
     $St->table('Pocket')->primaryKey('PocketID')->column('Name', 'varchar(255)')->column('Page', 'varchar(50)', null)->column('Location', 'varchar(50)')->column('Sort', 'smallint')->column('Repeat', 'varchar(25)')->column('Body', 'text')->column('Format', 'varchar(20)')->column('Condition', 'varchar(500)', null)->column('Disabled', 'smallint', '0')->column('Attributes', 'text', null)->column('MobileOnly', 'tinyint', '0')->column('MobileNever', 'tinyint', '0')->column('EmbeddedNever', 'tinyint', '0')->column('ShowInDashboard', 'tinyint', '0')->column('Type', array(Pocket::TYPE_DEFAULT, Pocket::TYPE_AD), Pocket::TYPE_DEFAULT)->set();
     $PermissionModel = Gdn::permissionModel();
     $PermissionModel->define(array('Garden.NoAds.Allow' => 0));
 }
开发者ID:vanilla,项目名称:addons,代码行数:14,代码来源:class.pockets.plugin.php

示例8: structure

 /**
  * Run on utility/update.
  *
  * @throws Exception
  */
 public function structure()
 {
     Gdn::structure()->table('Discussion')->column('DateRevived', 'datetime', true)->set();
 }
开发者ID:ravilrrr,项目名称:addons,代码行数:9,代码来源:class.necro.plugin.php

示例9: array

if (!defined('APPLICATION')) {
    exit;
}
/**
 *
 *
 * @copyright 2009-2016 Vanilla Forums Inc.
 * @license http://www.opensource.org/licenses/gpl-2.0.php GNU GPL v2
 * @package Addons
 * @since 2.0
 */
$Drop = false;
$Explicit = false;
$SQL = Gdn::sql();
$Construct = Gdn::structure();
$Px = $Construct->databasePrefix();
$Construct->table('AddonType')->primaryKey('AddonTypeID')->column('Label', 'varchar(50)')->column('Visible', 'tinyint(1)', '1')->set($Explicit, $Drop);
$SQL->replace('AddonType', array('Label' => 'Plugin', 'Visible' => '1'), array('AddonTypeID' => 1), true);
$SQL->replace('AddonType', array('Label' => 'Theme', 'Visible' => '1'), array('AddonTypeID' => 2), true);
$SQL->replace('AddonType', array('Label' => 'Style', 'Visible' => '0'), array('AddonTypeID' => 3), true);
$SQL->replace('AddonType', array('Label' => 'Locale', 'Visible' => '1'), array('AddonTypeID' => 4), true);
$SQL->replace('AddonType', array('Label' => 'Application', 'Visible' => '1'), array('AddonTypeID' => 5), true);
$SQL->replace('AddonType', array('Label' => 'Core', 'Visible' => '1'), array('AddonTypeID' => 10), true);
$Construct->table('Addon');
$Description2Exists = $Construct->columnExists('Description2');
$Construct->primaryKey('AddonID')->column('CurrentAddonVersionID', 'int', true, 'key')->column('AddonKey', 'varchar(50)', null, 'index')->column('AddonTypeID', 'int', false, 'key')->column('InsertUserID', 'int', false, 'key')->column('UpdateUserID', 'int', true)->column('Name', 'varchar(100)')->column('Icon', 'varchar(200)', true)->column('Description', 'text', true)->column('Description2', 'text', null)->column('Requirements', 'text', true)->column('CountComments', 'int', '0')->column('CountDownloads', 'int', '0')->column('Visible', 'tinyint(1)', '1')->column('Vanilla2', 'tinyint(1)', '1')->column('DateInserted', 'datetime')->column('DateUpdated', 'datetime', true)->column('Checked', 'tinyint(1)', '0')->column('Official', 'tinyint(1)', '0')->column('License', 'varchar(100)')->column('GitHub', 'varchar(100)', null)->column('EnName', 'varchar(100)', null)->column('PercentComplete', 'tinyint', null)->set($Explicit, $Drop);
if (!$Description2Exists) {
    $Construct->query("update {$Px}Addon set Description2 = Description where Checked = 0");
}
$Construct->table('AddonVersion')->primaryKey('AddonVersionID')->column('AddonID', 'int', false, 'key')->column('File', 'varchar(200)', true)->column('Version', 'varchar(20)')->column('TestedWith', 'text', null)->column('FileSize', 'int', null)->column('MD5', 'varchar(32)')->column('Notes', 'text', null)->column('Format', 'varchar(10)', 'Html')->column('InsertUserID', 'int', false, 'key')->column('DateInserted', 'datetime')->column('DateReviewed', 'datetime', true)->column('Checked', 'tinyint(1)', '0')->column('Deleted', 'tinyint(1)', '0')->set($Explicit, $Drop);
开发者ID:vanilla,项目名称:community,代码行数:30,代码来源:structure.php

示例10: runStructure

 /**
  * Run the database structure or /utility/structure.
  *
  * Note: Keep this method protected!
  *
  * @param string $appName Unique app name or 'all' (default).
  * @param bool $captureOnly Whether to list changes rather than execute (0 or 1).
  * @throws Exception
  */
 protected function runStructure($appName = 'all', $captureOnly = true)
 {
     // This permission is run again to be sure someone doesn't accidentally call this method incorrectly.
     $this->permission('Garden.Settings.Manage');
     $Files = array();
     $appName = $appName == '' ? 'all' : $appName;
     if ($appName == 'all') {
         // Load all application structure files.
         $ApplicationManager = new Gdn_ApplicationManager();
         $Apps = $ApplicationManager->enabledApplications();
         $AppNames = array_column($Apps, 'Folder');
         foreach ($AppNames as $appName) {
             $Files[] = combinePaths(array(PATH_APPLICATIONS, $appName, 'settings', 'structure.php'), DS);
         }
         $appName = 'all';
     } else {
         // Load that specific application structure file.
         $Files[] = combinePaths(array(PATH_APPLICATIONS, $appName, 'settings', 'structure.php'), DS);
     }
     $Drop = false;
     $Explicit = false;
     $captureOnly = !($captureOnly == '0');
     $Structure = Gdn::structure();
     $Structure->CaptureOnly = $captureOnly;
     $SQL = Gdn::sql();
     $SQL->CaptureModifications = $captureOnly;
     $this->setData('CaptureOnly', $Structure->CaptureOnly);
     $this->setData('Drop', $Drop);
     $this->setData('Explicit', $Explicit);
     $this->setData('ApplicationName', $appName);
     $this->setData('Status', '');
     $FoundStructureFile = false;
     foreach ($Files as $File) {
         if (file_exists($File)) {
             $FoundStructureFile = true;
             try {
                 include $File;
             } catch (Exception $Ex) {
                 $this->Form->addError($Ex);
             }
         }
     }
     // Run the structure of all of the plugins.
     $Plugins = Gdn::pluginManager()->enabledPlugins();
     foreach ($Plugins as $PluginKey => $Plugin) {
         $PluginInstance = Gdn::pluginManager()->getPluginInstance($PluginKey, Gdn_PluginManager::ACCESS_PLUGINNAME);
         if (method_exists($PluginInstance, 'Structure')) {
             $PluginInstance->structure();
         }
     }
     if (property_exists($Structure->Database, 'CapturedSql')) {
         $this->setData('CapturedSql', (array) $Structure->Database->CapturedSql);
     } else {
         $this->setData('CapturedSql', array());
     }
     if ($this->Form->errorCount() == 0 && !$captureOnly && $FoundStructureFile) {
         $this->setData('Status', 'The structure was successfully executed.');
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:68,代码来源:class.utilitycontroller.php

示例11: structure

 /**
  * Update database structure based on current definitions in each app's structure.php file.
  *
  * @since 2.0.?
  * @access public
  * @param string $AppName Unique app name or 'all' (default).
  * @param int $CaptureOnly Whether to list changes rather than execture (0 or 1).
  * @param int $Drop Whether to drop first (0 or 1).
  * @param int $Explicit Whether to force to only columns currently listed (0 or 1).
  */
 public function structure($AppName = 'all', $CaptureOnly = '1', $Drop = '0', $Explicit = '0')
 {
     $this->permission('Garden.Settings.Manage');
     $Files = array();
     $AppName = $AppName == '' ? 'all' : $AppName;
     if ($AppName == 'all') {
         // Load all application structure files.
         $ApplicationManager = new Gdn_ApplicationManager();
         $Apps = $ApplicationManager->enabledApplications();
         $AppNames = array_column($Apps, 'Folder');
         foreach ($AppNames as $AppName) {
             $Files[] = combinePaths(array(PATH_APPLICATIONS, $AppName, 'settings', 'structure.php'), DS);
         }
         $AppName = 'all';
     } else {
         // Load that specific application structure file.
         $Files[] = combinePaths(array(PATH_APPLICATIONS, $AppName, 'settings', 'structure.php'), DS);
     }
     $Validation = new Gdn_Validation();
     $Database = Gdn::database();
     $Drop = $Drop == '0' ? false : true;
     $Explicit = $Explicit == '0' ? false : true;
     $CaptureOnly = !($CaptureOnly == '0');
     $Structure = Gdn::structure();
     $Structure->CaptureOnly = $CaptureOnly;
     $SQL = Gdn::sql();
     $SQL->CaptureModifications = $CaptureOnly;
     $this->setData('CaptureOnly', $Structure->CaptureOnly);
     $this->setData('Drop', $Drop);
     $this->setData('Explicit', $Explicit);
     $this->setData('ApplicationName', $AppName);
     $this->setData('Status', '');
     $FoundStructureFile = false;
     foreach ($Files as $File) {
         if (file_exists($File)) {
             $FoundStructureFile = true;
             try {
                 include $File;
             } catch (Exception $Ex) {
                 $this->Form->addError($Ex);
             }
         }
     }
     // Run the structure of all of the plugins.
     $Plugins = Gdn::pluginManager()->enabledPlugins();
     foreach ($Plugins as $PluginKey => $Plugin) {
         $PluginInstance = Gdn::pluginManager()->getPluginInstance($PluginKey, Gdn_PluginManager::ACCESS_PLUGINNAME);
         if (method_exists($PluginInstance, 'Structure')) {
             $PluginInstance->structure();
         }
     }
     if (property_exists($Structure->Database, 'CapturedSql')) {
         $this->setData('CapturedSql', (array) $Structure->Database->CapturedSql);
     } else {
         $this->setData('CapturedSql', array());
     }
     if ($this->Form->errorCount() == 0 && !$CaptureOnly && $FoundStructureFile) {
         $this->setData('Status', 'The structure was successfully executed.');
     }
     $this->addSideMenu('dashboard/settings/configure');
     $this->addCssFile('admin.css');
     $this->setData('Title', t('Database Structure Upgrades'));
     $this->render();
 }
开发者ID:bryanjamesmiller,项目名称:vanilla,代码行数:74,代码来源:class.utilitycontroller.php

示例12: structure

 /**
  * Database structure: on update
  */
 public function structure()
 {
     Gdn::structure()->table('User')->column('Troll', 'int', '0')->column('Fingerprint', 'varchar(50)', null, 'index')->set();
 }
开发者ID:vanilla,项目名称:addons,代码行数:7,代码来源:class.trollmanagement.plugin.php

示例13: BadgeModel

}
// Define 'Answer' badges
if (Gdn::addonManager()->isEnabled('badges', \Vanilla\Addon::TYPE_ADDON) && c('Plugins.QnA.Badges', true)) {
    $this->Badges = true;
}
if ($this->Badges && class_exists('BadgeModel')) {
    $BadgeModel = new BadgeModel();
    // Answer Counts
    $BadgeModel->define(array('Name' => 'First Answer', 'Slug' => 'answer', 'Type' => 'UserCount', 'Body' => 'Answering questions is a great way to show your support for a community!', 'Photo' => 'http://badges.vni.la/100/answer.png', 'Points' => 2, 'Attributes' => array('Column' => 'CountAcceptedAnswers'), 'Threshold' => 1, 'Class' => 'Answerer', 'Level' => 1, 'CanDelete' => 0));
    $BadgeModel->define(array('Name' => '5 Answers', 'Slug' => 'answer-5', 'Type' => 'UserCount', 'Body' => 'Your willingness to share knowledge has definitely been noticed.', 'Photo' => 'http://badges.vni.la/100/answer-2.png', 'Points' => 3, 'Attributes' => array('Column' => 'CountAcceptedAnswers'), 'Threshold' => 5, 'Class' => 'Answerer', 'Level' => 2, 'CanDelete' => 0));
    $BadgeModel->define(array('Name' => '25 Answers', 'Slug' => 'answer-25', 'Type' => 'UserCount', 'Body' => 'Looks like you&rsquo;re starting to make a name for yourself as someone who knows the score!', 'Photo' => 'http://badges.vni.la/100/answer-3.png', 'Points' => 5, 'Attributes' => array('Column' => 'CountAcceptedAnswers'), 'Threshold' => 25, 'Class' => 'Answerer', 'Level' => 3, 'CanDelete' => 0));
    $BadgeModel->define(array('Name' => '50 Answers', 'Slug' => 'answer-50', 'Type' => 'UserCount', 'Body' => 'Why use Google when we could just ask you?', 'Photo' => 'http://badges.vni.la/100/answer-4.png', 'Points' => 10, 'Attributes' => array('Column' => 'CountAcceptedAnswers'), 'Threshold' => 50, 'Class' => 'Answerer', 'Level' => 4, 'CanDelete' => 0));
    $BadgeModel->define(array('Name' => '100 Answers', 'Slug' => 'answer-100', 'Type' => 'UserCount', 'Body' => 'Admit it, you read Wikipedia in your spare time.', 'Photo' => 'http://badges.vni.la/100/answer-5.png', 'Points' => 15, 'Attributes' => array('Column' => 'CountAcceptedAnswers'), 'Threshold' => 100, 'Class' => 'Answerer', 'Level' => 5, 'CanDelete' => 0));
    $BadgeModel->define(array('Name' => '250 Answers', 'Slug' => 'answer-250', 'Type' => 'UserCount', 'Body' => 'Is there *anything* you don&rsquo;t know?', 'Photo' => 'http://badges.vni.la/100/answer-6.png', 'Points' => 20, 'Attributes' => array('Column' => 'CountAcceptedAnswers'), 'Threshold' => 250, 'Class' => 'Answerer', 'Level' => 6, 'CanDelete' => 0));
}
// Define 'Accept' reaction
if (Gdn::addonManager()->isEnabled('Reactions', \Vanilla\Addon::TYPE_ADDON) && c('Plugins.QnA.Reactions', true)) {
    $this->Reactions = true;
}
if ($this->Reactions && class_exists('ReactionModel')) {
    $Rm = new ReactionModel();
    if (Gdn::structure()->table('ReactionType')->columnExists('Hidden')) {
        $points = 3;
        if (c('QnA.Points.Enabled', false)) {
            $points = c('QnA.Points.AcceptedAnswer', 1);
        }
        // AcceptAnswer
        $Rm->defineReactionType(['UrlCode' => 'AcceptAnswer', 'Name' => 'Accept Answer', 'Sort' => 0, 'Class' => 'Positive', 'IncrementColumn' => 'Score', 'IncrementValue' => 5, 'Points' => $points, 'Permission' => 'Garden.Curation.Manage', 'Hidden' => 1, 'Description' => "When someone correctly answers a question, they are rewarded with this reaction."]);
    }
    Gdn::structure()->reset();
}
开发者ID:vanilla,项目名称:addons,代码行数:31,代码来源:structure.php

示例14:

<?php

if (!defined('APPLICATION')) {
    exit;
}
Gdn::structure()->table('Newsletter')->primaryKey('NewsletterID')->column('Email', 'varchar(200)', null)->column('Subscribe', 'tinyint(1)', '0')->column('DateInserted', 'datetime')->set();
Gdn::structure()->table('User')->column('Newsletter', 'tinyint(1)', '0')->column('DateContributorAgreement', 'datetime', true)->set();
开发者ID:vanilla,项目名称:community,代码行数:7,代码来源:structure.php

示例15: structure

 public function structure()
 {
     $Structure = Gdn::structure();
     $Structure->table('Discussion')->column('DiscussionEventDate', 'date', true, 'index')->set();
     $Structure->table('Discussion')->column('DiscussionEventGuests', 'varchar(65535)', true, 'index')->set();
 }
开发者ID:pkonecki,项目名称:DiscussionEvent,代码行数:6,代码来源:class.discussionevent.plugin.php


注:本文中的Gdn::structure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。