本文整理汇总了PHP中Fisharebest\Webtrees\Auth::isModerator方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::isModerator方法的具体用法?PHP Auth::isModerator怎么用?PHP Auth::isModerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Auth
的用法示例。
在下文中一共展示了Auth::isModerator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MediaController
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\Functions\FunctionsPrintFacts;
use Fisharebest\Webtrees\Functions\FunctionsPrintLists;
define('WT_SCRIPT_NAME', 'mediaviewer.php');
require './includes/session.php';
$controller = new MediaController();
if ($controller->record && $controller->record->canShow()) {
$controller->pageHeader();
if ($controller->record->isPendingDeletion()) {
if (Auth::isModerator($controller->record->getTree())) {
echo '<p class="ui-state-highlight">', I18N::translate('This media object has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>';
} elseif (Auth::isEditor($controller->record->getTree())) {
echo '<p class="ui-state-highlight">', I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>';
}
} elseif ($controller->record->isPendingAddtion()) {
if (Auth::isModerator($controller->record->getTree())) {
echo '<p class="ui-state-highlight">', I18N::translate('This media object has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>';
} elseif (Auth::isEditor($controller->record->getTree())) {
echo '<p class="ui-state-highlight">', I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>';
}
}
} else {
http_response_code(404);
$controller->pageHeader();
echo '<p class="ui-state-error">', I18N::translate('This media object does not exist or you do not have permission to view it.'), '</p>';
return;
}
$controller->addInlineJavascript('
jQuery("#media-tabs")
.tabs({
create: function(e, ui){
示例2: elseif
$source->deleteFact($fact->getFactId(), true);
} elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) {
// Level 2-3 links
$source->updateFact($fact->getFactId(), preg_replace(array('/\\n2 OBJE @' . $target . '@(\\n[3-9].*)*/', '/\\n3 OBJE @' . $target . '@(\\n[4-9].*)*/'), '', $fact->getGedcom()), true);
}
}
}
}
} else {
http_response_code(406);
}
break;
case 'reject-changes':
// Reject all the pending changes for a record
$record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) {
FlashMessages::addMessage(I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
FunctionsImport::rejectAllChanges($record);
} else {
http_response_code(406);
}
break;
case 'theme':
// Change the current theme
$theme = Filter::post('theme');
if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) {
Session::put('theme_id', $theme);
// Remember our selection
Auth::user()->setPreference('theme', $theme);
} else {
// Request for a non-existant theme.
示例3: canAcceptChanges
/**
* Can a user accept changes for this tree?
*
* @param User $user
*
* @return bool
*/
public function canAcceptChanges(User $user)
{
return Auth::isModerator($this, $user);
}
示例4: SimpleController
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Fisharebest\Webtrees;
/**
* Defined in session.php
*
* @global Tree $WT_TREE
*/
global $WT_TREE;
use Fisharebest\Webtrees\Controller\SimpleController;
use Fisharebest\Webtrees\Functions\FunctionsImport;
define('WT_SCRIPT_NAME', 'edit_changes.php');
require './includes/session.php';
$controller = new SimpleController();
$controller->restrictAccess(Auth::isModerator($WT_TREE))->setPageTitle(I18N::translate('Pending changes'))->pageHeader()->addInlineJavascript("\n\t\tfunction show_diff(diffurl) {\n\t\t\twindow.opener.location = diffurl;\n\t\t\treturn false;\n\t\t}\n\t");
$action = Filter::get('action');
$change_id = Filter::getInteger('change_id');
$index = Filter::get('index');
$ged = Filter::getInteger('ged');
echo '<div id="pending"><h2>', I18N::translate('Pending changes'), '</h2>';
switch ($action) {
case 'undo':
$gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
$xref = Database::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
// Undo a change, and subsequent changes to the same record
Database::prepare("UPDATE `##change`" . " SET status = 'rejected'" . " WHERE status = 'pending'" . " AND gedcom_id = ?" . " AND xref = ?" . " AND change_id >= ?")->execute(array($gedcom_id, $xref, $change_id));
break;
case 'accept':
$gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
$xref = Database::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
示例5: pendingChangesExist
/**
* Are there any pending changes for us to approve?
*
* @return bool
*/
protected function pendingChangesExist()
{
return $this->tree && $this->tree->hasPendingEdit() && Auth::isModerator($this->tree);
}
示例6: getBlock
/**
* Generate the HTML content of this block.
*
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
$sendmail = $this->getBlockSetting($block_id, 'sendmail', '1');
$days = $this->getBlockSetting($block_id, 'days', '1');
$block = $this->getBlockSetting($block_id, 'block', '1');
foreach (array('days', 'sendmail', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
${$name} = $cfg[$name];
}
}
$changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
if ($changes === '1' && $sendmail === '1') {
// There are pending changes - tell moderators/managers/administrators about them.
if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
// Which users have pending changes?
foreach (User::all() as $user) {
if ($user->getPreference('contactmethod') !== 'none') {
foreach (Tree::getAll() as $tree) {
if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) {
I18N::init($user->getPreference('language'));
Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>');
I18N::init(WT_LOCALE);
}
}
}
}
Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
}
}
if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) {
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
if ($ctype === 'user' || Auth::isManager($WT_TREE)) {
$title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>';
} else {
$title = '';
}
$title .= $this->getTitle();
$content = '';
if (Auth::isModerator($WT_TREE)) {
$content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
}
if ($sendmail === '1') {
$content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
$content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
}
$content .= '<ul>';
$changes = Database::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll();
foreach ($changes as $change) {
$record = GedcomRecord::getInstance($change->xref, $WT_TREE);
if ($record->canShow()) {
$content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>';
}
}
$content .= '</ul>';
if ($template) {
if ($block) {
$class .= ' small_inner_block';
}
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
}