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