Changing the functionality of the status "Expired"

Phoca Download - download manager
demos112
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 31 May 2020, 08:56

Changing the functionality of the status "Expired"

Post by demos112 » 31 May 2020, 09:37

Hello.
I need to implement a restriction on downloading a file.
How it works:
1) The file has the name "1.mp4". It must be available for download a certain time (set in Publishing Options-> Finish Publishing)
download link: my-site com / 1/2? download = 145: 1
2) After the publication deadline, the status of the file changes from "Active" to "Expired"
3) When obtaining the status "Expired", you cannot download the file - the link does not work
4) After extending the publication period (set in Publishing Options-> Finish Publishing), the file receives the "Active" stasus and can be downloaded at my-site com / 1/2? Download = 145: 1.
How it should work for me:
3 *) Upon receiving the status "Expired", the file can be downloaded, but not "1.mp4", but "2.mp4". In other words, when the status "Expired" appears, a "stub" is downloaded with the name "2.mp4" accessible via the same link (my-site com / 1/2? Download = 145: 1) as the file "1.mp4" . This file "2.mp4" should be applicable to all files with the status "Expired".
4 *) After extending the publication period (set in Publishing Options-> Finish Publishing) the file receives the "Active" stasus and we can download the file "1.mp4" as always.
Please tell me what changes you need to make in the code in order to change the "Expired" status rule. I will be very grateful to you!

User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 42872
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Changing the functionality of the status "Expired"

Post by Jan » 31 May 2020, 20:33

Hi, you just need to check the database for the date (start publishing, finish publishing) and comparte with current date - then you can do any other action based on current status :idea:

Jan
If you find Phoca extensions useful, please support the project

demos112
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 31 May 2020, 08:56

Re: Changing the functionality of the status "Expired"

Post by demos112 » 01 Jun 2020, 08:22

Jan wrote:
31 May 2020, 20:33
Hi, you just need to check the database for the date (start publishing, finish publishing) and comparte with current date - then you can do any other action based on current status :idea:

Jan
Thank you for your reply. I already thought about it.
Only I do not know all the features of MyphpAdmin.
I think so:
It is necessary to make a trigger and write a condition in it:
If "finish publishing" = "current time database"
Then
column replacement
filename "1.mp4" to "2.mp4"
and so that access to the file does not disappear, you need to set the date to zero - instead of 2020-03-16 12:30:15 write 0000-00-00 00:00:00
If I'm right, tell me which variable is responsible for the server time of the database and how to implement the trigger? As far as I understand, it is necessary to use a trigger to automatically trigger a function. I'm new to MyphpAdmin

User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 42872
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Changing the functionality of the status "Expired"

Post by Jan » 01 Jun 2020, 15:27

Hi, Phoca Download does not have any variable responsible for server time, all is managed by Joomla!/PHP/SQL(mysql,mariadb), etc.

So, example, when Phoca Download ask for the valid document, it asks this way:

Code: Select all

// Active
$jnow		= JFactory::getDate();
$now		= $jnow->toSql();
$nullDate	= $this->_db->getNullDate();
$wheres[] = ' ( c.publish_up = '.$this->_db->Quote($nullDate).' OR c.publish_up <= '.$this->_db->Quote($now).' )';
$wheres[] = ' ( c.publish_down = '.$this->_db->Quote($nullDate).' OR c.publish_down >= '.$this->_db->Quote($now).' )';
in:
components\com_phocadownload\models\category.php

Jan
If you find Phoca extensions useful, please support the project

demos112
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 31 May 2020, 08:56

Re: Changing the functionality of the status "Expired"

Post by demos112 » 01 Jun 2020, 17:06

Jan wrote:
01 Jun 2020, 15:27
Hi, Phoca Download does not have any variable responsible for server time, all is managed by Joomla!/PHP/SQL(mysql,mariadb), etc.

So, example, when Phoca Download ask for the valid document, it asks this way:

Code: Select all

// Active
$jnow		= JFactory::getDate();
$now		= $jnow->toSql();
$nullDate	= $this->_db->getNullDate();
$wheres[] = ' ( c.publish_up = '.$this->_db->Quote($nullDate).' OR c.publish_up <= '.$this->_db->Quote($now).' )';
$wheres[] = ' ( c.publish_down = '.$this->_db->Quote($nullDate).' OR c.publish_down >= '.$this->_db->Quote($now).' )';
in:
components\com_phocadownload\models\category.php

Jan
Thanks, now I understand. I wanted to make changes to the database itself, since I don’t know which file is responsible for issuing / disabling links in the "Active /" Expired "mode
If it’s not difficult, please tell me in which file do you need to make changes? or in what file is the "Expired" mode described?
Essentially, I need to copy the code for Active mode.
and add it to "Expired" mode and make changes

User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 42872
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Changing the functionality of the status "Expired"

Post by Jan » 01 Jun 2020, 23:38

Hi, not sure what do you exactly mean. When saving the file, date is just stored and then on the place of displaying we just ask if the date is active. There is no specific file for "expired" - there is just listing of all files which are not expired (and this is just managed by database - to say which file is expired and which not - with only onte recorded item - date).

Jan
If you find Phoca extensions useful, please support the project

demos112
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 31 May 2020, 08:56

Re: Changing the functionality of the status "Expired"

Post by demos112 » 02 Jun 2020, 08:23

Jan wrote:
01 Jun 2020, 23:38
Hi, not sure what do you exactly mean. When saving the file, date is just stored and then on the place of displaying we just ask if the date is active. There is no specific file for "expired" - there is just listing of all files which are not expired (and this is just managed by database - to say which file is expired and which not - with only onte recorded item - date).

Jan
If the status is "expired" you can’t download the link, I need to change the code so that it can be downloaded as with the status of "Active"
which means there should be a line - "If" expired "then the link is disabled" - it needs to be deleted
and add this line
"If" expired "then download file" 2.mp4 "
Where can this be written?

User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 42872
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Changing the functionality of the status "Expired"

Post by Jan » 04 Jun 2020, 00:47

Hi, I think, you can customize it in the file, we have mentioned - in the module:

components\com_phocadownload\models\category.php

So you will skip this condtion. And you should get the info from database about the status, if expired, you should write the second file. But this are really theoretical ideas from me. Unfortunately I cannot give any clue advice there as I didn't do such customization yet :idea:

Jan
If you find Phoca extensions useful, please support the project

demos112
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 31 May 2020, 08:56

Re: Changing the functionality of the status "Expired"

Post by demos112 » 07 Jun 2020, 10:42

Jan wrote:
04 Jun 2020, 00:47
Hi, I think, you can customize it in the file, we have mentioned - in the module:

components\com_phocadownload\models\category.php

So you will skip this condtion. And you should get the info from database about the status, if expired, you should write the second file. But this are really theoretical ideas from me. Unfortunately I cannot give any clue advice there as I didn't do such customization yet :idea:

Jan
I understood you. Thank you so much for your work! I would be glad if you tell someone who can do this for me.

User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 42872
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Changing the functionality of the status "Expired"

Post by Jan » 07 Jun 2020, 19:59

Ok
If you find Phoca extensions useful, please support the project

Post Reply