本文整理汇总了PHP中BackendAuthentication::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendAuthentication::getUser方法的具体用法?PHP BackendAuthentication::getUser怎么用?PHP BackendAuthentication::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackendAuthentication
的用法示例。
在下文中一共展示了BackendAuthentication::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadForm
/**
* Load the form
*/
private function loadForm()
{
$this->imageIsAllowed = BackendModel::getModuleSetting($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', BackendModel::getModuleSetting($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);
}
示例2: 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', BackendLanguage::getInterfaceLanguages(), BackendModel::getModuleSetting('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());
// permissons
$this->frm->addCheckbox('active', true);
$this->frm->addCheckbox('api_access', false);
$this->frm->addMultiCheckbox('groups', $groups, $checkedGroups);
}
示例3: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('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 ? $this->frm->getField('template')->getValue() : $this->templates[0];
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['hidden'] = $this->frm->getField('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']);
}
}
}
示例4: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired'));
$this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired'));
$this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired'));
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['meta_id'] = $this->meta->save();
$item['category_id'] = $this->frm->getField('category_id')->getValue();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['language'] = BL::getWorkingLanguage();
$item['question'] = $this->frm->getField('title')->getValue();
$item['answer'] = $this->frm->getField('answer')->getValue(true);
$item['created_on'] = BackendModel::getUTCDate();
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1;
// save the data
$item['id'] = BackendFaqModel::insert($item);
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// add search index
BackendSearchModel::saveIndex('faq', $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=row-' . $item['id']);
}
}
}
示例5: 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[optional] $columns The column names you want to use.
* @param array[optional] $excludeColumns The columns you want to exclude.
*/
public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null)
{
// get settings
$splitCharacter = BackendAuthentication::getUser()->getSetting('csv_split_character');
$lineEnding = BackendAuthentication::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
$headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET;
$headers[] = 'Content-Disposition: attachment; filename="' . $filename;
$headers[] = 'Content-Length: ' . strlen($csv);
$headers[] = 'Pragma: no-cache';
// overwrite the headers
SpoonHTTP::setHeaders($headers);
// ouput the CSV
echo $csv;
exit;
}
示例6: 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)), BackendModel::getModuleSetting($this->URL->getModule(), 'overview_num_items', 10));
$this->frm->addDropdown('recent_articles_full_number_of_items', array_combine(range(1, 10), range(1, 10)), BackendModel::getModuleSetting($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)), BackendModel::getModuleSetting($this->URL->getModule(), 'recent_articles_list_num_items', 5));
// add fields for spam
$this->frm->addCheckbox('spamfilter', BackendModel::getModuleSetting($this->URL->getModule(), 'spamfilter', false));
// no Akismet-key, so we can't enable spam-filter
if (BackendModel::getModuleSetting('core', 'akismet_key') == '') {
$this->frm->getField('spamfilter')->setAttribute('disabled', 'disabled');
$this->tpl->assign('noAkismetKey', true);
}
// add fields for comments
$this->frm->addCheckbox('allow_comments', BackendModel::getModuleSetting($this->URL->getModule(), 'allow_comments', false));
$this->frm->addCheckbox('moderation', BackendModel::getModuleSetting($this->URL->getModule(), 'moderation', false));
// add fields for notifications
$this->frm->addCheckbox('notify_by_email_on_new_comment_to_moderate', BackendModel::getModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', false));
$this->frm->addCheckbox('notify_by_email_on_new_comment', BackendModel::getModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment', false));
// add fields for SEO
$this->frm->addCheckbox('ping_services', BackendModel::getModuleSetting($this->URL->getModule(), 'ping_services', false));
// add fields for RSS
$this->frm->addCheckbox('rss_meta', BackendModel::getModuleSetting($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), true));
$this->frm->addText('rss_title', BackendModel::getModuleSetting($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage()));
$this->frm->addTextarea('rss_description', BackendModel::getModuleSetting($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage()));
$this->frm->addText('feedburner_url', BackendModel::getModuleSetting($this->URL->getModule(), 'feedburner_url_' . BL::getWorkingLanguage()));
// god user?
if ($this->isGod) {
$this->frm->addCheckbox('show_image_form', BackendModel::getModuleSetting($this->URL->getModule(), 'show_image_form', true));
}
}
示例7: loadForm
/**
* Load the form
*/
private function loadForm()
{
$this->isGod = BackendAuthentication::getUser()->isGod();
$this->frm = new BackendForm('settingsEmail');
// email settings
$mailerFrom = BackendModel::getModuleSetting('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'] : '');
$mailerTo = BackendModel::getModuleSetting('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'] : '');
$mailerReplyTo = BackendModel::getModuleSetting('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'] : '');
if ($this->isGod) {
$mailerType = BackendModel::getModuleSetting('core', 'mailer_type', 'mail');
$this->frm->addDropdown('mailer_type', array('mail' => 'PHP\'s mail', 'smtp' => 'SMTP'), $mailerType);
// smtp settings
$this->frm->addText('smtp_server', BackendModel::getModuleSetting('core', 'smtp_server', ''));
$this->frm->addText('smtp_port', BackendModel::getModuleSetting('core', 'smtp_port', 25));
$this->frm->addText('smtp_username', BackendModel::getModuleSetting('core', 'smtp_username', ''));
$this->frm->addPassword('smtp_password', BackendModel::getModuleSetting('core', 'smtp_password', ''));
}
$this->tpl->assign('isGod', $this->isGod);
}
示例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
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// get parameters
$newSequence = SpoonFilter::getPostValue('new_sequence', null, '');
// validate
if ($newSequence == '') {
$this->output(self::BAD_REQUEST, null, 'no new_sequence provided');
}
// convert into array
$json = @json_decode($newSequence, true);
// validate
if ($json === false) {
$this->output(self::BAD_REQUEST, null, 'invalid new_sequence provided');
}
// initialize
$userSequence = array();
$hiddenItems = array();
// loop columns
foreach ($json as $column => $widgets) {
$columnValue = 'left';
if ($column == 1) {
$columnValue = 'middle';
}
if ($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
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// user is god?
$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(false), null, 'string');
$name = SpoonFilter::getPostValue('name', null, null, 'string');
$type = SpoonFilter::getPostValue('type', BackendModel::getDB()->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 (!SpoonFilter::isValidAgainstRegexp('|^([a-z0-9\\-\\_])+$|', $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);
}
}
示例11: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$this->isGod = BackendAuthentication::getUser()->isGod();
$this->setFilter();
$this->loadForm();
$this->loadDataGrid();
$this->parse();
$this->display();
}
示例12: validateForm
/**
* Validate the form
*
* @return void
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// shorten the fields
$txtName = $this->frm->getField('name');
$txtEmail = $this->frm->getField('email');
$ddmMethod = $this->frm->getField('method');
$txtSuccessMessage = $this->frm->getField('success_message');
$txtIdentifier = $this->frm->getField('identifier');
// validate fields
$txtName->isFilled(BL::getError('NameIsRequired'));
$txtSuccessMessage->isFilled(BL::getError('SuccessMessageIsRequired'));
if ($ddmMethod->isFilled(BL::getError('NameIsRequired')) && $ddmMethod->getValue() == 'database_email') {
$txtEmail->isEmail(BL::getError('EmailIsRequired'));
}
// identifier
if ($txtIdentifier->isFilled()) {
// invalid characters
if (!SpoonFilter::isValidAgainstRegexp('/^[a-zA-Z0-9\\.\\_\\-]+$/', $txtIdentifier->getValue())) {
$txtIdentifier->setError(BL::getError('InvalidIdentifier'));
} elseif (BackendFormBuilderModel::existsIdentifier($txtIdentifier->getValue())) {
$txtIdentifier->setError(BL::getError('UniqueIdentifier'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build array
$values['language'] = BL::getWorkingLanguage();
$values['user_id'] = BackendAuthentication::getUser()->getUserId();
$values['name'] = $txtName->getValue();
$values['method'] = $ddmMethod->getValue();
$values['email'] = $values['method'] == 'database_email' ? $txtEmail->getValue() : null;
$values['success_message'] = $txtSuccessMessage->getValue(true);
$values['identifier'] = $txtIdentifier->isFilled() ? $txtIdentifier->getValue() : BackendFormBuilderModel::createIdentifier();
$values['created_on'] = BackendModel::getUTCDate();
$values['edited_on'] = BackendModel::getUTCDate();
// insert the item
$id = BackendFormBuilderModel::insert($values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $values));
// set frontend locale
FL::setLocale(BL::getWorkingLanguage());
// create submit button
$field['form_id'] = $id;
$field['type'] = 'submit';
$field['settings'] = serialize(array('values' => ucfirst(FL::getLabel('Send'))));
BackendFormBuilderModel::insertField($field);
// everything is saved, so redirect to the editform
$this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $id . '&report=added&var=' . urlencode($values['name']) . '#tabFields');
}
}
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
// check if the user is really logged on
if (BackendAuthentication::getUser()->isAuthenticated()) {
$this->redirect($this->getParameter('querystring', 'string', BackendModel::createUrlForAction(null, 'dashboard')));
}
parent::execute();
$this->load();
$this->validateForm();
$this->parse();
$this->display();
}
示例14: loadForm
/**
* Load the form
*/
private function loadForm()
{
// create user objects
$this->user = new BackendUser($this->id);
$this->authenticatedUser = BackendAuthentication::getUser();
// create form
$this->frm = new BackendForm('edit');
// get active groups
$groups = BackendGroupsModel::getGroupsByUser($this->id);
// loop through groups and set checked
foreach ($groups as $group) {
$checkedGroups[] = $group['id'];
}
// create elements
// profile
$this->frm->addText('email', $this->record['email'], 255);
if ($this->user->isGod()) {
$this->frm->getField('email')->setAttributes(array('disabled' => 'disabled'));
}
$this->frm->addText('name', $this->record['settings']['name'], 255);
$this->frm->addText('surname', $this->record['settings']['surname'], 255);
$this->frm->addText('nickname', $this->record['settings']['nickname'], 24);
$this->frm->addImage('avatar');
// password
// check if we're god or same user
if ($this->authenticatedUser->getUserId() == $this->id || $this->authenticatedUser->isGod()) {
// allow to set new password
$this->frm->addPassword('new_password', null, 75);
$this->frm->addPassword('confirm_password', null, 75);
// disable autocomplete
$this->frm->getField('new_password')->setAttributes(array('autocomplete' => 'off'));
$this->frm->getField('confirm_password')->setAttributes(array('autocomplete' => 'off'));
}
// settings
$this->frm->addDropdown('interface_language', BackendLanguage::getInterfaceLanguages(), $this->record['settings']['interface_language']);
$this->frm->addDropdown('date_format', BackendUsersModel::getDateFormats(), $this->user->getSetting('date_format'));
$this->frm->addDropdown('time_format', BackendUsersModel::getTimeFormats(), $this->user->getSetting('time_format'));
$this->frm->addDropdown('number_format', BackendUsersModel::getNumberFormats(), $this->user->getSetting('number_format', 'dot_nothing'));
$this->frm->addDropDown('csv_split_character', BackendUsersModel::getCSVSplitCharacters(), $this->user->getSetting('csv_split_character'));
$this->frm->addDropDown('csv_line_ending', BackendUsersModel::getCSVLineEndings(), $this->user->getSetting('csv_line_ending'));
// permissions
$this->frm->addCheckbox('active', $this->record['active'] == 'Y');
// disable active field for current users
if ($this->authenticatedUser->getUserId() == $this->record['id']) {
$this->frm->getField('active')->setAttribute('disabled', 'disabled');
}
$this->frm->addCheckbox('api_access', isset($this->record['settings']['api_access']) && $this->record['settings']['api_access'] == 'Y');
$this->frm->addMultiCheckbox('groups', BackendGroupsModel::getAll(), $checkedGroups);
}
示例15: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// is the user a GodUser?
$this->isGod = BackendAuthentication::getUser()->isGod();
// set filter
$this->setFilter();
// load form
$this->loadForm();
// load datagrids
$this->loadDataGrid();
// parse page
$this->parse();
// display the page
$this->display();
}