Author Topic

Piotrek Karaś

Friday 04 July 2008 4:42:12 pm

Comment35302

Hey guys,

Similar experiences here. Here's what I did at first:

    public static function isContentobjectRegisterable( $contentobjectID )
    {
        $isRegistrable = false;
        
        $db = eZDB::instance();
        // This query checks the most important values and relations between
        // object's values across different tables. Is is to determine if
        // it should be possible to register this object, or maybe it should
        // be considered invalid.
        $query = "SELECT COUNT(*) AS count_valid 
            FROM ezcontentobject co, ezcontentobject_tree cot 
            WHERE co.id=" . (int)$contentobjectID . " 
            AND co.id=cot.contentobject_id 
            AND cot.main_node_id>0 
            AND co.status=" . eZContentObject::STATUS_PUBLISHED ;
        $result = $db->arrayQuery( $query, array( 'column' => 'count_valid' ) );
        $validCount = (int)$result[0];
        if( $validCount > 0 )
        {
            $isRegistrable = true;
        }

        return $isRegistrable;
    } 

I decided not to fix the problem here, but make my extension aware of possible corruptions.

Yet, I will definitely check out Jonny's scripts.

Cheers,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu