The feed deleted for 2 weeks does not work in the cpanel, this error message:

Tamás Varga Posted in Technical Support 3 years ago

The feed deleted for 2 weeks does not work in the cpanel, this error message:

/home/elittagh/public_html/cron/cron.php: line 1: ?php: No such file
or directory
/home/elittagh/public_html/cron/cron.php: line 2: syntax error near
unexpected token `'OSSN_ALLOW_SYSTEM_START','
/home/elittagh/public_html/cron/cron.php: line 2:
`define('OSSN_ALLOW_SYSTEM_START', TRUE);'

cron.php:

<?php
define('OSSN_ALLOW_SYSTEM_START', true);
require_once ('system/start.php');
function delete_2weeks_posts() {
    $wall = new OssnWall;
    $listUser = $wall->GetPosts(array(
        'type' => 'user',
        'page_limit' => false,
        'wheres' => array(
            "(FROM_UNIXTIME(o.time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK))"
        )
    ));
    if ($listUser) {
        foreach ($listUser as $post) {
            $post->deleteObject($post->guid);
            ossn_trigger_callback('post', 'delete', $post->guid);
        }
    }
}
delete_2weeks_posts();
Replies
Hungarian Tamás Varga Replied 3 years ago

I know I’m very stupid for programming. Please write the absolutely good code because I don't understand how it will be good.

German Michael Zülsdorff Replied 3 years ago

Ok,
so you need to change the $groups_query of that GroupPostsNewsfeed component to fetch only those group records
which are NEWER than 14 days.
So this time, Arsalan's original condition will do the trick. ;)

Hungarian Tamás Varga Replied 3 years ago

Absolute correct.

German Michael Zülsdorff Replied 3 years ago

Oh ... I think I start to understand your issue:
On one hand you want to keep ALL Group postings to make them appear within the group.
That's why we can't delete them.
But now since you are using Arsalan's Show Group Posts in Newsfeed
all these group postings appear in the Newsfeed . And of course the old ones, too.
But on the other hand you don't want to see OLDER group posts in the Newsfeed.
Is this correct?

Hungarian Tamás Varga Replied 3 years ago

Thank you very much ~ Z ~ Man. Is it possible to make everything disappear from the feed so that the posts remain in the groups? Entries older than 2 weeks, of course.

German Michael Zülsdorff Replied 3 years ago

This was Arsalan's original query:

$listUser = $wall->GetPosts(array(
            'page_limit' => false,
            'wheres' => array(
                    "(FROM_UNIXTIME(o.time_created) >= DATE_SUB(NOW(), INTERVAL 2 WEEK))"               
            );
    ));

It was fetching ALL wall postings (group wall and main/user wall) NEWER than 14 days.
The >= was a mistake, so we changed it to <= to make the query fetch records OLDER than 14 days.
Additionally you requested to NOT delete the Group postings, so we changed the query to fetch records of type 'user' only like

$listUser = $wall->GetPosts(array(
            'type' => 'user',
            'page_limit' => false,
            'wheres' => array(
                "(FROM_UNIXTIME(o.time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK))"
            )
        ));

Yesterday we tried that query, it found 1 record to delete, and you said: No there are. more!
And yes, there are more indeed. But these are GROUP records, and you did NOT want to delete GROUP records.
That was your request.
So I can't see anything wrong with the result from yesterday.

Hungarian Tamás Varga Replied 3 years ago

Arsalan’s first code erased everything, including the feed and messages, but within 2 weeks of that date. Came a fix and deleted the new code from the old entries in the feed, but this so that the index.php file had the new code. then there was nothing in the feed, after that nothing was deleted anymore because i tried from cron. What was wrong?

German Michael Zülsdorff Replied 3 years ago

Tamas,
one month ago on https://www.opensource-socialnetwork.org/discussion/view/5139/can-only-the-wall-be-deleted-automatically?offset=4
you complained:

He also deleted everything in the groups. Fault.

So we changed Arsalan's original code NOT to delete group posts,
and on https://www.opensource-socialnetwork.org/discussion/view/5139/can-only-the-wall-be-deleted-automatically?offset=1
you confirmed

Super :)

that's the way you wanted it.

And now you're complaining that these older group are not deleted?!?

Hungarian Tamás Varga Replied 3 years ago

enter image description here

German Michael Zülsdorff Replied 3 years ago

Let's investigate:
Click onto the date of that post
enter image description here
This will open a new page which will show the guid of that post (in my example it is 260)
enter image description here
Memorize your post guid
Then use phpmyadmin and open the ossn_object table
enter image description here
Click on the column header 'guid' to sort that column (ascending or descending order)
Then find the guid you just memorized and make a screenshot of the complete line please