• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to US and in need of some help
#1
Hi all!

First of all I am not a native English speaker so you might encounter some mistakes here and there.

I apologise in advance.

I don't even know if this is the right place to post my request for some help. My apologies if it's the wrong forum.

I managed to install US with ease. No major problems.

What I am looking for is, besides managing users (I can easily do that with the admin panels), to be able to have some basic tasks that, becoause of my very basic knowledge of PHP, I haven't been able to figure out properly.

When a user goes to a "protected" page I need the user to be presented with a login page if not logged in already, or continue reading the page if logged in.

After login, I need the user to get back to where it was stopped because the user had to login and continue.

Besides that, I would like to have user name on the top right side of each page he visits after login with the option to edit his profile and log out if desired.

Does any of you guys have some spare time to waste to provide me some detailed guidance for this?

I tried adding the suggested piece of code on top of the pages I wish to protect:

?>

require_once '../users/init.php';
require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
if(isset($user) && $user->isLoggedIn()){
}

?>

What happens id that if I login as Admin I get the dashboard (which is fine) but if I login as User, I am redirected to the main page, while I would like the following:

If login ok, then continue visiting the page, if not redirected to another page of my choice.

I thank everybody in advance for any help you may provide.

Best and congrats for the great scripts provided to all.


Carlo
  Reply
#2
(05-11-2019, 04:13 PM)Carlo Wrote: Hi all!

First of all I am not a native English speaker so you might encounter some mistakes here and there.

I apologise in advance.

I don't even know if this is the right place to post my request for some help. My apologies if it's the wrong forum.

I managed to install US with ease. No major problems.

What I am looking for is, besides managing users (I can easily do that with the admin panels), to be able to have some basic tasks that, becoause of my very basic knowledge of PHP, I haven't been able to figure out properly.

When a user goes to a "protected" page I need the user to be presented with a login page if not logged in already, or continue reading the page if logged in.

After login, I need the user to get back to where it was stopped because the user had to login and continue.

Besides that, I would like to have user name on the top right side of each page he visits after login with the option to edit his profile and log out if desired.

Does any of you guys have some spare time to waste to provide me some detailed guidance for this?

I tried adding the suggested piece of code on top of the pages I wish to protect:

?>

require_once '../users/init.php';
require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
if(isset($user) && $user->isLoggedIn()){
}

?>

What happens id that if I login as Admin I get the dashboard (which is fine) but if I login as User, I am redirected to the main page, while I would like the following:

If login ok, then continue visiting the page, if not redirected to another page of my choice.

I thank everybody in advance for any help you may provide.

Best and congrats for the great scripts provided to all.


Carlo
Hi Carlo. Your English is great.  I'm on vacation so I don't have all my resources with me right now.  Let me try to see if I can help.

The easy one is the name in the upper right hand corned.  If you go to the admin panel and settings->general settings, there is an option about the echouser function.  If you set that to something other than username, that will be where the username is now and clicking that will take them to their account page.  I think that's what you want.  If not, let me know.  That same settings page also has a place where you can choose where the user is redirected after a "normal" login.

The way the system works now is pretty much how I think you are wanting it to work.  
1.  If you just visit login.php, you are redirected to the "default" page the we set or you can specify a page in the settings.
2. If you were trying to visit a certain page and got redirected to login, you will go back there automatically. 

You can test this by logging out and then trying to visit users/user_settings.php  After you login, you will be taken back to that page.



Let me know if any of this does not work for you and I can give you more detailed instructions.
Dan
  Reply
#3

.php   AltLangEngine.php (Size: 17.62 KB / Downloads: 0)
.php   it-test.mo.php (Size: 23.22 KB / Downloads: 0)
.php   it-test.po.php (Size: 23.3 KB / Downloads: 0)

Hi Dan...

Maybe I did not explain properly what I meant...

As I said, I installed US without big problems, thanks to your install procedure.

The first thing that I had to consider was the fact that I installed it on an already existing project.

I already had an existing index.php on my main page.

So I had two choices: either copy the content of my index into yours or not use yours. I chose the latter.

I hope this was not the origin of my troubles.

When I navigate to pages that are not protected there are no problems, since the site is acting as it was before installing US.

But when I tried to navigate to a "protected" page, I got into the current problem.

Please do consider that I can manage MySQL sufficiently and I have some little experience with PHP but, nevertheless, I am unable to follow the intricacies of your code. (or any other code that appears complex to me, for what it counts).

This is what I want to achieve and I was hoping to do it with the three lines of code that you suggest putting on top of each protected page.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.

It will then ascertain what kind of clearance you have and according to that will allow you to view that page or redirect you somewhere else, unless you are an Admin in which case you are presented with the dashboard. (talking of which, it seems that only English is available for such page).

Is there a way to change the last of the three lines  required with something that says, in pseudo English, the following?

IF
you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

Such redirection should be or might be different for each protected page.

In other words, I would like to be able to indicate for each protected page a destination page of my choice according to my desire.

Is this feasible?
And if yes, what kind of code should I put on top of each protected page?

Because this

require_once '../users/init.php';  //make sure this path is correct!

require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
if (!securePage($_SERVER['PHP_SELF'])){die();}

does not do that, unless the lack of the initial index.php were not the real problem.

Is my question now any clearer? Please consider that I am not native English so my choice of words may be somehow inappropriate to descrive the situation.

Back to the Dashboard.

To me is not a big problem: I can manage fine the English descriptions that are there with ease.

Bur I was wondering about that, for non English speakers or for anyone who is more familiar with his own language.

I sort of thought of a solution but, before venturing into the code, I would love to get your opinion.

I thought of changing the structure of the pages where language is involved with the following (an example):

//User Settings
$lang = array_merge($lang,array(
"SET_PIN" => _("Reset PIN"),
"SET_WHY" => _("Why can't I change this?"),
"SET_PW_MATCH" => _("Must match the New Password"),

At that point, adding a simple .po .mo files in the appropriate folder as required by PHP's gettext function, should do the trick.

Once the .po file is created, you may add all the other sentences that need translation in any US pages, by simply changing the sentence to be translated with something like (as an example)

BEFORE
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr">Original sentence in English <a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

AFTER
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr"><? echo _("Original sentence in English") ?><a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

Thus getting the translation in your chosen language for each and every instance in US, working on a single .po file (one for each language provided).

Naturally all this will require some extra general settings like a couple of lines of code for the environmental changes required, but that should be a walk in the park...

If you think that the above is feasible, I can dedicate my time to operate the required changes in the html sections and provide you with the resulting code for your view and tests. If it works as I expect, you can use it freely.

Let me know, if you please, the solution to my needs if it is not meaning for you too much effort and what do you think about the "language" solution.

Thank you in advance for your time and assistance.

Best,

Carlo

P.S. I attached some files for Italian as an example (which I doubt you will need). I had to add a false .php extension to upload the .mo and .po files. I hope this is not against the Forum rules.
  Reply
#4
(05-14-2019, 07:21 PM)Carlo Wrote: Hi Dan...

Maybe I did not explain properly what I meant...

As I said, I installed US without big problems, thanks to your install procedure.

The first thing that I had to consider was the fact that I installed it on an already existing project.

I already had an existing index.php on my main page.

So I had two choices: either copy the content of my index into yours or not use yours. I chose the latter.

I hope this was not the origin of my troubles.

When I navigate to pages that are not protected there are no problems, since the site is acting as it was before installing US.

But when I tried to navigate to a "protected" page, I got into the current problem.

Please do consider that I can manage MySQL sufficiently and I have some little experience with PHP but, nevertheless, I am unable to follow the intricacies of your code. (or any other code that appears complex to me, for what it counts).

This is what I want to achieve and I was hoping to do it with the three lines of code that you suggest putting on top of each protected page.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.

It will then ascertain what kind of clearance you have and according to that will allow you to view that page or redirect you somewhere else, unless you are an Admin in which case you are presented with the dashboard. (talking of which, it seems that only English is available for such page).

Is there a way to change the last of the three lines  required with something that says, in pseudo English, the following?

IF
you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

Such redirection should be or might be different for each protected page.

In other words, I would like to be able to indicate for each protected page a destination page of my choice according to my desire.

Is this feasible?
And if yes, what kind of code should I put on top of each protected page?

Because this

require_once '../users/init.php';  //make sure this path is correct!

require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
if (!securePage($_SERVER['PHP_SELF'])){die();}

does not do that, unless the lack of the initial index.php were not the real problem.

Is my question now any clearer? Please consider that I am not native English so my choice of words may be somehow inappropriate to descrive the situation.

Back to the Dashboard.

To me is not a big problem: I can manage fine the English descriptions that are there with ease.

Bur I was wondering about that, for non English speakers or for anyone who is more familiar with his own language.

I sort of thought of a solution but, before venturing into the code, I would love to get your opinion.

I thought of changing the structure of the pages where language is involved with the following (an example):

//User Settings
$lang = array_merge($lang,array(
"SET_PIN" => _("Reset PIN"),
"SET_WHY" => _("Why can't I change this?"),
"SET_PW_MATCH" => _("Must match the New Password"),

At that point, adding a simple .po .mo files in the appropriate folder as required by PHP's gettext function, should do the trick.

Once the .po file is created, you may add all the other sentences that need translation in any US pages, by simply changing the sentence to be translated with something like (as an example)

BEFORE
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr">Original sentence in English <a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

AFTER
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr"><? echo _("Original sentence in English") ?><a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

Thus getting the translation in your chosen language for each and every instance in US, working on a single .po file (one for each language provided).

Naturally all this will require some extra general settings like a couple of lines of code for the environmental changes required, but that should be a walk in the park...

If you think that the above is feasible, I can dedicate my time to operate the required changes in the html sections and provide you with the resulting code for your view and tests. If it works as I expect, you can use it freely.

Let me know, if you please, the solution to my needs if it is not meaning for you too much effort and what do you think about the "language" solution.

Thank you in advance for your time and assistance.

Best,

Carlo

P.S. I attached some files for Italian as an example (which I doubt you will need). I had to add a false .php extension to upload the .mo and .po files. I hope this is not against the Forum rules.
Let me see if I can get these in order....

You're fine not using our index.php but you probably want some of the things that are in it (like init.php, some of the stuff in prep.php) and possibly the footer.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.
This is true if the following conditions are met. 
1. The page has this line with the proper path require_once 'users/init.php';
2. The page has if (!securePage($_SERVER['PHP_SELF'])){die();}
3. The folder that the page is in is covered in the z_us_root.php file 
4. The page shows up when you view it in the "pages" section of the dashboard.


IF

you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

This logic would automatically redirect admins to the dashboard instead of letting them see the protected page.  If that's what you want, the logic would be like this


Code:
//get rid of the securePage line
//add this...
if(isset($user) && $user->isLoggedIn()){
  if(hasPerm([2],$user->data()->id)){//admin
Redirect::to($us_url_root.'users/admin.php');
}elseif(!hasPerm([1],$user->data()->id)){
Redirect::to($us_url_root.'users/whatver.php');
}
}else{
  Redirect::to($us_url_root.'users/login.php');
}


What that does is...if the user is not logged in, redirect them to login.  If they're admin, redirect to dashboard.  If they do NOT have one of the permissions specified in that [1] (you can separate multiple perms by comma) Redirect them to whatever.php


I haven't tested this but you can try instead of Redirect::to($us_url_root.'users/login.php');


Code:
$urlRootLength=strlen($us_url_root);
$page=substr($uri,$urlRootLength,strlen($uri)-$urlRootLength);
$dest=encodeURIComponent("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
Redirect::to($us_url_root.'users/login.php?dest='.$dest);

Admin language is expected to be a part of version 5.0.  Front end language was just released a few months ago, so we're working on making sure everything is right before doing backend. 

Gettext is not a viable solution for our application because it doesn't work universally across all servers.  We have tested this.  I don't LOVE our solution, but it does have the same fallback option as gettext and it works a lot better for what we're doing.  

Sorry for the slow response.  I've been on vacation and I'm answering messages as fast as I can.

We don't have Italian right now, I would love to offer it!
  Reply
#5
(05-15-2019, 01:45 PM)mudmin Wrote:
(05-14-2019, 07:21 PM)Carlo Wrote: Hi Dan...

Maybe I did not explain properly what I meant...

As I said, I installed US without big problems, thanks to your install procedure.

The first thing that I had to consider was the fact that I installed it on an already existing project.

I already had an existing index.php on my main page.

So I had two choices: either copy the content of my index into yours or not use yours. I chose the latter.

I hope this was not the origin of my troubles.

When I navigate to pages that are not protected there are no problems, since the site is acting as it was before installing US.

But when I tried to navigate to a "protected" page, I got into the current problem.

Please do consider that I can manage MySQL sufficiently and I have some little experience with PHP but, nevertheless, I am unable to follow the intricacies of your code. (or any other code that appears complex to me, for what it counts).

This is what I want to achieve and I was hoping to do it with the three lines of code that you suggest putting on top of each protected page.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.

It will then ascertain what kind of clearance you have and according to that will allow you to view that page or redirect you somewhere else, unless you are an Admin in which case you are presented with the dashboard. (talking of which, it seems that only English is available for such page).

Is there a way to change the last of the three lines  required with something that says, in pseudo English, the following?

IF
you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

Such redirection should be or might be different for each protected page.

In other words, I would like to be able to indicate for each protected page a destination page of my choice according to my desire.

Is this feasible?
And if yes, what kind of code should I put on top of each protected page?

Because this

require_once '../users/init.php';  //make sure this path is correct!

require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
if (!securePage($_SERVER['PHP_SELF'])){die();}

does not do that, unless the lack of the initial index.php were not the real problem.

Is my question now any clearer? Please consider that I am not native English so my choice of words may be somehow inappropriate to descrive the situation.

Back to the Dashboard.

To me is not a big problem: I can manage fine the English descriptions that are there with ease.

Bur I was wondering about that, for non English speakers or for anyone who is more familiar with his own language.

I sort of thought of a solution but, before venturing into the code, I would love to get your opinion.

I thought of changing the structure of the pages where language is involved with the following (an example):

//User Settings
$lang = array_merge($lang,array(
"SET_PIN" => _("Reset PIN"),
"SET_WHY" => _("Why can't I change this?"),
"SET_PW_MATCH" => _("Must match the New Password"),

At that point, adding a simple .po .mo files in the appropriate folder as required by PHP's gettext function, should do the trick.

Once the .po file is created, you may add all the other sentences that need translation in any US pages, by simply changing the sentence to be translated with something like (as an example)

BEFORE
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr">Original sentence in English <a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

AFTER
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr"><? echo _("Original sentence in English") ?><a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

Thus getting the translation in your chosen language for each and every instance in US, working on a single .po file (one for each language provided).

Naturally all this will require some extra general settings like a couple of lines of code for the environmental changes required, but that should be a walk in the park...

If you think that the above is feasible, I can dedicate my time to operate the required changes in the html sections and provide you with the resulting code for your view and tests. If it works as I expect, you can use it freely.

Let me know, if you please, the solution to my needs if it is not meaning for you too much effort and what do you think about the "language" solution.

Thank you in advance for your time and assistance.

Best,

Carlo

P.S. I attached some files for Italian as an example (which I doubt you will need). I had to add a false .php extension to upload the .mo and .po files. I hope this is not against the Forum rules.
Let me see if I can get these in order....

You're fine not using our index.php but you probably want some of the things that are in it (like init.php, some of the stuff in prep.php) and possibly the footer.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.
This is true if the following conditions are met. 
1. The page has this line with the proper path require_once 'users/init.php';
2. The page has if (!securePage($_SERVER['PHP_SELF'])){die();}
3. The folder that the page is in is covered in the z_us_root.php file 
4. The page shows up when you view it in the "pages" section of the dashboard.


IF

you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

This logic would automatically redirect admins to the dashboard instead of letting them see the protected page.  If that's what you want, the logic would be like this


Code:
//get rid of the securePage line
//add this...
if(isset($user) && $user->isLoggedIn()){
  if(hasPerm([2],$user->data()->id)){//admin
Redirect::to($us_url_root.'users/admin.php');
}elseif(!hasPerm([1],$user->data()->id)){
Redirect::to($us_url_root.'users/whatver.php');
}
}else{
  Redirect::to($us_url_root.'users/login.php');
}


What that does is...if the user is not logged in, redirect them to login.  If they're admin, redirect to dashboard.  If they do NOT have one of the permissions specified in that [1] (you can separate multiple perms by comma) Redirect them to whatever.php


I haven't tested this but you can try instead of Redirect::to($us_url_root.'users/login.php');


Code:
$urlRootLength=strlen($us_url_root);
$page=substr($uri,$urlRootLength,strlen($uri)-$urlRootLength);
$dest=encodeURIComponent("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
Redirect::to($us_url_root.'users/login.php?dest='.$dest);

Admin language is expected to be a part of version 5.0.  Front end language was just released a few months ago, so we're working on making sure everything is right before doing backend. 

Gettext is not a viable solution for our application because it doesn't work universally across all servers.  We have tested this.  I don't LOVE our solution, but it does have the same fallback option as gettext and it works a lot better for what we're doing.  

Sorry for the slow response.  I've been on vacation and I'm answering messages as fast as I can.

We don't have Italian right now, I would love to offer it!

Hi Dan...

Here is your it-IT.php with the same structure of en-US.php

I checked it twice and I hope I haven't skipped any accented vowels.

Enjoy.


Attached Files
.php   it-IT.php (Size: 18.67 KB / Downloads: 0)
  Reply
#6
(05-16-2019, 03:45 AM)Carlo Wrote:
(05-15-2019, 01:45 PM)mudmin Wrote:
(05-14-2019, 07:21 PM)Carlo Wrote: Hi Dan...

Maybe I did not explain properly what I meant...

As I said, I installed US without big problems, thanks to your install procedure.

The first thing that I had to consider was the fact that I installed it on an already existing project.

I already had an existing index.php on my main page.

So I had two choices: either copy the content of my index into yours or not use yours. I chose the latter.

I hope this was not the origin of my troubles.

When I navigate to pages that are not protected there are no problems, since the site is acting as it was before installing US.

But when I tried to navigate to a "protected" page, I got into the current problem.

Please do consider that I can manage MySQL sufficiently and I have some little experience with PHP but, nevertheless, I am unable to follow the intricacies of your code. (or any other code that appears complex to me, for what it counts).

This is what I want to achieve and I was hoping to do it with the three lines of code that you suggest putting on top of each protected page.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.

It will then ascertain what kind of clearance you have and according to that will allow you to view that page or redirect you somewhere else, unless you are an Admin in which case you are presented with the dashboard. (talking of which, it seems that only English is available for such page).

Is there a way to change the last of the three lines  required with something that says, in pseudo English, the following?

IF
you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

Such redirection should be or might be different for each protected page.

In other words, I would like to be able to indicate for each protected page a destination page of my choice according to my desire.

Is this feasible?
And if yes, what kind of code should I put on top of each protected page?

Because this

require_once '../users/init.php';  //make sure this path is correct!

require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
if (!securePage($_SERVER['PHP_SELF'])){die();}

does not do that, unless the lack of the initial index.php were not the real problem.

Is my question now any clearer? Please consider that I am not native English so my choice of words may be somehow inappropriate to descrive the situation.

Back to the Dashboard.

To me is not a big problem: I can manage fine the English descriptions that are there with ease.

Bur I was wondering about that, for non English speakers or for anyone who is more familiar with his own language.

I sort of thought of a solution but, before venturing into the code, I would love to get your opinion.

I thought of changing the structure of the pages where language is involved with the following (an example):

//User Settings
$lang = array_merge($lang,array(
"SET_PIN" => _("Reset PIN"),
"SET_WHY" => _("Why can't I change this?"),
"SET_PW_MATCH" => _("Must match the New Password"),

At that point, adding a simple .po .mo files in the appropriate folder as required by PHP's gettext function, should do the trick.

Once the .po file is created, you may add all the other sentences that need translation in any US pages, by simply changing the sentence to be translated with something like (as an example)

BEFORE
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr">Original sentence in English <a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

AFTER
<!-- Force Password Reset -->
                  <div class="form-group">
                    <label for="force_pr"><? echo _("Original sentence in English") ?><a href="#!" tabindex="-1" title="Note" data-trigger="focus" class="nounderline" data-toggle="popover" data-content="When a user is created from the admin panel, force their password to be reset upon login, this will also send them a password reset link on manual creation no matter what password you enter on the form. If you enable this, the force_pr value in your users database for this user will be 1 when created. Default: No."><i class="fa fa-question-circle"></i></a></label>

Thus getting the translation in your chosen language for each and every instance in US, working on a single .po file (one for each language provided).

Naturally all this will require some extra general settings like a couple of lines of code for the environmental changes required, but that should be a walk in the park...

If you think that the above is feasible, I can dedicate my time to operate the required changes in the html sections and provide you with the resulting code for your view and tests. If it works as I expect, you can use it freely.

Let me know, if you please, the solution to my needs if it is not meaning for you too much effort and what do you think about the "language" solution.

Thank you in advance for your time and assistance.

Best,

Carlo

P.S. I attached some files for Italian as an example (which I doubt you will need). I had to add a false .php extension to upload the .mo and .po files. I hope this is not against the Forum rules.
Let me see if I can get these in order....

You're fine not using our index.php but you probably want some of the things that are in it (like init.php, some of the stuff in prep.php) and possibly the footer.

My assumptions are that when you navigate to a protected page, US checks if you are logged and, if not, prompts you to login.
This is true if the following conditions are met. 
1. The page has this line with the proper path require_once 'users/init.php';
2. The page has if (!securePage($_SERVER['PHP_SELF'])){die();}
3. The folder that the page is in is covered in the z_us_root.php file 
4. The page shows up when you view it in the "pages" section of the dashboard.


IF

you are an Adim, get to the Dashboard
ELSE
IF 
logged and authorised to view the page, proceed.
ELSE
Redirect to a page of mu choice

This logic would automatically redirect admins to the dashboard instead of letting them see the protected page.  If that's what you want, the logic would be like this


Code:
//get rid of the securePage line
//add this...
if(isset($user) && $user->isLoggedIn()){
  if(hasPerm([2],$user->data()->id)){//admin
Redirect::to($us_url_root.'users/admin.php');
}elseif(!hasPerm([1],$user->data()->id)){
Redirect::to($us_url_root.'users/whatver.php');
}
}else{
  Redirect::to($us_url_root.'users/login.php');
}


What that does is...if the user is not logged in, redirect them to login.  If they're admin, redirect to dashboard.  If they do NOT have one of the permissions specified in that [1] (you can separate multiple perms by comma) Redirect them to whatever.php


I haven't tested this but you can try instead of Redirect::to($us_url_root.'users/login.php');


Code:
$urlRootLength=strlen($us_url_root);
$page=substr($uri,$urlRootLength,strlen($uri)-$urlRootLength);
$dest=encodeURIComponent("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
Redirect::to($us_url_root.'users/login.php?dest='.$dest);

Admin language is expected to be a part of version 5.0.  Front end language was just released a few months ago, so we're working on making sure everything is right before doing backend. 

Gettext is not a viable solution for our application because it doesn't work universally across all servers.  We have tested this.  I don't LOVE our solution, but it does have the same fallback option as gettext and it works a lot better for what we're doing.  

Sorry for the slow response.  I've been on vacation and I'm answering messages as fast as I can.

We don't have Italian right now, I would love to offer it!

Hi Dan...

Here is your it-IT.php with the same structure of en-US.php

I checked it twice and I hope I haven't skipped any accented vowels.

Enjoy.

Dear Dan,

In order to avoid any mistake due to my previous small changes in code, I re-installed us from scratch, prior to test your suggestions.

While doing that, I checked the it-IT.php file and there were two lines amiss.

As we say here in Italy, the mother of the imbeciles is always pregnant...

My bad...

Please find attached the correct it.IT.php file with my apologies.

When you will need to translate into Italian other sections of us, please let me know and I'll make myself available with pleasure.

Best,

Carlo


Attached Files Thumbnail(s)
   

.php   it-IT.php (Size: 18.75 KB / Downloads: 2)
  Reply
#7
Thank you so ,much! I have it ready for 4.4.12!
  Reply
#8
(05-17-2019, 11:01 AM)mudmin Wrote: Thank you so ,much! I have it ready for 4.4.12!

Thanks to you for your availability and for letting me help somehow...

I have no idea how you are going to implement languages for the rest of scripts that need it but, if you already have a list of the sentences that will need translation, please sent it to me and I will take care of that.

I also have no clue if you guys intend to translate documentation and other documents now only available in English.

Should that be the case, I will try help you for that task.

Best,

Carlo
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)