本文整理汇总了PHP中Message::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::addError方法的具体用法?PHP Message::addError怎么用?PHP Message::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::addError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Try to login with Facebook
* @param array
* @return boolean
*/
public function login($arrProfile = null)
{
if (parent::login() === true) {
return true;
}
// Return if the user is not found
if (!$arrProfile || $this->findBy('fblogin', $arrProfile['id']) == false) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
return false;
}
// Return if the user ID does not match
if (!$this->fblogin || $this->fblogin != $arrProfile['id']) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
return false;
}
$this->setUserFromDb();
// Update the record
$this->lastLogin = $this->currentLogin;
$this->currentLogin = time();
$this->loginCount = $GLOBALS['TL_CONFIG']['loginCount'];
$this->save();
// Generate the session
$this->generateSession();
$this->log('User "' . $this->username . '" has logged in', get_class($this) . ' login()', TL_ACCESS);
// HOOK: post login callback
if (isset($GLOBALS['TL_HOOKS']['postLogin']) && is_array($GLOBALS['TL_HOOKS']['postLogin'])) {
foreach ($GLOBALS['TL_HOOKS']['postLogin'] as $callback) {
$this->import($callback[0], 'objLogin', true);
$this->objLogin->{$callback}[1]($this);
}
}
return true;
}
示例2: initializeDefaultValues
protected function initializeDefaultValues()
{
// Set default session data
$arrSession = \Session::getInstance()->get('iso_reports');
if ($arrSession[$this->name]['period'] == '') {
$arrSession[$this->name]['period'] = 'month';
}
if ($arrSession[$this->name]['columns'] == '') {
$arrSession[$this->name]['columns'] = '6';
}
if ($arrSession[$this->name]['from'] == '') {
$arrSession[$this->name]['from'] = '';
} elseif (!is_numeric($arrSession[$this->name]['from'])) {
// Convert date formats into timestamps
try {
$objDate = new \Date($arrSession[$this->name]['from'], $GLOBALS['TL_CONFIG']['dateFormat']);
$arrSession[$this->name]['from'] = $objDate->tstamp;
} catch (\OutOfBoundsException $e) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $GLOBALS['TL_CONFIG']['dateFormat']));
$arrSession[$this->name]['from'] = '';
}
}
if (!isset($arrSession[$this->name]['iso_status'])) {
$objStatus = \Database::getInstance()->query("SELECT id FROM " . \Isotope\Model\OrderStatus::getTable() . " WHERE paid=1 ORDER BY sorting");
$arrSession[$this->name]['iso_status'] = $objStatus->id;
}
\Session::getInstance()->set('iso_reports', $arrSession);
}
示例3: updateRobotsTxt
/**
* Update the robots.txt when the page was stored.
*/
public function updateRobotsTxt(DataContainer $dc)
{
if (Hofff\Contao\RobotsTxtEditor\RobotsTxtEditor::generateRobotsTxts()) {
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['robotstxt_updated']);
} else {
\Message::addError($GLOBALS['TL_LANG']['ERR']['robotstxt_not_updated']);
}
}
示例4: getConfirm
public function getConfirm($code)
{
if ($this->auth->confirmByCode($code)) {
\Message::addSuccess(trans('account.alerts.confirmation'));
} else {
\Message::addError(trans('account.alerts.wrong_confirmation'));
}
return redirect('/customer/login');
}
示例5: run
/**
* Run the controller and parse the password template
*/
public function run()
{
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_password');
if (\Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = \Input::postUnsafeRaw('password');
$cnf = \Input::postUnsafeRaw('confirm');
// The passwords do not match
if ($pw != $cnf) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (utf8_strlen($pw) < \Config::get('minPasswordLength')) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
} elseif ($pw == $this->User->username) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
// Make sure the password has been changed
if (\Encryption::verify($pw, $this->User->password)) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$this->loadDataContainer('tl_user');
// Trigger the save_callback
if (is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$pw = $this->{$callback[0]}->{$callback[1]}($pw);
} elseif (is_callable($callback)) {
$pw = $callback($pw);
}
}
}
$objUser = \UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = \Encryption::hash($pw);
$objUser->save();
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php');
}
}
$this->reload();
}
$objTemplate->theme = \Backend::getTheme();
$objTemplate->messages = \Message::generate();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$objTemplate->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
$objTemplate->output();
}
示例6: run
/**
* Export data
*
* @access public
* @param string
* @return void
*/
public static function run($dc = null, $strName = 'formsubmissions', $blnHeaders = true)
{
if (!in_array('!composer', \ModuleLoader::getActive())) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['exportExcelNoComposer']);
\System::redirect(str_ireplace('&key=exportExcel', '', \Environment::get('request')));
return;
}
if (!is_file(TL_ROOT . '/composer/vendor/phpoffice/phpexcel/Classes/PHPExcel.php')) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['exportExcelNoPHPExcel']);
\System::redirect(str_ireplace('&key=exportExcel', '', \Environment::get('request')));
return;
}
parent::run($dc, $strName, $blnHeaders);
}
示例7: importRobotsTxt
/**
* Import the default robots.txt
* @param \DataContainer
*/
public function importRobotsTxt(\DataContainer $dc)
{
if (\Input::get('key') != 'importRobotsTxt') {
return '';
}
if (!file_exists(TL_ROOT . "/" . FILE_ROBOTS_TXT_DEFAULT)) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['no_robotstxt_default']);
$this->redirect(str_replace('&key=importRobotsTxt', '', \Environment::get('request')));
}
$objVersions = new \Versions($dc->table, \Input::get('id'));
$objVersions->create();
$strFileContent = file_get_contents(TL_ROOT . "/" . FILE_ROBOTS_TXT_DEFAULT);
\Database::getInstance()->prepare("UPDATE " . $dc->table . " SET robotsTxtContent=? WHERE id=?")->execute($strFileContent, \Input::get('id'));
$this->redirect(str_replace('&key=importRobotsTxt', '', \Environment::get('request')));
}
示例8: exportBe
public static function exportBe($objDc)
{
$strGlobalOperationKey = \Input::get('key');
$strTable = \Input::get('table') ?: $objDc->table;
if (!$strGlobalOperationKey || !$strTable) {
return;
}
if (($objConfig = ExporterModel::findByKeyAndTable($strGlobalOperationKey, $strTable)) === null) {
if (empty($_SESSION['TL_ERROR'])) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['exporter']['noConfigFound']);
\Controller::redirect($_SERVER['HTTP_REFERER']);
}
} else {
static::export($objConfig, \Input::get('id'));
}
}
示例9: run
/**
* Run the controller and parse the password template
*/
public function run()
{
$this->Template = new BackendTemplate('be_password');
if (Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = Input::post('password');
$cnf = Input::post('confirm');
// Do not allow special characters
if (preg_match('/[#\\(\\)\\/<=>]/', html_entity_decode(Input::post('password')))) {
Message::addError($GLOBALS['TL_LANG']['ERR']['extnd']);
} elseif ($pw != $cnf) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (utf8_strlen($pw) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
} elseif ($pw == $this->User->username) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
list(, $strSalt) = explode(':', $this->User->password);
$strPassword = sha1($strSalt . $pw);
// Make sure the password has been changed
if ($strPassword . ':' . $strSalt == $this->User->password) {
Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
$strPassword = sha1($strSalt . $pw);
$objUser = UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = $strPassword . ':' . $strSalt;
$objUser->save();
Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('contao/main.php');
}
}
$this->reload();
}
$this->Template->theme = $this->getTheme();
$this->Template->messages = Message::generate();
$this->Template->base = Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$this->Template->action = ampersand(Environment::get('request'));
$this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
$this->Template->output();
}
示例10: checkFileServerConnection
/**
* Check the FTP connection
* @param \DataContainer
*/
public function checkFileServerConnection(\DataContainer $dc)
{
if ($dc->activeRecord->type != 'ftp' || $dc->activeRecord->file_connection != 'ftp') {
return;
}
$strClass = $GLOBALS['NOTIFICATION_CENTER']['FTP'][$dc->activeRecord->ftp_type];
if (!class_exists($strClass)) {
\Message::addError($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_class']);
return;
}
$objHandler = new $strClass();
try {
$objHandler->connect($dc->activeRecord);
} catch (\Exception $e) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_connect'], $e->getMessage()));
return;
}
\Message::addConfirmation($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_confirm']);
}
示例11: generate
/**
* Store Login Module ID in Session, required by LdapAuth (Module config)
* @return string
*/
public function generate()
{
// Login
if (\Input::post('FORM_SUBMIT') == 'tl_login') {
if (\Input::post('username', true) && \Input::post('password', true)) {
$objMember = \MemberModel::findBy('username', \Input::post('username', true));
if ($objMember !== null) {
// always reset the password to a random value, otherwise checkCredentialsHook will never be triggered
LdapMember::resetPassword($objMember, \Input::post('username', true));
}
}
// validate email
if ($GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' && !\Validator::isEmail(\Input::post('username', true))) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['email']);
$this->reload();
}
}
$strParent = parent::generate();
return $strParent;
}
示例12: run
/**
* Run the controller and parse the password template
*/
public function run()
{
$this->Template = new BackendTemplate('be_password');
if (Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = Input::post('password', true);
$cnf = Input::post('confirm', true);
// The passwords do not match
if ($pw != $cnf) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (utf8_strlen($pw) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
} elseif ($pw == $this->User->username) {
Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
// Make sure the password has been changed
if (crypt($pw, $this->User->password) == $this->User->password) {
Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$objUser = UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = Encryption::hash($pw);
$objUser->save();
Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('contao/main.php');
}
}
$this->reload();
}
$this->Template->theme = $this->getTheme();
$this->Template->messages = Message::generate();
$this->Template->base = Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$this->Template->action = ampersand(Environment::get('request'));
$this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
$this->Template->output();
}
示例13: authenticateLdapMember
public static function authenticateLdapMember($strUsername, $strPassword)
{
$objLdapUser = LdapMemberModel::findLdapMember($strUsername);
if ($objLdapUser) {
if (!@ldap_bind(Ldap::getConnection(), $objLdapUser->dn, $strPassword)) {
$errno = ldap_errno(Ldap::getConnection());
switch ($errno) {
case static::LDAP_INVALID_CREDENTIALS:
return false;
}
return false;
}
// ldap account requires an valid email and uid
if ($objLdapUser->uid['count'] == 0 || $objLdapUser->mail['count'] == 0) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['ldap']['emailUidMissing']);
return false;
}
return true;
} else {
return false;
}
}
示例14: importExt
public function importExt()
{
$this->loadLanguageFile("tl_calendar_events");
$this->Template = new BackendTemplate('be_importExt_calendar');
$this->Template->headline = 'Test';
$this->Template->message = \Message::generate();
$this->Template->event_type = $this->getEventTypeWidget();
$this->Template->hrefBack = ampersand(str_replace('&key=import', '', \Environment::get('request')));
$this->Template->goBack = $GLOBALS['TL_LANG']['MSC']['goBack'];
$this->Template->headline = $GLOBALS['TL_LANG']['MSC']['import_calendar'][0];
$this->Template->request = ampersand(\Environment::get('request'), ENCODE_AMPERSANDS);
$this->Template->submit = specialchars($GLOBALS['TL_LANG']['tl_calendar_events']['importExt'][0]);
if (\Input::post('FORM_SUBMIT') == 'tl_importExt_calendar') {
if (empty(\Input::post('event_type'))) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
$this->reload();
} else {
$this->Session->set('event_type', \Input::post('event_type'));
$this->redirect(str_replace('&key=importExt', '&key=import', \Environment::get('request')));
}
}
return $this->Template->parse();
}
示例15: export
public static function export($objDc)
{
$strExportType = \Input::get('exportType') ?: 'list';
$strGlobalOperationKey = \Input::get('key');
$intId = \Input::get('id') ?: '';
$strTable = \Input::get('table') ?: $objDc->table;
if (!$strGlobalOperationKey || !$strTable) {
return;
}
if (($objConfig = ExporterModel::findByKeyAndTable($strGlobalOperationKey, $strTable)) === null) {
if (empty($_SESSION['TL_ERROR'])) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['exporter']['noConfigFound']);
\Controller::redirect($_SERVER['HTTP_REFERER']);
}
} else {
$objExporter = null;
switch ($objConfig->fileType) {
case EXPORTER_FILE_TYPE_CSV:
$objExporter = new CsvExporter($objConfig);
break;
case EXPORTER_FILE_TYPE_MEDIA:
$objExporter = new MediaExporter($objConfig);
break;
case EXPORTER_FILE_TYPE_PDF:
$objExporter = new PdfExporter($objConfig);
break;
case EXPORTER_FILE_TYPE_XLS:
$objExporter = new XlsExporter($objConfig);
break;
}
if ($objExporter) {
$objExporter->export($strExportType, $intId);
}
die;
}
}