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
    • NavigationMain
    • 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
  • 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 client collection and item class.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       GenericDB_Model
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Bjoern Behrens
 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:  * Client collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiClientCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor
 28:      */
 29:     public function __construct() {
 30:         global $cfg;
 31:         parent::__construct($cfg['tab']['clients'], 'idclient');
 32:         $this->_setItemClass('cApiClient');
 33:     }
 34: 
 35:     /**
 36:      * Creates a new client entry
 37:      *
 38:      * @global object $auth
 39:      * @param string $name
 40:      * @param int $errsite_cat
 41:      * @param int $errsite_art
 42:      * @param string $author
 43:      * @param string $created
 44:      * @param string $lastmodified
 45:      * @return cApiClient
 46:      */
 47:     public function create($name, $errsite_cat = 0, $errsite_art = 0, $author = '', $created = '', $lastmodified = '') {
 48:         global $auth;
 49: 
 50:         if (empty($author)) {
 51:             $author = $auth->auth['uname'];
 52:         }
 53:         if (empty($created)) {
 54:             $created = date('Y-m-d H:i:s');
 55:         }
 56:         if (empty($lastmodified)) {
 57:             $lastmodified = date('Y-m-d H:i:s');
 58:         }
 59: 
 60:         $item = parent::createNewItem();
 61:         $item->set('name', $name);
 62:         $item->set('errsite_cat', $errsite_cat);
 63:         $item->set('errsite_art', $errsite_art);
 64:         $item->set('author', $author);
 65:         $item->set('created', $created);
 66:         $item->set('lastmodified', $lastmodified);
 67:         $item->store();
 68: 
 69:         return $item;
 70:     }
 71: 
 72:     /**
 73:      * Returns all clients available in the system
 74:      *
 75:      * @return array Array with id and name entries
 76:      */
 77:     public function getAvailableClients() {
 78:         $clients = array();
 79: 
 80:         $this->select();
 81: 
 82:         while (($item = $this->next()) !== false) {
 83:             $clients[$item->get('idclient')] = array(
 84:                 'name' => $item->get('name')
 85:             );
 86:         }
 87: 
 88:         return $clients;
 89:     }
 90: 
 91:     /**
 92:      * Returns all clients available in the system
 93:      *
 94:      * @return array Array with id and name entries
 95:      */
 96:     public function getAccessibleClients() {
 97:         global $perm;
 98:         $clients = array();
 99:         $this->select();
100:         while (($item = $this->next()) !== false) {
101:             if ($perm->have_perm_client("client[" . $item->get('idclient') . "]") || $perm->have_perm_client("admin[" . $item->get('idclient') . "]") || $perm->have_perm_client()) {
102:                 $clients[$item->get('idclient')] = array(
103:                     'name' => $item->get('name')
104:                 );
105:             }
106:         }
107:         return $clients;
108:     }
109: 
110:     /**
111:      * Returns first client available in the system
112:      *
113:      * @return cApiClient|null
114:      */
115:     public function getFirstAccessibleClient() {
116:         global $perm;
117:         $this->select();
118:         while (($item = $this->next()) !== false) {
119:             if ($perm->have_perm_client("client[" . $item->get('idclient') . "]") || $perm->have_perm_client("admin[" . $item->get('idclient') . "]")) {
120:                 return $item;
121:             }
122:         }
123:         return null;
124:     }
125: 
126:     /**
127:      * Returns the clientname of the given clientid
128:      *
129:      * @param int $idClient
130:      * @return string Clientname if found, or empty string if not.
131:      */
132:     public function getClientname($idClient) {
133:         $this->select("idclient='" . (int) $idClient . "'");
134:         if (($item = $this->next()) !== false) {
135:             return $item->get('name');
136:         } else {
137:             return i18n("No client");
138:         }
139:     }
140: 
141:     /**
142:      * Returns if the given client has a language
143:      *
144:      * @param int $idClient
145:      * @return bool true if the client has a language
146:      */
147:     public function hasLanguageAssigned($idClient) {
148:         $client = new cApiClient($idClient);
149: 
150:         return $client->hasLanguages();
151:     }
152: 
153: }
154: 
155: /**
156:  * Class cApiClient, client item
157:  *
158:  * @package Core
159:  * @subpackage GenericDB_Model
160:  * @author Marco Jahn
161:  */
162: class cApiClient extends Item {
163: 
164:     public $idclient;
165: 
166:     /**
167:      * Property collection instance
168:      *
169:      * @var cApiPropertyCollection
170:      */
171:     protected $_oPropertyCollection;
172: 
173:     /**
174:      * Constructor Function
175:      *
176:      * @param mixed $id Specifies the ID of item to load
177:      */
178:     public function __construct($id = false) {
179:         global $cfg;
180:         parent::__construct($cfg['tab']['clients'], 'idclient');
181:         if ($id !== false) {
182:             $this->loadByPrimaryKey($id);
183:         }
184:     }
185: 
186:     /**
187:      * Static accessor to the singleton instance.
188:      *
189:      * @todo There is no need since caching is available at GenericDB level
190:      * @param int $client
191:      * @return cApiClient Reference to the singleton instance.
192:      */
193:     public static function getInstance($client = false) {
194:         static $currentInstance = array();
195: 
196:         if (!$client) {
197:             // Use global $client
198:             $client = cRegistry::getClientId();
199:         }
200: 
201:         if (!isset($currentInstance[$client])) {
202:             $currentInstance[$client] = new cApiClient($client);
203:         }
204: 
205:         return $currentInstance[$client];
206:     }
207: 
208:     /**
209:      * Load dataset by primary key
210:      *
211:      * @param int $idKey
212:      * @return bool
213:      */
214:     public function loadByPrimaryKey($idKey) {
215:         if (parent::loadByPrimaryKey($idKey) == true) {
216:             $this->idclient = $idKey;
217:             return true;
218:         }
219:         return false;
220:     }
221: 
222:     /**
223:      * Set client property
224:      *
225:      * @param mixed $type Type of the data to store (arbitary data)
226:      * @param mixed $name Entry name
227:      * @param mixed $value Value
228:      * @param mixed $idproperty
229:      */
230:     public function setProperty($type, $name, $value, $idproperty = 0) {
231:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
232:         $oPropertyColl->setValue('clientsetting', $this->idclient, $type, $name, $value, $idproperty);
233:     }
234: 
235:     /**
236:      * Get client property
237:      *
238:      * @param mixed $type Type of the data to get
239:      * @param mixed $name Entry name
240:      * @param int $client  Client id (not used, it's declared because of PHP strict warnings)
241:      * @return mixed Value
242:      */
243:     public function getProperty($type, $name, $client = 0) {
244:         $propertyColl = $this->_getPropertiesCollectionInstance();
245:         return $propertyColl->getValue('clientsetting', $this->idclient, $type, $name);
246:     }
247: 
248:     /**
249:      * Delete client property
250:      *
251:      * @param int $idProp Id of property
252:      * @param string $p2 Not used, is here to prevent PHP Strict warnings
253:      * @param int $client  Client id (not used, it's declared because of PHP strict warnings)
254:      * @return void
255:      */
256:     public function deleteProperty($idProp, $p2 = "", $client = 0) {
257:         $propertyColl = $this->_getPropertiesCollectionInstance();
258:         $propertyColl->delete($idProp);
259:     }
260: 
261:     /**
262:      * Get client properties by type
263:      *
264:      * @param mixed $type Type of the data to get
265:      * @return array Assoziative array
266:      */
267:     public function getPropertiesByType($type) {
268:         $propertyColl = $this->_getPropertiesCollectionInstance();
269:         return $propertyColl->getValuesByType('clientsetting', $this->idclient, $type);
270:     }
271: 
272:     /**
273:      * Get all client properties
274:      *
275:      * @param mixed $mType Type of the data to get
276:      * @return array false array
277:      * @todo return value should be the same as getPropertiesByType(), e. g. an
278:      *       empty array instead false
279:      */
280:     public function getProperties() {
281:         $propertyColl = $this->_getPropertiesCollectionInstance();
282:         $propertyColl->select("itemid='" . $this->idclient . "' AND itemtype='clientsetting'", "", "type, name, value ASC");
283: 
284:         if ($propertyColl->count() > 0) {
285:             $array = array();
286: 
287:             while (($item = $propertyColl->next()) !== false) {
288:                 $array[$item->get('idproperty')]['type'] = $item->get('type');
289:                 $array[$item->get('idproperty')]['name'] = $item->get('name');
290:                 $array[$item->get('idproperty')]['value'] = $item->get('value');
291:             }
292: 
293:             return $array;
294:         } else {
295:             return false;
296:         }
297:     }
298: 
299:     /**
300:      * Check if client has at least one language
301:      *
302:      * @return bool
303:      */
304:     public function hasLanguages() {
305:         $clientLanguageCollection = new cApiClientLanguageCollection();
306:         $clientLanguageCollection->setWhere("idclient", $this->get("idclient"));
307:         $clientLanguageCollection->query();
308: 
309:         if ($clientLanguageCollection->next()) {
310:             return true;
311:         } else {
312:             return false;
313:         }
314:     }
315: 
316:     /**
317:      * Userdefined setter for client fields.
318:      *
319:      * @param string $name
320:      * @param mixed $value
321:      * @param bool $bSafe Flag to run defined inFilter on passed value
322:      */
323:     public function setField($name, $value, $bSafe = true) {
324:         switch ($name) {
325:             case 'errsite_cat':
326:             case 'errsite_art':
327:                 $value = (int) $value;
328:                 break;
329:         }
330: 
331:         parent::setField($name, $value, $bSafe);
332:     }
333: 
334:     /**
335:      * Lazy instantiation and return of properties object
336:      * @param int $client  Client id (not used, it's declared because of PHP strict warnings)
337:      *
338:      * @return cApiPropertyCollection
339:      */
340:     protected function _getPropertiesCollectionInstance($client = 0) {
341:         // Runtime on-demand allocation of the properties object
342:         if (!is_object($this->_oPropertyCollection)) {
343:             $this->_oPropertyCollection = new cApiPropertyCollection();
344:             $this->_oPropertyCollection->changeClient($this->idclient);
345:         }
346:         return $this->_oPropertyCollection;
347:     }
348: 
349: }
350: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0