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


PHP Branch::loadHubDB方法代码示例

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


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

示例1: testDB

 /**
  * Once the database information has been posted successfully,
  * testDB determines if the database connection can be made and,
  * if so, if there a database to which to connect. If not, then
  * it creates the database (if specified)
  */
 public function testDB($force_on_populated = false)
 {
     $connection = $this->checkConnection();
     Branch::loadHubDB();
     switch ($connection) {
         case BRANCH_CONNECT_NO_DB:
             // connection made, but database does not exist
             if (isset($_POST['createdb'])) {
                 $result = $this->createDB();
                 if (PHPWS_Error::isError($result)) {
                     $this->message[] = dgettext('branch', 'An error occurred when trying to connect to the database.');
                     $this->edit_db();
                 } elseif ($result) {
                     $this->message[] = dgettext('branch', 'Database created successfully.');
                     $this->setCreateStep(2);
                     $this->saveDSN();
                     $this->edit_basic();
                 } else {
                     $this->message[] = dgettext('branch', 'Unable to create the database. You will need to create it manually.');
                     $this->edit_db();
                 }
             } else {
                 $this->message[] = dgettext('branch', 'Connected successfully, but the database does not exist.');
                 $this->edit_db();
             }
             break;
         case BRANCH_NO_CONNECTION:
         case BRANCH_CONNECT_BAD_DB:
             // Failed connection
             $this->message[] = dgettext('branch', 'Could not connect to the database.');
             $this->edit_db();
             break;
         case BRANCH_CONNECT_SUCCESS:
             // connection successful
             $this->setCreateStep(2);
             $this->saveDSN();
             $this->message[] = dgettext('branch', 'Connection successful. Database available.');
             $this->edit_basic();
             break;
         case BRANCH_CONNECT_WITH_TABLES:
             if ($force_on_populated && !empty($this->dbprefix)) {
                 $this->setCreateStep(2);
                 $this->saveDSN();
                 $this->message[] = dgettext('branch', 'Connection successful. Database available.');
                 $this->edit_basic();
             } else {
                 $this->message[] = dgettext('branch', 'Connected successfully, but this database already contains tables.');
                 if (!empty($this->dbprefix)) {
                     $this->message[] = dgettext('branch', 'Though not recommended, you can force installation by clicking Continue below.');
                     $force = true;
                 } else {
                     $this->message[] = dgettext('branch', 'Though not recommended, prefixing will allow you to install to this database.');
                     $force = false;
                 }
                 $this->edit_db($force);
             }
             break;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:65,代码来源:Branch_Admin.php

示例2: users_install

/**
 * boost install file for users
 *
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function users_install(&$content)
{
    PHPWS_Core::initModClass('users', 'Users.php');
    PHPWS_Core::initModClass('users', 'Action.php');
    PHPWS_Core::configRequireOnce('users', 'config.php');
    if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'branch') {
        $db = new PHPWS_DB();
        PHPWS_Settings::clear();
        if (!createLocalAuthScript()) {
            $content[] = 'Could not create authorization script.';
            return false;
        }
        Branch::loadHubDB();
        $db = new PHPWS_DB('mod_settings');
        $db->addWhere('module', 'users');
        $db->addWhere('setting_name', 'site_contact');
        $db->addColumn('small_char');
        $site_contact = $db->select('one');
        $db = new PHPWS_DB('users');
        $sql = 'select a.password, b.* from user_authorization as a, users as b where b.deity = 1 and a.username = b.username';
        $deities = $db->getAll($sql);
        if (PHPWS_Error::isError($deities)) {
            PHPWS_Error::log($deities);
            $content[] = dgettext('users', 'Could not access hub database.');
            Branch::restoreBranchDB();
            return FALSE;
        } elseif (empty($deities)) {
            $content[] = dgettext('users', 'Could not find any hub deities.');
            Branch::restoreBranchDB();
            return FALSE;
        } else {
            Branch::restoreBranchDB();
            PHPWS_Settings::set('users', 'site_contact', $site_contact);
            PHPWS_Settings::save('users');
            $auth_db = new PHPWS_DB('user_authorization');
            $user_db = new PHPWS_DB('users');
            $group_db = new PHPWS_DB('users_groups');
            foreach ($deities as $deity) {
                $auth_db->addValue('username', $deity['username']);
                $auth_db->addValue('password', $deity['password']);
                $result = $auth_db->insert();
                if (PHPWS_Error::isError($result)) {
                    PHPWS_Error::log($result);
                    $content[] = dgettext('users', 'Unable to copy deity login to branch.');
                    continue;
                }
                unset($deity['password']);
                $user_db->addValue($deity);
                $result = $user_db->insert();
                if (PHPWS_Error::isError($result)) {
                    PHPWS_Error::log($result);
                    $content[] = dgettext('users', 'Unable to copy deity users to branch.');
                    Branch::loadBranchDB();
                    return FALSE;
                }
                $group_db->addValue('active', 1);
                $group_db->addValue('name', $deity['username']);
                $group_db->addValue('user_id', $result);
                if (PHPWS_Error::logIfError($group_db->insert())) {
                    $content[] = dgettext('users', 'Unable to copy deity user group to branch.');
                    Branch::loadBranchDB();
                    return FALSE;
                }
                $group_db->reset();
                $auth_db->reset();
                $user_db->reset();
            }
            $content[] = dgettext('users', 'Deity users copied to branch.');
        }
        return TRUE;
    }
    if (!createLocalAuthScript()) {
        $content[] = 'Could not create local authorization script.';
        return false;
    }
    $authorize_id = PHPWS_Settings::get('users', 'local_script');
    $user = new PHPWS_User();
    $content[] = '<hr />';
    return TRUE;
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:86,代码来源:install.php

示例3: updateBranches

 public function updateBranches(&$content)
 {
     if (!PHPWS_Core::moduleExists('branch')) {
         return true;
     }
     PHPWS_Core::initModClass('branch', 'Branch_Admin.php');
     $branches = Branch_Admin::getBranches(true);
     if (empty($branches)) {
         return true;
     }
     $keys = array_keys($this->status);
     foreach ($branches as $branch) {
         $GLOBALS['Boost_In_Branch'] = $branch;
         // used as the "local" directory in updateFiles
         $GLOBALS['boost_branch_dir'] = $branch->directory;
         if (PHPWS_Error::isError($branch->loadBranchDB())) {
             $content[] = dgettext('boost', 'Problem connecting to the branch. May be too many connections.');
             continue;
         }
         // create a new boost based on the branch database
         $branch_boost = new PHPWS_Boost();
         $branch_boost->loadModules($keys, false);
         $content[] = '<hr />';
         $content[] = sprintf(dgettext('boost', 'Updating branch %s'), $branch->branch_name);
         $result = $branch_boost->update($content);
         if (PHPWS_Error::isError($result)) {
             PHPWS_Error::log($result);
             $content[] = dgettext('boost', 'Unable to update branch.');
         }
     }
     Branch::loadHubDB();
     $GLOBALS['Boost_In_Branch'] = false;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:33,代码来源:Boost.php


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