本文整理汇总了PHP中Fisharebest\Webtrees\Auth::accessLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::accessLevel方法的具体用法?PHP Auth::accessLevel怎么用?PHP Auth::accessLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Auth
的用法示例。
在下文中一共展示了Auth::accessLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActiveModulesByComponent
/**
* Get a list of modules which (a) provide a specific function and (b) we have permission to see.
*
* We cannot currently use auto-loading for modules, as there may be user-defined
* modules about which the auto-loader knows nothing.
*
* @param Tree $tree
* @param string $component The type of module, such as "tab", "report" or "menu"
*
* @return AbstractModule[]
*/
private static function getActiveModulesByComponent(Tree $tree, $component)
{
$module_names = Database::prepare("SELECT SQL_CACHE module_name" . " FROM `##module`" . " JOIN `##module_privacy` USING (module_name)" . " WHERE gedcom_id = :tree_id AND component = :component AND status = 'enabled' AND access_level >= :access_level" . " ORDER BY CASE component WHEN 'menu' THEN menu_order WHEN 'sidebar' THEN sidebar_order WHEN 'tab' THEN tab_order ELSE 0 END, module_name")->execute(array('tree_id' => $tree->getTreeId(), 'component' => $component, 'access_level' => Auth::accessLevel($tree)))->fetchOneColumn();
$array = array();
foreach ($module_names as $module_name) {
$interface = '\\Fisharebest\\Webtrees\\Module\\Module' . ucfirst($component) . 'Interface';
$module = self::getModuleByName($module_name);
if ($module instanceof $interface) {
$array[$module_name] = $module;
}
}
// The order of menus/sidebars/tabs is defined in the database. Others are sorted by name.
if ($component !== 'menu' && $component !== 'sidebar' && $component !== 'tab') {
uasort($array, function (AbstractModule $x, AbstractModule $y) {
return I18N::strcasecmp($x->getTitle(), $y->getTitle());
});
}
return $array;
}
示例2: access
protected function access()
{
global $WT_TREE;
if ($this->getSetting('FTV_PDF_ACCESS_LEVEL', '2') >= Auth::accessLevel($WT_TREE)) {
return true;
}
}
示例3: getMenu
public function getMenu()
{
global $controller, $WT_TREE;
$menu_titles = $this->getMenuList();
$lang = '';
$min_block = webtrees\Database::prepare("SELECT MIN(block_order) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
foreach ($menu_titles as $items) {
$languages = $this->getBlockSetting($items->block_id, 'languages');
if (in_array(WT_LOCALE, explode(',', $languages))) {
$lang = WT_LOCALE;
} else {
$lang = '';
}
}
$default_block = webtrees\Database::prepare("SELECT ##block.block_id FROM `##block`, `##block_setting` WHERE block_order=? AND module_name=? AND ##block.block_id = ##block_setting.block_id AND ##block_setting.setting_value LIKE ?")->execute(array($min_block, $this->getName(), '%' . $lang . '%'))->fetchOne();
$main_menu_address = webtrees\Database::prepare("SELECT setting_value FROM `##block_setting` WHERE block_id=? AND setting_name=?")->execute(array($default_block, 'menu_address'))->fetchOne();
if (count($menu_titles) > 1) {
$main_menu_title = $this->getMenuTitle();
} else {
$main_menu_title = webtrees\Database::prepare("SELECT setting_value FROM `##block_setting` WHERE block_id=? AND setting_name=?")->execute(array($default_block, 'menu_title'))->fetchOne();
}
if (webtrees\Auth::isSearchEngine()) {
return null;
}
if (file_exists(WT_MODULES_DIR . $this->getName() . '/themes/' . webtrees\Theme::theme()->themeId() . '/')) {
echo '<link rel="stylesheet" href="' . WT_MODULES_DIR . $this->getName() . '/themes/' . webtrees\Theme::theme()->themeId() . '/style.css" type="text/css">';
} else {
echo '<link rel="stylesheet" href="' . WT_MODULES_DIR . $this->getName() . '/themes/webtrees/style.css" type="text/css">';
}
//-- main menu item
$menu = new webtrees\Menu($main_menu_title, $main_menu_address, $this->getName());
$menu->addClass('menuitem', 'menuitem_hover', '');
foreach ($menu_titles as $items) {
if (count($menu_titles) > 1) {
$languages = $this->getBlockSetting($items->block_id, 'languages');
if ((!$languages || in_array(WT_LOCALE, explode(',', $languages))) && $items->menu_access >= webtrees\Auth::accessLevel($WT_TREE)) {
$submenu = new webtrees\Menu(webtrees\I18N::translate($items->menu_title), $items->menu_address, $this->getName() . '-' . str_replace(' ', '', $items->menu_title));
$menu->addSubmenu($submenu);
}
}
}
if (webtrees\Auth::isAdmin()) {
$submenu = new webtrees\Menu(webtrees\I18N::translate('Edit menus'), $this->getConfigLink(), $this->getName() . '-edit');
$menu->addSubmenu($submenu);
}
return $menu;
}
示例4: hFactSourcePrepend
/**
* {@inhericDoc}
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
*/
public function hFactSourcePrepend($srec)
{
global $WT_TREE;
$html = '';
$sid = null;
if ($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)) {
if (!$srec || strlen($srec) == 0) {
return $html;
}
$certificate = null;
$subrecords = explode("\n", $srec);
$levelSOUR = substr($subrecords[0], 0, 1);
$match = null;
if (preg_match('~^' . $levelSOUR . ' SOUR @(' . WT_REGEX_XREF . ')@$~', $subrecords[0], $match)) {
$sid = $match[1];
}
$nb_subrecords = count($subrecords);
for ($i = 0; $i < $nb_subrecords; $i++) {
$subrecords[$i] = trim($subrecords[$i]);
$tag = substr($subrecords[$i], 2, 4);
$text = substr($subrecords[$i], 7);
if ($tag == '_ACT') {
$certificate = new Certificate($text, $WT_TREE, $this->getProvider());
}
}
if ($certificate && $certificate->canShow()) {
$html = $this->getDisplay_ACT($certificate, $sid);
}
}
return $html;
}
示例5: printFamilyFacts
/**
* Print the facts
*/
public function printFamilyFacts()
{
global $linkToID;
$linkToID = $this->record->getXref();
// -- Tell addmedia.php what to link to
$indifacts = $this->record->getFacts();
if ($indifacts) {
Functions::sortFacts($indifacts);
foreach ($indifacts as $fact) {
FunctionsPrintFacts::printFact($fact, $this->record);
}
} else {
echo '<tr><td class="messagebox" colspan="2">', I18N::translate('No facts exist for this family.'), '</td></tr>';
}
if (Auth::isEditor($this->record->getTree())) {
FunctionsPrint::printAddNewFact($this->record->getXref(), $indifacts, 'FAM');
echo '<tr><td class="descriptionbox">';
echo I18N::translate('Note');
echo '</td><td class="optionbox">';
echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','NOTE');\">", I18N::translate('Add a note'), '</a>';
echo '</td></tr>';
echo '<tr><td class="descriptionbox">';
echo I18N::translate('Shared note');
echo '</td><td class="optionbox">';
echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SHARED_NOTE');\">", I18N::translate('Add a shared note'), '</a>';
echo '</td></tr>';
if ($this->record->getTree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($this->record->getTree())) {
echo '<tr><td class="descriptionbox">';
echo I18N::translate('Media object');
echo '</td><td class="optionbox">';
echo "<a href=\"#\" onclick=\"window.open('addmedia.php?action=showmediaform&linktoid=" . $this->record->getXref() . "', '_blank', edit_window_specs); return false;\">", I18N::translate('Add a media object'), '</a>';
echo FunctionsPrint::helpLink('OBJE');
echo '<br>';
echo "<a href=\"#\" onclick=\"window.open('inverselink.php?linktoid=" . $this->record->getXref() . "&linkto=family', '_blank', find_window_specs); return false;\">", I18N::translate('Link to an existing media object'), '</a>';
echo '</td></tr>';
}
echo '<tr><td class="descriptionbox">';
echo I18N::translate('Source');
echo '</td><td class="optionbox">';
echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SOUR');\">", I18N::translate('Add a source citation'), '</a>';
echo '</td></tr>';
}
}
示例6: canShow
/**
* Do the privacy rules allow us to display this fact to the current user
*
* @param int|null $access_level
*
* @return bool
*/
public function canShow($access_level = null)
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->getParent()->getTree());
}
// Does this record have an explicit RESN?
if (strpos($this->gedcom, "\n2 RESN confidential")) {
return Auth::PRIV_NONE >= $access_level;
}
if (strpos($this->gedcom, "\n2 RESN privacy")) {
return Auth::PRIV_USER >= $access_level;
}
if (strpos($this->gedcom, "\n2 RESN none")) {
return true;
}
// Does this record have a default RESN?
$xref = $this->parent->getXref();
$fact_privacy = $this->parent->getTree()->getFactPrivacy();
$individual_fact_privacy = $this->parent->getTree()->getIndividualFactPrivacy();
if (isset($individual_fact_privacy[$xref][$this->tag])) {
return $individual_fact_privacy[$xref][$this->tag] >= $access_level;
}
if (isset($fact_privacy[$this->tag])) {
return $fact_privacy[$this->tag] >= $access_level;
}
// No restrictions - it must be public
return true;
}
示例7: analyticsGoogleTracker
/**
* Create the tracking code for Google Analytics.
*
* See https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced
*
* @param string $analytics_id
*
* @return string
*/
protected function analyticsGoogleTracker($analytics_id)
{
if ($analytics_id) {
// Add extra dimensions (i.e. filtering categories)
$dimensions = (object) array('dimension1' => $this->tree ? $this->tree->getName() : '-', 'dimension2' => $this->tree ? Auth::accessLevel($this->tree) : '-');
return '<script async src="https://www.google-analytics.com/analytics.js"></script>' . '<script>' . 'window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;' . 'ga("create","' . $analytics_id . '","auto");' . 'ga("send", "pageview", ' . json_encode($dimensions) . ');' . '</script>';
} else {
return '';
}
}
示例8: listAll
/**
* Certificate@listAll
*/
public function listAll()
{
global $WT_TREE;
$controller = new PageController();
$controller->setPageTitle(I18N::translate('Certificates'))->restrictAccess($this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE));
$city = Filter::get('city');
if (!empty($city) && strlen($city) > 22) {
$city = Functions::decryptFromSafeBase64($city);
$controller->setPageTitle(I18N::translate('Certificates for %s', $city));
}
$data = new ViewBag();
$data->set('title', $controller->getPageTitle());
$data->set('url_module', $this->module->getName());
$data->set('url_action', 'Certificate@listAll');
$data->set('url_ged', $WT_TREE->getNameUrl());
$data->set('cities', $this->provider->getCitiesList());
$data->set('selected_city', $city);
$data->set('has_list', false);
if (!empty($city)) {
$table_id = 'table-certiflist-' . Uuid::uuid4();
$certif_list = $this->provider->getCertificatesList($city);
if (!empty($certif_list)) {
$data->set('has_list', true);
$data->set('table_id', $table_id);
$data->set('certificate_list', $certif_list);
$controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript('
/* Initialise datatables */
jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);};
jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);};
jQuery("#' . $table_id . '").dataTable( {
dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
' . I18N::datatablesI18N() . ',
jQueryUI: true,
autoWidth: false,
processing: true,
columns: [
/* 0-Date */ { dataSort: 1, width: "15%", class: "center" },
/* 1-DateSort */ { type: "unicode", visible : false },
/* 2-Type */ { width: "5%", searchable: false, class: "center"},
/* 3-CertificateSort */ { type: "unicode", visible : false },
/* 4-Certificate */ { dataSort: 3, class: "left" }
],
sorting: [[0,"asc"], [2,"asc"]],
displayLength: 20,
pagingType: "full_numbers"
});
jQuery(".certificate-list").css("visibility", "visible");
jQuery(".loading-image").css("display", "none");
');
}
}
ViewFactory::make('CertificatesList', $this, $controller, $data)->render();
}
示例9: menuMedia
protected function menuMedia()
{
$resns = $this->tree->getFactPrivacy();
if (isset($resns['OBJE'])) {
$resn = $resns['OBJE'];
} else {
$resn = Auth::PRIV_PRIVATE;
}
if ($resn >= Auth::accessLevel($this->tree)) {
$MEDIA_DIRECTORY = $this->tree->getPreference('MEDIA_DIRECTORY');
$folders = $this->themeOption('mediafolders');
$show_subfolders = $this->themeOption('show_subfolders') ? '&subdirs=on' : '';
if (count($folders) > 1) {
$menu = new Menu(I18N::translate('Media'), '', 'menu-media');
$submenu = new Menu(I18N::translate('Media'), 'medialist.php?' . $this->tree_url . '&action=filter&search=no&folder=&sortby=title' . $show_subfolders . '&max=20&columns=2&action=submit', 'menu-media-all');
$menu->addSubmenu($submenu);
// divider
$divider = new Menu('', '#', 'menu-media-divider divider');
$menu->addSubmenu($divider);
foreach ($folders as $key => $folder) {
if ($key !== $MEDIA_DIRECTORY) {
$submenu = new Menu(ucfirst($folder), 'medialist.php?' . $this->tree_url . '&action=filter&search=no&folder=' . Filter::escapeUrl($key) . '&sortby=title' . $show_subfolders . '&max=20&columns=2&action=submit', 'menu-media-' . preg_replace('/[^A-Za-z0-9\\. -]/', '', str_replace(" ", "-", $folder)));
$menu->addSubmenu($submenu);
}
}
} else {
// fallback if we don't have any subfolders added to the list
$menu = new Menu(I18N::translate('Media'), 'medialist.php?' . $this->tree_url . '&sortby=title&max=20&columns=2&action=submit', 'menu-media');
}
return $menu;
}
}
示例10: hPrintFooter
/**
* {@inheritDoc}
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface::hPrintFooter()
*/
public function hPrintFooter()
{
global $WT_TREE;
$html = '';
if ($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1) {
$html .= '<br/>';
$html .= '<div class="center">';
$cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', '');
if ($cnil_ref != '') {
$html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref);
}
$html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', Theme::theme()->contactLink(User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'))));
$html .= '</div>';
}
if ($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1) {
if (Auth::accessLevel($WT_TREE) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')) {
$html .= $this->getSetting('MAJ_HTML_FOOTER', '');
}
}
return $html;
}
示例11: gmdate
$filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';
$expireOffset = 3600 * 24;
// tell browser to cache this image for 24 hours
if (Filter::get('cb')) {
$expireOffset = $expireOffset * 7;
}
// if cb parameter was sent, cache for 7 days
$expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $expireOffset) . ' GMT';
$type = isImageTypeSupported($imgsize['ext']);
$usewatermark = false;
// if this image supports watermarks and the watermark module is intalled...
if ($type) {
// if this is not a thumbnail, or WATERMARK_THUMB is true
if ($which === 'main' || $WT_TREE->getPreference('WATERMARK_THUMB')) {
// if the user’s priv’s justify it...
if (Auth::accessLevel($WT_TREE) > $WT_TREE->getPreference('SHOW_NO_WATERMARK')) {
// add a watermark
$usewatermark = true;
}
}
}
// determine whether we have enough memory to watermark this image
if ($usewatermark) {
if (!FunctionsMedia::hasMemoryForImage($serverFilename)) {
// not enough memory to watermark this file
$usewatermark = false;
}
}
$watermarkfile = '';
$generatewatermark = false;
if ($usewatermark) {
示例12: getTreeBlocks
/**
* Get the blocks for the specified tree
*
* @param int $gedcom_id
*
* @return string[][]
*/
public static function getTreeBlocks($gedcom_id)
{
if ($gedcom_id < 0) {
$access_level = Auth::PRIV_NONE;
} else {
$access_level = Auth::accessLevel(Tree::findById($gedcom_id));
}
$blocks = array('main' => array(), 'side' => array());
$rows = Database::prepare("SELECT SQL_CACHE location, block_id, module_name" . " FROM `##block`" . " JOIN `##module` USING (module_name)" . " JOIN `##module_privacy` USING (module_name, gedcom_id)" . " WHERE gedcom_id = :tree_id" . " AND status='enabled'" . " AND access_level >= :access_level" . " ORDER BY location, block_order")->execute(array('tree_id' => $gedcom_id, 'access_level' => $access_level))->fetchAll();
foreach ($rows as $row) {
$blocks[$row->location][$row->block_id] = $row->module_name;
}
return $blocks;
}
示例13:
?>
</ul>
<div id="media-edit">
<table class="facts_table">
<tr>
<td style="text-align:center; width:150px;">
<?php
// When we have a pending edit, $controller->record shows the *old* data.
// As a temporary kludge, fetch a "normal" version of the record - which includes pending changes
// Perhaps check both, and use RED/BLUE boxes.
$tmp = Media::getInstance($controller->record->getXref(), $WT_TREE);
echo $tmp->displayImage();
if (!$tmp->isExternal()) {
if ($tmp->fileExists('main')) {
if ($WT_TREE->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($WT_TREE)) {
echo '<p><a href="' . $tmp->getHtmlUrlDirect('main', true) . '">' . I18N::translate('Download file') . '</a></p>';
}
} else {
echo '<p class="ui-state-error">' . I18N::translate('The file “%s” does not exist.', $tmp->getFilename()) . '</p>';
}
}
?>
</td>
<td>
<table class="facts_table">
<?php
foreach ($facts as $fact) {
FunctionsPrintFacts::printFact($fact, $controller->record);
}
?>
示例14: canDisplayIsSourced
/**
* Check if the IsSourced information can be displayed
*
* @param int $access_level
* @return boolean
*/
public function canDisplayIsSourced($access_level = null)
{
global $global_facts;
if (!$this->gedcomrecord->canShow($access_level)) {
return false;
}
if ($access_level === null) {
$access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());
}
if (isset($global_facts['SOUR'])) {
return $global_facts['SOUR'] >= $access_level;
}
return true;
}
示例15:
} else {
$action = 'setup';
}
break;
case 'FAM':
$record = Family::getInstance($var, $WT_TREE);
if ($record && $record->canShowName()) {
$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
} else {
$action = 'setup';
}
break;
case 'SOUR':
$record = Source::getInstance($var, $WT_TREE);
if ($record && $record->canShowName()) {
$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
} else {
$action = 'setup';
}
break;
default:
break;
}
}
}
$vars = $newvars;
foreach ($varnames as $name) {
if (!isset($vars[$name])) {
$vars[$name]['id'] = '';
}
}