Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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
  • cUpgradeJob_0013
  • cUpgradeJob_0014
  • cUpgradeJob_0015
  • cUpgradeJob_0016
  • cUpgradeJob_0017
  • cUpgradeJob_0018
  • 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:  * @author     Murat Purc <murat@purc>
  8:  * @copyright  four for business AG <www.4fb.de>
  9:  * @license    http://www.contenido.org/license/LIZENZ.txt
 10:  * @link       http://www.4fb.de
 11:  * @link       http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Upgrade job 4.
 18:  * Runs the upgrade job to takeover some properties from upload to upload_meta
 19:  *
 20:  * @package Setup
 21:  * @subpackage UpgradeJob
 22:  */
 23: class cUpgradeJob_0004 extends cUpgradeJobAbstract {
 24: 
 25:     public $maxVersion = "4.9.0-beta1";
 26: 
 27:     public function _execute() {
 28:         global $cfg;
 29: 
 30:         if ($this->_setupType != 'setup') {
 31:             $done = false;
 32:             $sSql = "SHOW COLUMNS FROM " . $cfg['tab']['upl'];
 33:             $this->_oDb->query($sSql);
 34:             while ($this->_oDb->nextRecord()) {
 35:                 if ($this->_oDb->f("Field") == 'description') {
 36:                     $done = true;
 37:                 }
 38:             }
 39:             if ($done) {
 40:                 $this->_updateUpl2Meta();
 41:             }
 42:         }
 43:     }
 44: 
 45:     //update description from con_upl to con_upl_meta
 46:     protected function _updateUpl2Meta() {
 47:         global $cfg;
 48: 
 49:         $db = $this->_oDb;
 50:         $aUploads = array();
 51:         $sSql = "SELECT * FROM " . $cfg['tab']['upl'] . " WHERE `description` != '' ORDER BY idupl ASC";
 52:         $db->query($sSql);
 53: 
 54:         while ($db->nextRecord()) {
 55:             $uploadId = $db->f('idupl');
 56:             $aUploads[$uploadId]['description'] = $db->f('description');
 57:             $aUploads[$uploadId]['author'] = $db->f('author');
 58:             $aUploads[$uploadId]['created'] = $db->f('created');
 59:             $aUploads[$uploadId]['lastmodified'] = $db->f('lastmodified');
 60:             $aUploads[$uploadId]['modifiedby'] = $db->f('modifiedby');
 61:             $aUploads[$uploadId]['idclient'] = $db->f('idclient');
 62:         }
 63: 
 64:         $aClientLanguages = array();
 65:         $sSql = "SELECT idclient, idlang FROM " . $cfg['tab']['clients_lang'] . " ORDER BY idclient ASC";
 66:         $db->query($sSql);
 67:         while ($db->nextRecord()) {
 68:             $clientId = $db->f('idclient');
 69:             $aClientLanguages[$clientId][] = $db->f('idlang');
 70:         }
 71: 
 72:         $bError = false;
 73:         $j = 0;
 74: 
 75:         foreach ($aUploads as $idupl => $elem) {
 76:             if ($elem['description'] == '') {
 77:                 continue;
 78:             }
 79: 
 80:             $clientId = $elem['idclient'];
 81:             if (isset($aClientLanguages[$clientId]) === false) {
 82:                 continue;
 83:             }
 84: 
 85:             foreach ($aClientLanguages[$clientId] as $idlang) {
 86:                 $aUplMeta = array();
 87:                 $sSql = "SELECT * FROM " . $cfg['tab']['upl_meta'] . " WHERE idlang = " . $idlang . "  AND idupl = " . $idupl . " ORDER BY id_uplmeta ASC";
 88:                 $db->query($sSql);
 89:                 $i = 0;
 90:                 while ($db->nextRecord()) {
 91:                     $aUplMeta[$i]['description'] = $db->f('description');
 92:                     $aUplMeta[$i]['id_uplmeta'] = $db->f('id_uplmeta');
 93:                     $i++;
 94:                 }
 95: 
 96:                 if (count($aUplMeta) < 1) {
 97:                     //there is no entry in con_upl_meta for this upload
 98:                     $sSql = "INSERT INTO " . $cfg['tab']['upl_meta'] . " SET
 99:                             idupl = $idupl,
100:                             idlang = $idlang,
101:                             medianame = '',
102:                             description = '" . $elem['description'] . "',
103:                             keywords = '',
104:                             internal_notice = '',
105:                             author = '" . $elem['author'] . "',
106:                             created = '" . $elem['created'] . "',
107:                             modified = '" . $elem['lastmodified'] . "',
108:                             modifiedby = '" . $elem['modifiedby'] . "',
109:                             copyright = ''";
110:                 } elseif (count($aUplMeta) == 1 && $aUplMeta[0]['description'] == '') {
111:                     //there is already an entry and the field "description" is empty
112:                     $sSql = "UPDATE " . $cfg['tab']['upl_meta'] . " SET
113:                             description = '" . $elem['description'] . "'
114:                             WHERE id_uplmeta = " . $aUplMeta[0]['id_uplmeta'];
115:                 } else {
116:                     //there is already an entry with an exising content in "description"
117:                     //do nothing;
118:                 }
119: 
120:                 $db->query($sSql);
121:                 if ($db->getErrorNumber() != 0) {
122:                     $bError = true;
123:                     $this->_logError($sSql . "\nMysql Error:" . $db->getErrorMessage() . "(" . $db->getErrorNumber() . ")");
124:                 }
125:             }
126: 
127:             $j++;
128:         }
129: 
130:         // At the end remove all values of con_upl.description and drop the field from table
131:         if ($bError === false && $j == count($aUploads)) {
132:             $sSql = "ALTER TABLE `" . $cfg['tab']['upl'] . "` DROP `description`";
133:             $db->query($sSql);
134:             if ($db->getErrorNumber() != 0) {
135:                 $this->_logError($sSql . "\nMysql Error:" . $db->getErrorMessage() . "(" . $db->getErrorNumber() . ")");
136:             }
137:         } else {
138:             $this->_logError("error on _updateUpl2Meta();" . $j . '==' . count($aUploads));
139:         }
140:     }
141: 
142: }
143: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0