Location: PHPKode > projects > Epiware Document Management > Epiware_4.8.6/epi/user_pref_common.inc.php
<?
/******************************************************************************
Epiware: Project and Document Management
http://www.epiware.com
Copyright (C) 2006 James Kern

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. 

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. 

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Epiware, Inc. and Praxis Inc, hereby disclaims all copyright
interest in the program 'Epiware' written
by James Kern, Edward Kline, Ryan Gilfether, Ray Gorospe, Patrick Waddingham

06 September 2006
James Kern, President of Epiware 
Jack Chapman, President of Praxis
*****************************************************************************/ 


function check_default_front($db,$group_id,$user_id,$page,$default_template){
  //  Just do a check to see if this guys has a front page defined...
  //  If he does not then insert into the DB, befire a diplay query is called.
  //  We pay becuase we have to check verytime page is loaded... But is welll 
  //  worth the cost........jk
  //----------------------------------------------------------
 
   if($default_template==1){
           insert_default_menu($db,$group_id,$user_id);     
   } else {

     $sql="select count(*) as num from user_pref where "
	. " group_id=$group_id and "
	. " user_id=$user_id and "
	. " page='SUM' ";
   	 if($result = $db->perform_looping_query($sql))
     {
        if($row = $db->get_next_row($result)) {
	        $num=$row["num"];
		    if($num==0){
				if(defined("PRE_DETERMINED_ORDERING"))
                {
                  insert_default_menu_pre_deterined($db,$group_id,$user_id);     
                } else {
                  insert_default_menu($db,$group_id,$user_id);     
                }
            }
        }
	 }
   }

} //END OF FUNCTION CHECK_DEFAULT_FRON
 




function insert_default_menu($db,$group_id,$user_id){
	   //-----------------------------------       
	   // This will be the SUMMARY page...
	   // Just a first stab jk..
	   //-----------------------------------
       $page='SUM';
       $sql="delete from user_pref where group_id=$group_id and user_id=$user_id and page='$page'";
       $db->perform_action_query($sql);
       $description='';
       $item_id=5;
       $title='Calendar'; 
       $col=1;
			$ordering=0;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
       $item_id=6;
       $title='Tasks'; 
       $col=1;
			$ordering=1;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

       $item_id=7;
       $title='Forums'; 
       $col=1;
			$ordering=2;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

         //This is the SENCOND COLUMN..........
		 //-------------------------------------

       $item_id=1;
       $col=2;
       $title='My Account'; 
			$ordering=0;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering, $title,$description);
       $item_id=2;
       $title='News Room'; 
       $col=2;
			$ordering=1;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
       $item_id=3;
       $col=2;
	   $title='Newest Library Files'; 
	   	   $ordering=2;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
       $item_id=4;
       $title='RSS News Feeds'; 
       $col=2;
			$ordering=3;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
      $item_id=8;
       $title='Resources'; 
       $col=2;
			$ordering=4;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
} // END OF FUNCTION INSERT DEFAULT MENU 




function insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description  ){
        $sql="insert into user_pref (item_id,user_id,group_id,page,col,visible,title,ordering) " 
        . " values ('$item_id','$user_id','$group_id','$page','$col','1','$title','$ordering'  ) ";
		//print $sql ."<BR><BR>";
        $db->perform_action_query($sql);

} // END OF FUNCTION INSET_DEFAULT_ITEM







function insert_default_menu_pre_deterined($db,$group_id,$user_id){
	   //-----------------------------------       
	   // This will be the SUMMARY page...
	   // Just a first stab jk..
	   //-----------------------------------
       $page='SUM';
       $sql="delete from user_pref where group_id=$group_id and user_id=$user_id and page='$page'";
       $db->perform_action_query($sql);
       $description='';

       $item_id=5;
       $title='Calendar'; 
       $col=1;
	   $ordering=0;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
       $item_id=6;
       $title='Tasks'; 
       $col=1;
	   $ordering=3;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

       $item_id=7;
       $title='Forums'; 
       $col=1;
	   $ordering=2;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

         //This is the SENCOND COLUMN..........
		 //-------------------------------------



       $title='My Account'; 
       $item_id=1;
	   $ordering=2;
       $col=2;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering, $title,$description);

       $title='News Room'; 
       $item_id=2;
       $ordering=1;
       $col=1;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

       $item_id=3;
	   $title='Newest Library Files'; 
       $col=2;
   	   $ordering=0;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

       $item_id=4;
       $title='RSS News Feeds'; 
       $col=1;
       $ordering=4;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );

       $item_id=8;
       $title='Resources'; 
       $col=2;
	   $ordering=1;
			insert_default_item($db,$user_id,$group_id,$item_id,$page,$col,$ordering,$title,$description );
} // END OF FUNCTION INSERT DEFAULT MENU 
?>
Return current item: Epiware Document Management