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:  * This file contains the action collection and item class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB_Model
  7:  * @author Timo Hummel
  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:  * Action collection.
 18:  *
 19:  * @package Core
 20:  * @subpackage GenericDB_Model
 21:  */
 22: class cApiActionCollection extends ItemCollection {
 23: 
 24:     /**
 25:      * Constructor.
 26:      */
 27:     public function __construct() {
 28:         global $cfg;
 29:         parent::__construct($cfg['tab']['actions'], 'idaction');
 30:         $this->_setItemClass('cApiAction');
 31: 
 32:         // set the join partners so that joins can be used via link() method
 33:         $this->_setJoinPartner('cApiAreaCollection');
 34:     }
 35: 
 36:     /**
 37:      * Creates an action entry.
 38:      *
 39:      * @param string|int $area
 40:      * @param string|int $name
 41:      * @param string|int $alt_name [optional]
 42:      * @param string $code [optional]
 43:      * @param string $location [optional]
 44:      * @param int $relevant [optional]
 45:      *
 46:      * @return cApiAction
 47:      */
 48:     public function create($area, $name, $alt_name = '', $code = '', $location = '', $relevant = 1) {
 49:         $item = $this->createNewItem();
 50: 
 51:         if (is_string($area)) {
 52:             $c = new cApiArea();
 53:             $c->loadBy('name', $area);
 54:             if ($c->isLoaded()) {
 55:                 $area = $c->get('idarea');
 56:             } else {
 57:                 $area = 0;
 58:                 cWarning(__FILE__, __LINE__, "Could not resolve area [$area] passed to method [create], assuming 0");
 59:             }
 60:         }
 61: 
 62:         if (is_string($area)) {
 63:             $area = $this->escape($area);
 64:         }
 65:         if (is_string($name)) {
 66:             $name = $this->escape($name);
 67:         }
 68:         if (is_string($alt_name)) {
 69:             $alt_name = $this->escape($alt_name);
 70:         }
 71: 
 72:         $item->set('idarea', $area);
 73:         $item->set('name', $name);
 74:         $item->set('alt_name', $alt_name);
 75:         $item->set('code', $code);
 76:         $item->set('location', $location);
 77:         $item->set('relevant', $relevant);
 78: 
 79:         $item->store();
 80: 
 81:         return $item;
 82:     }
 83: 
 84:     /**
 85:      * Returns all actions available in the system.
 86:      *
 87:      * @return array
 88:      *         Array with id and name entries
 89:      */
 90:     public function getAvailableActions() {
 91:         global $cfg;
 92: 
 93:         $sql = "SELECT action.idaction, action.name, area.name AS areaname
 94:                 FROM `%s` AS action LEFT JOIN `%s` AS area
 95:                 ON area.idarea = action.idarea
 96:                 WHERE action.relevant = 1 ORDER BY action.name;";
 97: 
 98:         $this->db->query($sql, $this->table, $cfg['tab']['area']);
 99: 
100:         $actions = array();
101: 
102:         while ($this->db->nextRecord()) {
103:             $newentry['name'] = $this->db->f('name');
104:             $newentry['areaname'] = $this->db->f('areaname');
105:             $actions[$this->db->f('idaction')] = $newentry;
106:         }
107: 
108:         return $actions;
109:     }
110: 
111:     /**
112:      * Return name of passed action.
113:      *
114:      * @param int $action
115:      *         Id of action
116:      * @return string|NULL
117:      */
118:     public function getActionName($action) {
119:         $this->db->query("SELECT name FROM `%s` WHERE idaction = %d", $this->table, $action);
120: 
121:         return ($this->db->nextRecord()) ? $this->db->f('name') : NULL;
122:     }
123: 
124:     /**
125:      * Returns the area for the given action.
126:      *
127:      * @param string|int
128:      *         Name or id of action
129:      * @return int|NULL
130:      *         with the area ID for the given action or NULL
131:      */
132:     function getAreaForAction($action) {
133:         if (!is_numeric($action)) {
134:             $this->db->query("SELECT idarea FROM `%s` WHERE name = '%s'", $this->table, $action);
135:         } else {
136:             $this->db->query("SELECT idarea FROM `%s` WHERE idaction = %d", $this->table, $action);
137:         }
138: 
139:         return ($this->db->nextRecord()) ? $this->db->f('idarea') : NULL;
140:     }
141: }
142: 
143: /**
144:  * Action item.
145:  *
146:  * @package Core
147:  * @subpackage GenericDB_Model
148:  */
149: class cApiAction extends Item {
150: 
151:     /**
152:      * Constructor.
153:      *
154:      * @param mixed $mId [optional]
155:      *         Specifies the ID of item to load
156:      */
157:     public function __construct($mId = false) {
158:         global $cfg;
159: 
160:         parent::__construct($cfg['tab']['actions'], 'idaction');
161:         $this->setFilters(array(
162:             'addslashes'
163:         ), array(
164:             'stripslashes'
165:         ));
166: 
167:         if ($mId !== false) {
168:             $this->loadByPrimaryKey($mId);
169:         }
170: 
171:         // @todo Where is this used???
172:         $this->_wantParameters = array();
173:     }
174: 
175:     /**
176:      * Userdefined setter for action fields.
177:      *
178:      * @param string $name
179:      * @param mixed $value
180:      * @param bool $bSafe [optional]
181:      *         Flag to run defined inFilter on passed value
182:      * @return bool
183:      */
184:     public function setField($name, $value, $bSafe = true) {
185:         switch ($name) {
186:              case 'relevant':
187:                 $value = (int) $value;
188:                 break;
189:         }
190: 
191:         return parent::setField($name, $value, $bSafe);
192:     }
193: 
194: }
195: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0