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


PHP Module::setDefaultAccess方法代码示例

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


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

示例1: create

 /**
  * Create a new tree
  *
  * @param string $tree_name
  * @param string $tree_title
  *
  * @return Tree
  */
 public static function create($tree_name, $tree_title)
 {
     try {
         // Create a new tree
         Database::prepare("INSERT INTO `##gedcom` (gedcom_name) VALUES (?)")->execute(array($tree_name));
         $tree_id = Database::prepare("SELECT LAST_INSERT_ID()")->fetchOne();
     } catch (PDOException $ex) {
         // A tree with that name already exists?
         return self::findByName($tree_name);
     }
     // Update the list of trees - to include this new one
     self::$trees = null;
     $tree = self::findById($tree_id);
     $tree->setPreference('imported', '0');
     $tree->setPreference('title', $tree_title);
     // Module privacy
     Module::setDefaultAccess($tree_id);
     // Set preferences from default tree
     Database::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " SELECT :tree_id, setting_name, setting_value" . " FROM `##gedcom_setting` WHERE gedcom_id = -1")->execute(array('tree_id' => $tree_id));
     Database::prepare("INSERT INTO `##default_resn` (gedcom_id, tag_type, resn)" . " SELECT :tree_id, tag_type, resn" . " FROM `##default_resn` WHERE gedcom_id = -1")->execute(array('tree_id' => $tree_id));
     Database::prepare("INSERT INTO `##block` (gedcom_id, location, block_order, module_name)" . " SELECT :tree_id, location, block_order, module_name" . " FROM `##block` WHERE gedcom_id = -1")->execute(array('tree_id' => $tree_id));
     // Gedcom and privacy settings
     $tree->setPreference('CONTACT_USER_ID', Auth::id());
     $tree->setPreference('WEBMASTER_USER_ID', Auth::id());
     $tree->setPreference('LANGUAGE', WT_LOCALE);
     // Default to the current admin’s language
     switch (WT_LOCALE) {
         case 'es':
             $tree->setPreference('SURNAME_TRADITION', 'spanish');
             break;
         case 'is':
             $tree->setPreference('SURNAME_TRADITION', 'icelandic');
             break;
         case 'lt':
             $tree->setPreference('SURNAME_TRADITION', 'lithuanian');
             break;
         case 'pl':
             $tree->setPreference('SURNAME_TRADITION', 'polish');
             break;
         case 'pt':
         case 'pt-BR':
             $tree->setPreference('SURNAME_TRADITION', 'portuguese');
             break;
         default:
             $tree->setPreference('SURNAME_TRADITION', 'paternal');
             break;
     }
     // Genealogy data
     // It is simpler to create a temporary/unimported GEDCOM than to populate all the tables...
     $john_doe = I18N::translate('John /DOE/');
     $note = I18N::translate('Edit this individual and replace their details with your own.');
     Database::prepare("INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data) VALUES (?, ?)")->execute(array($tree_id, "0 HEAD\n1 CHAR UTF-8\n0 @I1@ INDI\n1 NAME {$john_doe}\n1 SEX M\n1 BIRT\n2 DATE 01 JAN 1850\n2 NOTE {$note}\n0 TRLR\n"));
     // Update our cache
     self::$trees[$tree->tree_id] = $tree;
     return $tree;
 }
开发者ID:AlexSnet,项目名称:webtrees,代码行数:64,代码来源:Tree.php

示例2: catch

                        $page_name = 'index.php';
                        $page_parameter = 'gedcom:' . $GED_DATA['id'];
                    }
                    try {
                        $statement->execute(array($GED_DATA['id'], $page_name, $page_parameter, $match[3]));
                    } catch (PDOException $ex) {
                        // Primary key violation? Ignore?
                    }
                }
            }
        }
    }
}
////////////////////////////////////////////////////////////////////////////////
foreach ($GEDCOMS as $GED_DATA) {
    Module::setDefaultAccess($GED_DATA['id']);
}
echo '<p>pgv_site_setting => wt_module_setting…</p>';
Database::prepare("REPLACE INTO `##module_setting` (module_name, setting_name, setting_value)" . " SELECT 'googlemap', site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . " WHERE site_setting_name LIKE 'GM_%'")->execute();
Database::prepare("REPLACE INTO `##module_setting` (module_name, setting_name, setting_value)" . " SELECT 'lightbox', site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . " WHERE site_setting_name LIKE 'LB_%'")->execute();
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_favorites => wt_favorite…</p>';
try {
    Database::prepare("REPLACE INTO `##favorite` (favorite_id, user_id, gedcom_id, xref, favorite_type, url, title, note)" . " SELECT fv_id, u.user_id, g.gedcom_id, fv_gid, fv_type, fv_url, fv_title, fv_note" . " FROM `{$DBNAME}`.`{$TBLPREFIX}favorites` f" . " LEFT JOIN `##gedcom` g ON (f.fv_username=g.gedcom_name)" . " LEFT JOIN `##user`   u ON (f.fv_username=u.user_name)")->execute();
} catch (PDOException $ex) {
    // This table will only exist if the favorites module is installed in WT
}
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_news => wt_news…</p>';
try {
    Database::prepare("REPLACE INTO `##news` (news_id, user_id, gedcom_id, subject, body, updated)" . " SELECT n_id, u.user_id, g.gedcom_id, n_title, n_text, FROM_UNIXTIME(n_date)" . " FROM `{$DBNAME}`.`{$TBLPREFIX}news` n" . " LEFT JOIN `##gedcom` g ON (n.n_username=g.gedcom_name)" . " LEFT JOIN `##user` u ON (n.n_username=u.user_name)")->execute();
开发者ID:tronsmit,项目名称:webtrees,代码行数:31,代码来源:admin_pgv_to_wt.php


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