Location: PHPKode > projects > MembersGear > membersgear/admin/admin_protected_folder_v.php
<?php
  require_once "../config/config.php";
 //for display the header.php
  require_once INCLUDE_DIR."/users_class.php"; 
  
  if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
     unset($_SESSION[SESSION_PREFIX.'page_referrer']);
  
          echo($smarty->fetch('admin_header.php'));
          $users=new users_class(); 
            if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can view protect folders')==false)
            {
                Redirect('admin_nopermission.php',true);  
            }  
           
            echo "<div id=\"content\" class=\"setdiv\"> ";
            if($message->IsMessageExists())
           {    
                $lsmsg=$message->GetMessage();
                if($_GET['err']=="true")
                 $errorHeader= "<div class=\"errormsg\" style=\"width:400px\">$lsmsg</div>";
                else
                   $errorHeader= "<div class=\"succmsg\" style=\"width:400px\">$lsmsg</div>";
                   
               echo  $errorHeader;   
           }

            echo "<div id=\"full-contentdiv\">";
            echo "<div class=\"righttop\">";
            echo "<h2 align=\"center\">";
            echo "Protected Folders";
            echo "</h2>";
            echo "</div>";
            echo "<div class=\"whole-page clear\">";
            
            /****************************************************************************
            * Updated By Jayesh : for display character based paging
            *****************************************************************************/
            echo "<div class='controlDiv'>";
            echo PrintABCDPaging();
            echo "</div>";
            
             if(isset($_GET['letter']) and $_GET['letter'] != 'all')
              {
                    $lsSearchLetter = $_GET['letter'];
              }
              else
              {
                    $lsSearchLetter = '';   
              }
            
          //echo $res;
                /*$sql = "SELECT min( p.`id` ) AS id, p.`folder` , (
                        SELECT pmv.value FROM prefix_master pm
                        JOIN prefix_master_values pmv ON pm.id = pmv.masterid
                        WHERE upper( pm.name ) = upper( 'protectionmethod' )
                        AND pmv.id = p.protection_method
                        )protection_method, (
                        SELECT CAST( GROUP_CONCAT( pr.`name`
                        ORDER BY pr.`name` ASC
                        SEPARATOR ',' ) AS CHAR ) AS products
                        FROM prefix_product_protect pi
                        JOIN prefix_products pr ON pr.id = pi.allowed_productid
                        WHERE UPPER( trim( folder ) ) = (
                        SELECT UPPER( trim( folder ) )
                        FROM prefix_product_protect ppi
                        WHERE ppi.`id` = p.`id` )
                        AND pr.isapproved =1
                        AND pr.isdeleted !=1
                        ) AS `allowed_products` , p.`is_invalid_access_message` , p.`invalid_access_message`
                        FROM prefix_product_protect p
                        GROUP BY p.`folder` , p.`protection_method` , p.`is_invalid_access_message` , p.`invalid_access_message`" ; */
                
                
          
                $lsweburl=WEB_URL;        
                /*$sql = "SELECT min( p.`id` ) AS id, concat('<a href=\"$lsweburl',p.`folder`,'\">',p.`folder`,'</a>') as folder , (
                        SELECT pmv.value FROM ".TABLE_PREFIX."master pm
                        JOIN ".TABLE_PREFIX."master_values pmv ON pm.id = pmv.masterid
                        WHERE upper( pm.name ) = upper( 'protectionmethod' )
                        AND pmv.id = p.protection_method
                        )protection_method, (
                        SELECT CAST( GROUP_CONCAT( pr.`name`
                        ORDER BY pr.`name` ASC
                        SEPARATOR ',' ) AS CHAR ) AS products
                        FROM ".TABLE_PREFIX. "product_protect pi
                        JOIN ".TABLE_PREFIX."products pr ON pr.id = pi.allowed_productid
                        WHERE UPPER( trim( folder ) ) = (
                        SELECT UPPER( trim( folder ) )
                        FROM ".TABLE_PREFIX."product_protect ppi
                        WHERE ppi.`id` = p.`id` )
                        AND pr.isapproved =1
                        AND pr.isdeleted !=1
                        ) AS `allowed_products` , p.`is_invalid_access_message` , p.`invalid_access_message`
                        FROM prefix_product_protect p WHERE p.folder like '/$lsSearchLetter%' 
                        GROUP BY p.`folder` , p.`protection_method` , p.`is_invalid_access_message` , p.`invalid_access_message`" ; */
                
           
                  $sql="SELECT min( p.`id` ) AS id, concat('<a href=\"$lsweburl',prd.`protectedurl`,'\" target=\"_blanks\">',p.`folder`,'</a>') as folder ,
                        (SELECT case when pmv.value='new_rewrite' then 'new_rewrite (recommended)' else pmv.value end FROM ".TABLE_PREFIX."master pm
                          JOIN ".TABLE_PREFIX."master_values pmv ON pm.id = pmv.masterid
                            WHERE upper( pm.name ) = upper( 'protectionmethod' )
                              AND
                              pmv.id = p.protection_method )protection_method,
                              (SELECT CAST( GROUP_CONCAT(concat('-', pr.`name`) ORDER BY pr.`name` ASC SEPARATOR ',<br/>' ) AS CHAR ) AS products
                               FROM ".TABLE_PREFIX."product_protect pi
                               JOIN ".TABLE_PREFIX."products pr
                                 ON pr.id = pi.allowed_productid
                                     WHERE UPPER( trim( folder ) ) = (SELECT UPPER( trim( folder ) )
                                     FROM ".TABLE_PREFIX."product_protect ppi WHERE ppi.`id` = p.`id` )
                                     AND
                                       pr.isapproved =1 AND pr.isdeleted !=1 ) AS `allowed_products`
                                      , p.`is_invalid_access_message` , p.`invalid_access_message`,prd.`protectedurl`
                                    FROM ".TABLE_PREFIX."product_protect p
                                   join ".TABLE_PREFIX."products prd on prd.`id`=p.`allowed_productid`
                                   WHERE p.folder like '/$lsSearchLetter%'     GROUP BY p.`folder` ,
                                   p.`protection_method` , p.`is_invalid_access_message` , p.`invalid_access_message`  ";
                        
                # execute the sql query
                $db->execute($sql);


                # creates a new phpSortColumn object for ID´s 
                //$col_0 = new phpSortColumn("id", "ID");
                
                #creates a new phpSortcolunm objects for name
                $col_0 = new phpSortColumn("folder", "Folder Path");
                
                # creates a new phpSortColumn object for Tile
                $col_1 = new phpSortColumn("protection_method", "Protection Method");

                # creates a new phpSortColumn object for Field Type
                $col_2 = new phpSortColumn("allowed_products", "Allowed Products");
                
                 $col_3 = new phpSortColumn("invalid_access_message", "Invalid Access Message");
                                                                                        
                # add the columns to an array 
                $columns = array(0=>$col_0, 1=>$col_1, 2=>$col_2,3=>$col_3);

                # create a new phpSortable object with the abstracted db object
                # and the array of column object
                $sortable = new phpSortable($db, $columns);

                # define the table format: cellpadding, cellspacing, border
                $sortable->setTableFormat ("2", "2", "0");

                # define the table title
                $sortable->tableTitle = "";

                # Encrypt Edit and Delete Link
                $sortable->encryptlink = false;
                
                # define the link for edit of entries
                $sortable->editLink = "admin_protected_folder.php?action=edit";

                # open the edit page in a new window
                //$sortable->editTarget = "_blank";

                # window format for the edit page
               // $sortable->editWindowFormat = "'width=300,height=400'";

               $quest="&";
                if(isset($_GET) && !empty($_GET))
                 {
                     foreach($_GET as $keyname => $value) {
                          $quest.=$keyname."=".$value."&";
                        }     
                 
                 }
                # define the link for delete of entries
                $sortable->deleteLink = "admin_protected_folder.php?action=delete$quest";

                # define the link for add new entries
                $sortable->addLink = "admin_protected_folder.php";
                
                # set visibility of add,edit,delete link of the grid
                if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can manage protect folders')==false)
                {
                     $sortable->showaddLink=false; 
                     $sortable->showeditLink=false;
                     $sortable->showdeleteLink=false;
                }

                # define the hint to be displyed over the add button
                $sortable->addText = "Add New Protected Folder";

                # define the key name to be attached to links
                $sortable->urlKeyName = "id";

                # define the column name of to be attached to links as key value
                $sortable->tableKeyName = "id";

                # define the prompt message to be diplayed on clicking the edit button            
                //$sortable->editPromptMsg = "Are you sure you want to edit this affiliate?";

                # define the prompt message to be diplayed on clicking the delete button
                $sortable->deletePromptMsg = "Are you sure you want to delete this Protected Folder?";

                # define the message to be diplayed if there are no results found
                $sortable->emptyMsg = "No Field found.";

                #define the deafult row number to be displayed
                $sortable->defaultRowsNum = "10";

                #define the path for the css file
                $sortable->cssFilePath = ADMIN_CSS_DIR."/phpSortable.css";

                #define the path for of the images directory
                $sortable->imgFilePath = ADMIN_IMAGE_DIR."/phpgrid/";

                # print the table            
                $sortable->printTable();

              echo "</div>";
              echo "</div>";
              echo "</div>";
                
              //For display footer.php
              echo($smarty->fetch('admin_footer.php'));   
 
?>
Return current item: MembersGear