本文整理汇总了PHP中Backend\Core\Engine\Authentication类的典型用法代码示例。如果您正苦于以下问题:PHP Authentication类的具体用法?PHP Authentication怎么用?PHP Authentication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Authentication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse the form
*/
protected function parse()
{
parent::parse();
// assign the data
$this->tpl->assign('item', $this->record);
$this->tpl->assign('showFaqDeleteCategory', BackendFaqModel::deleteCategoryAllowed($this->id) && BackendAuthentication::isAllowedAction('DeleteCategory'));
}
示例2: 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);
}
示例3: 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']);
}
}
}
示例4: 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));
}
}
示例5: loadDatagrids
/**
* Loads the dataGrids
*/
private function loadDatagrids()
{
// load all categories
$categories = BackendFaqModel::getCategories(true);
// loop categories and create a dataGrid for each one
foreach ($categories as $categoryId => $categoryTitle) {
$dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId));
$dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop'));
$dataGrid->setColumnsHidden(array('category_id', 'sequence'));
$dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>');
$dataGrid->setColumnsSequence('dragAndDropHandle');
$dataGrid->setColumnAttributes('question', array('class' => 'title'));
$dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle'));
$dataGrid->setRowAttributes(array('id' => '[id]'));
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('Edit')) {
$dataGrid->setColumnURL('question', BackendModel::createURLForAction('Edit') . '&id=[id]');
$dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit'));
}
// add dataGrid to list
$this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent());
}
// set empty datagrid
$this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => '')));
$this->emptyDatagrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop emptyGrid'));
$this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null));
}
示例6: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendAuthentication::logout();
// redirect to login-screen
$this->redirect(BackendModel::createURLForAction('Index', $this->getModule()));
}
示例7: 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;
}
示例8: 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);
}
示例9: 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')));
}
示例10: 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'));
}
}
}
示例11: loadDataGrid
/**
* Load the datagrid
*/
public function loadDataGrid()
{
$this->dataGrid = new BackendDataGridDB(BackendGroupsModel::QRY_BROWSE);
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('Edit')) {
$this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('Edit') . '&id=[id]');
$this->dataGrid->setColumnURL('num_users', BackendModel::createURLForAction('Edit') . '&id=[id]#tabUsers');
$this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]');
}
}
示例12: loadDataGrid
/**
* Load the datagrids
*/
private function loadDataGrid()
{
$this->dataGrid = new BackendDataGridDB(BackendContentBlocksModel::QRY_BROWSE, array('active', BL::getWorkingLanguage()));
$this->dataGrid->setSortingColumns(array('title'));
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('Edit')) {
$this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]');
$this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit'));
}
}
示例13: parse
/**
* Parse & display the page
*/
protected function parse()
{
parent::parse();
$this->tpl->assign('dataGrid', $this->dataGrid->getNumResults() != 0 ? $this->dataGrid->getContent() : false);
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('AddCategory') && $this->multipleCategoriesAllowed) {
$this->tpl->assign('showAgendaAddCategory', true);
} else {
$this->tpl->assign('showAgendaAddCategory', false);
}
}
示例14: loadDataGrid
/**
* Load the dataGrid
*/
protected function loadDataGrid()
{
$this->dataGrid = new DataGridDB(BackendInstagramModel::QRY_DATAGRID_BROWSE, Language::getWorkingLanguage());
// Reform date
$this->dataGrid->setColumnFunction(array('Backend\\Core\\Engine\\DataGridFunctions', 'getLongDate'), array('[created_on]'), 'created_on', true);
// Check if this action is allowed
if (Authentication::isAllowedAction('Edit')) {
$this->dataGrid->addColumn('edit', null, Language::lbl('Edit'), Model::createURLForAction('Edit') . '&id=[id]', Language::lbl('Edit'));
$this->dataGrid->setColumnURL('username', Model::createURLForAction('Edit') . '&id=[id]');
}
}
示例15: CheckAuthentication
/**
* This function must check the user session to be sure that he/she is
* authorized to upload and access files in the File Browser.
*
* @return boolean
*/
function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
// return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
// ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
// user logs in your system. To be able to use session variables don't
// forget to add session_start() at the top of this file.
return BackendAuthentication::isLoggedIn();
}