diff --git a/include/utils/ListViewUtils.php b/include/utils/ListViewUtils.php
index 3ea02a3d5e8f5fc61a4ef0885046b210a3719081..3fb50b958117f3a2afaba49657697d5a2a0bcf2d 100755
--- a/include/utils/ListViewUtils.php
+++ b/include/utils/ListViewUtils.php
@@ -694,7 +694,7 @@ function popup_decode_html($str) {
 //function added to check the text length in the listview.
 function textlength_check($field_val) {
 	global $listview_max_textlength, $default_charset;
-	if ($listview_max_textlength && $listview_max_textlength > 0) {
+	if ($field_val && $listview_max_textlength && $listview_max_textlength > 0) {
 		$temp_val = preg_replace("/(<\/?)(\w+)([^>]*>)/i", "", $field_val);
 		if (function_exists('mb_strlen')) {
 			if (mb_strlen(decode_html($temp_val)) > $listview_max_textlength) {
diff --git a/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl b/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl
index 7b66072dd814057890cb6d36c64c15c0df2ebd9f..6c9a82a0f83ed633634acee5d258b05ff4d5d773 100644
--- a/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl
+++ b/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl
@@ -28,7 +28,8 @@
 					{/if}
 					{if $MODULE neq 'Vtiger'}
 						{assign var=ALLOWED_MODULES value=","|explode:'Users,Profiles,Groups,Roles,Webforms,Workflows'}
-						{if $MODULE_MODEL and $MODULE|in_array:$ALLOWED_MODULES}
+						{assign var=URL value=""}
+						{if isset($MODULE_MODEL) and $MODULE|in_array:$ALLOWED_MODULES}
 							{if $MODULE eq 'Webforms'}
 								{assign var=URL value=$MODULE_MODEL->getListViewUrl()}
 							{else}
@@ -202,7 +203,7 @@
 				</div>
 			</div>
 		</div>
-		{if $FIELDS_INFO neq null}
+		{if isset($FIELDS_INFO) && $FIELDS_INFO neq null}
 			<script type="text/javascript">
 				var uimeta = (function () {
 					var fieldInfo = {$FIELDS_INFO};
diff --git a/layouts/v7/modules/Settings/Vtiger/SettingsMenuStart.tpl b/layouts/v7/modules/Settings/Vtiger/SettingsMenuStart.tpl
index e3781d568e50bc4a41bf25c04c3f9cfa13163c7c..81595158254b3512e546aeea3de9055c1a868145 100644
--- a/layouts/v7/modules/Settings/Vtiger/SettingsMenuStart.tpl
+++ b/layouts/v7/modules/Settings/Vtiger/SettingsMenuStart.tpl
@@ -24,7 +24,7 @@
         <div class="modal-dialog">
         </div>
     </div>
-{if $FIELDS_INFO neq null}
+{if isset($FIELDS_INFO) && $FIELDS_INFO neq null}
     <script type="text/javascript">
         var uimeta = (function() {
             var fieldInfo  = {$FIELDS_INFO};
diff --git a/layouts/v7/modules/Users/CalendarSettingsDetailView.tpl b/layouts/v7/modules/Users/CalendarSettingsDetailView.tpl
index f268a505c8b8e63594eab5e8c8453c8d142edd64..d7f6836e9531dddd26f6442fa44a93431769a5cc 100644
--- a/layouts/v7/modules/Users/CalendarSettingsDetailView.tpl
+++ b/layouts/v7/modules/Users/CalendarSettingsDetailView.tpl
@@ -12,7 +12,7 @@
 {strip}
     <form id="detailView" data-name-fields='{ZEND_JSON::encode($MODULE_MODEL->getNameFields())}' method="POST">
         <div class="contents">
-            {foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE}
+            {foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE name=CalendarDetailViewBlockLevelLoop}
                 <div class="block block_{$BLOCK_LABEL_KEY}" data-block="{$BLOCK_LABEL_KEY}">
                     {assign var=BLOCK value=$BLOCK_LIST[$BLOCK_LABEL_KEY]}
                 {if $BLOCK eq null or $FIELD_MODEL_LIST|@count lte 0}{continue}{/if}
@@ -134,7 +134,7 @@
                                         {/if}
                                     {/foreach}
                                     {* adding additional column for odd number of fields in a block *}
-                                    {if $FIELD_MODEL_LIST|@end eq true and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
+                                    {if $smarty.foreach.CalendarDetailViewBlockLevelLoop.last and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
                                     <td class="fieldLabel {$WIDTHTYPE}"></td><td class="{$WIDTHTYPE}"></td>
                                     {/if}
                             </tr>
@@ -144,4 +144,4 @@
             </div>
             <br>
         {/foreach}
-    {/strip}
\ No newline at end of file
+    {/strip}
diff --git a/layouts/v7/modules/Users/DetailViewBlockView.tpl b/layouts/v7/modules/Users/DetailViewBlockView.tpl
index 18f2528e965f31245df4260364218a0e7b773286..ea4d1a6eccfa7dad01b280fe35d4a0cf6ae94116 100644
--- a/layouts/v7/modules/Users/DetailViewBlockView.tpl
+++ b/layouts/v7/modules/Users/DetailViewBlockView.tpl
@@ -10,7 +10,7 @@
 {strip}
 	<input type=hidden name="timeFormatOptions" data-value='{$DAY_STARTS}' />
         <input type='hidden' name='pwd_regex' value= {ZEND_json::encode($PWD_REGEX)} />
-	{foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE}
+	{foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE name=DetailViewBlockViewLoop}
 		{if $BLOCK_LABEL_KEY neq 'LBL_CALENDAR_SETTINGS'}
 			{assign var=BLOCK value=$BLOCK_LIST[$BLOCK_LABEL_KEY]}
 			{if $BLOCK eq null or $FIELD_MODEL_LIST|@count lte 0}{continue}{/if}
@@ -132,7 +132,7 @@
 									{/if}
 								{/foreach}
 								{* adding additional column for odd number of fields in a block *}
-								{if $FIELD_MODEL_LIST|@end eq true and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
+								{if $smarty.foreach.DetailViewBlockViewLoop.last and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
 									<td class="fieldLabel {$WIDTHTYPE}"></td><td class="{$WIDTHTYPE}"></td>
 								{/if}
 							</tr>
@@ -143,4 +143,4 @@
 			<br>
 		{/if}
 	{/foreach}
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl b/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl
index f2a99adfeeebedfe2cf40b996156fe25bbcd9862..5bc9758e0a9900c9702747402e67fb535910548e 100644
--- a/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl
+++ b/layouts/v7/modules/Vtiger/DetailViewBlockView.tpl
@@ -12,7 +12,7 @@
 		<input type="hidden" name="picklistDependency" value='{Vtiger_Util_Helper::toSafeHTML($PICKIST_DEPENDENCY_DATASOURCE)}' />
 	{/if}
 
-	{foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE}
+	{foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE name=DetailViewBlockViewLoop}
 		{assign var=BLOCK value=$BLOCK_LIST[$BLOCK_LABEL_KEY]}
 		{if $BLOCK eq null or $FIELD_MODEL_LIST|@count lte 0}{continue}{/if}
 		<div class="block block_{$BLOCK_LABEL_KEY}" data-block="{$BLOCK_LABEL_KEY}" data-blockid="{$BLOCK_LIST[$BLOCK_LABEL_KEY]->get('id')}">
@@ -130,7 +130,7 @@
 								{/if}
 							{/foreach}
 							{* adding additional column for odd number of fields in a block *}
-							{if $FIELD_MODEL_LIST|@end eq true and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
+							{if $smarty.foreach.DetailViewBlockViewLoop.last and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
 								<td class="fieldLabel {$WIDTHTYPE}"></td><td class="{$WIDTHTYPE}"></td>
 							{/if}
 						</tr>
@@ -140,4 +140,4 @@
 		</div>
 		<br>
 	{/foreach}
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/layouts/vlayout/modules/Inventory/EditViewBlocks.tpl b/layouts/vlayout/modules/Inventory/EditViewBlocks.tpl
index bef3651d3566f3688f311aedc5839111745a0535..d33d3f37534a05d695c8bca7499b2e3b01426df6 100644
--- a/layouts/vlayout/modules/Inventory/EditViewBlocks.tpl
+++ b/layouts/vlayout/modules/Inventory/EditViewBlocks.tpl
@@ -170,11 +170,11 @@
 				{/if}
 			{/foreach}
 			{* adding additional column for odd number of fields in a block *}
-			{if $BLOCK_FIELDS|@end eq true and $BLOCK_FIELDS|@count neq 1 and $COUNTER eq 1}
+			{if $smarty.foreach.EditViewBlockLevelLoop.last and $BLOCK_FIELDS|@count neq 1 and $COUNTER eq 1}
 				<td class="fieldLabel {$WIDTHTYPE}"></td><td class="{$WIDTHTYPE}"></td>
 			{/if}
 			</tr>
 			</table>
 			<br>
 		{/foreach}
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/layouts/vlayout/modules/Vtiger/DetailViewBlockView.tpl b/layouts/vlayout/modules/Vtiger/DetailViewBlockView.tpl
index 7171a71aa949efa10b9f0720def30bd05ddfb1ac..313db2a9d654f87077e5c0b45aa4cb808070fe0a 100644
--- a/layouts/vlayout/modules/Vtiger/DetailViewBlockView.tpl
+++ b/layouts/vlayout/modules/Vtiger/DetailViewBlockView.tpl
@@ -29,7 +29,7 @@
 		 <tbody {if $IS_HIDDEN} class="hide" {/if}>
 		{assign var=COUNTER value=0}
 		<tr>
-		{foreach item=FIELD_MODEL key=FIELD_NAME from=$FIELD_MODEL_LIST}
+		{foreach item=FIELD_MODEL key=FIELD_NAME from=$FIELD_MODEL_LIST name=DetailViewBlockViewLoop}
 			{if !$FIELD_MODEL->isViewableInDetailView()}
 				 {continue}
 			 {/if}
@@ -113,7 +113,7 @@
 		{/if}
 		{/foreach}
 		{* adding additional column for odd number of fields in a block *}
-		{if $FIELD_MODEL_LIST|@end eq true and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
+		{if $smarty.foreach.DetailViewBlockViewLoop.last and $FIELD_MODEL_LIST|@count neq 1 and $COUNTER eq 1}
 			<td class="fieldLabel {$WIDTHTYPE}"></td><td class="{$WIDTHTYPE}"></td>
 		{/if}
 		</tr>
@@ -121,4 +121,4 @@
 	</table>
 	<br>
 	{/foreach}
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/layouts/vlayout/modules/Vtiger/EditViewBlocks.tpl b/layouts/vlayout/modules/Vtiger/EditViewBlocks.tpl
index 1bbaf482a8a701afdeb6e071cc96733d3021faae..f1f46237dca5ed9cbfc97159e3a4180a0bfdd419 100644
--- a/layouts/vlayout/modules/Vtiger/EditViewBlocks.tpl
+++ b/layouts/vlayout/modules/Vtiger/EditViewBlocks.tpl
@@ -125,7 +125,7 @@
             {/if}
         {/foreach}
 		{* adding additional column for odd number of fields in a block *}
-		{if $BLOCK_FIELDS|@end eq true and $BLOCK_FIELDS|@count neq 1 and $COUNTER eq 1}
+		{if $smarty.foreach.EditViewBlockLevelLoop.last and $BLOCK_FIELDS|@count neq 1 and $COUNTER eq 1}
 			<td class="fieldLabel {$WIDTHTYPE}"></td><td class="{$WIDTHTYPE}"></td>
 		{/if}
     </tr>
@@ -133,4 +133,4 @@
 </table>
 <br>
 {/foreach}
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/modules/Settings/Vtiger/models/Module.php b/modules/Settings/Vtiger/models/Module.php
index aa26e3527f8c1eed34b0cfce5a8fbc43200c5b69..4a9f38848cee583f5d7351c8daeebfb261f416cb 100644
--- a/modules/Settings/Vtiger/models/Module.php
+++ b/modules/Settings/Vtiger/models/Module.php
@@ -18,6 +18,7 @@ class Settings_Vtiger_Module_Model extends Vtiger_Base_Model {
 	var $listFields = array('name' => 'Name', 'description' => 'Description');
 	var $nameFields = array('name');
 	var $name = 'Vtiger';
+	var $listFieldModels = null;
 
 	public function getName($includeParentIfExists = false) {
 		if($includeParentIfExists) {
@@ -105,7 +106,7 @@ class Settings_Vtiger_Module_Model extends Vtiger_Base_Model {
 	 * @return Settings_Vtiger_Module_Model instance
 	 */
 	public static function getInstance() {
-            list($name) = func_get_args();
+            list($name) = func_num_args() > 0 ? func_get_args() : "";
             if(empty($name)){
                 $name='Settings:Vtiger';
             }
@@ -155,7 +156,7 @@ class Settings_Vtiger_Module_Model extends Vtiger_Base_Model {
 		$qualifiedModuleName = $request->getModule(false);
 
 		$arrayParams = array();
-		$whereCondition .= "linkto LIKE ?  ";
+		$whereCondition = "linkto LIKE ?  ";
         $arrayParams[] = "%$moduleName%";
  		if ($moduleName != 'LanguageEditor') {
  			$whereCondition .= "AND (linkto LIKE '%parent=Settings%' OR linkto LIKE '%parenttab=Settings%')";
diff --git a/modules/Settings/Vtiger/views/List.php b/modules/Settings/Vtiger/views/List.php
index b4a265c199dc41e7a9baa6cb46bffad45ccedea3..13857c5dd041a4b84c90fb91aafcda41406530c2 100644
--- a/modules/Settings/Vtiger/views/List.php
+++ b/modules/Settings/Vtiger/views/List.php
@@ -12,6 +12,8 @@ class Settings_Vtiger_List_View extends Settings_Vtiger_Index_View {
 	protected $listViewEntries = false;
 	protected $listViewHeaders = false;
 	protected $listviewinitcalled = false;
+	protected $listViewLinks = array();
+	protected $pagingModel = null;
 
 	function __construct() {
 		parent::__construct();
diff --git a/modules/Users/models/Record.php b/modules/Users/models/Record.php
index 035e2b4990be62507b3a31fb8de01ca99ddab0d5..0308b1739a918d5a593258f7bbb8d6d00286177f 100644
--- a/modules/Users/models/Record.php
+++ b/modules/Users/models/Record.php
@@ -732,7 +732,8 @@ class Users_Record_Model extends Vtiger_Record_Model {
 	public function isAccountOwner() {
 		$db = PearDatabase::getInstance();
 		$query = 'SELECT is_owner FROM vtiger_users WHERE id = ?';
-		$isOwner = $db->query_result($db->pquery($query, array($this->getId())), 0, 'is_owner');
+		$rs = $db->pquery($query, array($this->getId()));
+		$isOwner = $db->query_result($rs, 0, 'is_owner');
 		if($isOwner == 1) {
 			return true;
 		}