Пример #1
0
  public function validate_name($op) {
    if ($this->name != "") {
      
      // check there isn't already a field set with this name 
      
      $taxonomy_name = $this->visibility["taxonomies"];

      if ($this->name != "") {

        $extra_check = "";
      
        if ($op != "insert") {

          $extra_check = " AND fg.id <> ".$this->id." ";

        }
      
      }
    
      // check if a field set already exists specific to this post type 

      if ($post_type) {
        $sql = "SELECT * FROM ".MPU::table("field-sets")." fg WHERE type = 'x' AND fg.name = '{$this->name}' AND ".MPM::visibility_rlike("taxonomies", $taxonomy_name).$extra_check;
        $result = MPM_FieldSet::get_model("field-set", $sql );
      }

      if (isset($result) && $result) {
        $this->err(sprintf(__("Sorry, a field set named <em>%s</em> already exists for taxonomy <em>%s</em>. Please enter another name.", MASTERPRESS_DOMAIN), $this->name, $taxonomy_name), "name");
      }
      
    }
  }