From 4a7b9eb4e2ee0f67ec2f60aebf7b3587cca031ac Mon Sep 17 00:00:00 2001
From: Prasad <prasad@vtiger.com>
Date: Tue, 11 Oct 2022 23:57:42 +0530
Subject: [PATCH] Fixed undefined variable warning during installation

---
 include/utils/VtlibUtils.php              | 7 +++++--
 modules/Users/CreateUserPrivilegeFile.php | 4 +++-
 modules/Users/Users.php                   | 9 +++++----
 vtlib/Vtiger/Deprecated.php               | 2 +-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php
index 7e3629c6c..f8054c1d0 100644
--- a/include/utils/VtlibUtils.php
+++ b/include/utils/VtlibUtils.php
@@ -665,6 +665,7 @@ function vtlib_purify($input, $ignore = false) {
     static $purified_cache = array();
     $value = $input;
 
+	$encryptInput = null;
     if (!is_array($input)) {
         $encryptInput = hash('sha256',$input);
         if (array_key_exists($encryptInput, $purified_cache)) {
@@ -718,8 +719,10 @@ function vtlib_purify($input, $ignore = false) {
                 $value = purifyHtmlEventAttributes($value, true);
             }
         }
-        $purified_cache[$encryptInput] = $value;
-    }
+        if ($encryptInput != null) {
+			$purified_cache[$encryptInput] = $value;
+    	}
+	}
 
 	if ($value && !is_array($value)) {
 		$value = str_replace('&amp;', '&', $value);
diff --git a/modules/Users/CreateUserPrivilegeFile.php b/modules/Users/CreateUserPrivilegeFile.php
index 530275f2a..6f6a6f6ae 100644
--- a/modules/Users/CreateUserPrivilegeFile.php
+++ b/modules/Users/CreateUserPrivilegeFile.php
@@ -39,7 +39,9 @@ function createUserPrivilegesfile($userid)
 		$user_focus->id = $userid; 
 		foreach($user_focus->column_fields as $field=>$value_iter)
         	{
-               		$userInfo[$field]= $user_focus->$field;
+               		if (property_exists($user_focus, $field)) {
+						$userInfo[$field]= $user_focus->$field;
+					}
         	}
 
 		if($user_focus->is_admin == 'on')
diff --git a/modules/Users/Users.php b/modules/Users/Users.php
index d9dd37481..3166680b5 100755
--- a/modules/Users/Users.php
+++ b/modules/Users/Users.php
@@ -751,7 +751,7 @@ class Users extends CRMEntity {
 	function insertIntoEntityTable($table_name, $module, $fileid='') {
 		global $log;
 		$log->info("function insertIntoEntityTable ".$module.' vtiger_table name ' .$table_name);
-		global $adb, $current_user;
+		global $adb, $current_user, $app_strings;
 		$insertion_mode = $this->mode;
 		//Checkin whether an entry is already is present in the vtiger_table to update
 		if($insertion_mode == 'edit') {
@@ -824,7 +824,7 @@ class Users extends CRMEntity {
 					}
 
 				}elseif($uitype == 15) {
-					if($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) {
+					if($app_strings && $this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) {
 						//If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value.
 						$sql="select $columname from  $table_name where ".$this->tab_name_index[$table_name]."=?";
 						$res = $adb->pquery($sql,array($this->id));
@@ -1325,11 +1325,12 @@ class Users extends CRMEntity {
 		global $log,$adb;
 		$log->debug("Entering in function saveHomeOrder($id)");
 
+		$save_array = array();
 		 if($this->mode == 'edit')
 		 {
 			 for($i = 0;$i < php7_count($this->homeorder_array);$i++)
 			 {
-				 if($_REQUEST[$this->homeorder_array[$i]] != '')
+				 if(isset($_REQUEST[$this->homeorder_array[$i]]) && $_REQUEST[$this->homeorder_array[$i]] != '')
 				 {
 					$save_array[] = $this->homeorder_array[$i];
 					$qry=" update vtiger_homestuff,vtiger_homedefault set vtiger_homestuff.visible=0 where vtiger_homestuff.stuffid=vtiger_homedefault.stuffid and vtiger_homestuff.userid=? and vtiger_homedefault.hometype=?";//To show the default Homestuff on the the Home Page
@@ -1341,7 +1342,7 @@ class Users extends CRMEntity {
 					$result=$adb->pquery($qry, array($id, $this->homeorder_array[$i]));
 				}
 			}
-			if($save_array !="")
+			if($save_array)
 				$homeorder = implode(',',$save_array);
 		}
 		 else
diff --git a/vtlib/Vtiger/Deprecated.php b/vtlib/Vtiger/Deprecated.php
index 3dacc5148..d65cca2ab 100644
--- a/vtlib/Vtiger/Deprecated.php
+++ b/vtlib/Vtiger/Deprecated.php
@@ -342,7 +342,7 @@ class Vtiger_Deprecated {
 
 	static function SaveTagCloudView($id = "") {
 		global $adb;
-		$tag_cloud_status = $_REQUEST['tagcloudview'];
+		$tag_cloud_status = isset($_REQUEST['tagcloudview']) ? $_REQUEST['tagcloudview'] : false;
 		if ($tag_cloud_status == "true") {
 			$tag_cloud_view = 0;
 		} else {
-- 
GitLab