Ejemplo n.º 1
0
	function get_value_with_referenced()
	{
		$final_value = null;
		$this_type = get_class($this);
	$sql = "select ".str_replace("_prop","_val",strtolower($this_type))." from ".
strtolower($this_type)." where prop_id = ".$this->my_prop_id." and ent_prop_id = ".$this->my_ent_prop_id;
		$result = mysql_query($sql);
		if (mysql_num_rows($result)==0)
			return "";
		$value = mysql_result($result,0);
		
		if (ClientServerDataOps::has_lookup_table($this->my_prop_id) && !empty($value))
		{
			$final_value = ClientServerDataOps::get_value_by_id($value,$this->my_prop_id);
		}
		else
		{
			$final_value = $value;
		}
		
		return $final_value;
	}
Ejemplo n.º 2
0
 function initialize()
 {
     //if eid = 0, it's necessary to create empty record for specified type, can't cache!
     //or if doing filter proprties, as the record xml returned will vary
     //$do_memcache = (!empty($this->eid) && empty($this->filter_properties));
     $do_memcache = false;
     //don't need this
     /* procedural API */
     $xml_string = "";
     if ($do_memcache) {
         $memcache_obj = memcache_connect('localhost', 11211);
         //echo "eid: ".$this->eid."<br>";
         $xml_string = memcache_get($memcache_obj, $this->eid);
     }
     if ($xml_string && $this->eid) {
         // echo "got it!";
         $this->xml_string = $xml_string;
     } else {
         //echo microtime()." -Record: initialize;  entering  <br>";
         //get the number of Categories properties added to this entity
         if ($this->set_ids_num_extra_from_lookup_count) {
             $tempglu = new Glue();
             $tempglu->set_type_id($this->type_id);
             $tempglu->prop_ids = array(6);
             //category property id = 6
             $tempglu->set_prop_id_prop_obj_hash();
             $tempglu->set_ent_prop_3dhash($this->eid);
             //print_r( $tempglu->ent_prop_3dhash); echo "count".count($tempglu->ent_prop_3dhash[6])."<br>";
             //echo "category count:". count(ClientServerDataOps::get_table_DS("category"));
             //debug_print_backtrace();
             $this->glu->prop_ids_num_extra[6] = count(ClientServerDataOps::get_table_DS("category")) - count($tempglu->ent_prop_3dhash[6]);
             //total categories minus those assigned to this entity - 2009-04-03 Adam George
             //get the number of SubCategories properties added to this entity
             $tempglu = new Glue();
             $tempglu->set_type_id($this->type_id);
             $tempglu->prop_ids = array(50);
             //subcategory property id = 50
             $tempglu->set_prop_id_prop_obj_hash();
             $tempglu->set_ent_prop_3dhash($this->eid);
             $this->glu->prop_ids_num_extra[50] = count(ClientServerDataOps::get_table_DS("subcategory")) - count($tempglu->ent_prop_3dhash[50]);
             //total subcategories minus those assigned to this entity - 2009-04-05 Adam George
             //echo "count esubcats: ".count(ClientServerDataOps::get_table_DS("subcategory"))."<br>count from glu: ".
             //$this->glu->prop_ids_num_extra[50]."--".count($tempglu->ent_prop_3dhash[50]);
         }
         if ($this->type_id != 3) {
             $this->glu->prop_ids_num_extra[11] = 1;
         }
         //	$this->glu->prop_ids_num_extra[50] = 1;
         //	$this->glu->prop_ids_num_extra[35] = 1;
         $this->glu->set_prop_ids_num_extra_by_group_id(1);
         $this->glu->set_prop_ids_num_extra_by_group_id(2);
         $this->glu->set_prop_ids_num_extra_by_group_id(3);
         //$this->glu->set_prop_ids_num_extra_by_group_id(2);
         $this->glu->set_type_frame($this->type_id);
         //$this->glu->set_type_id($this->type_id);
         //$this->glu->set_prop_ids();
         //$this->glu->set_prop_id_prop_obj_hash();
         //echo microtime()." -Record: initialize;  calling ".'$this->glu->set_ent_prop_3dhash($this->eid);'."<br>";
         $this->ent_prop_3dhash = $this->glu->set_ent_prop_3dhash($this->eid);
         //echo microtime()." -Record: initialize;  calling ".'this->create_xml_rec();'."<br>";
         $this->xml_string = $this->create_xml_rec();
         if ($do_memcache) {
             $result = memcache_set($memcache_obj, $this->eid, $this->xml_string, MEMCACHE_COMPRESSED, 0);
             //echo "succeed?".$result.",memcachekey:".$this->eid;
         }
     }
     if ($do_memcache) {
         $memcache_obj->close();
     }
     //print_r( $this->glu->ent_prop_3dhash); echo "count".count($glu->ent_prop_3dhash[6])."<br>";
     //$this->xslt_file = $_SERVER['DOCUMENT_ROOT']."/XSLTemplates/testrec.xsl"; //get rid of this line
     //echo "eid: ".$this->eid."microtime:".microtime()." -Record: initialize;  end <br>";
 }
Ejemplo n.º 3
0
	function get_LookupTableObj()
	{
		return ClientServerDataOps::get_LookupTableObj();
	}
Ejemplo n.º 4
0
 function search_and_gather_eids($ctns_prop_ids, $ctns_prop_vals, $ctns_prop_vals_exact_match, $ctns_prop_vals_inverse_match, $prop_ids, $prop_vals, $type_id, $sort_prop_ids, $prop_comps, $type_ids, $group_nums, $ctns_prop_types)
 {
     //print_r(func_get_args());
     //$debug_time = "";
     $fin_eids = array();
     $filt_eids = null;
     $all_filts_any = true;
     //$debug_time .= microtime().'entering search_and_gather_eids<br>';
     //filter by set
     //Currently assumes ORing of match properties, need to do as below for text search!
     for ($i = 0; $i < count($prop_ids); $i++) {
         //echo '-- $search_prop_id'.$prop_ids[$i]." searchpropval: ".$prop_vals[$i]." , typeid: ".$type_id;
         $search_prop_val = $prop_vals[$i];
         $search_prop_id = $prop_ids[$i];
         $search_prop_comp = $prop_comps[$i];
         //note: if using comparison function, must include spc[] post variable for all prop_ids
         $group_num = $group_nums[$i];
         if (count($type_ids) > 0) {
             $_type_id = $type_ids[$i];
         } else {
             $_type_id = $type_id;
         }
         if ($search_prop_val == 0 && strlen($search_prop_comp) == 0) {
             //echo '<br>$search_prop_val:'.$search_prop_val;
             continue;
         } else {
             $all_filts_any = false;
         }
         //	$eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $type_id);
         if (strlen($search_prop_val) == 0) {
             $eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $_type_id);
         } else {
             $eids = RecordsSys_EntityManagementSystems::get_eids($search_prop_val, $search_prop_id, $_type_id, $search_prop_comp);
         }
         $arr2 = array();
         foreach ($eids as $eid) {
             array_push($arr2, $eid);
         }
         if ($group_num) {
             if (!isset($filt_eids)) {
                 $filt_eids = $arr2;
             } else {
                 $filt_eids = array_unique(array_merge($filt_eids, $arr2));
             }
         } else {
             if (!isset($filt_eids)) {
                 //echo "search_prop_val: ".$search_prop_val." -- search_prop_id: " . $search_prop_id." filt_eids: " . print_r($filt_eids,true).", arr2: " . print_r($arr2, true)."<br>";
                 $filt_eids = $arr2;
             } else {
                 $filt_eids = array_intersect($filt_eids, $arr2);
             }
         }
     }
     //echo "<br>all filters any? ".$all_filts_any." or the filteids:". print_r($filt_eids,true);
     //intersect with Contains search
     //echo count($ctns_prop_ids)."yo".print_r($ctns_prop_ids,true);
     if (empty($ctns_prop_ids) or count($ctns_prop_ids) == 0) {
         //	echo '<br>;starting contains search. $all_filts_any: '.$all_filts_any.', $ctns_prop_ids: '.print_r($ctns_prop_ids,true);
         //			.'; count($cnts_prop_ids)'.count($ctns_prop_ids);
         $fin_eids = $filt_eids;
         //	echo 'n4ello'.print_r($fin_eids,true);
     } else {
         //$debug_time .= microtime().' starting contains filter'.print_r($fin_eids,true)."<br>";
         for ($i = 0; $i < count($ctns_prop_ids); $i++) {
             $search_prop_val = count($ctns_prop_vals) > 1 ? $ctns_prop_vals[$i] : $ctns_prop_vals[0];
             $search_prop_val_exact_match = count($ctns_prop_vals_exact_match) > 1 ? $ctns_prop_vals_exact_match[$i] : $ctns_prop_vals_exact_match[0];
             //not sure if this will work with more than one ctnse, need to test
             $search_prop_val_inverse_match = count($ctns_prop_vals_inverse_match) > 1 ? $ctns_prop_vals_inverse_match[$i] : $ctns_prop_vals_inverse_match[0];
             //not sure if this will work with more than one ctnse, need to test
             //echo "heeeelo".$search_prop_val_exact_match."end";
             $search_prop_val = trim($search_prop_val);
             $search_prop_id = $ctns_prop_ids[$i];
             $ctns_prop_type = empty($ctns_prop_types[$i]) ? $type_id : $ctns_prop_types[$i];
             //echo " <br>the ctns_prop_types[i]: ".$ctns_prop_types[$i];
             //echo "<br>SEARCH COUNT for $search_prop_val :". count($eids)."<br>";
             if ($search_prop_id == "by_eid") {
                 $eids = empty($search_prop_val) ? array() : array($search_prop_val);
             } elseif ($search_prop_val_exact_match) {
                 //echo "BLOWBLOWBLOWBLWO".$search_prop_val_exact_match;
                 //$eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $type_id);
                 $eids = RecordsSys_EntityManagementSystems::get_eids($search_prop_val, $search_prop_id, $_type_id, $search_prop_comp);
             } else {
                 //echo "<br>IN CONTAINS SEARCH!!$search_prop_val, $search_prop_id, $ctns_prop_type<BR>".empty($search_prop_val)."yo";
                 $eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $ctns_prop_type);
                 //echo "<BR>result eids: ".print_r($eids,true);
             }
             if ($search_prop_val_inverse_match) {
                 $data_type = "varchar";
                 if ($ctns_prop_type == 3) {
                     $type_category = "user";
                 } else {
                     $type_category = "product";
                 }
                 //echo $ctns_prop_type."type? ".$type_id;
                 $all_product_eids = RecordsSys_EntityManagementSystems::get_all_eids_by_type_category_and_datatype($data_type, $type_category, $ctns_prop_type);
                 $eids = array_diff($all_product_eids, $eids);
             }
             //echo "<br>HERE variables: eid: $eid, fin_eids: ".print_r($fin_eids,true).", filt_eids: ".print_r($filt_eids,true)." all_filts_any: $all_filts_any, ";
             foreach ($eids as $eid) {
                 if (!in_array($eid, $fin_eids) && ($all_filts_any || in_array($eid, $filt_eids))) {
                     //echo "<br>pusing eid: ".$eid;
                     array_push($fin_eids, $eid);
                 }
             }
         }
     }
     //echo "<BR>COUNT OF FINEIDS:".count($fin_eids)."<br>";
     //$debug_time .= microtime().' starting sort'."<br>";
     //Currently assumes only 1 property to sort by
     if ($sort_prop_ids[0] == 0) {
         $sort_prop_ids[0] = 1;
         //customer wants sort by name by default
     }
     if ($sort_prop_ids[0] != 0 && count($fin_eids) > 0) {
         //get prop values for final eid set; do asort
         $sorted_eids = array();
         $desc = 0;
         //NOTE: sorting also takes place below for lookuptable values
         $eidsvalshash = RecordsSys_EntityManagementSystems::get_eids_values_hash($fin_eids, $sort_prop_ids[0], $type_id, $desc);
         //can't do page offset/limit filter here because there may be duplicate eids
         $prop_id = $sort_prop_ids[0];
         if (ClientServerDataOps::has_lookup_table($prop_id)) {
             foreach ($eidsvalshash as $eid => $val) {
                 $newval = ClientServerDataOps::get_value_by_id($val, $prop_id);
                 $eidsvalshash[$eid] = $newval;
             }
             asort($eidsvalshash);
         }
         foreach ($eidsvalshash as $eid => $val) {
             if (!in_array($eid, $sorted_eids)) {
                 array_push($sorted_eids, $eid);
             }
         }
         //any for which entity doesn't have set property, on which this function sorts -- means no match goes after all the matches
         foreach ($fin_eids as $eid) {
             if (!in_array($eid, $sorted_eids)) {
                 array_push($sorted_eids, $eid);
             }
         }
         $fin_eids = $sorted_eids;
     }
     //$debug_time .= microtime().' end of search and gather eids'.print_r($fin_eids,true)."<br>";
     //echo $debug_time;
     //echo 'hello'.print_r($fin_eids,true);
     return $fin_eids;
 }
 function get_id_for_LookupTable_record_contains($prop_id, $contains_string)
 {
     return ClientServerDataOps::get_id_for_LookupTable_record_contains($prop_id, $contains_string);
 }