⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldap.users.class.inc

📁 groupoffice
💻 INC
📖 第 1 页 / 共 2 页
字号:
    global $GO_LDAP;    $GO_LDAP->search("mail=$email", $GO_LDAP->PeopleDN);    if ($GO_LDAP->num_entries() > 0) {      return true;    }    return false;  }      /*  MKS: Some behaviour has changed.  Regional settings like language, currency decimal sep etc.  are stored in language/locale.inc  They should be retrieved with the given locale_code.  See sql.users.class.inc for an example.  */  function add_user($username, $password, $first_name, $middle_name,      $last_name, $initials, $title, $sex, $birthday,      $email, $work_phone, $home_phone, $fax,      $cellular, $country, $state, $city, $zip, $address,      $company, $work_country, $work_state, $work_city,      $work_zip, $work_address, $work_fax, $homepage,      $department, $function, $locale_code='', $theme='', $start_module='',      $visible=true, $user_id=-1) {    global $GO_CONFIG;    //don't forget to get preferences with new method.    //See sql.user.class add_user()    if ($language == '') {      $language=$GO_CONFIG->language;    }    if ($theme == '') {      $theme=$GO_CONFIG->theme;    }    if ($user_id < 0) {      $user_id = $this->nextid("users");    }    if ($user_id > 0) {      // TODO we need to add this user to LDAP.      return -1;    }  }  function max_users_reached() {    global $GO_CONFIG;    if( ( $this->get_users() < $GO_CONFIG->max_users ) ||        ( $GO_CONFIG->max_users == 0 ) ) {      return false;    } else {      return true;    }  }  // TODO  function set_preferences($user_id, $date_format, $time_format, $thousands_seperator, $decimal_seperator, $currency, $mail_client, $max_rows_list, $timezone_offset, $start_module, $language, $theme, $first_weekday)  {  	global $GO_LANGUAGE;  	      $_SESSION['GO_SESSION']['thousands_seperator'] = $thousands_seperator;      $_SESSION['GO_SESSION']['decimal_seperator'] = $decimal_seperator;      $_SESSION['GO_SESSION']['date_format']= $date_format;      $_SESSION['GO_SESSION']['time_format']= $time_format;      $_SESSION['GO_SESSION']['currency'] = $currency;      $_SESSION['GO_SESSION']['mail_client'] = $mail_client;      $_SESSION['GO_SESSION']['max_rows_list'] = $max_rows_list;      $_SESSION['GO_SESSION']['timezone'] = $timezone_offset;      $_SESSION['GO_SESSION']['start_module'] = $start_module;      $_SESSION['GO_SESSION']['theme'] = $theme;      $GO_LANGUAGE->set_language($profile['language']);      $_SESSION['GO_SESSION']['first_weekday'] = $first_weekday;  }  function delete_user($user_id)  {    global $GO_CONFIG,$GO_SECURITY, $GO_MODULES, $GO_GROUPS;    if($user = $this->get_user($user_id))    {      $acl_id = $this->f("acl_id");      $username = $this->f("username");      // TODO user should be deleted from LDAP (only!)      $sql = "DELETE FROM users WHERE id='$user_id'";      if ($this->query($sql))      {	$GO_SECURITY->delete_acl($acl_id);	$GO_SECURITY->delete_user($acl_id);	// TODO these module->delete_user should work via an enumeration of	// all modules.	if ($GO_MODULES->get_module('email'))	{	  require_once($GO_CONFIG->class_path."email.class.inc");	  $email = new email();	  $email->delete_user($user_id);	}	if ($GO_MODULES->get_module('addressbook'))	{	  require_once($GO_CONFIG->class_path."addressbook.class.inc");	  $ab = new addressbook();	  $ab->delete_user($user_id);	}	if ($GO_MODULES->get_module('scheduler'))	{	  require_once($GO_CONFIG->class_path."scheduler.class.inc");	  $scheduler = new scheduler();	  $scheduler->delete_user($user_id);	}	if ($GO_MODULES->get_module('calendar'))	{	  require_once($GO_CONFIG->class_path."calendar.class.inc");	  $calendar = new calendar();	  $calendar->delete_user($user_id);	}	if ($GO_MODULES->get_module('filesystem'))	{	  require_once($GO_CONFIG->class_path."filesystem.class.inc");	  $filesystem = new filesystem();	  $filesystem->delete_user($user_id);	}	if ($GO_MODULES->get_module('projects'))	{	  require_once($GO_CONFIG->class_path."projects.class.inc");	  $projects = new projects();	  $projects->delete_user($user_id);	}	if ($GO_MODULES->get_module('cms'))	{	  require_once($GO_CONFIG->class_path."cms.class.inc");	  $cms = new cms();	  $cms->delete_user($user_id);	}	if ($GO_MODULES->get_module('notes'))	{	  require_once($GO_CONFIG->class_path."notes.class.inc");	  $notes = new notes();	  $notes->delete_user($user_id);	}	require_once($GO_CONFIG->class_path."bookmarks.class.inc");	$bookmarks = new bookmarks();	$bookmarks->delete_user($user_id);	$GO_GROUPS->delete_user($user_id);	$sql = "SELECT * FROM acl_items WHERE user_id='$user_id'";	$this->query($sql);	while($this->next_record())	{	  $GO_SECURITY->delete_acl($this->f('id'));	}	system('rm -Rf '.$GO_CONFIG->file_storage_path.$username);	return true;      }    }    return false;  }  function increment_logins( $user_id ) {    // TODO  }	/**	 * Convert an LDAP entry to an SQL record.	 * 	 * This function takes an LDAP entry, as you get from ldap_fetch_entries()	 * and converts this entry to an SQL result record. It is used to convert	 * the account data that is stored in the directory server to an SQL style	 * result as is expected from the framework.	 * The mapping of table-columns to ldap-attributes is included from the	 * users.ldap.mapping file (which is located in the lib/ldap directory),	 * which is loaded from the constructor in this class. The name of this	 * file can be overridden in the configuration.	 * 	 * @access private	 * 	 * @param $entry is the LDAP entry that should be converted.	 * 	 * @return Array is the converted entry.	 */	function convertEntryToRecord( $entry ) {		global $GO_SECURITY, $GO_CONFIG, $GO_LDAP, $GO_GROUPS;		/*		 * If the user is not member of the everyone group, he should be added		 * if ( !$GO_GROUPS->is_in_group( $entry["uidnumber"][0], $GO_CONFIG->group_everyone ) ) {		 * 		$GO_GROUPS->add_user_to_group( $entry["uidnumber"][0], $GO_CONFIG->group_everyone );		 * }		 */		$row = array();		/*		 * Process each SQL/LDAP key pair of the mapping array, so that we can		 * fetch all values that are needed for each SQL key.		 */		foreach ( $this->mapping as $key => $ldapkey ) {			/*			 * If the ldapkey is undefined, we don't know any attributes that			 * match the specifiy SQL column, so we can leave it empty.			 */			if ( $ldapkey == '' ) {				$row[$key] = '';				continue;			}			/*			 * If the ldapkey is 'goAclID' this means, that we should store			 * the user's acl_id in this key. The ACL-ID is identified by the			 * user's email address. So we can search if there is already an			 * id associated with this address. If it is, we can store it in			 * the current key, otherwise we have to create a new one.			 */			if ( $ldapkey == 'goAclID' ) {				if ( isset( $entry['mail'][0] ) ) {					$this->db->query( 'SELECT * FROM acl_items WHERE description="'.$entry['mail'][0].'"' );					if ( $this->db->next_record() ) {						$row[$key] = $this->db->f( 'id' );					} else {						$acl_id = $GO_SECURITY->get_new_acl( $entry['mail'][0] );						$GO_SECURITY->add_group_to_acl( $GO_CONFIG->group_root, $acl_id );						$row[$key] = $acl_id;					}				}				continue;			}			/*			 * If the ldapkey is 'uid', we have to fetch the user's name from			 * the entry. This can either be stored inside the LDAP-DN, or in			 * the 'uid' attribute. We only read the DN, if there is more than			 * one 'uid' attribute, otherwise we use this attribute.			 */			if ( $ldapkey == 'uid' ) {				if ( $entry['uid']['count'] > 1 ) {					$dn = $entry['dn'];					$dn = substr( $dn, 0, strpos( $dn, ',' ) );					$value = substr( $dn, strpos( $dn, '=' ) + 1 );				} else {					$value = utf8_decode( $entry['uid'][0] );				}				if ( !$value ) {					$value = '';				}				$row[$key] = $value;				continue;			}			/*			 * The following keys identify how some values are displayed in			 * Group-Office. We fill them with default values, because we have			 * no idea, where these things can be stored in an directory.			 */			if ( $ldapkey == 'gofirstweekday' ) {				$row[$key] = '1';				continue;			}			if ( $ldapkey == 'godateformat' ) {				$row[$key] = 'd-m-Y';				continue;			}			if ( $ldapkey == 'gotimeformat' ) {				$row[$key] = 'G:i';				continue;			}			if ( $ldapkey == 'godecimalseperator' ) {				$row[$key] = ',';				continue;			}			if ( $ldapkey == 'gothousandsseperator' ) {				$row[$key] = '.';				continue;			}			if ( $ldapkey == 'gosortname' ) {				$row[$key] = '';				continue;			}			/*			 * All other ldapkeys have no special meaning, so we can directly			 * fetch them from the entry, and use them as values. If the			 * attribute is emtpy, we return an empty column.			 */			if ( isset( $entry[$ldapkey] ) ) {				$value = utf8_decode( $entry[$ldapkey][0] );			} else {				$value = '';			}			if ( !$value ) {				$value = '';			}			$row[$key] = $value;		}		/*		 * We have processed all mapping fields and created our SQL result		 * array. So we can return it.		 */		return $row;	}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -