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 right collection and item class.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       GenericDB_Model
  8:  * @author           Murat Purc <murat@purc.de>
  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:  * Right collection
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class cApiRightCollection 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']['rights'], 'idright');
 31:         $this->_setItemClass('cApiRight');
 32: 
 33:         // set the join partners so that joins can be used via link() method
 34:         $this->_setJoinPartner('cApiUserCollection');
 35:         $this->_setJoinPartner('cApiAreaCollection');
 36:         $this->_setJoinPartner('cApiActionCollection');
 37:         $this->_setJoinPartner('cApiCategoryCollection');
 38:         $this->_setJoinPartner('cApiClientCollection');
 39:         $this->_setJoinPartner('cApiLanguageCollection');
 40:     }
 41: 
 42:     /**
 43:      * Creates a right entry.
 44:      *
 45:      * @param string $userId
 46:      * @param int $idarea
 47:      * @param int $idaction
 48:      * @param int $idcat
 49:      * @param int $idclient
 50:      * @param int $idlang
 51:      * @param int $type
 52:      * @return cApiRight
 53:      */
 54:     public function create($userId, $idarea, $idaction, $idcat, $idclient, $idlang, $type) {
 55:         $oItem = $this->createNewItem();
 56: 
 57:         $oItem->set('user_id', $userId);
 58:         $oItem->set('idarea', $idarea);
 59:         $oItem->set('idaction', $idaction);
 60:         $oItem->set('idcat', $idcat);
 61:         $oItem->set('idclient', $idclient);
 62:         $oItem->set('idlang', $idlang);
 63:         $oItem->set('type', $type);
 64: 
 65:         $oItem->store();
 66: 
 67:         return $oItem;
 68:     }
 69: 
 70:     /**
 71:      * Checks if a specific user has frontend access to a protected category.
 72:      *
 73:      * @param int $idcat
 74:      * @param string $userId
 75:      * @return bool
 76:      */
 77:     public function hasFrontendAccessByCatIdAndUserId($idcat, $userId) {
 78:         global $cfg;
 79: 
 80:         $sql = "SELECT :pk FROM `:rights` AS A, `:actions` AS B, `:area` AS C
 81:                 WHERE B.name = 'front_allow' AND C.name = 'str' AND A.user_id = ':userid'
 82:                     AND A.idcat = :idcat AND A.idarea = C.idarea AND B.idaction = A.idaction
 83:                 LIMIT 1";
 84: 
 85:         $params = array(
 86:             'pk' => $this->getPrimaryKeyName(),
 87:             'rights' => $this->table,
 88:             'actions' => $cfg['tab']['actions'],
 89:             'area' => $cfg['tab']['area'],
 90:             'userid' => $userId,
 91:             'idcat' => (int) $idcat
 92:         );
 93: 
 94:         $sql = $this->db->prepare($sql, $params);
 95:         $this->db->query($sql);
 96:         return $this->db->nextRecord();
 97:     }
 98: 
 99:     /**
100:      * Deletes right entries by user id.
101:      *
102:      * @todo Implement functions to delete rights by area, action, cat, client,
103:      *       language.
104:      * @param string $userId
105:      * @return bool
106:      */
107:     public function deleteByUserId($userId) {
108:         $result = $this->deleteBy('user_id', $userId);
109:         return ($result > 0) ? true : false;
110:     }
111: 
112: }
113: 
114: /**
115:  * Right item
116:  *
117:  * @package Core
118:  * @subpackage GenericDB_Model
119:  */
120: class cApiRight extends Item {
121: 
122:     /**
123:      * Constructor to create an instance of this class.
124:      *
125:      * @param mixed $mId [optional]
126:      *         Specifies the ID of item to load
127:      */
128:     public function __construct($mId = false) {
129:         global $cfg;
130:         parent::__construct($cfg['tab']['rights'], 'idright');
131:         $this->setFilters(array(), array());
132:         if ($mId !== false) {
133:             $this->loadByPrimaryKey($mId);
134:         }
135:     }
136: 
137:     /**
138:      * Userdefined setter for right fields.
139:      *
140:      * @param string $name
141:      * @param mixed $value
142:      * @param bool $bSafe [optional]
143:      *         Flag to run defined inFilter on passed value
144:      * @return bool
145:      */
146:     public function setField($name, $value, $bSafe = true) {
147:         switch ($name) {
148:             case 'idarea':
149:                 $value = (int) $value;
150:                 break;
151:             case 'idaction':
152:                 $value = (int) $value;
153:                 break;
154:             case 'idcat':
155:                 $value = (int) $value;
156:                 break;
157:             case 'idclient':
158:                 $value = (int) $value;
159:                 break;
160:             case 'idlang':
161:                 $value = (int) $value;
162:                 break;
163:             case 'type':
164:                 $value = (int) $value;
165:                 break;
166:         }
167: 
168:         return parent::setField($name, $value, $bSafe);
169:     }
170: 
171: }
172: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0