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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the CONTENIDO module functions.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Jan Lengowski
 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: cInclude('includes', 'functions.tpl.php');
 19: cInclude('includes', 'functions.con.php');
 20: 
 21: /**
 22:  * Saves changes of modules and regenerates code cache if required
 23:  * @param int $idmod module id
 24:  * @param string $name name of the module
 25:  * @param string $description module description text
 26:  * @param string $input module input content
 27:  * @param string $output module output content
 28:  * @param string $template template field in module's database entry (seems deprecated)
 29:  * @param string $type module type (common values are '', 'content', 'head', 'layout', 'navigation' and 'script')
 30:  * @return mixed idmod or nothing
 31:  */
 32: function modEditModule($idmod, $name, $description, $input, $output, $template, $type = '') {
 33:     global $db, $client, $cfgClient, $auth, $cfg, $sess, $area, $area_tree, $perm, $frame;
 34:     $description = stripslashes($description);
 35: 
 36:     $date = date('Y-m-d H:i:s');
 37:     $author = $auth->auth['uname'];
 38:     $contenidoModuleHandler = '';
 39:     $messageIfError = '';
 40: 
 41:     // Alias for modul name for the file system
 42:     $alias = strtolower(cModuleHandler::getCleanName($name));
 43: 
 44:     // Track version
 45:     $oVersion = new cVersionModule($idmod, $cfg, $cfgClient, $db, $client, $area, $frame);
 46:     $oVersion->createNewVersion();
 47: 
 48:     if (!$idmod) {
 49:         $cApiModuleCollection = new cApiModuleCollection();
 50:         $cApiModule = $cApiModuleCollection->create($name);
 51: 
 52:         $idmod = $cApiModule->get('idmod');
 53: 
 54:         cInclude('includes', 'functions.rights.php');
 55:         createRightsForElement('mod', $idmod);
 56:     } else {
 57:         $cApiModule = new cApiModule($idmod);
 58:     }
 59: 
 60:     $contenidoModuleHandler = new cModuleHandler($idmod);
 61: 
 62:     // Save contents of input or output
 63:     $retInput = $contenidoModuleHandler->saveInput(stripslashes($input));
 64:     $retOutput = $contenidoModuleHandler->saveOutput(stripslashes($output));
 65: 
 66:     // clear the client cache if the module code was written successfully
 67:     if ($retInput || $retOutput) {
 68:         $purge = new cSystemPurge();
 69:         $purge->clearClientCache($client);
 70:     }
 71: 
 72:     if ($cApiModule->get('name') != stripslashes($name) || $cApiModule->get('alias') != stripslashes($alias) || $cApiModule->get('template') != stripslashes($template) || $cApiModule->get('description') != stripslashes($description) || $cApiModule->get('type') != stripslashes($type)) {
 73: 
 74:         // Rename the module if the name changed
 75:         $change = false;
 76:         $oldName = $cApiModule->get('alias');
 77: 
 78:         if ($cApiModule->get('alias') != $alias) {
 79:             $change = true;
 80:             // if modul exist show message
 81:             if ($contenidoModuleHandler->modulePathExistsInDirectory($alias)) {
 82:                 cRegistry::addErrorMessage(i18n('Module name exist in module directory, please choose another name.'));
 83:                 $page = new cGuiPage('generic_page');
 84:                 $page->abortRendering();
 85:                 $page->render();
 86:                 die();
 87:             }
 88:         }
 89: 
 90:         // Name of module changed
 91:         if ($change == true) {
 92:             cRegistry::addInfoMessage(i18n('Renamed module successfully!'));
 93:             $cApiModule->set('name', $name);
 94:             $cApiModule->set('template', $template);
 95:             $cApiModule->set('description', $description);
 96:             $cApiModule->set('type', $type);
 97:             $cApiModule->set('lastmodified', date('Y-m-d H:i:s'));
 98: 
 99:             // False: The new name of modul dont exist im modul dir
100:             if ($contenidoModuleHandler->renameModul($oldName, $alias) == false) {
101:                 cRegistry::addWarningMessage(i18n("Can't rename module, is a module file open?! Saving only database changes!"));
102:             } else {
103:                 $cApiModule->set('alias', $alias);
104:             }
105: 
106:             $cApiModule->store();
107: 
108:             // Set the new module name
109:             $contenidoModuleHandler->changeModuleName($alias);
110:             // Save input and output in file
111:             if ($contenidoModuleHandler->saveInput(stripslashes($input)) == false) {
112:                 $messageIfError .= '<br>' . i18n("Can't save input !");
113:             }
114: 
115:             if ($contenidoModuleHandler->saveOutput(stripslashes($output)) == false) {
116:                 $messageIfError .= '<br>' . i18n("Can't save output !");
117:             }
118: 
119:             if ($contenidoModuleHandler->saveInfoXML($name, $description, $type, $alias) == false) {
120:                 $messageIfError .= '<br>' . i18n("Can't save xml module info file!");
121:             }
122: 
123:             // Display error
124:             if ($messageIfError !== '') {
125:                 cRegistry::addErrorMessage($messageIfError);
126:                 // Set the old name because module could not be renamed
127:                 $cApiModule->set('name', $oldName);
128:                 $cApiModule->store();
129:             }
130:         } else {
131:             $cApiModule->set('name', $name);
132:             $cApiModule->set('template', $template);
133:             $cApiModule->set('description', $description);
134:             $cApiModule->set('type', $type);
135:             $cApiModule->set('lastmodified', date('Y-m-d H:i:s'));
136:             $cApiModule->set('alias', $alias);
137:             $cApiModule->store();
138: 
139:             if ($contenidoModuleHandler->saveInfoXML($name, $description, $type, $alias) == false) {
140:                 cRegistry::addErrorMessage(i18n("Can't save xml module info file!"));
141:             }
142: 
143:             if ($retInput === true && $retOutput === true) {
144:                 cRegistry::addInfoMessage(i18n('Saved module successfully!'));
145:             } else {
146:                 $messageIfError = '<br>' . i18n("Can't save input !");
147:                 $messageIfError .= '<br>' . i18n("Can't save output !");
148:                 cRegistry::addErrorMessage($messageIfError);
149:             }
150:         }
151:     } else {
152:         // No changes for save
153:         if ($retInput == true && $retOutput == true) {
154:             // regenerate code cache because module input and output got saved 
155:             $cApiModule->store();
156:             cRegistry::addInfoMessage(i18n('Saved module successfully!'));
157:         } else {
158:             $messageIfError = i18n("Can't save input !");
159:             $messageIfError .= ' ' . i18n("Can't save output !");
160:             cRegistry::addErrorMessage($messageIfError);
161:         }
162:     }
163: 
164:     return $idmod;
165: }
166: 
167: // @fixme: Document me!
168: function modDeleteModule($idmod) {
169:     global $db, $sess, $client, $cfg, $area_tree, $perm;
170: 
171:     $sql = 'DELETE FROM ' . $cfg['tab']['mod'] . ' WHERE idmod = ' . (int) $idmod . ' AND idclient = ' . (int) $client;
172:     $db->query($sql);
173: 
174:     // Delete rights for element
175:     cInclude('includes', 'functions.rights.php');
176:     deleteRightsForElement('mod', $idmod);
177: }
178: 
179: /**
180:  * @deprecated [2013-10-02]  This function is not longer supported and will always return false.
181:  */
182: function modTestModule($code, $id, $output = false) {
183:     cDeprecated("This function is not longer supported and will always return false. Use cModuleHandler::testInput() and cModuleHandler::testOutput() instead.");
184:     return false;
185: }
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen