watchdog($moduleName, $message, $variables = array($id), $severity = WATCHDOG_NOTICE, $link = NULL);
In drupal all the information related to error will be logged into table name called as watchdog
Or you can do it through the ui: Navigate to /admin/reports/dblog
Related
using : cakePHP, Bancha, ExtJS
I try to create a login with ExtJS --> Bancha --> cakePHP.
ExtJS layout has been developed and I can call the cakePHP function login by Bancha. But if i call the the function, I get no result from the $this->Auth->user() function. I need the result (with username and role ) because serveral roles are allow to see serveral pages.
public function login($username = null, $password = null) {
$logged = $this->Auth->login(); // result is boolean(true) all the time
$userObj = $this->Auth->user(); // only the user name
switch ($userObj['role']) { ... // Illegal string offset 'role'
does anyone has a hint?
thx
I've call the static function AuthContrller::users(). now it works.
I'm trying to create a user with the DNN 7 services framework. I've taken my working code from my custom registration module and modified to work within a DNN webapi function.
When I get to the UserController.CreateUser call in the code below I receive a
"\"There was an error generating the XML document.\""
exception. My user makes it into the aspnet_Users table and the DNN users table but does not make it into the DNN userportals table. Any ideas would be appreciated.
private void CreateUser()
{
//Update DisplayName to conform to Format
UpdateDisplayName();
User.Membership.Approved = PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration;
var user = User;
CreateStatus = UserController.CreateUser(ref user);
I finally found the issue. I was not setting the portal ID for my new users and DNN was excepting out when it was adding them to a portal. All it took was User.PortalId = 0 before the CreateUser call.
I have found by trial and error that the minimum needed to create a viable DNN user is:
UserInfo uiNewUser = new UserInfo();
uiNewUser.Username = "<myUsername>";
uiNewUser.Displayname = "<myDisplayname>";
uiNewUser.Email = "<myUserEmail>";
UserMembership newMembership = new UserMembership(uiNewUser);
newMembership.Password = "<myUserPassword>";
uiNewUser.Membership = newMembership;
uiNewUser.PortalID = <myPortalID>;
DotNetNuke.Security.Membership.UserCreateStatus uStatus;
uStatus = DotNetNuke.Security.Membership.MembershipProvider.Instance().CreateUser(ref uiNewUser);
RoleInfo newRole = RoleController.Instance.GetRoleByName(uiNewUser.PortalID, "Registered Users");
RoleController.Instance.AddUserRole(uiNewUser.PortalID, uiNewUser.UserID, newRole.RoleID, (RoleStatus)1, false, DateTime.MinValue, DateTime.MaxValue);
If any of these are missed out, parts of the user are created in the database, but the user may not be visible in the Admin list of users, or an Exception may be generated. Other details can be added later.
everybody! I'm doing an application with several databases where each one belongs to one specific department.
So, I have on my Bootstrap.php the method _initDoctrine() that initialize the connection with DB (meanwhile, i have only one).
public function _initDoctrine() {
$this->getApplication()->getAutoloader()
->pushAutoloader(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(
Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE
);
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
$doctrineConfig = $this->getOption('doctrine');
Doctrine::loadModels($doctrineConfig['models_path']);
$conn = Doctrine_Manager::connection($doctrineConfig['dsn'], 'doctrine');
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
return $conn;
}
In my login page, there's 3 options (databases) which the user will choose to connect.
So, there's anyway to init doctrine config after login??
PS: sorry my english
I have a CakePHP 2.0 application with a MySQL database. Two database tables are connected with a 1:n relation and a foreign key constraint.
So if I want to delete an entry which is connected in the other database table, I get the error:
Error: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a forein key constraint fails (...)
SQL Query: DELETE 'Test' FROM 'tests' AS 'Test' WHERE 'Test'.'id' = 10
Notice: If you want to customize this error message, create app/View/Errors/pdo_error.ctp
But what I want to do is to handle the error message! I read something about 'onError' but putting it into the 'AppModel' it seems not to be called (maybe it works only with CakePHP 1.3?):
class Test extends AppModel {
function onError() {
echo "TESTTESTTEST";
$db = ConnectionManager::getDataSource('default');
$err = $db->lastError();
$this->log($err);
$this->log($this->data);
}
}
So what can I do? I want to remain on this page, and I want to show only an error message (not a stack trace and this kind of stuff).
Anyone an idea?
What about using the .ctp?
If you want to customize this error message, create app/View/Errors/pdo_error.ctp
The one that's being used is in the Cake directory, you could just copy that to your app/View/Errors directory and remove the stack trace from that if you like.
There's also the beforeDelete() Model callback function you could use to set a flashMessage.
Data base error normally give 500 error so cakephp handle 500 exception by using
View/Errors/error500.ctp or app/View/Errors/pdo_error.ctp only and customize this page
and add this function bellow in AppController.php
function beforeRender() {
if($this->name == 'CakeError') {
$this->set('title','Internal error occurs');
$this->layout = 'frontend';
}
}
I've had a look at the other questions relating to this topic but none have been useful.
Expected Outcome
From a homepage with links to different web apps, the user clicks to access a web app. The user is redirected to the login page. I've tried to override the login function to auto-login network users based on a lookup on their IP address. Their machine name is stored as their username in the database and all the passwords are the same. This is validated and the user is automatically logged in and redirected to the web apps home page, with no need to see a login form.
Note: this auto-login works when accessing the web address directly, but this problem started when I added in the "dashboard" of web apps. However, this is required so there is only one shortcut on the users desktop.
routes.php Code
Router::connect('/', array('controller' => 'cns', 'action' => 'view'));
app_controller.php Code
function beforeFilter() {
$this->Auth->allow('display');
# Users need authorised before viewing these pages
$this->Auth->deny('index','view', 'add','edit','delete');
$this->Auth->loginRedirect = array( 'controller'=>'cns', 'action'=>'view');
$this->Auth->logoutRedirect = array( 'controller'=>'pages', 'action'=>'logged_out');
}
users_controller.php Code
function beforeFilter() {
$this->Auth->autoRedirect = false;
}
function login () {
# Automatic login based on computer name
$this->data['User']['password'] = $this->Auth->password('qwerty');
# Result: x-xxxxxx.domain.local (function declared below)
$full_host = gethostbyaddr($this->get_user_IP_address());
# Result: x-xxxxxx[.domain.local]
$position_of_split = strrpos($full_host, ".gmi.local");
# Result: x-xxxxxx
$computer_name = substr($full_host,0,$position_of_split);
# If username is not been provided, use the computer name discovered by auto-login
(!isset($this->data['User']['username']) ? $this->data['User']['username'] = $computer_name : null);
# If login is successful, redirect to view. Otherwise, echo error message.
if($this->Auth->login($this->data)){
$this->redirect(array('controller' => 'cns', 'action' => 'view'));
} else {
echo "Unable to log you in. Please advise IT."; die;
}
}
function get_user_IP_address() {
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
return $_SERVER["HTTP_X_FORWARDED_FOR"];
if (isset($_SERVER["HTTP_CLIENT_IP"]))
return $_SERVER["HTTP_CLIENT_IP"];
return $_SERVER["REMOTE_ADDR"];
}
if (getenv('HTTP_X_FORWARDED_FOR'))
return getenv('HTTP_X_FORWARDED_FOR');
if (getenv('HTTP_CLIENT_IP'))
return getenv('HTTP_CLIENT_IP');
return getenv('REMOTE_ADDR');
}
If you need further code or explanation, just ask in the comments.
Thanks in advance. :)
I don't know if you found the solution to your problem but I had the same problem and found the following article which describes the cause and provides workaround.
Infinite loop login redirect