Results 1 to 10 of 10

Thread: Litle correction for Favorite Listing

  1. #1
    Join Date
    Jul 2004
    Posts
    37

    Default Litle correction for Favorite Listing

    If you don't want members having same name for favorite folders

    in cp/favorite_create.php

    Code:
      
    function ProcessFormCreateFavorite() {
    
        // vars global configuration
        global $theme_path, $COOKIE_USERNAME;
    
        // vars url & form
        global $id, $title, $description;
    
        // vars messages
        global $msg;
    
        // vars template
        global $error_msg;
    
    
        // verify input
    
        $title = $_POST["title"];
    
        if (empty($title))
          $error_msg = $msg["20081"];
    
        if (empty($error_msg)) {
          $links_obj = new clsLink;
          $links_obj->favorite_table_name = "idx_favorites";
    	  $doesTitleExist = $links_obj->CheckFavorite($COOKIE_USERNAME, $title);
    
    	  if ( $doesTitleExist == 1)
    	  $error_msg = $msg["20082"];
    	  else {
    	  	$links_obj->CreateFavorite($COOKIE_USERNAME, $title, $description);
          	DisplayTemplate($theme_path . "cp/favorite_create_ok.html", "\$novar");
    	  }
        }
    	
    	if (!empty($error_msg)) ShowFormCreateFavorite();
      }
    
    in cp/favorite_edit.php
    Code:
    
      function ProcessFormEditFavorites() {
    
        // vars global configuration
        global $theme_path, $COOKIE_USERNAME;
    
        // vars url & form
        global $id, $title, $description, $Oldtitle;
    
        // vars messages
        global $msg;
    
        // vars template
        global $error_msg;
    
    
        // verify input
    
        $title = $_POST["title"];
    
        if (empty($title))
          $error_msg = $msg["20071"];
    	
    
        if (empty($error_msg)) {
          $links_obj = new clsLink;
          $links_obj->favorite_table_name = "idx_favorites";
    	  $doesTitleExist = 0;
    	  if ($Oldtitle != $title ) $doesTitleExist = $links_obj->CheckFavorite($COOKIE_USERNAME, $title);
    	  if ( $doesTitleExist == 1)
    		  $error_msg = $msg["20082"];
    	  else {
    		  $links_obj->template_file       = $theme_path . "cp/favorite_edit_ok.html";
    		  $links_obj->EditFavorite("process_form", $COOKIE_USERNAME, $id);
    		  if ($edit_result == 1)
    			DisplayTemplate($theme_path . "cp/not_allowed.html", "\$novar");
    	  }
        }
    	
        if (!empty($error_msg)) ShowFormEditFavorites();
    	
      }
    in themes/kosmos/msg.php
    after :
    $msg['20081'] = $lang['empty_favorite_title'];
    add :
    Code:
    
    $msg['20082'] = $lang['favorite_title_already_exist'];
    
    in themes/kosmos/cp/favorite_edit_form.html
    after :
    <input type=hidden name=id value=<%$id%>>
    add :
    Code:
    
    <input type=hidden name=Oldtitle value=<%$title%>>
    
    in lib/link.class
    add after the last } of function RemoveDetailFavorite :

    Code:
    
        // method to Check favorite
        // input :    $username
        //            $title
        // output :   0 : success 
        //            1 : title for this favorite ALREADY exist
        // ------------------------------------------
    
        function CheckFavorite($username, $title) {
          global $dbConn;
          $query  = "select favorite_id from $this->favorite_table_name where title = '$title' and username = '$username' ";
          $result = $dbConn->Execute($query);
          $favorite_id = $result->Fields("favorite_id");
    
          if(empty($favorite_id)) 
    	    return 0;
          else
            return 1;
        }
    
    in lang/english.php
    after :
    $lang['empty_favorite_title'] = 'Please enter the title';
    add :
    Code:
    
    $lang['favorite_title_already_exist']= 'This title for Favorite Listing already exist';
    
    Last edited by gcn; 04-16-2006 at 02:17 PM.

  2. #2
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by gcn
    If you don't want members having same name for favorite folders

    in cp/favorite_create.php

    in cp/favorite_edit.php
    hmmm...can you somehow highlight what you did in the above files.

    also, YellowGreen would not be my color of choice for displaying text on this particular background. Kinda hard to see. Even bolded is kinda hard to see



    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  3. #3
    Join Date
    Jul 2004
    Posts
    37

    Default

    If you don't want members having same name for favorite folders

    in cp/favorite_create.php

    Code:
    function ProcessFormCreateFavorite() {
    
        // vars global configuration
        global $theme_path, $COOKIE_USERNAME;
    
        // vars url & form
        global $id, $title, $description;
    
        // vars messages
        global $msg;
    
        // vars template
        global $error_msg;
    
    
        // verify input
    
        $title = $_POST["title"];
    
        if (empty($title))
          $error_msg = $msg["20081"];
    
        if (empty($error_msg)) {
          $links_obj = new clsLink;
          $links_obj->favorite_table_name = "idx_favorites";
    	
      $doesTitleExist = $links_obj->CheckFavorite($COOKIE_USERNAME, $title);
    
    	  if ( $doesTitleExist == 1)
    	  $error_msg = $msg["20082"];
    	  else {
    	  	$links_obj->CreateFavorite($COOKIE_USERNAME, $title, $description);
          	DisplayTemplate($theme_path . "cp/favorite_create_ok.html", "\$novar");
    	  }
        }
    	
    	if (!empty($error_msg)) ShowFormCreateFavorite();
    
      }
    in cp/favorite_edit.php
    Code:
      function ProcessFormEditFavorites() {
    
        // vars global configuration
        global $theme_path, $COOKIE_USERNAME;
    
        // vars url & form
        global $id, $title, $description, $Oldtitle;
    
        // vars messages
        global $msg;
    
        // vars template
        global $error_msg;
    
    
        // verify input
    
        $title = $_POST["title"];
    
        if (empty($title))
          $error_msg = $msg["20071"];
    	
    
        if (empty($error_msg)) {
          $links_obj = new clsLink;
          $links_obj->favorite_table_name = "idx_favorites";
    	  $doesTitleExist = 0;
    	  if ($Oldtitle != $title ) $doesTitleExist = $links_obj->CheckFavorite($COOKIE_USERNAME, $title);
    	  if ( $doesTitleExist == 1)
    		  $error_msg = $msg["20082"];
    	  else {
    		  $links_obj->template_file       = $theme_path . "cp/favorite_edit_ok.html";
    		  $links_obj->EditFavorite("process_form", $COOKIE_USERNAME, $id);
    		  if ($edit_result == 1)
    			DisplayTemplate($theme_path . "cp/not_allowed.html", "\$novar");
    	  }
        }
    	
        if (!empty($error_msg)) ShowFormEditFavorites();
    	
      }
    in themes/kosmos/msg.php
    after :
    $msg['20081'] = $lang['empty_favorite_title'];
    add :
    Code:
    
    $msg['20082'] = $lang['favorite_title_already_exist'];
    
    in themes/kosmos/cp/favorite_edit_form.html
    after :
    <input type=hidden name=id value=<%$id%>>
    add :
    Code:
    
    <input type=hidden name=Oldtitle value=<%$title%>>
    
    in lib/link.class
    add after the last } of function RemoveDetailFavorite :

    Code:
    
        // method to Check favorite
        // input :    $username
        //            $title
        // output :   0 : success 
        //            1 : title for this favorite ALREADY exist
        // ------------------------------------------
    
        function CheckFavorite($username, $title) {
          global $dbConn;
          $query  = "select favorite_id from $this->favorite_table_name where title = '$title' and username = '$username' ";
          $result = $dbConn->Execute($query);
          $favorite_id = $result->Fields("favorite_id");
    
          if(empty($favorite_id)) 
    	    return 0;
          else
            return 1;
        }
    
    in lang/english.php
    after :
    $lang['empty_favorite_title'] = 'Please enter the title';
    add :
    Code:
    
    $lang['favorite_title_already_exist']= 'This title for Favorite Listing already exist';
    
    Last edited by gcn; 04-16-2006 at 02:14 PM.

  4. #4
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    very nice.

    what can I say...! I'm just a lazy sod...!



    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  5. #5
    Join Date
    Jul 2004
    Posts
    37

    Default

    i correct i forgot ; after $msg['20061'] = $lang['favorite_link_already_exist']

    thanks i prepare a mod for secure directory

    post soon


  6. #6
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by gcn
    i prepare a mod for secure directory
    care to elaborate?



    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  7. #7
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

  8. #8
    Join Date
    Jul 2004
    Posts
    37

    Default

    care to elaborate?
    I contribute my share gradually

    np Thanks to you

  9. #9
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    np. I just have no clue as to what you mean by "a mod for secure directory."


    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  10. #10
    Join Date
    Jul 2004
    Posts
    37

    Default

    sorry nevermind sometimes i talk too fast i had an idea when i wrote and the second after i forgot lol
    that s why i wrote on forum lol

Similar Threads

  1. sitemap.php correction
    By gcn in forum v5.x
    Replies: 3
    Last Post: 11-12-2006, 09:36 AM
  2. Favorite listing
    By marengo in forum v5.x
    Replies: 3
    Last Post: 05-07-2005, 04:51 AM
  3. Favorite bug
    By martijn in forum v5.x
    Replies: 0
    Last Post: 05-15-2002, 01:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •