Changeset 2448 for branches/schema06/system/classes/post.php
- Timestamp:
- 09/05/08 13:32:48 (4 months ago)
- Files:
-
- 1 modified
-
branches/schema06/system/classes/post.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/schema06/system/classes/post.php
r2410 r2448 582 582 public function insert() 583 583 { 584 $this->newfields[ 'updated' ]= HabariDateTime::date_create(); 584 $this->newfields['updated']= HabariDateTime::date_create(); 585 $this->newfields['modified'] = $this->newfields['updated']; 585 586 $this->setslug(); 586 587 $this->setguid(); … … 606 607 $this->info->commit( DB::last_insert_id() ); 607 608 $this->save_tags(); 609 $this->create_default_permissions(); 608 610 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' ); 609 611 Plugins::act( 'post_insert_after', $this ); … … 620 622 * function update 621 623 * Updates an existing post in the posts table 622 */ 623 public function update() 624 { 625 $this->updated= HabariDateTime::date_create(); 624 * @param bool $minor Indicates if this is a major or minor update 625 */ 626 public function update( $minor = true ) 627 { 628 $this->modified = HabariDateTime::date_create(); 629 if ( ! $minor ) { 630 $this->updated = $this->modified; 631 } 626 632 if ( isset( $this->fields['guid'] ) ) { 627 633 unset( $this->newfields['guid'] ); … … 691 697 $this->info->delete_all(); 692 698 } 699 // Delete all permissions associated with this post 700 $this->delete_permissions(); 701 693 702 $result= parent::deleteRecord( DB::table( 'posts' ), array( 'slug'=>$this->slug ) ); 694 703 EventLog::log( sprintf(_t('Post %1$s (%2$s) deleted.'), $this->id, $this->slug), 'info', 'content', 'habari' ); … … 982 991 } 983 992 993 /** 994 * Creates default permissions on a post 995 */ 996 public function create_default_permissions() 997 { 998 $this->add_permission( $this->content_type() ); 999 } 1000 1001 /** 1002 * Add a permission to a post 1003 * @param string $permission The name of the permission to add 1004 **/ 1005 public function add_permission( $permission ) 1006 { 1007 $token_id = ACL::token_id( $permission ); 1008 if ( $token_id !== FALSE ) { 1009 DB::insert( '{post_tokens}', array( 'post_id' => $this->id, 'token_id' => $token_id ) ); 1010 } 1011 } 1012 1013 /** 1014 * Deletes permissions on a post 1015 */ 1016 public function delete_permissions() 1017 { 1018 DB::delete( '{post_tokens}', array( 'post_id', => $this->id ) ); 1019 } 984 1020 } 985 1021 ?>
