SourceForge.net LogoPHPGallue
[ class tree: libgallue ] [ index: libgallue ] [ all elements ]

Class: GALComment

Source Location: /libgallue/comment.inc.php

Class Overview

GALRow
   |
   --GALTableRow
      |
      --GALComment

Provide information about a comment's content, it's parent and follow-up comments.


Variables

Methods


Inherited Variables

Inherited Methods

Class: GALTableRow

GALTableRow::__construct()
Initializes this object.
GALTableRow::delete()
Deletes this row from the database.
GALTableRow::getParent()
Returns the top level parent of this row.
GALTableRow::set()
Sets the specified field of this row to the specified value.
GALTableRow::__set()
Magic method to set a field of this row almost like a native PHP property.

Class: GALRow

GALRow::__construct()
Initializes a row.
GALRow::countFields()
Returns the number of fields contained in a result.
GALRow::get()
Returns the value of a field.
GALRow::getData()
Provides access to the stored data.
GALRow::getFields()
Returns all fields contained in this result.
GALRow::getFlags()
Gets the flags of the given field.
GALRow::getLength()
Gets the length of the given field.
GALRow::getParent()
Returns the top level parent of an entity.
GALRow::getTable()
Gets the name of the table the given field is contained in.
GALRow::getType()
Gets the type of the given field.
GALRow::isField()
Checks if the given field is contained in a result.
GALRow::__destruct()
Deletes the stored data and sets $_dead to TRUE.
GALRow::__get()
Magic method to access this row's fields like native PHP properties.

Class Details

[line 268]
Provide information about a comment's content, it's parent and follow-up comments.

This class provides various properties accessed via the magic methods __get() and __set(). Some of these properties correspond to database fields, some do not. The __get() and __set() methods internally use the get() and set() methods which provide access control - in contrast to the parent class's GALRow::get() and GALTableRow::set() methods. After performing the access control, these are used to read and write the properties corresponding to database fields. All properties corresponding to database fields are of type string, but instead database types are given here. (r indicates readable, w writable)

  1. Properties corresponding to database fields:
  • INTEGER UNSIGNED commentID r The comment's numerical ID, the primary key of the Comments table.
  • VARCHAR(20) parentClass rw Identifier for the parent's type, typically it's class name.
  • INTEGER UNSIGNED parentID rw Identifies an unique item of type parentClass which is the comment's parent.
  • INTEGER UNSIGNED ownerID r The ID of the GALUser the comment belongs to. Foreign key field from Users.ownerID.
  • INTEGER changeDate rw The UNIX timestamp of the moment the comment was changed the last time.
  • INTEGER createDate rw The UNIX timestamp of the moment the comment was created.
  • INTEGER tag rw A value that has no fixed meaning. It might be used to organize items beyond the structure of libgallue.
  • TINYINT permission rw The comment's access permission, one of GAL_PERMISSION_LOCKED, GAL_PERMISSION_PRIVATE, GAL_PERMISSION_PROTECTED, GAL_PERMISSION_PUBLIC.
  • VARCHAR(255) title rw The comment's title.
  • MEDIUMTEXT comment rw The comment's text.
  • ENUM ('ltr', 'rtl') direction rw The text direction.
2. Properties generated using database fields
  • GALUser owner (from ownerID) r The user the comment belongs to.
  • object or string parent (from parentClass, parentID) The comment's parent.
3. Properties not corresponding to database fields.
  • comments r New iterator on all follow-up comments made about this comment
The properties of the third kind are all iterators, so before working with them, you have to store them in a local variable. It is to be considered if one should provide these iterators with methods like <source>getCommentsIterator()</source> to make this clear.

In most cases parentClass is one of GALImage, GALComment, GALCategory, GALGroup, GALSeries or GALFilm. These classes have got a singe numerical value as their table's primary key, so parentClass and parentID identify the parent object which can be accessed through the "parent" property or getParent(). Because parentID doesn't reference a specific key, it cannot be protected by a FOREIGN KEY construct, and bugs inside libgallue could result in invalid values, but normally the delete() methods should also delete all depending comments. If parentClass contains a value different from the values listed above, the "parent" property and getParent() just return the value of parentClass.

Note that all "real" properties (called object variables in the following) start with an underscore so that they do not interfere with properties accessed using __get() and __set().




[ Top ]


Class Variables

$_comments =  false

[line 282]

Cache follow-up comments about this comment.

The first time the comments property is accessed, this object variable is initialized with a GALCommentIterator on all follow-up comments about this comment. All requests for the comments property then just return a new iterator on this variable.




Tags:

access:  protected
see:  GALResultIterator::iterator()

Type:   mixed


[ Top ]

$_glb =  false

[line 272]

Link to GALGallery object.



Tags:

access:  protected

Type:   mixed


[ Top ]

$_recurseLock =  false

[line 293]

Avoid infinite recursion.

As parentClass and parentID can be set to arbitray values, it is possible to build loops of comments, where a follow-up comment references a parent as follow-up. This becomes a problem if one has to delete such a loop. One has to assure that every comment is deleted exactly once, otherwise data is corrupted or deleting doesn't terminate. This object variable is set to TRUE inside the delete() method on it's first call, and future calls of delete() return immediately without performing an operation.




Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 303]

GALComment __construct( GALGallery $glb, $result, &$data, $table, array $data)

Initialize.

This constructor is not intended to be called by library users, it is called inside GALCommentIterator::fetch().




Overrides GALTableRow::__construct() (Initializes this object.)

Parameters:

GALGallery   $glb   Used to initialize the $_glb object variable.
GALResult   $result   Used in parent constructor GALTableRow::__construct().
array   $data   Used in parent constructor GALTableRow::__construct().
GALTable   $table   Used in parent constructor GALTableRow::__construct().
   &$data  

[ Top ]

method canEdit [line 585]

bool canEdit( GALUser $user)

Check if the specified user has got the privilege to change the comment's properties.



Tags:

return:  True if the user can change the comment, false otherwise.


Parameters:

GALUser   $user   The user whose privileges are checked.

[ Top ]

method canView [line 571]

bool canView( GALUser $user)

Check if the specified user has got the privilege to read the comment's properties.



Tags:

return:  True if the user can see the comment, false otherwise.


Parameters:

GALUser   $user   The user whose privileges are checked.

[ Top ]

method countComments [line 467]

GALCommentIterator countComments( $expr, [GALOrder $order = ""], [string $limit = ""], [string $additional = ""], [bool $super = false])

Counts follow-up comments about this comment.

It adds a comparison expression and ordering by commentID to the arguments and passes them to GALTable::extendedCount().




Tags:



Parameters:

GALExpression   $expr  
GALOrder   $order   Can also be an empty string or a string containing sth. like "`title` DESC".
string   $limit  
string   $additional  
bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method delete [line 535]

void delete( [bool $super = false])

Delete the comment.

This method deletes the comment and all follow-up comments. and forces reloading the cached information of it's parent and it's owner.




Overrides GALTableRow::delete() (Deletes this row from the database.)

Parameters:

bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method get [line 340]

void get( string $field, [bool $super = true])

Reads a property via method call.

First of all it performs access control. If successful, properties not corresponding to database fields are handled by this method itself. Properties corresponding to database fields are delegated to the inherited GALRow::get() method. It might seem strange that overriding access control is the default. It is like it is because GALRow::__construct() called by GALcomment::__construct reads the row's primary key using the get() method. In our case the original get() method is overridden by the current one, so it has to work in this case without second parameter.




Overrides GALRow::get() (Returns the value of a field.)

Parameters:

string   $field   The propertie's name
bool   $super   TRUE indicates privileged access overriding access control.

[ Top ]

method getID [line 423]

int getID( [ $super = false])

The value of the primary key field.

This method provides access to the primary key without knowing the name of the primary key field. This method is implemented by all classes whose tables have a single numerical primary key. At the moment it is only used in GALComments::add(). (Better: It was introduced for GALComments::add() ;-) )




Tags:

return:  The value of the primary key field.


Parameters:

   $super  

[ Top ]

method getParent [line 373]

mixed getParent( [bool $super = false])

Return the comment's parent.

In most cases parentClass is one of GALImage, GALComment, GALCategory, GALGroup, GALSeries or GALFilm. These classes have got a singe numerical value as their table's primary key, so parentClass and parentID identify the parent object which is in this case returned by this method. Because parentID doesn't reference a specific key, it cannot be protected by a FOREIGN KEY construct, and bugs inside libgallue could result in invalid values, but normally the delete() methods should also delete all depending comments. If parentClass contains a value different from the values listed above, this method just returns the value of parentClass.




Tags:

return:  The comment's parent (usually an object, otherwise a string).


Overrides GALTableRow::getParent() (Returns the top level parent of this row.)

Parameters:

bool   $super   If TRUE, override access control.

[ Top ]

method loadComments [line 439]

GALCommentIterator loadComments( $expr, [GALOrder $order = ""], [string $limit = ""], [string $additional = ""], [bool $super = false])

Loads follow-up comments about this comment.

It adds a comparison expression and ordering by commentID to the arguments and passes them to GALTable::extendedLoad().




Tags:



Parameters:

GALExpression   $expr  
GALOrder   $order   Can also be an empty string or a string containing sth. like "`title` DESC".
string   $limit  
string   $additional  
bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method refresh [line 524]

void refresh( )

Reload cached information.

Force reloading information about follow-up comments. The next time the "comments" property is read, the information is loaded again.




[ Top ]

method set [line 505]

void set( string $field, mixed $value, [bool $super = false])

Set a property via method call.

First of all it performs access control. If successful, properties not corresponding to database fields are handled by this method itself. Properties corresponding to database fields are delegated to the inherited GALTableRow::set() method. It also updates the changeDate property on every call.




Overrides GALTableRow::set() (Sets the specified field of this row to the specified value.)

Parameters:

string   $field   The propertie's name.
mixed   $value   The propertie's new value.
bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method __get [line 321]

mixed __get( string $field)

Magic method to read properties.

It internally uses the get() method with enforced access control. Library users should not explicitly call the __get() method - it is good for nothing. If you want to read a property with a method call, use get() instead. That method also provides overriding access control if required.




Tags:

return:  The propertie's value.


Overrides GALRow::__get() (Magic method to access this row's fields like native PHP properties.)

Parameters:

string   $field   The requested propertie's name.

[ Top ]

method __set [line 490]

void __set( string $field, mixed $value)

Magic method to set properties It internally uses set() with enforced access control.



Overrides GALTableRow::__set() (Magic method to set a field of this row almost like a native PHP property.)

Parameters:

string   $field   The name of the property to set.
mixed   $value   The propertie's new value.

[ Top ]


Documentation generated on Wed, 16 Aug 2006 15:35:31 +0200 by phpDocumentor 1.3.0RC6