Coder Social home page Coder Social logo

Comments (16)

thedmeyer avatar thedmeyer commented on May 29, 2024

I suggest changing the 'read' column to 'date_read' and make it a datetime type.

This would do the following:

  • Show when the PM was read.
  • If it's null, then the PM hasn't been read.
  • Cleaner implementation, in my opinion.

If you like this idea, I can draft a PR for it.

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

👍 good idea

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

i can write this in my PR too, should i?

from codeigniter-aauth.

tswagger avatar tswagger commented on May 29, 2024

I concur that this is a good idea. I would take it a step further and change the "date" column to "sent" or "date_sent" for consistency.

from codeigniter-aauth.

thedmeyer avatar thedmeyer commented on May 29, 2024

Sounds good. Eventually, we can add on to the pm feature to allow support for group messaging

from codeigniter-aauth.

thedmeyer avatar thedmeyer commented on May 29, 2024

@tswagger, @REJack did as you said. https://github.com/REJack/CodeIgniter-Aauth/commit/a11bdbe5800b9d85d4bb01df08acc675e540cb26

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

it was a briliant idea 😃

from codeigniter-aauth.

thedmeyer avatar thedmeyer commented on May 29, 2024

👍 Is there a way to modify the pm system to allow for multiple recipients?

Say an admin wants to message all the users on their website...

from codeigniter-aauth.

thedmeyer avatar thedmeyer commented on May 29, 2024

It would be a tricky implementation, perhaps it's best to make a site-wide announcement feature

(something separate from pm's)

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

idk i could write really easy :P but i would remove the error if the user is banned

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

i would write it like this 😄
$receiver_id can be int or array

public function send_pm( $sender_id, $receiver_id, $title, $message ){
    if(!is_array($receiver_id)){
        $receiver_id = array($receiver_id);
    }

    $query = $this->aauth_db->where('id', $sender_id);
    $query = $this->aauth_db->get( $this->config_vars['users'] );

    if ( $query->num_rows() < 1 ){
        $this->error($this->CI->lang->line('aauth_error_no_user'));
        return FALSE;
    }

    foreach ($receiver_id as $receiver) {
        if ( $sender_id == $receiver ){
            $this->error($this->CI->lang->line('aauth_error_self_pm'));
            continue;
        }
        $query = $this->aauth_db->where('id', $receiver);
        $query = $this->aauth_db->get( $this->config_vars['users'] );

        if ( $query->num_rows() < 1 ){
            $this->error('UserID: '.$receiver.' '.$this->CI->lang->line('aauth_error_no_user'));
            continue;
        }

        $data = array(
            'sender_id' => $sender_id,
            'receiver_id' => $receiver,
            'title' => $title,
            'message' => $message,
            'date_sent' => date('Y-m-d H:i:s')
        );

        $query = $this->aauth_db->insert( $this->config_vars['pms'], $data );
    }
    return TRUE;
}

from codeigniter-aauth.

thedmeyer avatar thedmeyer commented on May 29, 2024

From your implementation, I see you are creating multiple messages in the pms table. I feel this is unsatisfactory from a big data standpoint. It's bloat / extra fat in the DB...

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

than its to tricky with the readed status for any receiver

from codeigniter-aauth.

thedmeyer avatar thedmeyer commented on May 29, 2024

Better Implementation?

What about creating two tables? One that stores aauth_pms and another that holds the recipients with their respective date_read.

Call these two tables:

  • aauth_pms
  • aauth_pm_receivers
The table storing the pm would contain:
  • id
  • sender_id
  • title
  • message
  • date_sent
The table holding recipients would contain:
  • pm_id
  • receiver_id (user's id)
  • date_read

With this implementation then list_pms() could run the SQL query GET * FROM 'aauth_pm_receivers' WHERE 'receiver_id' = $user_id

from codeigniter-aauth.

REJack avatar REJack commented on May 29, 2024

that sounds good

from codeigniter-aauth.

emreakay avatar emreakay commented on May 29, 2024

i think it is solved 👍
Thank you @REJack and @Manebit @tswagger

from codeigniter-aauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.