Project

General

Profile

« Previous | Next » 

Revision 1648

Added by darkviper over 12 years ago

a litte fix in /admin/addons/index.php.
added unregister_Theme to CopyTheme::_doRollback()
added CopyTheme::_activateTheme()

View differences:

CopyTheme.php
38 38
		$this->_aLang = $GLOBALS['MESSAGE'];
39 39
	// import global Consts
40 40
		$this->_aGlobals['TablePrefix']     = TABLE_PREFIX;
41
		$this->_aGlobals['AddonTable']      = 'addons';
42
		$this->_aGlobals['SettingsTable']   = 'settings';
43

  
41 44
		$this->_aGlobals['Debug']           = (defined('DEBUG') && DEBUG === true);
42 45
		$this->_aGlobals['IsLinux']         = ((substr(__FILE__, 0, 1)) == '/');
43 46
		$this->_aGlobals['StringDirMode']   = STRING_DIR_MODE;
......
62 65
		if($this->_copyTree()) {
63 66
			if($this->_modifyInfoFile()) {
64 67
				if($this->_registerNewTheme()) {
65
					return true;
68
					if($this->_activateTheme()) {
69
						return true;
70
					}
66 71
				}
67 72
			}
68 73
		}
......
96 101
		$iCount = '';
97 102
		do {
98 103
			$sSearch = $sName.($iCount ? ' '.$iCount : '');
99
			$sql = 'SELECT COUNT(*) FROM `'.$this->_aGlobals['TablePrefix'].'addons` '
104
			$sql = 'SELECT COUNT(*) '
105
			     . 'FROM `'.$this->_aGlobals['TablePrefix'].$this->_aGlobals['AddonTable'].'` '
100 106
				 . 'WHERE LOWER(`name`)=\''.strtolower($sSearch).'\' AND `function`=\'theme\'';
101 107
			$exists = $this->_oDb->get_one($sql);
102 108
			$iCount = (int)$iCount + 1;
......
118 124
		$iCount = '';
119 125
		do {
120 126
			$sSearch = $sName.($iCount ? '_'.$iCount : '');
121
			$sql = 'SELECT COUNT(*) FROM `'.$this->_aGlobals['TablePrefix'].'addons` '
127
			$sql = 'SELECT COUNT(*) '
128
			     . 'FROM `'.$this->_aGlobals['TablePrefix'].$this->_aGlobals['AddonTable'].'` '
122 129
				 . 'WHERE `directory`=\''.$sSearch.'\' AND `function`=\'theme\'';
123 130
			$exists = $this->_oDb->get_one($sql);
124 131
			$iCount = (int)$iCount + 1;
......
231 238
		$bRetval = true;
232 239
		$sThemeInfoFile = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir.'/info.php';
233 240
		$aVariables = $this->_getThemeInfo($sThemeInfoFile);
234
		$sql = 'INSERT INTO `'.$this->_aGlobals['TablePrefix'].'addons` '
241
		$sql = 'INSERT INTO `'.$this->_aGlobals['TablePrefix'].$this->_aGlobals['AddonTable'].'` '
235 242
		     . 'SET `type`=\'template\', '
236 243
		     .     '`function`=\'theme\', '
237 244
		     .     '`directory`=\''.$aVariables['directory'].'\', '
......
312 319
		}
313 320
	}
314 321
/**
322
 * activates the new theme
323
 * @return boolean
324
 */
325
	private function _activateTheme()
326
	{
327
		$bRetval = true;
328
		if(!db_update_key_value( $this->_aGlobals['SettingsTable'],
329
		                         'default_theme',
330
		                         $value = $this->_sNewThemeDir))
331
		{
332
			$sMsg = 'CopyTheme::activateTheme('.$this->_sNewThemeName.') >> '
333
			        .$this->_aLang['GENERIC_NOT_UPGRADED'];
334
			$sMsg .= (($this->_aGlobals['Debug']) ? '<br />'.$this->_oDb->get_error() : '');
335
			$this->_setError($sMsg);
336
			$bRetval = false;
337
		}
338
		return $bRetval;
339
	}
340
/**
315 341
 * on Error undo all already done copy/create actions
316 342
 * @param string $dir
317 343
 */
......
331 357
		unset($path);
332 358
		unset($iterator);
333 359
		if(file_exists($dir)) { rmdir($dir); }
360
		$sql = 'DELETE FROM `'.$this->_aGlobals['TablePrefix'].$this->_aGlobals['AddonTable'].'` '
361
		     . 'WHERE `directory`=\''.$this->_sNewThemeDir.'\' AND `function`=\'theme\'';
362
		$this->_oDb->query($sql);
334 363
	}
335 364
/**
336 365
 * add a new error message to the queue

Also available in: Unified diff