Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • 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
  • 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
  • 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:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Timo Hummel
 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: /**
 19:  * Action collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiActionCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor
 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
 44:      * @param string $code
 45:      * @param string $location
 46:      * @param int $relevant
 47:      *
 48:      * @return cApiAction
 49:      */
 50:     public function create($area, $name, $alt_name = '', $code = '', $location = '', $relevant = 1) {
 51:         $item = $this->createNewItem();
 52: 
 53:         if (is_string($area)) {
 54:             $c = new cApiArea();
 55:             $c->loadBy('name', $area);
 56:             if ($c->isLoaded()) {
 57:                 $area = $c->get('idarea');
 58:             } else {
 59:                 $area = 0;
 60:                 cWarning(__FILE__, __LINE__, "Could not resolve area [$area] passed to method [create], assuming 0");
 61:             }
 62:         }
 63: 
 64:         if (is_string($area)) {
 65:             $area = $this->escape($area);
 66:         }
 67:         if (is_string($name)) {
 68:             $name = $this->escape($name);
 69:         }
 70:         if (is_string($alt_name)) {
 71:             $alt_name = $this->escape($alt_name);
 72:         }
 73: 
 74:         $item->set('idarea', $area);
 75:         $item->set('name', $name);
 76:         $item->set('alt_name', $alt_name);
 77:         $item->set('code', $code);
 78:         $item->set('location', $location);
 79:         $item->set('relevant', $relevant);
 80: 
 81:         $item->store();
 82: 
 83:         return $item;
 84:     }
 85: 
 86:     /**
 87:      * Returns all actions available in the system
 88:      *
 89:      * @return array 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 Id of action
116:      *
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 Name or id of action
129:      *
130:      * @return int NULL 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:      *
153:      * @var bool
154:      * @deprecated is not used by any core class
155:      */
156:     protected $_objectInvalid = false;
157: 
158:     /**
159:      * Constructor Function
160:      *
161:      * @param mixed $mId Specifies the ID of item to load
162:      */
163:     public function __construct($mId = false) {
164:         global $cfg;
165: 
166:         parent::__construct($cfg['tab']['actions'], 'idaction');
167:         $this->setFilters(array(
168:             'addslashes'
169:         ), array(
170:             'stripslashes'
171:         ));
172: 
173:         if ($mId !== false) {
174:             $this->loadByPrimaryKey($mId);
175:         }
176: 
177:         // @todo Where is this used???
178:         $this->_wantParameters = array();
179:     }
180: 
181:     /**
182:      * Userdefined setter for action fields.
183:      *
184:      * @param string $name
185:      * @param mixed $value
186:      * @param bool $bSafe Flag to run defined inFilter on passed value
187:      */
188:     public function setField($name, $value, $bSafe = true) {
189:         switch ($name) {
190:              case 'relevant':
191:                 $value = (int) $value;
192:                 break;
193:         }
194: 
195:         return parent::setField($name, $value, $bSafe);
196:     }
197: 
198: }
199: 
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0