Source for file BitSticky.php
Documentation is available at BitSticky.php
* @author spider <spider@steelsun.com>
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Authors: spider <spider@steelsun.com>
// +----------------------------------------------------------------------+
// $Id: BitSticky.php,v 1.9 2006/02/08 23:24:28 spiderr Exp $
require_once( LIBERTY_PKG_PATH. 'LibertyContent.php' );
define('TIKISTICKY_CONTENT_TYPE_GUID', 'tikisticky' );
function BitSticky( $pStickyId= NULL, $pContentId= NULL, $pNotatedContentId= NULL ) {
'content_description' => 'Sticky',
'handler_class' => 'BitSticky',
'handler_package' => 'stickies',
'handler_file' => 'BitSticky.php',
'maintainer_url' => 'http://www.bitweaver.org'
$this->mStickyId = $pStickyId;
$this->mNotatedContentId = $pNotatedContentId;
* Load a sticky object identified by mStickyId, $this->mNotatedContentId or mContentId in that order
* Populates the mInfo array with the following fields
* @return integer count of number of fields in MInfo
$whereSql = 'tn.`sticky_id`=?';
$bindVars = array( $this->mStickyId );
$whereSql = 'tn.`notated_content_id`=? AND lc.`user_id`=?';
$bindVars = array( $this->mNotatedContentId, $gBitUser->mUserId );
$whereSql = 'tn.`content_id`=?';
$query = "SELECT tn.*, lc.*
INNER JOIN `". BIT_DB_PREFIX. "liberty_content` lc ON (lc.`content_id` = tn.`content_id`)
$result = $this->mDb->query( $query, $bindVars );
if ( $result && $result->numRows() ) {
$this->mInfo = $result->fields;
$this->mContentId = $result->fields['content_id'];
$this->mStickyId = $result->fields['sticky_id'];
* Verify the core class data required to update the liberty_content table entries
* @param array Array of content data to be stored
* (See LibertyContent::verify for details of the core fields - which
* appends a [content_store] array with all the values for liberty_content)
* content_type_guid string Should contain 'tikisticky'
* notated_content_id integer content_id of the object to which the stickie isattached
* sticky_store - Array of values for entering in stickies
* sticky_id integer If existing then current sticky id
* otherwise populate from sequence
* content_id integer Content id of the note
* notated_content_id integer Content id of the object to which it is attached
function verify( &$pParamHash ) {
// It is possible a derived class set this to something different
$this->mErrors['content'] = "No content to notate";
$query = "SELECT tn.`sticky_id` FROM `". BIT_DB_PREFIX. "stickies` tn
INNER JOIN `". BIT_DB_PREFIX. "liberty_content` lc ON( tn.`content_id`=lc.`content_id` )
WHERE lc.`user_id`=? AND tn.`notated_content_id`=?";
$this->mStickyId = $this->mDb->getOne( $query, array( $gBitUser->mUserId, $pParamHash['notated_content_id'] ) );
$pParamHash['sticky_store']['notated_content_id'] = $pParamHash['notated_content_id'];
* Create a new stickies object or update an existing one
* @param array Array of content data to be stored (see verify for details)
* @return integer Number of errors detected ( 0 if successful )
function store( &$pParamHash ) {
if( $this->verify( $pParamHash ) ) {
$this->mDb->StartTrans();
$result = $this->mDb->associateUpdate( BIT_DB_PREFIX. "stickies", $pParamHash['sticky_store'], array( "sticky_id" => $this->mStickyId ) );
$pParamHash['sticky_store']['content_id'] = $pParamHash['content_id'];
$pParamHash['sticky_store']['sticky_id'] = $pParamHash['sticky_id'];
$pParamHash['sticky_store']['sticky_id'] = $this->mDb->GenID( 'stickies_sticky_id_seq');
$this->mPageId = $pParamHash['sticky_store']['sticky_id'];
$result = $this->mDb->associateInsert( BIT_DB_PREFIX. "stickies", $pParamHash['sticky_store'] );
$this->mDb->CompleteTrans();
$this->mDb->RollbackTrans();
* Delete stickies object and related content record
$this->mDb->StartTrans();
$query = "DELETE FROM `". BIT_DB_PREFIX. "stickies` WHERE `content_id` = ?";
$result = $this->mDb->query( $query, array( $this->mContentId ) );
$this->mDb->CompleteTrans();
$this->mDb->RollbackTrans();
|