public function trigger($nickname = null) { $user = $this->load_user($nickname); Website::triggerAll($user); Site::Flash('notice', 'Update has been triggered'); Redirect("admin/users/" . $user->permalink()); }
public function save() { if ($this->validate()) { $changed = false; if ($this->is_new) { $this->password = $this->hashPassword($this->password); $this->password_confirmation = $this->password; $this->activation_code = md5(time() . $this->nickname . $this->email . rand(10000, 99999)); $this->cookie = md5(time() . $this->nickname . $this->email . $this->activation_code . rand(10000, 99999)); $this->version = 1; $changed = true; } else { if ($this->changed_password) { $this->password = $this->hashPassword($this->password); $this->password_confirmation = $this->password; } if (!$this->cookie) { $this->cookie = md5(time() . $this->nickname . $this->email . $this->activation_code . rand(10000, 99999)); } // Update version if ($this->calculateHash() != $this->hash) { $this->version++; $changed = true; } } if ($this->activated && !$this->affiliate_code) { $this->affiliate_code = uniqid(); } $result = parent::save(self::table); if ($result) { if ($changed) { Website::triggerAll($this); } $this->sync_forums(); if ($this->activated and $this->allow_emails) { $this->newzapp_signup(); } $id = mysql_real_escape_string($this->id); $user_profile = UserProfile::find("user_profiles.user_id = '{$id}'"); if (!$user_profile) { // Create a profile for the user $user_profile = new UserProfile(); $user_profile->user_id = $this->id; $user_profile->save(); } } return $result; } else { return false; } }