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

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