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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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 = $this->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:  * Class cApiClient, client item
156:  *
157:  * @package Core
158:  * @subpackage GenericDB_Model
159:  * @author Marco Jahn
160:  */
161: class cApiClient extends Item {
162:     /**
163:      * Setting of client ID (deprecated)
164:      * @deprecated [2014-12-03] Class variable idclient is deprecated
165:      * @var int
166:      */
167:      private $idclient;
168: 
169:     /**
170:      * Property collection instance
171:      *
172:      * @var cApiPropertyCollection
173:      */
174:     protected $_oPropertyCollection;
175: 
176:     /**
177:      * Constructor Function
178:      *
179:      * @param mixed $id Specifies the ID of item to load
180:      */
181:     public function __construct($id = false) {
182:         global $cfg;
183:         parent::__construct($cfg['tab']['clients'], 'idclient');
184:         if ($id !== false) {
185:             $this->loadByPrimaryKey($id);
186:         }
187:     }
188: 
189:     /**
190:      * Magic getter method for deprecated idclient variable
191:      */
192:     public function __get($name) {
193:         if ($name === 'idclient') {
194:             return $this->get('idclient');
195:         }
196:     }
197:     
198:     /**
199:      * Magic setter method for deprecated idclient variable
200:      */
201:     public function __set($name, $value) {
202:         if ($name === 'idclient') {
203:             $this->set('idclient', cSecurity::toInteger($value));
204:         }
205:     }
206:     
207:     /**
208:      * Static accessor to the singleton instance.
209:      *
210:      * @todo There is no need since caching is available at GenericDB level
211:      * @param int $client
212:      * @return cApiClient Reference to the singleton instance.
213:      */
214:     public static function getInstance($client = false) {
215:         static $currentInstance = array();
216: 
217:         if (!$client) {
218:             // Use global $client
219:             $client = cRegistry::getClientId();
220:         }
221: 
222:         if (!isset($currentInstance[$client])) {
223:             $currentInstance[$client] = new cApiClient($client);
224:         }
225: 
226:         return $currentInstance[$client];
227:     }
228: 
229:     /**
230:      * Load dataset by primary key
231:      *
232:      * @param int $idKey
233:      * @return bool
234:      */
235:     public function loadByPrimaryKey($idKey) {
236:         if (parent::loadByPrimaryKey($idKey) == true) {
237:             $this->set('idclient', $idKey);
238:             return true;
239:         }
240:         return false;
241:     }
242: 
243:     /**
244:      * Set client property
245:      *
246:      * @param mixed $type Type of the data to store (arbitary data)
247:      * @param mixed $name Entry name
248:      * @param mixed $value Value
249:      * @param mixed $idproperty
250:      * @todo should return return value as overwritten method
251:      */
252:     public function setProperty($type, $name, $value, $idproperty = 0) {
253:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
254:         $oPropertyColl->setValue('clientsetting', $this->get('idclient'), $type, $name, $value, $idproperty);
255:     }
256: 
257:     /**
258:      * Get client property
259:      *
260:      * @param mixed $type Type of the data to get
261:      * @param mixed $name Entry name
262:      * @param int $client Client id (not used, it's declared because of PHP
263:      *            strict warnings)
264:      * @return mixed Value
265:      */
266:     public function getProperty($type, $name, $client = 0) {
267:         $propertyColl = $this->_getPropertiesCollectionInstance();
268:         return $propertyColl->getValue('clientsetting', $this->get('idclient'), $type, $name);
269:     }
270: 
271:     /**
272:      * Delete client property
273:      *
274:      * @param int $idProp Id of property
275:      * @param string $p2 Not used, is here to prevent PHP Strict warnings
276:      * @param int $client Client id (not used, it's declared because of PHP
277:      *            strict warnings)
278:      */
279:     public function deleteProperty($idProp, $p2 = "", $client = 0) {
280:         $propertyColl = $this->_getPropertiesCollectionInstance();
281:         $propertyColl->delete($idProp);
282:     }
283: 
284:     /**
285:      * Get client properties by type
286:      *
287:      * @param mixed $type Type of the data to get
288:      * @return array Assoziative array
289:      */
290:     public function getPropertiesByType($type) {
291:         $propertyColl = $this->_getPropertiesCollectionInstance();
292:         return $propertyColl->getValuesByType('clientsetting', $this->get('idclient'), $type);
293:     }
294: 
295:     /**
296:      * Get all client properties
297:      *
298:      * @return array false array
299:      * @todo return value should be the same as getPropertiesByType(), e.g. an
300:      *       empty array instead of false
301:      */
302:     public function getProperties() {
303:         $propertyColl = $this->_getPropertiesCollectionInstance();
304:         $whereString = "itemid='" . $this->get('idclient') . "' AND itemtype='clientsetting'";
305:         $propertyColl->select($whereString, "", "type, name, value ASC");
306: 
307:         if ($propertyColl->count() > 0) {
308:             $array = array();
309: 
310:             while (($item = $propertyColl->next()) !== false) {
311:                 $array[$item->get('idproperty')]['type'] = $item->get('type');
312:                 $array[$item->get('idproperty')]['name'] = $item->get('name');
313:                 $array[$item->get('idproperty')]['value'] = $item->get('value');
314:             }
315: 
316:             return $array;
317:         } else {
318:             return false;
319:         }
320:     }
321: 
322:     /**
323:      * Check if client has at least one language
324:      *
325:      * @return bool
326:      */
327:     public function hasLanguages() {
328:         $clientLanguageCollection = new cApiClientLanguageCollection();
329:         $clientLanguageCollection->setWhere("idclient", $this->get("idclient"));
330:         $clientLanguageCollection->query();
331: 
332:         if ($clientLanguageCollection->next()) {
333:             return true;
334:         } else {
335:             return false;
336:         }
337:     }
338: 
339:     /**
340:      * Userdefined setter for client fields.
341:      *
342:      * @param string $name
343:      * @param mixed $value
344:      * @param bool $bSafe Flag to run defined inFilter on passed value
345:      * @todo should return return value of overloaded method
346:      */
347:     public function setField($name, $value, $bSafe = true) {
348:         switch ($name) {
349:             case 'errsite_cat':
350:             case 'errsite_art':
351:                 $value = (int) $value;
352:                 break;
353:         }
354: 
355:         parent::setField($name, $value, $bSafe);
356:     }
357: 
358:     /**
359:      * Lazy instantiation and return of properties object
360:      *
361:      * @param int $client Client id (not used, it's declared because of PHP
362:      *            strict warnings)
363:      *
364:      * @return cApiPropertyCollection
365:      */
366:     protected function _getPropertiesCollectionInstance($client = 0) {
367:         // Runtime on-demand allocation of the properties object
368:         if (!is_object($this->_oPropertyCollection)) {
369:             $this->_oPropertyCollection = new cApiPropertyCollection();
370:             $this->_oPropertyCollection->changeClient($this->get('idclient'));
371:         }
372:         return $this->_oPropertyCollection;
373:     }
374: }
375: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen