Welcome Guest, Not a member yet? Register   Sign In
Rapyd, When data changed, so something!
#1

[eluser]Phil Sturgeon[/eluser]
I'll admit it, im a Rapyd n00b and having a spot of trouble.

Using models it would normally be fairly easy to do something like:

Code:
if($data['banned'] == 1) $data['banned_by'] = getUserId();

But of course, Rapyd in all its ingenious timesaving devices doesnt wanna let me do that. So it falls to you, the lovely CI community to let me know how the hell I do this.

I have so far tried something like:

Code:
function method(){
// ...
$edit = new DataEdit($data['pagetitle'], $this->user_table);
// ...
$edit->pre_process('update', 'set_ban');
// ...
}

function set_ban($object)
{
    // Make sure bannedBy is set to 0
    if($object->get('banned') == 0):
        $object->set('bannedBy', 0);
    endif;
        
    if($object->get('banned') == 1):
        $bannedBy = getUserProperty('id');
        $object->set('bannedBy', $bannedBy);
    endif;
        
    return TRUE;
}

Of course that code wont work, as its looking at whats CURRENTLY in the database, and not the data being used in the current submission. I cant work with data AFTER the current submission, as on the next pageload it will show old data until the user refreshes. I need DURING...
#2

[eluser]Michael Wales[/eluser]
lol, I gave up on Rapyd when I couldn't even get a login form to work. I spent more time trying to make that work than I would have on an entire User Management system.

Plus, after 3 days no one responded on their forums to a question.

Dead community, hard to understand documentation... thanks but no thanks.
#3

[eluser]Phil Sturgeon[/eluser]
While I can understand your frustration, I really dont think that was the intended purpose of Rapyd. Its for simplifying CRUD more than user auth. It does have some user auth built in though, but thats not the point.

I reckon I can achieve my code with:

Code:
// If someone gets banned, take the current usersID and show it.
    function set_ban($object)
    {
        // They have changed banned from 1 to 0?
        if($object->get('banned') == 1 && $this->input->post('banned') == 0):
            echo "nope";
            $object->set('bannedby', NULL);
        endif;
        
        if($this->input->post('banned') == 1 && $object->get('bannedby') == 0):
            echo 'new '.$bannedBy = getUserProperty('id');
            $object->set('bannedby', $bannedBy);
        endif;
        
        return TRUE;
    }

Lets try!




Theme © iAndrew 2016 - Forum software by © MyBB