/** * insert * * @access public * @return boolean */ public function insert() { $result = parent::insertRecord(DB::table('rateit_log')); $this->newfields['id'] = DB::last_insert_id(); // Make sure the id is set in the comment object to match the row id $this->fields = array_merge($this->fields, $this->newfields); $this->newfields = array(); return $result; }
/** * Save a new UserGroup to the UserGroup table */ public function insert() { $exists = DB::get_value('SELECT count(1) FROM {groups} WHERE name = ?', array($this->name)); if ($exists) { return false; } $allow = true; // plugins have the opportunity to prevent insertion $allow = Plugins::filter('usergroup_insert_allow', $allow, $this); if (!$allow) { return false; } Plugins::act('usergroup_insert_before', $this); $this->exclude_fields('id'); $result = parent::insertRecord(DB::table('groups')); $this->fields['id'] = DB::last_insert_id(); $this->set_member_list(); EventLog::log(sprintf(_t('New group created: %s'), $this->name), 'info', 'default', 'habari'); Plugins::act('usergroup_insert_after', $this); return $result; }
/** * function insert * Saves a new tag into the tags table */ public function insert() { $this->setslug(); $allow = true; $allow = Plugins::filter('tag_insert_allow', $allow, $this); if (!$allow) { return; } Plugins::act('tag_insert_before', $this); // Invoke plugins for all fields, since they're all "changed" when inserted foreach ($this->fields as $fieldname => $value) { Plugins::act('tag_update_' . $fieldname, $this, $this->id == 0 ? null : $value, $this->{$fieldname}); } $result = parent::insertRecord(DB::table('tags')); $this->newfields['id'] = DB::last_insert_id(); // Make sure the id is set in the Tag object to match the row id $this->fields = array_merge($this->fields, $this->newfields); $this->newfields = array(); EventLog::log(sprintf(_t('New tag %1$s (%2$s); Slug: %3$s'), $this->id, $this->tag_text, $this->tag_slug), 'info', 'content', 'habari'); Plugins::act('tag_insert_after', $this); return $result; }
/** * function insert * Saves a new post to the posts table */ public function insert() { $this->newfields['updated'] = HabariDateTime::date_create(); $this->newfields['modified'] = $this->newfields['updated']; $this->setguid(); if ( $this->pubdate->int > HabariDateTime::date_create()->int && $this->status == Post::status( 'published' ) ) { $this->status = Post::status( 'scheduled' ); } $allow = true; $allow = Plugins::filter( 'post_insert_allow', $allow, $this ); if ( ! $allow ) { return; } Plugins::act( 'post_insert_before', $this ); // Invoke plugins for all fields, since they're all "changed" when inserted foreach ( $this->fields as $fieldname => $value ) { Plugins::act( 'post_update_' . $fieldname, $this, ( $this->id == 0 ) ? null : $value, $this->$fieldname ); } // invoke plugins for status changes Plugins::act( 'post_status_' . self::status_name( $this->status ), $this, null ); $result = parent::insertRecord( DB::table( 'posts' ) ); $this->newfields['id'] = DB::last_insert_id(); // Make sure the id is set in the post object to match the row id $this->fields = array_merge( $this->fields, $this->newfields ); $this->newfields = array(); $this->info->commit( DB::last_insert_id() ); $this->save_tags(); $this->create_default_permissions(); EventLog::log( sprintf( _t( 'New post %1$s (%2$s); Type: %3$s; Status: %4$s' ), $this->id, $this->slug, Post::type_name( $this->content_type ), $this->statusname ), 'info', 'content', 'habari' ); Plugins::act( 'post_insert_after', $this ); //scheduled post if ( $this->status == Post::status( 'scheduled' ) ) { Posts::update_scheduled_posts_cronjob(); } return $result; }
/** * Saves a new comment to the comments table * @return integer|boolean The inserted record id on success, false if not */ public function insert() { $allow = true; $allow = Plugins::filter('comment_insert_allow', $allow, $this); if (!$allow) { return false; } Plugins::act('comment_insert_before', $this); // Invoke plugins for all fields, since they're all "changed" when inserted foreach ($this->fields as $fieldname => $value) { Plugins::act('comment_update_' . $fieldname, $this, $this->{$fieldname}, $value); } $result = parent::insertRecord(DB::table('comments')); $this->newfields['id'] = DB::last_insert_id(); // Make sure the id is set in the comment object to match the row id $this->fields = array_merge($this->fields, $this->newfields); $this->newfields = array(); $this->info->commit($this->fields['id']); Plugins::act('comment_insert_after', $this); return $result; }
/** * Saves a new rewrite rule to the rewrite_rules table */ public function insert() { return parent::insertRecord(DB::table('rewrite_rules')); }
/** * Saves a new cron job to the crontab table. * * @see QueryRecord::insertRecord() * @return CronJob The newly inserted cron job, or false if failed. */ public function insert() { return parent::insertRecord(DB::table('crontab')); }
/** * function insert * Saves a new term to the terms table */ public function insert() { $this->setslug(); // Let plugins disallow and act before we write to the database $allow = true; $allow = Plugins::filter( 'term_insert_allow', $allow, $this ); if ( !$allow ) { return false; } Plugins::act( 'term_insert_before', $this ); $result = parent::insertRecord( DB::table( 'terms' ) ); // Make sure the id is set in the term object to match the row id $this->newfields[ 'id' ] = DB::last_insert_id(); // Update the term's fields with anything that changed $this->fields = array_merge( $this->fields, $this->newfields ); // We've inserted the term, reset newfields $this->newfields = array(); // Commit the info records $this->info->commit( $this->fields['id'] ); EventLog::log( _t( 'New term %1$s: %2$s', array( $this->id, $this->term_display ) ), 'info', 'content', 'habari' ); // Let plugins act after we write to the database Plugins::act( 'term_insert_after', $this ); return $result; }
/** * Insert this block into the database * * @return boolean True on success */ public function insert() { // Let plugins disallow and act before we write to the database $allow = true; $allow = Plugins::filter('block_insert_allow', $allow, $this); if (!$allow) { return; } Plugins::act('block_insert_before', $this); $this->data = serialize($this->data_values); $result = parent::insertRecord(DB::table('blocks')); // Make sure the id is set in the block object to match the row id $this->newfields['id'] = DB::last_insert_id(); // Update the block's fields with anything that changed $this->fields = array_merge($this->fields, $this->newfields); // We've inserted the block, reset newfields $this->newfields = array(); EventLog::log(_t('New block %1$s: %2$s', array($this->id, $this->title)), 'info', 'content', 'habari'); // Let plugins act after we write to the database Plugins::act('block_insert_after', $this); return $result; }
/** * Saves a new post to the posts table * @return int|null The new post id on success, or false on failure */ public function insert() { // echo "<script>alert('我被执行了')</script>"; $this->newfields['updated'] = HabariDateTime::date_create(); $this->newfields['modified'] = $this->newfields['updated']; $this->setguid(); if ($this->pubdate->int > HabariDateTime::date_create()->int && $this->status == Post::status('published')) { $this->status = Post::status('scheduled'); } $allow = true; $allow = Plugins::filter('post_insert_allow', $allow, $this); if (!$allow) { return false; } Plugins::act('post_insert_before', $this); // Invoke plugins for all fields, since they're all "changed" when inserted foreach ($this->fields as $fieldname => $value) { $fieldvalue = isset($this->newfields[$fieldname]) ? $this->newfields[$fieldname] : $this->fields[$fieldname]; Plugins::act('post_update_' . $fieldname, $this, $this->id == 0 ? null : $value, $fieldvalue); } // invoke plugins for status changes Plugins::act('post_status_' . self::status_name($this->status), $this, null); // var_dump($this->get_schema_map()); // exit; $result = parent::insertRecord('posts', $this->get_schema_map()); $this->newfields['id'] = $result; // Make sure the id is set in the post object to match the row id $this->fields = array_merge($this->fields, $this->newfields); $this->newfields = array(); $this->info->commit(DB::last_insert_id()); $this->save_tags(); // This fires __call() which dispatches to any plugins on action_post_call_create_default_permissions() $this->create_default_permissions(); $this->create_default_tokens(); EventLog::log(_t('New post %1$s (%2$s); Type: %3$s; Status: %4$s', array($this->id, $this->slug, Post::type_name($this->content_type), $this->statusname)), 'info', 'content', 'habari'); Plugins::act('post_insert_after', $this); //scheduled post if ($this->status == Post::status('scheduled')) { Posts::update_scheduled_posts_cronjob(); } return $result; }
/** * Save a new user to the users table */ public function insert() { $allow = true; $allow = Plugins::filter('user_insert_allow', $allow, $this); if (!$allow) { return; } Plugins::act('user_insert_before', $this); $this->exclude_fields('id'); $result = parent::insertRecord(DB::table('users')); $this->fields['id'] = DB::last_insert_id(); // Make sure the id is set in the user object to match the row id $this->info->set_key($this->id); /* If a new user is being created and inserted into the db, info is only safe to use _after_ this set_key call. */ // $this->info->option_default = "saved"; // Set the default timezone, date format, and time format $this->info->locale_tz = Options::get('timezone'); $this->info->locale_date_format = Options::get('dateformat'); $this->info->locale_time_format = Options::get('timeformat'); $this->info->commit(); if ($result) { // Add the user to the default authenticated group if it exists if (UserGroup::exists('authenticated')) { $this->add_to_group('authenticated'); } } EventLog::log(sprintf(_t('New user created: %s'), $this->username), 'info', 'default', 'habari'); Plugins::act('user_insert_after', $this); return $result; }
/** * function insert * Saves a new vocabulary to the vocabularies table */ public function insert() { // Don't allow duplicate vocabularies if (Vocabulary::exists($this->fields['name'])) { return false; } // Let plugins disallow and act before we write to the database $allow = true; $allow = Plugins::filter('vocabulary_insert_allow', $allow, $this); if (!$allow) { return false; } Plugins::act('vocabulary_insert_before', $this); // Serialize features before they are stored if (isset($this->newfields['features'])) { $this->newfields['features'] = serialize($this->newfields['features']); } if (isset($this->fields['features'])) { $this->fields['features'] = serialize($this->fields['features']); } $result = parent::insertRecord(DB::table('vocabularies')); // Make sure the id is set in the vocabulary object to match the row id $this->newfields['id'] = DB::last_insert_id(); // Update the vocabulary's fields with anything that changed $this->fields = array_merge($this->fields, $this->newfields); // And unserialize the features if (isset($this->fields['features'])) { $this->fields['features'] = unserialize($this->fields['features']); } // We've inserted the vocabulary, reset newfields $this->newfields = array(); EventLog::log(_t('New vocabulary %1$s (%2$s)', array($this->id, $this->name)), 'info', 'content', 'habari'); // Let plugins act after we write to the database Plugins::act('vocabulary_insert_after', $this); return $result; }
/** * Insert this LogEntry data into the database */ public function insert() { if ( isset( $this->fields['severity'] ) ) { $this->severity_id = LogEntry::severity( $this->fields['severity'] ); unset( $this->fields['severity'] ); } if ( isset( $this->fields['module'] ) && isset( $this->fields['type'] ) ) { $this->type_id = LogEntry::type( $this->fields['module'], $this->fields['type'] ); unset( $this->fields['module'] ); unset( $this->fields['type'] ); } // if we're set to only log entries greater than a sertain level, make sure we're that level or higher if ( $this->fields['severity_id'] < Options::get( 'log_min_severity' ) ) { return; } // make sure data is a string and can be stored. lots of times it's convenient to hand in an array of data values if ( is_array( $this->fields['data'] ) || is_object( $this->fields['data'] ) ) { $this->fields['data'] = serialize( $this->fields['data'] ); } Plugins::filter( 'insert_logentry', $this ); parent::insertRecord( DB::table( 'log' ) ); $this->id = DB::last_insert_id(); }
/** * Insert this LogEntry data into the database */ public function insert() { if (isset($this->fields['severity'])) { $this->severity_id = LogEntry::severity($this->fields['severity']); unset($this->fields['severity']); } if (isset($this->fields['module']) && isset($this->fields['type'])) { $this->type_id = LogEntry::type($this->fields['module'], $this->fields['type']); unset($this->fields['module']); unset($this->fields['type']); } Plugins::filter('insert_logentry', $this); parent::insertRecord(DB::table('log')); $this->id = DB::last_insert_id(); }