Osclass forums

Development => Development => Topic started by: SmaRTeY on November 07, 2015, 02:38:24 pm

Title: Alerts in Admin
Post by: SmaRTeY on November 07, 2015, 02:38:24 pm
Hi there,

I dug a little deeper into the Alerts and the way it is setup at the moment. Correct me if I am wrong, at this moment Alerts are created by our users but when a user 'removes' one of his/her alerts what really happens is that the Alert for this user is getting an 'unsubscibe' date. The actual Alert is not removed from DB but for the user it is no longer active/working.

Okay, in Admin we keep seeing ALL the Alerts, the ones active as well as the ones deleted/removed by our users BUT in Admin all are 'active' which I think should not be the case since the user removed the alert. At least the alert 'Active' property should be set to inactive imo if a user 'removes' an Alert so Admins know it is NOT in use. How else would Admin know what Alerts can be 'removed' without surprising the owner of the Alert? 8)

Regards,
Eric
Title: Re: Alerts in Admin
Post by: marius-ciclistu on April 28, 2017, 03:36:47 pm
This is also happening in 3.7.1.
Title: Re: Alerts in Admin
Post by: marius-ciclistu on April 28, 2017, 11:11:16 pm
3.7.1:
/oc-includes/osclass/model/Alerts.php

put:
Code: [Select]

        /**
         * Unsub from an alert + deactivate + rename email to 'deleted'
         *
         * @access public
         * @since 3.1
         * @param string $id
         * @return mixed false on fail, int of num. of affected rows
         */
        function unsub($id)
        {   $this->dao->update($this->getTableName(), array('s_email' => 'deleted'), array('pk_i_id' => $id));
            $this->dao->update($this->getTableName(), array('b_active' => 0), array('pk_i_id' => $id));
            return $this->dao->update($this->getTableName(), array('dt_unsub_date' => date("Y-m-d H:i:s")), array('pk_i_id' => $id));
        }
instead of
Code: [Select]
        /**
         * Unsub from an alert
         *
         * @access public
         * @since 3.1
         * @param string $id
         * @return mixed false on fail, int of num. of affected rows
         */
        function unsub($id)
        {   
            return $this->dao->update($this->getTableName(), array('dt_unsub_date' => date("Y-m-d H:i:s")), array('pk_i_id' => $id));
        }

In this way you can search for deleted and delete more than one at once.
Title: Re: Alerts in Admin
Post by: marius-ciclistu on June 28, 2017, 10:25:59 pm
Sorry to dig this up, but what if the user deletes the alert from the db?

Would this affect the osclass script in any way?
Title: Re: Alerts in Admin
Post by: marius-ciclistu on January 05, 2018, 01:21:32 pm
SmaRTeY, I nailed it.
A cron job to delete the unsubscribed alerts from db and admin.
Title: Re: Alerts in Admin
Post by: SmaRTeY on May 15, 2018, 11:35:56 pm
Cool, that sounds like a way to keep your DB's integrity optimal in sync with reality and I for one do not have any use for disabled alerts which for the user looks like they are deleted… However, I would prefer a direct removal of the alert in Osclass core or an Admin option to chose either keep or delete.

Regards,
Eric

SmaRTeY, I nailed it.
A cron job to delete the unsubscribed alerts from db and admin.
Title: Re: Alerts in Admin
Post by: marius-ciclistu on May 16, 2018, 09:25:04 pm
Welcome back.