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

Classes

  • cApiAction
  • cApiActionCollection
  • cApiActionlog
  • cApiActionlogCollection
  • cApiArea
  • cApiAreaCollection
  • cApiArticle
  • cApiArticleCollection
  • cApiArticleLanguage
  • cApiArticleLanguageCollection
  • cApiArticleLanguageVersion
  • cApiArticleLanguageVersionCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiContentVersion
  • cApiContentVersionCollection
  • cApiDbfs
  • cApiDbfsCollection
  • cApiFile
  • cApiFileCollection
  • cApiFileInformation
  • cApiFileInformationCollection
  • cApiFrameFile
  • cApiFrameFileCollection
  • cApiFrontendGroup
  • cApiFrontendGroupCollection
  • cApiFrontendGroupMember
  • cApiFrontendGroupMemberCollection
  • cApiFrontendPermission
  • cApiFrontendPermissionCollection
  • cApiFrontendUser
  • cApiFrontendUserCollection
  • cApiGroup
  • cApiGroupCollection
  • cApiGroupMember
  • cApiGroupMemberCollection
  • cApiGroupProperty
  • cApiGroupPropertyCollection
  • cApiInUse
  • cApiInUseCollection
  • cApiIso3166
  • cApiIso3166Collection
  • cApiIso6392
  • cApiIso6392Collection
  • cApiKeyword
  • cApiKeywordCollection
  • cApiLanguage
  • cApiLanguageCollection
  • cApiLayout
  • cApiLayoutCollection
  • cApiMailLog
  • cApiMailLogCollection
  • cApiMailLogSuccess
  • cApiMailLogSuccessCollection
  • cApiMetaTag
  • cApiMetaTagCollection
  • cApiMetaTagVersion
  • cApiMetaTagVersionCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserPasswordRequest
  • cApiUserPasswordRequestCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the action collection and item class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GenericDB_Model
  8:  * @author Timo Hummel
  9:  * @copyright four for business AG <www.4fb.de>
 10:  * @license http://www.contenido.org/license/LIZENZ.txt
 11:  * @link http://www.4fb.de
 12:  * @link http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Action collection.
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class cApiActionCollection extends ItemCollection {
 24: 
 25:     /**
 26:      * Constructor to create an instance of this class.
 27:      */
 28:     public function __construct() {
 29:         global $cfg;
 30:         parent::__construct($cfg['tab']['actions'], 'idaction');
 31:         $this->_setItemClass('cApiAction');
 32: 
 33:         // set the join partners so that joins can be used via link() method
 34:         $this->_setJoinPartner('cApiAreaCollection');
 35:     }
 36: 
 37:     /**
 38:      * Creates an action entry.
 39:      *
 40:      * @param string|int $area
 41:      * @param string|int $name
 42:      * @param string|int $alt_name [optional]
 43:      * @param string $code [optional]
 44:      * @param string $location [optional]
 45:      * @param int $relevant [optional]
 46:      *
 47:      * @return cApiAction
 48:      */
 49:     public function create($area, $name, $alt_name = '', $code = '', $location = '', $relevant = 1) {
 50:         $item = $this->createNewItem();
 51: 
 52:         if (is_string($area)) {
 53:             $c = new cApiArea();
 54:             $c->loadBy('name', $area);
 55:             if ($c->isLoaded()) {
 56:                 $area = $c->get('idarea');
 57:             } else {
 58:                 $area = 0;
 59:                 cWarning(__FILE__, __LINE__, "Could not resolve area [$area] passed to method [create], assuming 0");
 60:             }
 61:         }
 62: 
 63:         if (is_string($area)) {
 64:             $area = $this->escape($area);
 65:         }
 66:         if (is_string($name)) {
 67:             $name = $this->escape($name);
 68:         }
 69:         if (is_string($alt_name)) {
 70:             $alt_name = $this->escape($alt_name);
 71:         }
 72: 
 73:         $item->set('idarea', $area);
 74:         $item->set('name', $name);
 75:         $item->set('alt_name', $alt_name);
 76:         $item->set('code', $code);
 77:         $item->set('location', $location);
 78:         $item->set('relevant', $relevant);
 79: 
 80:         $item->store();
 81: 
 82:         return $item;
 83:     }
 84: 
 85:     /**
 86:      * Returns all actions available in the system.
 87:      *
 88:      * @return array
 89:      *         Array with id and name entries
 90:      */
 91:     public function getAvailableActions() {
 92:         global $cfg;
 93: 
 94:         $sql = "SELECT action.idaction, action.name, area.name AS areaname
 95:                 FROM `%s` AS action LEFT JOIN `%s` AS area
 96:                 ON area.idarea = action.idarea
 97:                 WHERE action.relevant = 1 ORDER BY action.name;";
 98: 
 99:         $this->db->query($sql, $this->table, $cfg['tab']['area']);
100: 
101:         $actions = array();
102: 
103:         while ($this->db->nextRecord()) {
104:             $newentry['name'] = $this->db->f('name');
105:             $newentry['areaname'] = $this->db->f('areaname');
106:             $actions[$this->db->f('idaction')] = $newentry;
107:         }
108: 
109:         return $actions;
110:     }
111: 
112:     /**
113:      * Return name of passed action.
114:      *
115:      * @param int $action
116:      *         Id of action
117:      * @return string|NULL
118:      */
119:     public function getActionName($action) {
120:         $this->db->query("SELECT name FROM `%s` WHERE idaction = %d", $this->table, $action);
121: 
122:         return ($this->db->nextRecord()) ? $this->db->f('name') : NULL;
123:     }
124: 
125:     /**
126:      * Returns the area for the given action.
127:      *
128:      * @param string|int
129:      *         Name or id of action
130:      * @return int|NULL
131:      *         with the area ID for the given action or NULL
132:      */
133:     function getAreaForAction($action) {
134:         if (!is_numeric($action)) {
135:             $this->db->query("SELECT idarea FROM `%s` WHERE name = '%s'", $this->table, $action);
136:         } else {
137:             $this->db->query("SELECT idarea FROM `%s` WHERE idaction = %d", $this->table, $action);
138:         }
139: 
140:         return ($this->db->nextRecord()) ? $this->db->f('idarea') : NULL;
141:     }
142: }
143: 
144: /**
145:  * Action item.
146:  *
147:  * @package Core
148:  * @subpackage GenericDB_Model
149:  */
150: class cApiAction extends Item {
151: 
152:     /**
153:      * Constructor to create an instance of this class.
154:      *
155:      * @param mixed $mId [optional]
156:      *         Specifies the ID of item to load
157:      */
158:     public function __construct($mId = false) {
159:         global $cfg;
160: 
161:         parent::__construct($cfg['tab']['actions'], 'idaction');
162:         $this->setFilters(array(
163:             'addslashes'
164:         ), array(
165:             'stripslashes'
166:         ));
167: 
168:         if ($mId !== false) {
169:             $this->loadByPrimaryKey($mId);
170:         }
171: 
172:         // @todo Where is this used???
173:         $this->_wantParameters = array();
174:     }
175: 
176:     /**
177:      * Userdefined setter for action fields.
178:      *
179:      * @param string $name
180:      * @param mixed $value
181:      * @param bool $bSafe [optional]
182:      *         Flag to run defined inFilter on passed value
183:      * @return bool
184:      */
185:     public function setField($name, $value, $bSafe = true) {
186:         switch ($name) {
187:              case 'relevant':
188:                 $value = (int) $value;
189:                 break;
190:         }
191: 
192:         return parent::setField($name, $value, $bSafe);
193:     }
194: 
195: }
196: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0