本文整理汇总了PHP中Backend\Core\Engine\Authentication::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::getUser方法的具体用法?PHP Authentication::getUser怎么用?PHP Authentication::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend\Core\Engine\Authentication
的用法示例。
在下文中一共展示了Authentication::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadForm
/**
* Load the form
*/
private function loadForm()
{
$this->isGod = BackendAuthentication::getUser()->isGod();
$this->frm = new BackendForm('settingsEmail');
// email settings
$mailerFrom = $this->get('fork.settings')->get('Core', 'mailer_from');
$this->frm->addText('mailer_from_name', isset($mailerFrom['name']) ? $mailerFrom['name'] : '');
$this->frm->addText('mailer_from_email', isset($mailerFrom['email']) ? $mailerFrom['email'] : '')->setAttribute('type', 'email');
$mailerTo = $this->get('fork.settings')->get('Core', 'mailer_to');
$this->frm->addText('mailer_to_name', isset($mailerTo['name']) ? $mailerTo['name'] : '');
$this->frm->addText('mailer_to_email', isset($mailerTo['email']) ? $mailerTo['email'] : '')->setAttribute('type', 'email');
$mailerReplyTo = $this->get('fork.settings')->get('Core', 'mailer_reply_to');
$this->frm->addText('mailer_reply_to_name', isset($mailerReplyTo['name']) ? $mailerReplyTo['name'] : '');
$this->frm->addText('mailer_reply_to_email', isset($mailerReplyTo['email']) ? $mailerReplyTo['email'] : '')->setAttribute('type', 'email');
if ($this->isGod) {
$mailerType = $this->get('fork.settings')->get('Core', 'mailer_type', 'mail');
$this->frm->addDropdown('mailer_type', array('mail' => 'PHP\'s mail', 'smtp' => 'SMTP'), $mailerType);
// smtp settings
$this->frm->addText('smtp_server', $this->get('fork.settings')->get('Core', 'smtp_server', ''));
$this->frm->addText('smtp_port', $this->get('fork.settings')->get('Core', 'smtp_port', 25));
$this->frm->addText('smtp_username', $this->get('fork.settings')->get('Core', 'smtp_username', ''));
$this->frm->addPassword('smtp_password', $this->get('fork.settings')->get('Core', 'smtp_password', ''));
$this->frm->addDropdown('smtp_secure_layer', array('no' => ucfirst(BL::lbl('None')), 'ssl' => 'SSL', 'tls' => 'TLS'), $this->get('fork.settings')->get('Core', 'smtp_secure_layer', 'no'));
}
$this->tpl->assign('isGod', $this->isGod);
}
示例2: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$fields = $this->frm->getFields();
// validate fields
$fields['title']->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
// build item
$item['id'] = BackendContentBlocksModel::getMaximumId() + 1;
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['template'] = count($this->templates) > 1 ? $fields['template']->getValue() : $this->templates[0];
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $fields['title']->getValue();
$item['text'] = $fields['text']->getValue();
$item['hidden'] = $fields['hidden']->getValue() ? 'N' : 'Y';
$item['status'] = 'active';
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = BackendModel::getUTCDate();
// insert the item
$item['revision_id'] = BackendContentBlocksModel::insert($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例3: loadForm
/**
* Loads the settings form
*/
private function loadForm()
{
$this->isGod = BackendAuthentication::getUser()->isGod();
$this->frm = new BackendForm('settings');
// add fields for pagination
$this->frm->addDropdown('overview_number_of_items', array_combine(range(1, 30), range(1, 30)), $this->get('fork.settings')->get($this->URL->getModule(), 'overview_num_items', 10));
$this->frm->addDropdown('recent_articles_full_number_of_items', array_combine(range(1, 10), range(1, 10)), $this->get('fork.settings')->get($this->URL->getModule(), 'recent_articles_full_num_items', 5));
$this->frm->addDropdown('recent_articles_list_number_of_items', array_combine(range(1, 10), range(1, 10)), $this->get('fork.settings')->get($this->URL->getModule(), 'recent_articles_list_num_items', 5));
// add fields for spam
$this->frm->addCheckbox('spamfilter', $this->get('fork.settings')->get($this->URL->getModule(), 'spamfilter', false));
// no Akismet-key, so we can't enable spam-filter
if ($this->get('fork.settings')->get('Core', 'akismet_key') == '') {
$this->frm->getField('spamfilter')->setAttribute('disabled', 'disabled');
$this->tpl->assign('noAkismetKey', true);
}
// add fields for comments
$this->frm->addCheckbox('allow_comments', $this->get('fork.settings')->get($this->URL->getModule(), 'allow_comments', false));
$this->frm->addCheckbox('moderation', $this->get('fork.settings')->get($this->URL->getModule(), 'moderation', false));
// add fields for notifications
$this->frm->addCheckbox('notify_by_email_on_new_comment_to_moderate', $this->get('fork.settings')->get($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', false));
$this->frm->addCheckbox('notify_by_email_on_new_comment', $this->get('fork.settings')->get($this->URL->getModule(), 'notify_by_email_on_new_comment', false));
// add fields for SEO
// @TODO remove this when the api is kicked out
$this->frm->addCheckbox('ping_services', $this->get('fork.settings')->get($this->URL->getModule(), 'ping_services', false));
// add fields for RSS
$this->frm->addCheckbox('rss_meta', $this->get('fork.settings')->get($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), true));
$this->frm->addText('rss_title', $this->get('fork.settings')->get($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage()));
$this->frm->addTextarea('rss_description', $this->get('fork.settings')->get($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage()));
// god user?
if ($this->isGod) {
$this->frm->addCheckbox('show_image_form', $this->get('fork.settings')->get($this->URL->getModule(), 'show_image_form', true));
}
}
示例4: loadForm
/**
* Load the form
*/
private function loadForm()
{
$this->imageIsAllowed = $this->get('fork.settings')->get($this->URL->getModule(), 'show_image_form', true);
$this->frm = new BackendForm('add');
// set hidden values
$rbtHiddenValues[] = array('label' => BL::lbl('Hidden', $this->URL->getModule()), 'value' => 'Y');
$rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
// get categories
$categories = BackendBlogModel::getCategories();
$categories['new_category'] = \SpoonFilter::ucfirst(BL::getLabel('AddCategory'));
// create elements
$this->frm->addText('title', null, null, 'inputText title', 'inputTextError title');
$this->frm->addEditor('text');
$this->frm->addEditor('introduction');
$this->frm->addRadiobutton('hidden', $rbtHiddenValues, 'N');
$this->frm->addCheckbox('allow_comments', $this->get('fork.settings')->get($this->getModule(), 'allow_comments', false));
$this->frm->addDropdown('category_id', $categories, \SpoonFilter::getGetValue('category', null, null, 'int'));
if (count($categories) != 2) {
$this->frm->getField('category_id')->setDefaultElement('');
}
$this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), BackendAuthentication::getUser()->getUserId());
$this->frm->addText('tags', null, null, 'inputText tagBox', 'inputTextError tagBox');
$this->frm->addDate('publish_on_date');
$this->frm->addTime('publish_on_time');
if ($this->imageIsAllowed) {
$this->frm->addImage('image');
}
// meta
$this->meta = new BackendMeta($this->frm, null, 'title', true);
}
示例5: __construct
/**
* @param KernelInterface $kernel
*/
public function __construct(KernelInterface $kernel)
{
parent::__construct($kernel);
// store for later use throughout the application
$this->getContainer()->set('navigation', $this);
$this->URL = $this->getContainer()->get('url');
// check if navigation cache file exists
if (!is_file(self::getCacheDirectory() . 'navigation.php')) {
$this->buildCache();
}
// check if editor_link_list_LANGUAGE.js cache file exists
if (!is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js')) {
BackendPagesModel::buildCache(BackendLanguage::getWorkingLanguage());
}
$navigation = array();
// require navigation-file
require self::getCacheDirectory() . 'navigation.php';
// load it
$this->navigation = (array) $navigation;
$this->navigation = $this->addActiveStateToNavigation($this->navigation);
// cleanup navigation (not needed for god user)
if (!Authentication::getUser()->isGod()) {
$this->navigation = $this->cleanup($this->navigation);
}
}
示例6: outputCSV
/**
* Output a CSV-file as a download
*
* @param string $filename The name of the file.
* @param array $array The array to convert.
* @param array $columns The column names you want to use.
* @param array $excludeColumns The columns you want to exclude.
*/
public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null)
{
// get settings
$splitCharacter = Authentication::getUser()->getSetting('csv_split_character');
$lineEnding = Authentication::getUser()->getSetting('csv_line_ending');
// reformat
if ($lineEnding == '\\n') {
$lineEnding = "\n";
}
if ($lineEnding == '\\r\\n') {
$lineEnding = "\r\n";
}
// convert into CSV
$csv = \SpoonFileCSV::arrayToString($array, $columns, $excludeColumns, $splitCharacter, '"', $lineEnding);
// set headers for download
$charset = BackendModel::getContainer()->getParameter('kernel.charset');
$headers[] = 'Content-type: application/csv; charset=' . $charset;
$headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
$headers[] = 'Content-Length: ' . strlen($csv);
$headers[] = 'Pragma: no-cache';
// overwrite the headers
\SpoonHTTP::setHeaders($headers);
// output the CSV
echo $csv;
exit;
}
示例7: loadForm
/**
* Load the form
*/
private function loadForm()
{
// create form
$this->frm = new BackendForm('add');
// get the groups
$groups = BackendGroupsModel::getAll();
// if there is only one group we can check it so the user isn't bothered with an error for not selecting one
$checkedGroups = count($groups) == 1 ? $groups[0]['value'] : null;
// create elements
// profile
$this->frm->addText('email', null, 255);
$this->frm->addPassword('password', null, 75, 'inputText inputPassword passwordGenerator', 'inputTextError inputPasswordError passwordGenerator')->setAttributes(array('autocomplete' => 'off'));
$this->frm->addPassword('confirm_password', null, 75)->setAttributes(array('autocomplete' => 'off'));
$this->frm->addText('name', null, 255);
$this->frm->addText('surname', null, 255);
$this->frm->addText('nickname', null, 24);
$this->frm->addImage('avatar');
$this->frm->addDropdown('interface_language', BL::getInterfaceLanguages(), $this->get('fork.settings')->get('Core', 'default_interface_language'));
$this->frm->addDropdown('date_format', BackendUsersModel::getDateFormats(), BackendAuthentication::getUser()->getSetting('date_format'));
$this->frm->addDropdown('time_format', BackendUsersModel::getTimeFormats(), BackendAuthentication::getUser()->getSetting('time_format'));
$this->frm->addDropdown('number_format', BackendUsersModel::getNumberFormats(), BackendAuthentication::getUser()->getSetting('number_format', 'dot_nothing'));
$this->frm->addDropDown('csv_split_character', BackendUsersModel::getCSVSplitCharacters());
$this->frm->addDropDown('csv_line_ending', BackendUsersModel::getCSVLineEndings());
// permissions
$this->frm->addCheckbox('active', true);
$this->frm->addCheckbox('api_access', false);
$this->frm->addMultiCheckbox('groups', $groups, $checkedGroups);
}
示例8: parse
/**
* Parse into template
*/
private function parse()
{
// get the logged in user
$authenticatedUser = BackendAuthentication::getUser();
// check if we need to show the password strength and parse the label
$this->tpl->assign('showPasswordStrength', $authenticatedUser->getSetting('password_strength') !== 'strong');
$this->tpl->assign('passwordStrengthLabel', BL::lbl($authenticatedUser->getSetting('password_strength')));
}
示例9: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$newSequence = \SpoonFilter::getPostValue('new_sequence', null, '');
// validate
if ($newSequence == '') {
$this->output(self::BAD_REQUEST, null, 'no new_sequence provided');
} else {
// convert into array
$json = @json_decode($newSequence, true);
// validate
if ($json === false) {
$this->output(self::BAD_REQUEST, null, 'invalid new_sequence provided');
} else {
// initialize
$userSequence = array();
$hiddenItems = array();
// loop columns
foreach ($json as $column => $widgets) {
$columnValue = 'left';
if ($column == 1) {
$columnValue = 'middle';
} elseif ($column == 2) {
$columnValue = 'right';
}
// loop widgets
foreach ($widgets as $sequence => $widget) {
// store position
$userSequence[$widget['module']][$widget['widget']] = array('column' => $columnValue, 'position' => $sequence, 'hidden' => $widget['hidden'], 'present' => $widget['present']);
// add to array
if ($widget['hidden']) {
$hiddenItems[] = $widget['module'] . '_' . $widget['widget'];
}
}
}
// get previous setting
$currentSetting = BackendAuthentication::getUser()->getSetting('dashboard_sequence');
$data['reload'] = false;
// any settings?
if ($currentSetting !== null) {
// loop modules
foreach ($currentSetting as $module => $widgets) {
foreach ($widgets as $widget => $values) {
if ($values['hidden'] && isset($userSequence[$module][$widget]['hidden']) && !$userSequence[$module][$widget]['hidden']) {
$data['reload'] = true;
}
}
}
}
// store
BackendAuthentication::getUser()->setSetting('dashboard_sequence', $userSequence);
// output
$this->output(self::OK, $data, BL::msg('Saved'));
}
}
}
示例10: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$this->isGod = BackendAuthentication::getUser()->isGod();
$this->setFilter();
$this->loadForm();
$this->loadDataGrid();
$this->parse();
$this->display();
}
示例11: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$isGod = BackendAuthentication::getUser()->isGod();
// get possible languages
if ($isGod) {
$possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
} else {
$possibleLanguages = BL::getWorkingLanguages();
}
// get parameters
$language = \SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
$module = \SpoonFilter::getPostValue('module', BackendModel::getModules(), null, 'string');
$name = \SpoonFilter::getPostValue('name', null, null, 'string');
$type = \SpoonFilter::getPostValue('type', BackendModel::getContainer()->get('database')->getEnumValues('locale', 'type'), null, 'string');
$application = \SpoonFilter::getPostValue('application', array('Backend', 'Frontend'), null, 'string');
$value = \SpoonFilter::getPostValue('value', null, null, 'string');
// validate values
if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'Frontend' && $module != 'Core') {
$error = BL::err('InvalidValue');
}
// in case this is a 'act' type, there are special rules concerning possible values
if ($type == 'act' && !isset($error)) {
if (urlencode($value) != CommonUri::getUrl($value)) {
$error = BL::err('InvalidActionValue', $this->getModule());
}
}
// no error?
if (!isset($error)) {
// build item
$item['language'] = $language;
$item['module'] = $module;
$item['name'] = $name;
$item['type'] = $type;
$item['application'] = $application;
$item['value'] = $value;
$item['edited_on'] = BackendModel::getUTCDate();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
// does the translation exist?
if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
// add the id to the item
$item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
// update in db
BackendLocaleModel::update($item);
} else {
// insert in db
BackendLocaleModel::insert($item);
}
// output OK
$this->output(self::OK);
} else {
$this->output(self::ERROR, null, $error);
}
}
示例12: copy
/**
* Copy content blocks
*
* @param string $from The language code to copy the content blocks from.
* @param string $to The language code we want to copy the content blocks to.
*
* @return array
*
* @deprecated use the CopyContentBlocksToOtherLocale command
*/
public static function copy($from, $to)
{
trigger_error('Backend\\Modules\\ContentBlocks\\Engine::copy is deprecated.
Switch the CopyContentBlocksToOtherLocale command instead.', E_USER_DEPRECATED);
// get db
$db = BackendModel::getContainer()->get('database');
// init variables
$contentBlockIds = $oldIds = $newIds = array();
// copy the contentblocks
$contentBlocks = (array) $db->getRecords('SELECT * FROM content_blocks WHERE language = ? AND status = "active"', array($from));
// define counter
$i = 1;
// loop existing content blocks
foreach ($contentBlocks as $contentBlock) {
// define old id
$oldId = $contentBlock['extra_id'];
// init new block
$newBlock = array();
// build new block
$newBlock['id'] = self::getMaximumId() + $i;
$newBlock['language'] = $to;
$newBlock['created_on'] = BackendModel::getUTCDate();
$newBlock['edited_on'] = BackendModel::getUTCDate();
$newBlock['status'] = $contentBlock['status'];
$newBlock['user_id'] = BackendAuthentication::getUser()->getUserId();
$newBlock['template'] = $contentBlock['template'];
$newBlock['title'] = $contentBlock['title'];
$newBlock['text'] = $contentBlock['text'];
$newBlock['hidden'] = $contentBlock['hidden'];
// inset content block
$newId = self::insert($newBlock);
// save ids for later
$oldIds[] = $oldId;
$newIds[$oldId] = $newId;
// redefine counter
++$i;
}
// get the extra Ids for the content blocks
if (!empty($newIds)) {
// get content block extra ids
$contentBlockExtraIds = (array) $db->getRecords('SELECT revision_id, extra_id FROM content_blocks WHERE revision_id IN (' . implode(',', $newIds) . ')');
// loop new ids
foreach ($newIds as $oldId => $newId) {
foreach ($contentBlockExtraIds as $extraId) {
if ($extraId['revision_id'] == $newId) {
$contentBlockIds[$oldId] = $extraId['extra_id'];
}
}
}
}
// return contentBlockIds
return $contentBlockIds;
}
示例13: validateForm
/**
* Validate the form add image
*
* @return void
*/
private function validateForm()
{
//--Check if the add-image form is submitted
if ($this->frm->isSubmitted()) {
//--Clean up fields in the form
$this->frm->cleanupFields();
//--Get image field
$filImage = $this->frm->getField('images');
//--Check if the field is filled in
if ($filImage->isFilled()) {
//--Image extension and mime type
$filImage->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly'));
$filImage->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly'));
//--Check if there are no errors.
$strError = $filImage->getErrors();
if ($strError === null) {
//--Get the filename
$strFilename = BackendGalleriaModel::checkFilename(substr($filImage->getFilename(), 0, 0 - (strlen($filImage->getExtension()) + 1)), $filImage->getExtension());
//--Fill in the item
$item = array();
$item["album_id"] = (int) $this->id;
$item["user_id"] = BackendAuthentication::getUser()->getUserId();
$item["language"] = BL::getWorkingLanguage();
$item["filename"] = $strFilename;
$item["description"] = "";
$item["publish_on"] = BackendModel::getUTCDate();
$item["hidden"] = "N";
$item["sequence"] = BackendGalleriaModel::getMaximumImageSequence($this->id) + 1;
//--the image path
$imagePath = FRONTEND_FILES_PATH . '/Galleria/Images';
//--create folders if needed
if (!\SpoonDirectory::exists($imagePath . '/Source')) {
\SpoonDirectory::create($imagePath . '/Source');
}
if (!\SpoonDirectory::exists($imagePath . '/128x128')) {
\SpoonDirectory::create($imagePath . '/128x128');
}
if (!\SpoonDirectory::exists($imagePath . '/800x')) {
\SpoonDirectory::create($imagePath . '/800x');
}
//--image provided?
if ($filImage->isFilled()) {
//--upload the image & generate thumbnails
$filImage->generateThumbnails($imagePath, $item["filename"]);
}
//--Add item to the database
BackendGalleriaModel::insert($item);
}
}
}
}
示例14: loadDataGrid
/**
* Load the datagrid.
*/
private function loadDataGrid()
{
// create datagrid with an overview of all active and undeleted users
$this->dataGrid = new BackendDataGridDB(BackendUsersModel::QRY_BROWSE, array('N'));
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('Edit')) {
// add column
$this->dataGrid->addColumn('nickname', \SpoonFilter::ucfirst(BL::lbl('Nickname')), null, BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit'));
// add edit column
if (BackendAuthentication::isAllowedAction('Add') || BackendAuthentication::getUser()->isGod()) {
$this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]');
}
}
// show the user's nickname
$this->dataGrid->setColumnFunction(array('Backend\\Modules\\Users\\Engine\\Model', 'getSetting'), array('[id]', 'nickname'), 'nickname', false);
}
示例15: outputCSV
/**
* Output a CSV-file as a download
*
* @param string $filename The name of the file.
* @param array $array The array to convert.
* @param array $columns The column names you want to use.
* @param array $excludeColumns The columns you want to exclude.
*/
public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null)
{
// get settings
$splitCharacter = Authentication::getUser()->getSetting('csv_split_character');
$lineEnding = Authentication::getUser()->getSetting('csv_line_ending');
// reformat
if ($lineEnding == '\\n') {
$lineEnding = "\n";
}
if ($lineEnding == '\\r\\n') {
$lineEnding = "\r\n";
}
// convert into CSV
$csv = \SpoonFileCSV::arrayToString($array, $columns, $excludeColumns, $splitCharacter, '"', $lineEnding);
// set headers for download
$charset = BackendModel::getContainer()->getParameter('kernel.charset');
throw new RedirectException('Return the csv data', new Response($csv, Response::HTTP_OK, ['Content-type' => 'application/csv; charset=' . $charset, 'Content-Disposition' => 'attachment; filename="' . $filename . '"', 'Content-Length' => mb_strlen($csv), 'Pragma' => 'no-cache']));
}