static function removeClassName($contentClassID, $contentClassVersion)
 {
     $db = eZDb::instance();
     $db->begin();
     $sql = "DELETE FROM ezcontentclass_name WHERE contentclass_id = {$contentClassID} AND contentclass_version = {$contentClassVersion}";
     $db->query($sql);
     $db->commit();
 }
Пример #2
0
 function getClassAttributes($attribute_names = array())
 {
     $debug = false;
     $db = eZDb::instance();
     $ret = array();
     $result = array();
     $result2 = array();
     if (count($attribute_names) > 1) {
         foreach ($attribute_names as $key => $attribute_name) {
             $sql = "SELECT tmp.id, tmp.identifier from (select ezcontentclass.id, ezcontentclass.identifier from ezcontentclass,ezcontentclass_attribute where (ezcontentclass.id=ezcontentclass_attribute.contentclass_id AND ezcontentclass_attribute.identifier='servizio')) as tmp, ezcontentclass_attribute where tmp.id=ezcontentclass_attribute.contentclass_id AND ezcontentclass_attribute.identifier='argomento'";
             $ret[] = $db->arrayQuery($sql);
         }
     } else {
         foreach ($attribute_names as $key => $attribute_name) {
             $sql = "SELECT ezcontentclass.id, ezcontentclass.identifier \n                FROM ezcontentclass_attribute, ezcontentclass \n                WHERE ezcontentclass.id=ezcontentclass_attribute.contentclass_id \n                AND ezcontentclass_attribute.identifier='" . $attribute_name . "'";
             $ret[] = $db->arrayQuery($sql);
         }
     }
     if ($debug) {
         ezDebug::writeNotice($ret[0], 'getClassAttributes: risultato per ' . implode(',', $attribute_names));
     }
     return $ret[0];
 }
Пример #3
0
 function checkApproveCollaboration( $process, $event )
 {
     $db = eZDb::instance();
     $taskResult = $db->arrayQuery( 'select workflow_process_id, collaboration_id from ezapprove_items where workflow_process_id = ' . $process->attribute( 'id' )  );
     $collaborationID = $taskResult[0]['collaboration_id'];
     $collaborationItem = eZCollaborationItem::fetch( $collaborationID );
     $contentObjectVersion = eZApproveCollaborationHandler::contentObjectVersion( $collaborationItem );
     $approvalStatus = eZApproveCollaborationHandler::checkApproval( $collaborationID );
     if ( $approvalStatus == eZApproveCollaborationHandler::STATUS_WAITING )
     {
         eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'approval still waiting' );
         return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
     }
     else if ( $approvalStatus == eZApproveCollaborationHandler::STATUS_ACCEPTED )
     {
         eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'approval was accepted' );
         $status = eZWorkflowType::STATUS_ACCEPTED;
     }
     else if ( $approvalStatus == eZApproveCollaborationHandler::STATUS_DENIED or
               $approvalStatus == eZApproveCollaborationHandler::STATUS_DEFERRED )
     {
         eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'approval was denied' );
         $contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
         $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     else
     {
         eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, "approval unknown status '$approvalStatus'" );
         $contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_REJECTED );
         $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     $contentObjectVersion->sync();
     if ( $approvalStatus != eZApproveCollaborationHandler::STATUS_DEFERRED )
         $db->query( 'DELETE FROM ezapprove_items WHERE workflow_process_id = ' . $process->attribute( 'id' )  );
     return $status;
 }
Пример #4
0
 static function fetchAllClasses($asObject = true, $includeFilter = true, $groupList = false)
 {
     $filterTableSQL = '';
     $filterSQL = '';
     if (is_array($groupList)) {
         $filterTableSQL = ', ezcontentclass_classgroup ccg';
         $filterSQL = " AND" . "      cc.id = ccg.contentclass_id AND" . "      ccg.group_id ";
         $groupText = implode(', ', $groupList);
         if ($includeFilter) {
             $filterSQL .= "IN ( {$groupText} )";
         } else {
             $filterSQL .= "NOT IN ( {$groupText} )";
         }
     }
     $classNameFilter = eZContentClassName::sqlFilter('cc');
     $classList = array();
     $db = eZDb::instance();
     // If $asObject is true we fetch all fields in class
     $fields = $asObject ? "cc.*" : "cc.id, {$classNameFilter['nameField']}";
     $rows = $db->arrayQuery("SELECT DISTINCT {$fields} " . "FROM ezcontentclass cc{$filterTableSQL}, {$classNameFilter['from']} " . "WHERE cc.version = " . eZContentClass::VERSION_STATUS_DEFINED . "{$filterSQL} AND {$classNameFilter['where']}" . "ORDER BY {$classNameFilter['nameField']} ASC");
     $classList = eZPersistentObject::handleRows($rows, 'eZContentClass', $asObject);
     return $classList;
 }
Пример #5
0
$dbImpl = $options['db-driver'] ? $options['db-driver'] : false;
$showSQL = $options['sql'] ? true : false;
$siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false;
if ($siteAccess) {
    changeSiteAccessSetting($siteAccess);
}
function changeSiteAccessSetting($siteAccess)
{
    $cli = eZCLI::instance();
    if (in_array($siteAccess, eZINI::instance()->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) {
        $cli->output("Using siteaccess {$siteAccess} for nice url update");
    } else {
        $cli->notice("Siteaccess {$siteAccess} does not exist, using default siteaccess");
    }
}
$db = eZDb::instance();
if ($dbHost or $dbName or $dbUser or $dbImpl) {
    $params = array();
    if ($dbHost !== false) {
        $params['server'] = $dbHost;
    }
    if ($dbUser !== false) {
        $params['user'] = $dbUser;
        $params['password'] = '';
    }
    if ($dbPassword !== false) {
        $params['password'] = $dbPassword;
    }
    if ($dbName !== false) {
        $params['database'] = $dbName;
    }
Пример #6
0
    function versionLanguageName( $version, $lang = false )
    {
        $name = false;
        if ( !$version > 0 )
        {
            eZDebug::writeNotice( "There is no object name for version($version) of the content object ($contentObjectID) in language($lang)", __METHOD__ );
            return $name;
        }
        $db = eZDb::instance();
        $contentObjectID = $this->attribute( 'id' );
        if ( !$lang )
        {
            // If $lang not given we will use the initial language of the object
            $query = "SELECT initial_language_id FROM ezcontentobject WHERE id='$contentObjectID'";
            $rows = $db->arrayQuery( $query );
            if ( $rows )
            {
                $languageID = $rows[0]['initial_language_id'];
                $language = eZContentLanguage::fetch( $languageID );
                if ( $language )
                {
                    $lang = $language->attribute( 'locale' );
                }
                else
                {
                    return $name;
                }
            }
            else
            {
                return $name;
            }
        }
        $lang = $db->escapeString( $lang );
        $version = (int) $version;

        $languageID = $this->attribute( 'initial_language_id' );
        if ( $this->attribute( 'always_available' ) )
        {
            $languageID = (int) $languageID | 1;
        }

        $query= "SELECT name, content_translation
                 FROM ezcontentobject_name
                 WHERE contentobject_id = '$contentObjectID'
                       AND content_version = '$version'
                       AND ( content_translation = '$lang' OR language_id = '$languageID' )";
        $result = $db->arrayQuery( $query );

        $resCount = count( $result );
        if( $resCount < 1 )
        {
            eZDebug::writeNotice( "There is no object name for version($version) of the content object ($contentObjectID) in language($lang)", __METHOD__ );
        }
        else if( $resCount > 1 )
        {
            // we have name in requested language => find and return it
            foreach( $result as $row )
            {
                if( $row['content_translation'] == $lang )
                {
                    $name = $row['name'];
                    break;
                }
            }
        }
        else
        {
            // we don't have name in requested language(or requested language is the same as initial language) => use name in initial language
            $name = $result[0]['name'];
        }

        return $name;
    }
 function checkApproveCollaboration($process, $event, $collaborationID = 0)
 {
     $db = eZDb::instance();
     if ($collaborationID > 0) {
         $taskResult = $db->arrayQuery('select workflow_process_id, collaboration_id, target_node_ids from ezxapprovelocation_items where collaboration_id = ' . $collaborationID);
     } else {
         $taskResult = $db->arrayQuery('select workflow_process_id, collaboration_id, target_node_ids from ezxapprovelocation_items where workflow_process_id = ' . $process->attribute('id'));
     }
     $collaborationID = $taskResult[0]['collaboration_id'];
     $collaborationItem = eZCollaborationItem::fetch($collaborationID);
     $approvalStatus = approveLocationCollaborationHandler::checkApproval($collaborationID);
     $targetNodeIDs = json_decode($taskResult[0]['target_node_ids']);
     if ($approvalStatus == approveLocationCollaborationHandler::STATUS_WAITING) {
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approval still waiting');
         return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
     } elseif ($approvalStatus == approveLocationCollaborationHandler::STATUS_ACCEPTED) {
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approval was accepted');
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $targetNodeIDs, 'add new location(s)');
         return eZWorkflowType::STATUS_ACCEPTED;
     } elseif ($approvalStatus == approveLocationCollaborationHandler::STATUS_DENIED or $approvalStatus == approveLocationCollaborationHandler::STATUS_DEFERRED) {
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approval was denied');
         $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     } else {
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, "approval unknown status '{$approvalStatus}'");
         $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     if ($approvalStatus != approveLocationCollaborationHandler::STATUS_DEFERRED) {
         $db->query('DELETE FROM ezxapprovelocation_items WHERE workflow_process_id = ' . $process->attribute('id'));
     }
     return $status;
 }
 function content($collaborationItem)
 {
     $db = eZDb::instance();
     $taskResult = $db->arrayQuery('select target_node_ids from ezxapprovelocation_items where collaboration_id = ' . $collaborationItem->attribute('id'));
     return array("content_object_id" => $collaborationItem->attribute("data_int1"), "content_object_version" => $collaborationItem->attribute("data_int2"), "approval_status" => $collaborationItem->attribute("data_int3"), "target_node_ids" => json_decode($taskResult[0]['target_node_ids'], true));
 }