当前位置: 首页>>代码示例>>PHP>>正文


PHP I2CE::getUserAccessInit方法代码示例

本文整理汇总了PHP中I2CE::getUserAccessInit方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE::getUserAccessInit方法的具体用法?PHP I2CE::getUserAccessInit怎么用?PHP I2CE::getUserAccessInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在I2CE的用法示例。


在下文中一共展示了I2CE::getUserAccessInit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_initialize

 /**
  * Method called when the module is enabled for the first time.
  * @param boolean -- returns true on success. false on error.
  */
 public function action_initialize()
 {
     //initialize the user tables
     //initialize the user tables
     $init = I2CE::getUserAccessInit('DHIS');
     if (empty($init)) {
         $options = array();
     } else {
         $options = json_decode($init, true);
         if (!is_array($options)) {
             I2CE::raiseError("Invalid user access initilization string for DHIS");
             $options = array();
         }
     }
     $options = self::ensureDefaultOptions($options);
     $db = MDB2::singleton();
     $qrs = array();
     $qrs[] = 'CREATE TABLE IF NOT EXISTS ' . $options['detailTable'] . ' ' . '(userinfoid integer NOT NULL,' . ' surname  varchar(160) NOT NULL,' . ' firstname  varchar(160) NOT NULL,' . ' email  varchar(160),' . ' phonenumber  varchar(80),' . ' CONSTRAINT userinfo_pkey PRIMARY KEY (userinfoid)' . ')';
     $qrs[] = 'CREATE TABLE IF NOT EXISTS ' . $options['passTable'] . ' ' . '(userid integer NOT NULL,' . ' username  varchar(255) NOT NULL,' . ' password  varchar(255) NOT NULL,' . ' CONSTRAINT users_pkey PRIMARY KEY (userid),' . ' CONSTRAINT fk6a68e08f19893da FOREIGN KEY (userid)' . ' REFERENCES ' . $options['detailTable'] . ' (userinfoid) MATCH SIMPLE' . ' ON UPDATE NO ACTION ON DELETE NO ACTION,' . ' CONSTRAINT users_username_key UNIQUE (username)' . ')';
     $qrs[] = 'CREATE TABLE IF NOT EXISTS ' . $options['accessTable'] . ' ' . '( `user` int(11) NOT NULL,' . ' `role` varchar(255) collate utf8_bin NOT NULL,' . ' PRIMARY KEY  (`user`)' . ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin';
     $qrs[] = 'CREATE TABLE IF NOT EXISTS ' . $options['logTable'] . ' ' . '(`user` int(11) NOT NULL,' . ' `login` datetime NOT NULL,' . ' `logout` datetime default NULL,' . ' `session_id` varchar(50) NOT NULL,' . ' `activity` datetime NOT NULL,' . ' KEY `user` (`user`),' . ' KEY `login` (`login`)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8';
     I2CE::raiseError("Initializing User Table. Users' details table se stored in database {$options['userDB']}");
     foreach ($qrs as $qry) {
         if (I2CE::pearError($db->query($qry), "Cannot create user table")) {
             I2CE::raiseError("Could not initialize I2CE user tables");
             return false;
         }
     }
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:34,代码来源:I2CE_Module_UserAccess_DHIS.php

示例2: __construct

 /**
  * Create a new instance of a default I2CE  table user access mechanism
  */
 public function __construct()
 {
     $protocol = substr(get_class($this), 16);
     if (!$protocol) {
         $protocol = 'DEFAULT';
     }
     $this->protocol = $protocol;
     $init = I2CE::getUserAccessInit($protocol);
     if (empty($init)) {
         $options = array();
     } else {
         $options = json_decode($init, true);
         if (!is_array($options)) {
             I2CE::raiseError("Invalid user access initilization string");
             $options = array();
         }
     }
     if (!array_key_exists('admin_user', $options)) {
         $options['admin_user'] = 'i2ce_admin';
     }
     if (!array_key_exists('admin_pass', $options)) {
         $options['admin_pass'] = MDB2::singleton()->dsn['password'];
     }
     if (!array_key_exists('admin_details', $options) || !is_array($options['admin_details'])) {
         $options['admin_details'] = array();
     }
     if (!array_key_exists('auto_login', $options)) {
         $options['auto_login'] = 0;
     }
     if (!array_key_exists('auto_login_user', $options)) {
         $options['auto_login_user'] = false;
     }
     $this->options = $this->ensureDefaultOptions($options);
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:37,代码来源:I2CE_UserAccess_Mechanism.php

示例3: ensureUserTable

 /**
  * Ensure that the user table is presnet, if not attempt to create it
  * @returns boolean
  */
 protected function ensureUserTable()
 {
     //initialize the user tables
     $init = I2CE::getUserAccessInit('DEFAULT');
     if (empty($init)) {
         $options = array();
     } else {
         $options = json_decode($init, true);
         if (!is_array($options)) {
             I2CE::raiseError("Invalid user access initilization string for Default");
             $options = array();
         }
     }
     $options = self::ensureDefaultOptions($options);
     $db = MDB2::singleton();
     $qry = 'CREATE TABLE IF NOT EXISTS ' . $options['user_table'] . ' ' . '(`id` int(11) NOT NULL auto_increment,' . ' `username` varchar(20) NOT NULL,' . ' `role` varchar(255) collate utf8_bin NOT NULL,' . ' PRIMARY KEY  (`id`),' . ' UNIQUE KEY `username` (`username`)' . ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin';
     I2CE::raiseError("Initializing LDA-DB User Table. Users' details table se stored in database {$options['userDB']}");
     if (I2CE::pearError($db->query($qry), "Cannot create user access table: {$qry}")) {
         I2CE::raiseError("Could not initialize LDAP-DB user table");
         return false;
     }
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:27,代码来源:I2CE_Module_UserAccess_LDAP_Hybrid.php

示例4: updateAccessTable

 protected function updateAccessTable()
 {
     $db = MDB2::singleton();
     $options = self::getInitOptions(I2CE::getUserAccessInit('DEFAULT'));
     $rows = $db->queryAll("SHOW FULL COLUMNS FROM " . $options['accessTable'] . " WHERE Field='role'");
     if (substr($rows[0]->type, 0, 3) != 'int') {
         I2CE::raiseError("NOT doing access table");
         return true;
     }
     I2CE::raiseError("Altering access table to 3.x format");
     return I2CE::runSQLScript('update-access-table.sql');
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:12,代码来源:I2CE_Module_UserAccess.php

示例5: ensureOrganizationalEntries

 /**
  * Ensure the organziational entries in the LDAP server for People and Application
  * @returns boolean. True on success
  */
 protected function ensureOrganizationalEntries()
 {
     $init = I2CE::getUserAccessInit('LDAP');
     if (empty($init)) {
         $options = array();
     } else {
         $options = json_decode($init, true);
         if (!is_array($options)) {
             I2CE::raiseError("Invalid user access initilization string for LDAP");
             $options = array();
         }
     }
     $options = self::ensureDefaultOptions($options);
     $ldap = @ldap_connect($options['host'], $options['port']);
     if (!is_resource($ldap)) {
         I2CE::raiseError("Could not connect to ldap server on {$options['host']}:{$options['port']}");
         return false;
     }
     @ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
     @ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
     if ($options['ldap_user'] && $options['ldap_pass'] && !@ldap_bind($ldap, 'cn=' . $options['ldap_user'] . ',' . $options['dn'], $options['ldap_pass'])) {
         I2CE::raiseError("Could not bind to ldap server as user {$options['ldap_user']},{$options['dn']} ");
         @ldap_close($ldap);
         return false;
     }
     $dns = array($options['dn'] => array($options['people'], $options['apps']), 'ou=' . $options['apps'] . ', ' . $options['dn'] => array($options['app']), 'ou=' . $options['app'] . ',ou=' . $options['apps'] . ', ' . $options['dn'] => array($options['roles'], $options['ids']));
     foreach ($dns as $base => $ous) {
         foreach ($ous as $ou) {
             if (!($r = @ldap_search($ldap, $base, 'ou=' . $ou, array()))) {
                 I2CE::raiseError("Could not access at {$base}");
                 return false;
             }
             $dn = "ou={$ou},{$base}";
             if (ldap_count_entries($ldap, $r) > 0) {
                 I2CE::raiseError("{$dn} exists. not creating");
                 continue;
             }
             $entry = array('ou' => $ou, 'objectClass' => 'organizationalUnit');
             if (!@ldap_add($ldap, $dn, $entry)) {
                 I2CE::raiseError("Could not add at {$dn}:\n" . print_r($entry, true));
                 @ldap_close($ldap);
                 return false;
             }
             I2CE::raiseError("{$dn} created");
         }
     }
     @ldap_close($ldap);
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:53,代码来源:I2CE_Module_UserAccess_LDAP.php


注:本文中的I2CE::getUserAccessInit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。