Piotr Labudda 11 лет назад
Родитель
Сommit
f925903f38

+ 1 - 1
SE/VERSION

@@ -1 +1 @@
-3.9.10-8
+3.9.10-9

+ 8 - 0
SE/se-lib/Core/Client/Ldap.php

@@ -170,6 +170,14 @@ class Core_Client_Ldap {
 		return false;
 	}
 
+	public function mod_add($userUid, $attr) {
+		$result = ldap_mod_add($this->_conn, "uid={$userUid},cn=users,{$this->_base_dn}", $attr);
+		if (true === $result) {
+			return true;
+		}
+		return false;
+	}
+
 	public function groupAttrUpdate($groupUid, $attr) {
 		$result = ldap_mod_replace($this->_conn, "cn={$groupUid},cn=groups,{$this->_base_dn}", $attr);
 //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">ldap_mod_replace('."cn={$groupUid},cn=groups,{$this->_base_dn}".') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($result);echo'</pre>';

+ 3 - 3
SE/se-lib/Core/Database/Mysql.php

@@ -299,7 +299,7 @@ class Core_Database_Mysql extends Core_Database {
 		$id = $sql_obj->ID;
 
 		// check id record $id exists
-		if (($curr_obj = $this->get_by_id( $table, $sql_obj->ID )) == null) {
+		if (($curr_obj = $this->get_by_id($table, $sql_obj->ID)) == null) {
 			return -2;
 		}
 
@@ -321,8 +321,8 @@ class Core_Database_Mysql extends Core_Database {
 		$sql_arr = array();
 		// TODO: add admin columns if exists in table - search in session
 		$admin_col = array();
-		$admin_col []= 'A_RECORD_CREATE_DATE';
-		$admin_col []= 'A_RECORD_CREATE_AUTHOR';
+		$admin_col[] = 'A_RECORD_CREATE_DATE';
+		$admin_col[] = 'A_RECORD_CREATE_AUTHOR';
 		// ...
 		$sql_obj->A_RECORD_UPDATE_DATE = date('Y-m-d-H:i');
 		$sql_obj->A_RECORD_UPDATE_AUTHOR = User::getName();

+ 8 - 8
SE/se-lib/TableAjax.php

@@ -5165,11 +5165,11 @@ jQuery(document).ready(function(){
 			throw new HttpException("Brak dostępu do zapisu dla pola {$geomFieldName}", 403);
 		}
 
-		$itemPath = new stdClass();
-		$itemPath->{$geomFieldName} = "GeomFromText('{$polygon}')";
-		$itemPath->ID = $id;
+		$itemPatch = new stdClass();
+		$itemPatch->{$geomFieldName} = "GeomFromText('{$polygon}')";
+		$itemPatch->ID = $id;
 
-		$affected = $this->_dataSource->updateItem($itemPath);
+		$affected = $this->_dataSource->updateItem($itemPatch);
 
 		$response = new stdClass();
 		if ($affected > 0) {
@@ -5243,11 +5243,11 @@ jQuery(document).ready(function(){
 			return $response;
 		}
 
-		$itemPath = new stdClass();
-		$itemPath->{$geomFieldName} = "NULL";
-		$itemPath->ID = $id;
+		$itemPatch = new stdClass();
+		$itemPatch->{$geomFieldName} = "NULL";
+		$itemPatch->ID = $id;
 
-		$affected = $this->_dataSource->updateItem($itemPath);
+		$affected = $this->_dataSource->updateItem($itemPatch);
 
 		$response = new stdClass();
 		if ($affected > 0) {

+ 2 - 3
SE/se-lib/UserStorageDB.php

@@ -34,9 +34,9 @@ class UserStorageDB extends UserStorageBase {
 				, a.`ADM_ACCOUNT` as login
 				, a.`ADM_PASSWD` as password
 				, a.`ADM_NAME` as name
-				, a.`EMAIL` as email
+				, a.`EMAIL_LOCAL_ACCOUNT_ADDRESS` as email
 				, a.`ADM_PHONE` as phone
-				, '' as homeEmail
+				, a.`EMAIL` as homeEmail
 				, '' as homePhone
 				, a.`EMPLOYEE_TYPE` as employeeType
 				, IF(a.`A_STATUS`='NORMAL', 0, 1) as isDisabled
@@ -327,7 +327,6 @@ class UserStorageDB extends UserStorageBase {
 			where
 				`ADM_ACCOUNT`='{$usrLogin}'
 		";
-echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';
 		return false;
 	}
 

+ 13 - 1
SE/se-lib/UserStorageMacOSX.php

@@ -49,7 +49,7 @@ class UserStorageMacOSX extends UserStorageBase {
 		$user->name = V::get('cn', '', $usrLdap);
 		$user->email = V::get('mail', '', $usrLdap);
 		$user->phone = V::get('telephoneNumber', '', $usrLdap);
-		$user->homeEmail = '';
+		$user->homeEmail = V::get('carLicense', '', $usrLdap);
 		$user->homePhone = V::get('homePhone', '', $usrLdap);
 		$user->employeeType = V::get('employeeType', '', $usrLdap);
 		return $user;
@@ -263,6 +263,18 @@ class UserStorageMacOSX extends UserStorageBase {
 						$this->setError(1, "Nie udało się zmienić hasła dla usera '{$userName}'", '(' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . ')');
 					}
 					break;
+				case 'homeEmail':
+					$ldap = $this->_getAdminLdap();
+					if ($ldap) {
+						$attr = array();
+						$attr['carLicense'] = $val;
+						if (!$ldap->mod_replace($userName, $attr)) {
+							if (!$ldap->mod_add($userName, $attr)) {
+								//$this->setError(1, "TODO: update homeEmail failed " . $ldap->error(), '(' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . ')');
+							}
+						}
+					}
+					break;
 				default:
 					$this->setError(1, "TODO: update user {$userName} field {$fldName} to value '{$val}'", '(' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . ')');
 			}

+ 20 - 5
SE/se-lib/UsersLdapHelper.php

@@ -6,7 +6,15 @@ class UsersLdapHelper {
 	public static function getUser($userName, $allAttrs = false) {
 		$ldapUsers = array();
 
-		$attrMap = array('uid', 'apple-generateduid', 'givenName', 'uidNumber', 'cn', 'mail');// (givenName, sn) = cn
+		//$attrMap = array('uid', 'apple-generateduid', 'givenName', 'uidNumber', 'cn', 'mail', 'apple-user-mailattribute');// (givenName, sn) = cn
+		$attrMap = array();
+		$attrMap['uid'] = 'uid';
+		$attrMap['apple-generateduid'] = 'apple-generateduid';
+		$attrMap['givenName'] = 'givenName';
+		$attrMap['uidNumber'] = 'uidNumber';
+		$attrMap['cn'] = 'cn';
+		$attrMap['mail'] = 'mail';
+		$attrMap['carLicense'] = 'carLicense';
 
 		Lib::loadClass('LDAP');
 		$ldap = LDAP::getInstance();
@@ -30,10 +38,17 @@ class UsersLdapHelper {
 					}
 				}
 			} else {
-				foreach ($attrMap as $vAttrName) {
-					$vAttrVal = V::get($vAttrName, '', $attrs);
+				foreach ($attrMap as $kAttrName => $vFldName) {
+					$vAttrVal = V::get($kAttrName, '', $attrs);
 					if (is_array($vAttrVal) && !empty($vAttrVal)) {
-						$userObj->{$vAttrName} = $vAttrVal[0];
+						if ($vAttrVal['count'] > 1) {
+							$userObj->{$vFldName} = array();
+							for ($j = 0; $j < $vAttrVal['count']; $j++) {
+								$userObj->{$vFldName}[] = $vAttrVal[$j];
+							}
+						} else {
+							$userObj->{$vFldName} = $vAttrVal[0];
+						}
 					}
 				}
 			}
@@ -49,7 +64,7 @@ class UsersLdapHelper {
 	public static function getUsersAll() {
 		$allLdapUsers = array();
 
-		$attrMap = array('uid', 'apple-generateduid', 'givenName', 'uidNumber', 'cn', 'mail');// (givenName, sn) = cn
+		$attrMap = array('uid', 'apple-generateduid', 'givenName', 'uidNumber', 'cn', 'mail', 'carLicense');// (givenName, sn) = cn
 
 		Lib::loadClass('LDAP');
 		$ldap = LDAP::getInstance();

+ 3 - 3
SE/superedit-SYNC_LDAP_PERMS.php

@@ -86,7 +86,7 @@ function SYNC_LDAP_PERMS() {
 				if (!$synced) {
 					?>
 					<div class="alert alert-error">
-						Nie udało się zsynchronizować uprawnień użytkownika <?php echo $userName; ?>.
+						Nie udało się zsynchronizować uprawnień użytkownika <?php echo $userName; ?>.
 					</div>
 					<?php
 					echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($synUsers->getErrorsMsgListWithDbg());echo'</pre>';
@@ -129,7 +129,7 @@ function SYNC_LDAP_PERMS() {
 			if (!$synced) {
 				?>
 				<div class="alert alert-error">
-					Nie udało się zsynchronizować uprawnień użytkownika <?php echo $userName; ?>.
+					Nie udało się zsynchronizować uprawnień użytkownika <?php echo $userName; ?>.
 				</div>
 				<?php
 				echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($synUsers->getErrorsMsgListWithDbg());echo'</pre>';
@@ -239,7 +239,7 @@ function SYNC_LDAP_PERMS() {
 					if (!$synced) {
 						?>
 						<div class="alert alert-error">
-							Nie udało się zsynchronizować grupy [<?php echo $syncGroupID; ?>].
+							Nie udało się zsynchronizować grupy [<?php echo $syncGroupID; ?>].
 						</div>
 						<?php
 						echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($synUsers->getErrorsMsgListWithDbg());echo'</pre>';