/** * Log an event * @since Version 3.5 * @param int $userId * @param string $title * @param array $args * @param int $classId */ public function logEvent($userId = null, $title = null, $args = null, $classId = null) { if (!filter_var($userId, FILTER_VALIDATE_INT)) { throw new Exception("Cannot log event, no User ID given"); } if (!$title) { throw new Exception("Cannot log event, no title given"); } if (!filter_var($classId, FILTER_VALIDATE_INT)) { $classId = $this->id; } $Event = new \Railpage\SiteEvent(); $Event->user_id = $userId; $Event->title = $title; $Event->args = $args; $Event->key = "class_id"; $Event->value = $classId; $Event->module_name = "locos"; if ($title == "Photo tagged") { $Event->module_name = "flickr"; } $Event->commit(); return true; }
/** * Log an event * @since Version 3.5 * @param int $user_id * @param string $title * @param array $args */ public function logEvent($user_id = false, $title = false, $args = false) { if (!$user_id) { throw new Exception("Cannot log event, no User ID given"); return false; } if (!$title) { throw new Exception("Cannot log event, no title given"); return false; } $Event = new \Railpage\SiteEvent(); $Event->user_id = $user_id; $Event->title = $title; $Event->args = $args; $Event->key = "loco_id"; $Event->value = $this->id; $Event->module_name = "locos"; if ($title == "Photo tagged") { $Event->module_name = "flickr"; } $Event->commit(); return true; }
/** * Commit this post to the database * * If $this->id is not specified, it will try to create a new post * @since Version 3.0.1 * @version 3.3 * @return boolean */ function commit() { if (empty($this->bbcode_uid)) { $this->bbcode_uid = crc32($this->text); } // Set the editor version $this->editor_version = EDITOR_VERSION; /** * Validate the post */ $this->validate(); /** * Start the timer if we're in debug mode */ if (RP_DEBUG) { global $site_debug; $debug_timer_start = microtime(true); } /** * Process @mentions */ if (function_exists("process_mentions")) { $this->text = process_mentions($this->text); } /** * If this is an existing post, insert it into the edit table before we proceed */ if (filter_var($this->id, FILTER_VALIDATE_INT)) { global $User; #$CurrentPost = new Post($this->id); if ($this->old_text != $this->text) { $dataArray = array(); $dataArray['post_id'] = $this->id; $dataArray['thread_id'] = $this->thread->id; $dataArray['poster_id'] = $this->uid; $dataArray['edit_time'] = time(); $dataArray['edit_body'] = $this->old_text; $dataArray['bbcode_uid'] = $this->bbcode_uid; $dataArray['editor_id'] = $User->id; if ($this->db->insert("nuke_bbposts_edit", $dataArray)) { $changes = array("Forum" => $this->thread->forum->name, "Forum ID" => $this->thread->forum->id, "Thread" => $this->thread->title, "Thread ID" => $this->thread->id, "Author user ID" => $this->uid); try { $Event = new \Railpage\SiteEvent(); $Event->user_id = $User->id; $Event->title = "Forum post edited"; $Event->module_name = "forums"; $Event->args = $changes; $Event->key = "post_id"; $Event->value = $this->id; $Event->commit(); } catch (Exception $e) { $Error->save($e); } } } } unset($CurrentPost); unset($dataArray); unset($query); /** * Insert or update the post */ $data = array("topic_id" => $this->thread->id, "forum_id" => $this->thread->forum->id, "poster_id" => $this->uid, "post_time" => $this->timestamp, "poster_ip" => $this->ip, "enable_bbcode" => $this->flag_bbCode, "enable_html" => $this->flag_html, "enable_smilies" => $this->flag_smilies, "enable_sig" => $this->flag_signature, "post_rating" => $this->rating, "post_reported" => $this->reported, "post_herring_count" => $this->herring_count, "lat" => $this->lat, "lon" => $this->lon); $text = array("bbcode_uid" => $this->bbcode_uid, "post_subject" => $this->subject, "post_text" => $this->text, "editor_version" => $this->editor_version, "url_slug" => $this->url_slug); if (filter_var($this->id, FILTER_VALIDATE_INT)) { $data['post_edit_count'] = $this->edit_count++; $where = array("post_id = ?" => $this->id); $this->db->update("nuke_bbposts", $data, $where); $this->db->update("nuke_bbposts_text", $text, $where); $verb = "Update"; } else { $this->db->insert("nuke_bbposts", $data); $this->id = $this->db->lastInsertId(); $text['post_id'] = $this->id; $this->db->insert("nuke_bbposts_text", $text); $verb = "Insert"; $this->thread->reDrawStats(); } if (RP_DEBUG) { $site_debug[] = "Zend_DB: " . $verb . " Forum post ID " . $this->id . " in " . round(microtime(true) - $debug_timer_start, 5) . "s"; } $this->makeLinks(); if (!$this->Author instanceof User) { $this->loadAuthor(); } return true; }