Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cUpgradeJob_0001
  • cUpgradeJob_0002
  • cUpgradeJob_0003
  • cUpgradeJob_0004
  • cUpgradeJob_0005
  • cUpgradeJob_0006
  • cUpgradeJob_0007
  • cUpgradeJob_0008
  • cUpgradeJob_0009
  • cUpgradeJob_0010
  • cUpgradeJob_0011
  • cUpgradeJob_0012
  • cUpgradeJobAbstract
  • cUpgradeJobMain
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the upgrade job 4.
  4:  *
  5:  * @package    Setup
  6:  * @subpackage UpgradeJob
  7:  * @version    SVN Revision $Rev:$
  8:  *
  9:  * @author     Murat Purc <murat@purc>
 10:  * @copyright  four for business AG <www.4fb.de>
 11:  * @license    http://www.contenido.org/license/LIZENZ.txt
 12:  * @link       http://www.4fb.de
 13:  * @link       http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Upgrade job 4.
 20:  * Runs the upgrade job to takeover some properties from upload to upload_meta
 21:  *
 22:  * @package Setup
 23:  * @subpackage UpgradeJob
 24:  */
 25: class cUpgradeJob_0004 extends cUpgradeJobAbstract {
 26: 
 27:     public $maxVersion = "4.9.0-beta1";
 28: 
 29:     public function _execute() {
 30:         global $cfg;
 31: 
 32:         if ($this->_setupType != 'setup') {
 33:             $done = false;
 34:             $sSql = "SHOW COLUMNS FROM " . $cfg['tab']['upl'];
 35:             $this->_oDb->query($sSql);
 36:             while ($this->_oDb->nextRecord()) {
 37:                 if ($this->_oDb->f("Field") == 'description') {
 38:                     $done = true;
 39:                 }
 40:             }
 41:             if ($done) {
 42:                 $this->_updateUpl2Meta();
 43:             }
 44:         }
 45:     }
 46: 
 47:     //update description from con_upl to con_upl_meta
 48:     protected function _updateUpl2Meta() {
 49:         global $cfg;
 50: 
 51:         $db = $this->_oDb;
 52:         $aUploads = array();
 53:         $sSql = "SELECT * FROM " . $cfg['tab']['upl'] . " WHERE `description` != '' ORDER BY idupl ASC";
 54:         $db->query($sSql);
 55: 
 56:         while ($db->nextRecord()) {
 57:             $uploadId = $db->f('idupl');
 58:             $aUploads[$uploadId]['description'] = $db->f('description');
 59:             $aUploads[$uploadId]['author'] = $db->f('author');
 60:             $aUploads[$uploadId]['created'] = $db->f('created');
 61:             $aUploads[$uploadId]['lastmodified'] = $db->f('lastmodified');
 62:             $aUploads[$uploadId]['modifiedby'] = $db->f('modifiedby');
 63:             $aUploads[$uploadId]['idclient'] = $db->f('idclient');
 64:         }
 65: 
 66:         $aClientLanguages = array();
 67:         $sSql = "SELECT idclient, idlang FROM " . $cfg['tab']['clients_lang'] . " ORDER BY idclient ASC";
 68:         $db->query($sSql);
 69:         while ($db->nextRecord()) {
 70:             $clientId = $db->f('idclient');
 71:             $aClientLanguages[$clientId][] = $db->f('idlang');
 72:         }
 73: 
 74:         $bError = false;
 75:         $j = 0;
 76: 
 77:         foreach ($aUploads as $idupl => $elem) {
 78:             if ($elem['description'] == '') {
 79:                 continue;
 80:             }
 81: 
 82:             $clientId = $elem['idclient'];
 83:             if (isset($aClientLanguages[$clientId]) === false) {
 84:                 continue;
 85:             }
 86: 
 87:             foreach ($aClientLanguages[$clientId] as $idlang) {
 88:                 $aUplMeta = array();
 89:                 $sSql = "SELECT * FROM " . $cfg['tab']['upl_meta'] . " WHERE idlang = " . $idlang . "  AND idupl = " . $idupl . " ORDER BY id_uplmeta ASC";
 90:                 $db->query($sSql);
 91:                 $i = 0;
 92:                 while ($db->nextRecord()) {
 93:                     $aUplMeta[$i]['description'] = $db->f('description');
 94:                     $aUplMeta[$i]['id_uplmeta'] = $db->f('id_uplmeta');
 95:                     $i++;
 96:                 }
 97: 
 98:                 if (count($aUplMeta) < 1) {
 99:                     //there is no entry in con_upl_meta for this upload
100:                     $sSql = "INSERT INTO " . $cfg['tab']['upl_meta'] . " SET
101:                             idupl = $idupl,
102:                             idlang = $idlang,
103:                             medianame = '',
104:                             description = '" . $elem['description'] . "',
105:                             keywords = '',
106:                             internal_notice = '',
107:                             author = '" . $elem['author'] . "',
108:                             created = '" . $elem['created'] . "',
109:                             modified = '" . $elem['lastmodified'] . "',
110:                             modifiedby = '" . $elem['modifiedby'] . "',
111:                             copyright = ''";
112:                 } elseif (count($aUplMeta) == 1 && $aUplMeta[0]['description'] == '') {
113:                     //there is already an entry and the field "description" is empty
114:                     $sSql = "UPDATE " . $cfg['tab']['upl_meta'] . " SET
115:                             description = '" . $elem['description'] . "'
116:                             WHERE id_uplmeta = " . $aUplMeta[0]['id_uplmeta'];
117:                 } else {
118:                     //there is already an entry with an exising content in "description"
119:                     //do nothing;
120:                 }
121: 
122:                 $db->query($sSql);
123:                 if ($db->getErrorNumber() != 0) {
124:                     $bError = true;
125:                     $this->_logError($sSql . "\nMysql Error:" . $db->getErrorMessage() . "(" . $db->getErrorNumber() . ")");
126:                 }
127:             }
128: 
129:             $j++;
130:         }
131: 
132:         // At the end remove all values of con_upl.description and drop the field from table
133:         if ($bError === false && $j == count($aUploads)) {
134:             $sSql = "ALTER TABLE `" . $cfg['tab']['upl'] . "` DROP `description`";
135:             $db->query($sSql);
136:             if ($db->getErrorNumber() != 0) {
137:                 $this->_logError($sSql . "\nMysql Error:" . $db->getErrorMessage() . "(" . $db->getErrorNumber() . ")");
138:             }
139:         } else {
140:             $this->_logError("error on _updateUpl2Meta();" . $j . '==' . count($aUploads));
141:         }
142:     }
143: 
144: }
145: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0