/** * Constructor. Accepts following configuration options: * userClass string Name of User class. Default is RM_Account_Simple_User * groupClass string Name of Group class. Default is RM_Account_Simple_Group * * @param conf hash Configuration * @return */ public function __construct(array $conf = array()) { $this->_userClass = lor(@$conf['userClass'], 'RM_Account_Simple_User'); $this->_groupClass = lor(@$conf['groupClass'], 'RM_Account_Simple_Group'); $this->_members = 'rm_account_user2group'; $this->_storage['user'] = M('Store')->storage(array('ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id login'), 'table' => 'rm_account_user', 'props' => qw2('id login password'), 'class' => $this->_userClass)); $this->_storage['group'] = M('Store')->storage(array('ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id name'), 'table' => 'rm_account_group', 'props' => qw2('id name'), 'class' => $this->_groupClass)); }
/** * Constructor. Accepts following configuration options: * userClass string Name of User class. Default is RM_Account_Simple_User * groupClass string Name of Group class. Default is RM_Account_Simple_Group * * @param conf hash Configuration * @return */ public function __construct(array $conf = array()) { $this->_userClass = lor(@$conf['userClass'], 'RM_Account_Simple_User_Edited'); $this->_groupClass = lor(@$conf['groupClass'], 'RM_Account_Simple_Group'); $this->_members = 'panelie_user_role'; $this->_storage['user'] = M('Store')->storage(array('ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id login'), 'table' => 'panelie_user', 'props' => qw2('id>user_id login password city_id first_name'), 'class' => $this->_userClass)); $this->_storage['group'] = M('Store')->storage(array('ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id name alias'), 'table' => 'panelie_role', 'props' => qw2('id name alias'), 'class' => $this->_groupClass)); }
/** * Constructor * * @param 0 int wrap len * @param 1 bool UTF-8 maintenance * @param 2 string delimiter * * @return */ public function __construct($args = array()) { $this->_len = lor(@$args[0], 40); $this->_utf8 = lor(@$args[1], true); $this->_delimiter = lor(@$args[2], "\n"); $this->_max_lines = lor(@$args[3], false); $this->_break = lor(@$args[4], false); }
public function __construct() { $conf = C('guid'); $this->_pools = array(); $this->_size = lor(@$conf['default-spool-size'], 5); $this->_strict = isset($conf['strict']) ? $conf['strict'] : 0; $this->_table = M('Db')->table("rm_guid"); $this->_conf = array(); $this->_guidNames = array(); foreach (M('Config')->getList('guid.type') as $row) { if (!isset($row['id'])) { throw new RM_Guid_Exception("Unspecified guid identifier for type '" . $row['name'] . "'"); } $this->_conf[$row['id']] = array('create' => @$row['create'], 'name' => $row['name']); } }
/** * Constructor. Accepts following confugration options: * NAME TYPE DEFAULT DESCRIPTION * page_size int 0 Number of objects per page * total_count int -1 Total count of objects. * auto_count bool 1 Automatically count objects when process() is called * init_param string 'page' Name of _REQUEST[] parameter with page var * auto_init bool 1 Set current page automatically from _REQUEST * * @param conf hash|int Pager configuration (see above) or just number of objects per page. * @return */ public function __construct($conf) { if (!is_array($conf)) { $conf = array('page_size' => $conf); } $this->_page = 0; $this->_pageCount = 0; $this->_pageSize = lor(@$conf['page_size'], 0); $this->_totalCount = lor(@$conf['total_count'], -1); $this->_autoCount = @$conf['auto_count'] !== 0 ? lor(@$conf['auto_count'], 1) : 0; $this->_initParam = lor(@$conf['init_param'], 'page'); $this->_itemsName = lor(@$conf['items_name'], ''); $this->_autoInit = lor(@$conf['auto_init'], 1); $this->_all = false; if ($this->_autoInit and $this->_initParam) { $this->setPage(@$_REQUEST[$this->_initParam]); } else { $this->_validate(); } }
/** * Remove unused PS. If psId not specified, current open store is removed * * @param psId int PS-ID * @return void */ public function pwdStoreDelete($psId = NULL) { $this->_mapper->psDelete(lor($psId, $this->_psId)); }
function getIterator() { return M('Store')->factoryIterator($this->_factory, new LimitIterator($this->_getIter(), intval($this->_offset), lor($this->_limit, -1))); }
/** * Process event queue until it's empty * * @param maxEvents int Maximum number of events to process * @return void */ public function processQueue($maxEvents = 100) { if ($lockFile = $this->_getLockFilename()) { $this->_lockFile = fopen($lockFile, 'ab'); } $this->_trace("Processing queue"); for ($maxEvents = lor(C('event.queue-process.max-events'), $maxEvents); $maxEvents > 0; $maxEvents--) { if (!$this->_processEvent("SELECT e.name AS event_name, q.* FROM {$this->eventQueue} q, {$this->event} e WHERE e.id = q.event_id and process_start IS NULL LIMIT 1")) { return; } } # auto-close of lock file $this->_trace("MAX_EVENTS is reached. Exiting"); if ($this->_lockFile) { fclose($this->_lockFile); $this->_lockFile = NULL; } }
function _repAdd($row, $prefix = '') { $this->_rep[] = $row; if (count($this->_rep) == 1) { $hdr = array(); foreach ($this->_columns as $k => $v) { $hdr[$k] = $v[0]; } $this->_repAdd($hdr); $this->_total = array(); $this->_rep = array(); $this->_rep[] = $row; } $fields = array(); foreach ($this->_columns as $id => $v) { $fields[] = str_pad(@$row[$id], @$v[1], ' ', @$v[2] == 'right' ? STR_PAD_LEFT : STR_PAD_RIGHT); @($this->_total[$k] += $row[$id]); } $this->_body .= lor($prefix, ' ') . join(" ", $fields) . "\n"; }
/** * Parse & return contents of language file. * * @param fileId string File ID in format: CODE1.CODE2. ... .CODE_N * @param lang string Custom specific language, default current language * @return string */ public function parseFile($fileId, $lang = NULL) { $lang = lor($lang, $this->_currentLang); $path = $this->_getRootDir($lang) . '/' . str_replace('.', '/', $fileId) . '.lng.php'; if (!is_file($path)) { M('Trace')->trace('lang', "Language file `{$path}' is missing"); } return include $path; }
/** * Constructor * * @param 0 string current directory (for relative links) * @param 1 string current host (if it isn't specified then all links will be without "host" part) * @param 2 string current protocol (if it isn't specified then all links will be without "protocol" part) * * @return */ public function __construct($args = array()) { $this->_curdir = lor(@$args[0], dirname(@$_SERVER['REQUEST_URI'])); $this->_host = lor(@$args[1], @$_SERVER['HTTP_HOST']); $this->_protocol = lor(@$args[2], M('Tools')->web()->isHTTPS() ? 'https' : 'http'); }
function __construct() { $conf = C('trace'); $this->init(lor(@$conf['driver'], 'empty'), $conf); }
/** * Main method :) * Creates and initialize set of objects for proper storage functioning. Accepts hash of following parameters: * * Name Type Default Description * ---- ---- ------- ----------- * table string Table name * props hash<prop:db> Object properies and DB mappings. See RM_Store_Object_Metadata for details * keys list|hash 'id' Keys. See RM_Store_Object_Metadata for details. Sample: qw2('id name>parent_id+name') * auto-id-prop string NULL Name of field to fill with AUTO_INCREMENT value. If NULL - AUTO_INCREMENT is disabled * guid string NULL Name of GUID type to auto alloc ID. If NULL - GUID is disabled. * Also passed as "guidType" parameter to object constructor. * guid-prop string 'id' Name of GUID property. Used only if guid is not NULL * guid-type-prop string 'guid_type' Name of GUID-TYPE property. Used only if guid is not NULL * Passed as "guidTypeProp" parameter to object constructor. * class string RM_Store_Object Class which will be instantiated for every object in storage. * If class is RM_Store_Object and GUID is enabled - * RM_Store_Object_Guid is used * cache-prefix string '' Cache prefix for caching loadById() requests. * If empty(default), caching is disabled * validator RM_Validator_iValidator NULL Validator for every created object * factory RM_Store_iFactory|string NULL Factory for creating objects. Default is RM_Store_Factory_Hash. See it doc for details. * You can pass either object or class name. Class constructor must be compatible with * RM_Store_Factory_Hash constructor. * no-lazy-load bool FALSE Always fetch all object fields in queries for objects sets * ctorArgs hash NULL Extra arguments to pass to object constructor. * For every item, property with same name AND PREFIXED * WITH UNDERSCORE! (_prop) will created! * WARNING! Properties with such names must exist in class. * * All parameters without default values ARE REQUIRED! * * @param args hash<name:value> Configuration * @return RM_Store_Object_Storage */ public function storage($args) { $mediator = new RM_Store_Object_Mediator(); # Meta data $mediator->setMeta(new RM_Store_Object_Metadata($args['props'], lor(@$args['keys'], qw2('id')))); # IdentityMap $mediator->setIdentityMap($this->_noCache ? new RM_Store_IdentityMap_Fake() : new RM_Store_IdentityMap_Simple($mediator)); # Validator if (@$args['validator']) { $mediator->setValidator($args['validator']); } # Factory if (@$args['guid']) { $args['ctorArgs']['guidType'] = $args['guid']; $args['ctorArgs']['guidTypeProp'] = @$args['guid-type-prop']; if (@$args['class'] == '') { $args['class'] = 'RM_Store_Object_Guid'; } } if (!@$args['factory']) { $args['factory'] = 'RM_Store_Factory_Hash'; } if (!is_object($args['factory'])) { $args['factory'] = new $args['factory']($mediator, lor(@$args['class'], 'RM_Store_Object'), @$args['ctorArgs']); } if (@$args['guid']) { $args['factory'] = $this->factoryGuid($args['factory'], @$args['guid'], lor(@$args['guid-prop'], 'id')); } $mediator->setFactory($args['factory']); # Storage $mediator->setStorage(new RM_Store_Object_Storage($mediator, array('table' => $args['table'], 'table-history' => @$args['table-history'] ? $args['table-history'] : null, 'auto-id-prop' => @$args['auto-id-prop'], 'cache-prefix' => $this->_noIdCache ? '' : @$args['cache-prefix'], 'no-lazy-load' => lor(@$args['no-lazy-load'], $this->_noLazyLoad)))); return $mediator->storage; }
public function refreshStatus() { if ($this->id()) { M('Log')->record('activity', 'session', sprintf("%s\t%s\t%s\t%s", $this->id(), M('Tools')->web()->getRealIP(), @$_REQUEST['CSID'], M('Tools')->web()->makeUrl('', $_GET, 'abs'))); $loginExpire = $this->_mapper->getLoginExpireByUserId($this->id()); return $this->_mapper->updateUserSession($this->id(), C('user.auth-cookie.online-expire'), lor($loginExpire, C('user.auth-cookie.login-expire'))); } }
/** * Adds table to Query. Table specification can have following format: * spec:= table | table AS alias | table alias * * @param tableSpec string Table specification * @param ... list Placeholders * @return void */ public function addTable($tableSpec) { if (!preg_match('/^(\\S+)(?:\\s+(?:AS\\s+)?(\\S+))?(?:\\s+FORCE\\s+INDEX\\s*\\(.*\\))?$/i', $tableSpec, $m)) { throw new RM_Base_Exception_BadUsage("Invalid table name - `{$tableSpec}'"); } $alias = lor(@$m[2], @$m[1]); if (isset($this->_tableAliases[$alias])) { throw new RM_Base_Exception_BadUsage("Duplicate table name in query `{$alias}'"); } $this->_tables[$alias] = M('Db')->getConnection()->tableName($tableSpec); $this->_tableAliases[$alias] = $alias; $this->_tableBinds[$alias] = sqlBindsAddFlat(func_get_args(), 1); return $this; }
/** * @return resource */ function _conn($ns) { $id = $this->_keyNs[$ns]['daemon']; if (!isset($this->_conns[$id])) { $host = $this->_daemons[$id]['host']; $port = lor($this->_daemons[$id]['port'], 11211); $this->_conns[$id] = memcache_pconnect($host, $port); if (!$this->_conns[$id]) { $this->_conns[$id] = memcache_connect($host, $port); } } return $this->_conns[$id]; }
/** * Returns signature fr user at moment $time * * @param array $user * @param int $time * @return string */ public function getSign(array $user, $time = 0) { return md5((isset($user['id']) ? $user['id'] : '') . (isset($user['nick']) ? $user['nick'] : '') . (isset($user['first_name']) ? $user['first_name'] : '') . (isset($user['last_name']) ? $user['last_name'] : '') . (isset($user['sex']) ? $user['sex'] : '') . round(lor($time, strtotime('now')) / 60, 0)); }
/** * Constructor. Accepts following configuration options: * session-var string Session var to keep logged user ID. Default is "user.logged" * * @param conf hash Configuration * @return */ public function __construct($conf) { $this->_var = lor(@$conf['session-var'], 'user.logged'); }
public function getFiltersFromSession() { @($_GET['f'] = lor(@$_GET['f'], @$_SESSION['f'])); @($_GET['page'] = lor(@$_GET['page'], @$_SESSION['page'])); }