Exemplo n.º 1
0
/**
 * Function to write the vtiger_parenttabid and name to a flat file parent_tabdata.txt so that the data
 * is obtained from the file instead of repeated queries
 * returns null
 */
function create_parenttab_data_file()
{
    global $log;
    $log->debug("Entering create_parenttab_data_file() method ...");
    $log->info("creating parent_tabdata file");
    global $adb;
    $sql = "select parenttabid,parenttab_label from vtiger_parenttab where visible=0 order by sequence";
    $result = $adb->pquery($sql, array());
    $num_rows = $adb->num_rows($result);
    $result_array = array();
    for ($i = 0; $i < $num_rows; $i++) {
        $parenttabid = $adb->query_result($result, $i, 'parenttabid');
        $parenttab_label = $adb->query_result($result, $i, 'parenttab_label');
        $result_array[$parenttabid] = $parenttab_label;
    }
    $filename = 'parent_tabdata.php';
    if (file_exists($filename)) {
        if (is_writable($filename)) {
            if (!($handle = fopen($filename, 'w+'))) {
                echo "Cannot open file ({$filename})";
                exit;
            }
            require_once 'modules/Users/CreateUserPrivilegeFile.php';
            $newbuf = '';
            $newbuf .= "<?php\n\n";
            $newbuf .= "\n";
            $newbuf .= "//This file contains the commonly used variables \n";
            $newbuf .= "\n";
            $newbuf .= "\$parent_tab_info_array=" . constructSingleStringValueArray($result_array) . ";\n";
            $newbuf .= "\n";
            $parChildTabRelArray = array();
            foreach ($result_array as $parid => $parvalue) {
                $childArray = array();
                //$sql = "select * from vtiger_parenttabrel where parenttabid=? order by sequence";
                // vtlib customization: Disabling the tab item based on presence
                $sql = "select * from vtiger_parenttabrel where parenttabid=?\r\n\t\t\t\t\tand tabid in (select tabid from vtiger_tab where presence in (0,2)) order by sequence";
                // END
                $result = $adb->pquery($sql, array($parid));
                $num_rows = $adb->num_rows($result);
                $result_array = array();
                for ($i = 0; $i < $num_rows; $i++) {
                    $tabid = $adb->query_result($result, $i, 'tabid');
                    $childArray[] = $tabid;
                }
                $parChildTabRelArray[$parid] = $childArray;
            }
            $newbuf .= "\n";
            $newbuf .= "\$parent_child_tab_rel_array=" . constructTwoDimensionalValueArray($parChildTabRelArray) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\n";
            $newbuf .= "\n";
            $newbuf .= "?>";
            fputs($handle, $newbuf);
            fclose($handle);
        } else {
            echo "The file {$filename} is not writable";
        }
    } else {
        echo "The file {$filename} does not exist";
        $log->debug("Exiting create_parenttab_data_file method ...");
        return;
    }
}
Exemplo n.º 2
0
 static function createModuleMetaFile()
 {
     $adb = PearDatabase::getInstance();
     $sql = "select * from vtiger_tab";
     $result = $adb->pquery($sql, array());
     $num_rows = $adb->num_rows($result);
     $result_array = array();
     $seq_array = array();
     $ownedby_array = array();
     for ($i = 0; $i < $num_rows; $i++) {
         $tabid = $adb->query_result($result, $i, 'tabid');
         $tabname = $adb->query_result($result, $i, 'name');
         $presence = $adb->query_result($result, $i, 'presence');
         $ownedby = $adb->query_result($result, $i, 'ownedby');
         $result_array[$tabname] = $tabid;
         $seq_array[$tabid] = $presence;
         $ownedby_array[$tabid] = $ownedby;
     }
     //Constructing the actionname=>actionid array
     $actionid_array = array();
     $sql1 = "select * from vtiger_actionmapping";
     $result1 = $adb->pquery($sql1, array());
     $num_seq1 = $adb->num_rows($result1);
     for ($i = 0; $i < $num_seq1; $i++) {
         $actionname = $adb->query_result($result1, $i, 'actionname');
         $actionid = $adb->query_result($result1, $i, 'actionid');
         $actionid_array[$actionname] = $actionid;
     }
     //Constructing the actionid=>actionname array with securitycheck=0
     $actionname_array = array();
     $sql2 = "select * from vtiger_actionmapping where securitycheck=0";
     $result2 = $adb->pquery($sql2, array());
     $num_seq2 = $adb->num_rows($result2);
     for ($i = 0; $i < $num_seq2; $i++) {
         $actionname = $adb->query_result($result2, $i, 'actionname');
         $actionid = $adb->query_result($result2, $i, 'actionid');
         $actionname_array[$actionid] = $actionname;
     }
     $filename = 'user_privileges/tabdata.php';
     if (file_exists($filename)) {
         if (is_writable($filename)) {
             if (!($handle = fopen($filename, 'w+'))) {
                 echo "Cannot open file ({$filename})";
                 exit;
             }
             require_once 'modules/Users/CreateUserPrivilegeFile.php';
             $newbuf = '';
             $newbuf .= "<?php\n\n";
             $newbuf .= "\n";
             $newbuf .= "//This file contains the commonly used variables \n";
             $newbuf .= "\n";
             $newbuf .= "\$tab_info_array=" . constructArray($result_array) . ";\n";
             $newbuf .= "\n";
             $newbuf .= "\$tab_seq_array=" . constructArray($seq_array) . ";\n";
             $newbuf .= "\n";
             $newbuf .= "\$tab_ownedby_array=" . constructArray($ownedby_array) . ";\n";
             $newbuf .= "\n";
             $newbuf .= "\$action_id_array=" . constructSingleStringKeyAndValueArray($actionid_array) . ";\n";
             $newbuf .= "\n";
             $newbuf .= "\$action_name_array=" . constructSingleStringValueArray($actionname_array) . ";\n";
             $newbuf .= "?>";
             fputs($handle, $newbuf);
             fclose($handle);
         } else {
             echo "The file {$filename} is not writable";
         }
     } else {
         echo "The file {$filename} does not exist";
     }
 }
Exemplo n.º 3
0
	static function createModuleGroupMetaFile() {
		global $adb;
		global $WERPASCOPEPARENTTABDATA;
		
		$sql = "select parenttabid,parenttab_label from vtiger_parenttab where visible=0 order by sequence";
		$result = $adb->pquery($sql, array());
		$num_rows = $adb->num_rows($result);
		$result_array = Array();
		for ($i = 0; $i < $num_rows; $i++) {
			$parenttabid = $adb->query_result($result, $i, 'parenttabid');
			$parenttab_label = $adb->query_result($result, $i, 'parenttab_label');
			$result_array[$parenttabid] = $parenttab_label;
		}

		$filename = $WERPASCOPEPARENTTABDATA;

		if (file_exists($filename)) {
			if (is_writable($filename)) {
				if (!$handle = fopen($filename, 'w+')) {
					echo "Cannot open file ($filename)";
					exit;
				}
				require_once('modules/Users/CreateUserPrivilegeFile.php');
				$newbuf = '';
				$newbuf .="<?php\n\n";
				$newbuf .="\n";
				$newbuf .= "//This file contains the commonly used variables \n";
				$newbuf .= "\n";
				$newbuf .= "\$parent_tab_info_array=" . constructSingleStringValueArray($result_array) . ";\n";
				$newbuf .="\n";

				$parChildTabRelArray = Array();

				foreach ($result_array as $parid => $parvalue) {
					$childArray = Array();
					//$sql = "select * from vtiger_parenttabrel where parenttabid=? order by sequence";
					// vtlib customization: Disabling the tab item based on presence
					$sql = "select * from vtiger_parenttabrel where parenttabid=?
						and tabid in (select tabid from vtiger_tab where presence in (0,2)) order by sequence";
					// END
					$result = $adb->pquery($sql, array($parid));
					$num_rows = $adb->num_rows($result);
					$result_array = Array();
					for ($i = 0; $i < $num_rows; $i++) {
						$tabid = $adb->query_result($result, $i, 'tabid');
						$childArray[] = $tabid;
					}
					$parChildTabRelArray[$parid] = $childArray;
				}
				$newbuf .= "\n";
				$newbuf .= "\$parent_child_tab_rel_array=" . constructTwoDimensionalValueArray($parChildTabRelArray) . ";\n";
				$newbuf .="\n";
				$newbuf .="\n";
				$newbuf .="\n";
				$newbuf .= "?>";
				fputs($handle, $newbuf);
				fclose($handle);
			} else {
				echo "The file $filename is not writable";
			}
		} else {
			echo "The file $filename does not exist";
		}
	}