Announcements - Date setting not working

Hi everyone.
I have searched for this problem without finding anything helpfull; I hope I am not repeating something already written, in that case please send me to the specific thread.
I am using the 2.4.8.0 version and I have some problems with announcements.
The order of appearance do not correspond to the date of each of them, it happens that an old one appears before the new one.

In details, as the announcements online displays:

Announcement X
[Text text]
Posted: 2017-03-27

Announcement Y
[Text text]
Posted: 2017-04-03

As you may see the Y should appear before the X, while it happens the opposite.
I hope it helps: the date of each announcement was set manually, not with blank space.
Is there any way to edit the order for announcements in OJS 2.4.8.0? Maybe in the config file?
I am not a skilled analyst (not even an analyst at all), I really hope it will not require too much editing in the config, I really fear to create more problems than solutions.
By the way, thanks everyone for the attention =)

Chiara

Hi @NuovaCultura,

Announcements in OJS 2.4.x are sorted by the order in which they were created – if you’d like to use dates instead, edit lib/pkp/classes/announcement/PKPAnnouncementDAO.inc.php, find any clauses that read ORDER BY announcement_id DESC, and change them to ORDER BY date_posted DESC.

Regards,
Alec Smecher
Public Knowledge Project Team

Dear Alec,

thank you for your quick respond, this information helps me in understanding and solving the problem.

I see the PKPAnnouncementDAO.inc.php and I have found several clauses that read ORDER BY announcement_id DESC; just to be sure to act correctly, may you confirm that I must change each of them to ORDER BY date_posted DESC?

In details:

function &getByAssocId($assocType, $assocId, $rangeInfo = null) {

                               $result =& $this->retrieveRange(

                                               'SELECT *

                                               FROM announcements

                                               WHERE assoc_type = ? AND assoc_id = ?

                                               ORDER BY announcement_id DESC',

                                               array((int) $assocType, (int) $assocId),

                                               $rangeInfo

 

function &getByTypeId($typeId, $rangeInfo = null) {

                               $result =& $this->retrieveRange(

                                               'SELECT * FROM announcements WHERE type_id = ? ORDER BY announcement_id DESC',

                                               (int) $typeId,

                                               $rangeInfo

                               );

 

function &getNumAnnouncementsByAssocId($assocType, $assocId, $numAnnouncements, $rangeInfo = null) {

                               $result =& $this->retrieveRange(

                                               'SELECT *

                                               FROM announcements

                                               WHERE assoc_type = ?

                                                               AND assoc_id = ?

                                               ORDER BY announcement_id DESC LIMIT ?',

                                               array((int) $assocType, (int) $assocId, (int) $numAnnouncements),

                                               $rangeInfo

                               );

 

function &getAnnouncementsNotExpiredByAssocId($assocType, $assocId, $rangeInfo = null) {

                               $result =& $this->retrieveRange(

                                               'SELECT *

                                               FROM announcements

                                               WHERE assoc_type = ?

                                                               AND assoc_id = ?

                                                               AND (date_expire IS NULL OR DATE(date_expire) > CURRENT_DATE)

                                                               AND (DATE(date_posted) <= CURRENT_DATE)

                                               ORDER BY announcement_id DESC',

                                               array((int) $assocType, (int) $assocId),

                                               $rangeInfo

                               );

 

function &getNumAnnouncementsNotExpiredByAssocId($assocType, $assocId, $numAnnouncements, $rangeInfo = null) {

                               $result =& $this->retrieveRange(

                                               'SELECT *

                                               FROM announcements

                                               WHERE assoc_type = ?

                                                               AND assoc_id = ?

                                                               AND (date_expire IS NULL OR DATE(date_expire) > CURRENT_DATE)

                                                               AND (DATE(date_posted) <= CURRENT_DATE)

                                               ORDER BY announcement_id DESC LIMIT ?',

                                               array((int) $assocType, (int) $assocId, (int) $numAnnouncements),

                                               $rangeInfo

                               );

 

function &getMostRecentPublishedAnnouncementByAssocId($assocType, $assocId) {

                               $result =& $this->retrieve(

                                               'SELECT *

                                               FROM   announcements

                                               WHERE assoc_type = ?

                                                               AND assoc_id = ?

                                                               AND (date_expire IS NULL OR DATE(date_expire) > CURRENT_DATE)

                                                               AND (DATE(date_posted) <= CURRENT_DATE)

                                               ORDER BY announcement_id DESC LIMIT 1',

                                               array((int) $assocType, (int) $assocId)

                               );

Thanks again for your kind support.

Best regards

logo nuova cultura giallo.png

Edizioni Nuova Cultura

Chiara Mastrantonio

Uff. Comunicazione

T e F (+39) 06 89566851

http://www.nuovacultura.it/ www.nuovacultura.it

download cid:image002.jpg@01D25A1A.DC16D8A0

Ai sensi del D. Lgs n. 196 del 30.06.03 si precisa che le informazioni contenute in questo messaggio sono riservate e ad uso esclusivo del destinatario. Qualora il messaggio in parola Le fosse pervenuto per errore, La preghiamo di eliminarlo senza copiarlo e di non inoltrarlo a terzi, dandocene gentilmente comunicazione. Grazie

This message, for the D. Lgs n. 196 / 30.06.03, may contain confidential and/or privileged informations. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for cooperation.

Yes, it looks like you’re headed in the right direction, and I think this is definitely a better strategy than ordering by announcement id.

Wonderful, I tested this solution and it works perfectly.

I totally agreed with you, ctgraham: even if you do not chose this way, I think it is important to know that you can edit announcements both by date and id.

Thank you all for your support, it has been vital and I deeply appreciate it.

Best Regards.

Chiara – Nuova Cultura

Hi all,

Thanks! I’ve made this change to the master branch for future releases.

Regards,
Alec Smecher
Public Knowledge Project Team