xFacility/Codes2010. 5. 17. 23:27
개발하다가 효율성이 떨어져 중도 포기한 Internal API 1.0입니다.

//Part1. Common API
//1. [xF]Secretary(xfx)
//1.1. Text
function xfx_trm_str($string, $character = ",;") {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Trim a special character(comma and semicolon) at end of string
CALL:
xfx_trm_str("lang=en,ko,jp,ch;hobby=reading books,programming,bowling;");
RETURN:
$string = "lang=en,ko,jp,ch;hobby=reading books,programming,bowling";
*/
//Define times for a Loop
$length = strlen($character);
//Check each character by a loop
for ($i=0; $i<$length; $i++) {
//If the end of string is a appointed character,
if(substr($string,-1) == substr($character, $i, 1)) {
//Delete the last character of string
$string = substr($string, 0, -1);
}
}
//Return a trimmed string
return $string;
}
function xfx_prs_ran ($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Parse Range to Array
CALL:
xfx_prs_ran("1-3,7,10-11");
RETURN:
$array[0] = "1";
$array[1] = "2";
$array[2] = "3";
$array[3] = "7";
$array[4] = "10";
$array[5] = "11";
*/
//Trim a string
$range = xfx_trm_str($range);
$range = trim($range);
//Parse a string by comma
$temp = split(",", $range);
//Move values to array
$now = 0;
for ($i=0; $i<=substr_count($range,","); $i++) {
//Check a hyphen
if (substr_count($temp[$i],"-") == 1) {
list($start, $end) = split("-", $temp[$i]);
$difference = $end - $start;
for ($j=0; $j<=$difference; $j++) {
$array[$now] = $start + $j;
$now += 1;
}
} else {
$array[$now] = $temp[$i];
$now += 1;
}
}
//Delete overlapping values 
$array = array_unique($array);
//Sort the array
sort($array);
reset($array);
//Return Array
return $array;
}
function xfx_cvt_ran ($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Convert a range to a condition of a SQL query
CALL:
xfx_cvt_ran("1-3,7,10-11");
RETURN:
$string = "`no` = '1' OR `no` = '2' OR `no` = '3', `no` = 7, `no` = '10', `no` = '11'";
*/
$array = xfx_prs_ran($range);
for($i=0; 1; $i++) {
//If the value is NULL,
if ($array[$i] == NULL) {
break;
} else {
//If this is the first time of loop,
if ($i == 0) {
$condition = "`no`='$array[$i]'";
} else {
$condition .= " OR `no`='$array[$i]'";
}
}
}
//Return condition
return $condition;
}
function xfx_prs_con ($container) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Parse a string including values to Array
CALL:
xfx_prs_con("lang=en,ko,jp,ch;hobby=reading books,programming,bowling;");
RETURN:
$array['lang'][0] = "en";
$array['lang'][1] = "ko";
$array['lang'][2] = "jp";
$array['lang'][3] = "ch";
$array['hobby'][0] = "reading books";
$array['hobby'][1] = "programming";
$array['hobby'][2] = "bowling";
*/

  //Trim a string of values
$container = xfx_trm_str($container);
//Parse a string by semicolon
$temp = split(";", $container);
//Define times for a loop
$counter = substr_count($container, ";");
for ($i = 0; $i<=$counter; $i++) {
//Parse a string into name and values
list($name, $values) = split("=", $temp[$i]);
//Trim a left of name
$name = ltrim($name);
//Parse values into each value
$array[$name] = split(",", $values);
//Define times for a internal loop
$counter2 = substr_count($values, ",");
for ($j = 0; $j<=$counter2; $j++) {
//Trim a left of value
$array[$name][$j] = ltrim($array[$name][$j]);
}
}
//Return Array
return $array;
}
function xfx_cvt_con($container) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Convert a string including values to a condition of a SQL query
CALL:
xfx_cvt_con("lang=en,ko,jp,ch;hobby=reading books,programming,bowling;");
RETURN:
$condition = "`lang` = 'en' OR `lang` = 'en' OR `lang` = 'en' OR `lang` = 'OR' `hobby` = 'reading books' OR `hobby` = 'programming' OR `hobby` = 'bowling'"; 
*/
//Trim a string of values
$container = xfx_trm_str($container);
//Parse a string by semicolon
$temp = split(";", $container);
//Define times for a loop
$counter = substr_count($container, ";");
for ($i = 0; $i<=$counter; $i++) {
//Parse a string into name and values
list($name, $values) = split("=", $temp[$i]);
//Trim a left of name
$name = ltrim($name);
//Parse values into each value
$value = split(",", $values);
//Define times for a internal loop
$counter2 = substr_count($values, ",");
for ($j = 0; $j<=$counter2; $j++) {
//If this is the first time of loop,
if ($i ==0 && $j == 0) {
$condition = "`$name`= '$value[$j]'";
} else {
$condition .= " OR `$name`= '$value[$j]'";
}
}
}
return $condition;
}
//1.2. Database
function xfx_exe_que($query) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Parse Range to Array
CALL:
xfx_exe_que("DROP TABLE `xf_authority`;");
RETURN:
$result = <<RESULT OF QUERY>>;
$result = NULL; // Error
*/
//Load information about DB 
include $_SERVER['DOCUMENT_ROOT']."/shelf/database.php";
//Connect to DB, Select DB and run a query
//If the database program is MySQL,
if($xf_db['kind'] == "mysql") {
//Connect to database Program
$link = @mysql_connect($xf_db['server'], $xf_db['username'], $xf_db['password']);
//Select database
mysql_select_db($xf_db['database'], $link);
$result = mysql_query($query, $link) or die("Query Error!\n");
//Close the connection
mysql_close();
} else {
$result = NULL;
}
//Return result of database
return $result;
}
function xfx_cnt_res($result) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Count the rows of a result 
CALL:
xfx_cnt_res(<<RESULT OF QUERY>>);
RETURN:
$number = 3;
$number = NULL; // Error
*/
//Load information about DB 
include $_SERVER['DOCUMENT_ROOT']."/shelf/database.php";
//If the database program is MySQL,
if($xf_db['kind'] == "mysql") {
$number = mysql_num_rows($result);
} else {
$number = NULL;
}
//Return a number
return $number;
}
function xfx_prs_res($result, $fields = NULL) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
22.Apr.2010.
DESCRIPTION:
Count the rows of a result 
CALL:
xfx_prs_res(<<RESULT OF QUERY>>);
RETURN:
$array['no'][0] = 3;
$array['indicator'][0] = 1349851283;
$array['status'][0] = 1;
$array['id'][0] = "root";
$array['pw'][0] = "*68F9CD57023F17CBE06EE6365D9B4FEBF3EB3EE4";
$array['etc'][0] = "lang=en,ko,jp,ch";
$array['no'][1] = 4;
$array['indicator'][1] = 1352878344;
$array['status'][1] = 1;
$array['id'][1] = "administrator";
$array['pw'][1] = "*1F7E399139C29C99909A2C7E8C56247043C4FEE1";
$array['etc'][1] = "lang=ko,en";
$array = NULL //Error
*/
//Load information about DB
include $_SERVER['DOCUMENT_ROOT']."/shelf/database.php";
//If the list of fields are missed,
if($fields == NULL) {
$counter = 0;
} else {
//Parse fields by comma
$temp = split(",", $fields);
//Estimate times for a loop
$counter = substr_count($fields, ",");
}
for ($i=0; $i<=$counter; $i++) {
//If the list of fields are missed,
if($fields == NULL) {
//If the database program is MySQL,
if($xf_db['kind'] == "mysql") {
//Get field Name
$field = @mysql_field_name($result, $i);
} else {
//Stop the processing of this function
return $array = NULL;
}
//If there is no field name,
if ($field == NULL) {
//Stop this Loop
break;
} else {
//One more time
$counter++;
}
} else {
$field = $temp[$i];
}
//Estimate times for a subloop
$counter2 = xfx_cnt_res($result);
for($j=0; $j<$counter2; $j++) {
//If the database program is MySQL,
if($xf_db['kind'] == "mysql") {
$array[$field][$j] = mysql_result($result, $j, $field);
} else {
//Stop the processing of this function
return $array = NULL;
}
}
}
//Return Array
return $array;
}
//1.3. XML

//1.4. xFaciltiy
function xfx_fnd_ite($table, $condition) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Find a item in xFacility
CALL:
xfx_fnd_ite("xf_user", "no='1'");
RETURN:
<<RESULT OF QUERY>>
*/
$query = "SELECT * FROM `$table` WHERE $condition;";
$result = xfx_exe_que($query);
return $result;
}
function xfx_mke_rel($table, $no, $event) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Make relationships with other library
CALL:
xfx_mke_rel("xf_party", 1, "write");
RETURN:
??
*/
//If the prefix is xf_party
if ($prefix == "xf_party") {

  //If the prefix is xf_shelf
} else if ($prefix == "xf_shelf") {

  //If the prefix is xf_compass,
} else if ($prefix == "xfc") {

  //If the prefix is xf_timeline,
} else if ($prefix == "xft") {
//If the prefix is xf_mission,
} else if ($prefix == "xfm") {
}
}

//Part2. System API
//2. xfu
//2.1. Write
function xfu_write_item($id, $pw, $etc = 'lang=en') {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Make a item in [xF]User
CALL:
xfu_write_item("root", "password");
RETURN:
$xf_user['no'][0] = 3;
$xf_user['indicator'][0] = 1349851283;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "root";
$xf_user['pw'][0] = "*68F9CD57023F17CBE06EE6365D9B4FEBF3EB3EE4";
$xf_user['etc'][0] = "lang=en";
$xf_user = NULL; //Error
*/
//Check same ID in [xF]User
$result = xfx_fnd_ite("xf_user", "`id`='$id'"); 
if (xfx_cnt_res($result) == 1) {
$xf_user = NULL;
return $xf_user;
}
//Make a indicator
$indicator = time();
$query = "INSERT INTO `xf_user`(indicator, status, id, pw, etc) VALUES('$indicator', '1', '$id', password('$pw'), '$etc')";
$result = xfx_exe_que($query);
//Get information for the registration
unset($result);
$result = xfx_fnd_ite("xf_user", "`id`='$id' AND `indicator`='$indicator'");
$xf_user = xfx_prs_res($result);
//Return registered information of user 
return $xf_user;
}
//2.2. Find
function xfu_find_items($container) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Find items in [xF]User
CALL:
xfu_find_item("id=root,admin,administrator;no=1;");
RETURN:
<<RESULT OF QUERY>>
*/
//Write a condition by values
$condition = xfx_cvt_con($container);
$result = xfx_fnd_ite("xf_user", $condition);
//Return information of user 
return $result;
}
//2.3. Read
function xfu_read_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Read a item in [xF]User
CALL:
xfu_read_items("1-3,7");
RETURN:
$xf_user['no'][0] = 3;
$xf_user['indicator'][0] = 1238944426;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "root";
$xf_user['pw'][0] = "*1F7E399139C29C99909A2C7E8C56247043C4FEE1";
$xf_user['etc'][0] = "lang=en,ko";
*/

  //Convert a range to condition
$condition = "`no`='$no'";
$result = xfx_fnd_ite("xf_user", $condition);
$xf_user = xfx_prs_res($result);
//Return user information
return $xf_user; 
}
function xfu_read_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Read items in [xF]User
CALL:
xfu_read_items("1-3,7");
RETURN:
$xf_user['no'][0] = 3;
$xf_user['indicator'][0] = 1238944426;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "root";
$xf_user['pw'][0] = "*1F7E399139C29C99909A2C7E8C56247043C4FEE1";
$xf_user['etc'][0] = "lang=en,ko";
$xf_user['no'][0] = 2;
$xf_user['indicator'][0] = 1283849349;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "administrator";
$xf_user['pw'][0] = "*68F9CD57023F17CBE06EE6365D9B4FEBF3EB3EE4";
$xf_user['etc'][0] = "lang=en,jp";
$xf_user['no'][0] = 3;
$xf_user['indicator'][0] = 1349851283;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "admin";
$xf_user['pw'][0] = "*B94651992BD5A5D8316CEE083B6D7E9E3AEAC137";
$xf_user['etc'][0] = "lang=en,ch";
$xf_user['no'][0] = 7;
$xf_user['indicator'][0] = 1739234725;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "michaelson";
$xf_user['pw'][0] = "*68F9CD57023F17CBE06EE6365D9B4FEBF3EB3EE4";
$xf_user['etc'][0] = "lang=ko,en";
*/

  //Convert a range to condition
$condition = xfx_cvt_ran($range);
$result = xfx_fnd_ite("xf_user", $condition);
$xf_user = xfx_prs_res($result);
//Return user information
return $xf_user; 
}
//2.4. Edit
function xfu_edit_item($no, $id, $pw, $etc = 'lang=en') {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Edit a item in [xF]User
CALL:
xfu_edit_item(3, "root", "password", "lang=en");
RETURN:
$xf_user['no'][0] = 3;
$xf_user['indicator'][0] = 1349851283;
$xf_user['status'][0] = 1;
$xf_user['id'][0] = "root";
$xf_user['pw'][0] = "*68F9CD57023F17CBE06EE6365D9B4FEBF3EB3EE4";
$xf_user['etc'][0] = "lang=en";
$xf_user = NULL; //Error
*/
//Is there information
$result = xfx_fnd_ite("xf_user", "`no`='$no'"); 
if (xfx_cnt_res($result) == 0) {
$xf_user = NULL;
return $xf_user;
}
//Check by rule
//Not register same id
$result = xfx_fnd_ite("xf_user", "`no`!='$no' AND `id`='$id'"); 
if (xfx_cnt_res($result) == 1) {
$xf_user = NULL;
return $xf_user;
}
$query = "UPDATE `xf_user` SET `id`='$id', `pw`=PASSWORD('$pw'), `etc`='$etc' WHERE `no`='$no';";
$result = xfx_exe_que($query);
//Get information about a user
$result = xfx_fnd_ite("xf_user", "`no`='$no'");
$xf_user = xfx_prs_res($result);
//Return registered information of user 
return $xf_user;
}
//2.5. Delete
function xfu_delete_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Delete a item in [xF]User
CALL:
xfu_delete_items(3);
RETURN:
<<RESULT OF QUERY>>
*/
$query = "DELETE FROM `xf_user` WHERE `no`='$no'";
$result = xfx_exe_que($query);
return $result;
}
function xfu_delete_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Delete items in [xF]User
CALL:
xfu_delete_items("1-3,7");
RETURN:
<<RESULT OF QUERY>>
*/
$condition = xfx_cvt_ran($range);
$query = "DELETE FROM `xf_user` WHERE $condition";
$result = xfx_exe_que($query);
//Return result
return $result;
}
//3. xfo
//3.1. Write
function xfo_write_item($status, $owner_type, $owner_no, $own_type, $own_no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Make a item in [xF]Owner
CALL:
xfo_write_item(1, "xf_party", 1, "xf_shelf", 34);
RETURN:
$xf_owner['no'][0] = 3;
$xf_owner['indicator'][0] = 1349851283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "1";
$xf_owner['own_type'][0] = "xf_shelf";
$xf_owner['own_no'][0] = "34";
$xf_owner = NULL; //Error
*/
//Check by the rule
//Not own itself
if ($owner_type == $own_type && $owner_no == $own_no) {
$xf_owner = NULL;
return $xf_owner;
}
//Not own each other
$result = xfx_fnd_ite("xf_owner", "`owner_type`='$own_type' AND `owner_no`='$own_no'");
if(xfx_cnt_res($result) >= 1) {
$xf_owner = NULL;
return $xf_owner;
}
$result = xfx_fnd_ite("xf_owner", "`own_type`='$owner_type' AND `own_no`='$owner_no'");
if(xfx_cnt_res($result) >= 1) {
$xf_owner = NULL;
return $xf_owner;
}
//Not register same thing
$result = xfx_fnd_ite("xf_owner", "`owner_type`='$owner_type' AND `owner_no`='$owner_no' AND `own_type`='$own_type' AND `own_no`='$own_no'");
if(xfx_cnt_res($result) >= 1) {
$xf_owner = NULL;
return $xf_owner;
}
//Reset a value of status
$status = 1;
//Set indicator
$indicator = time();
//Write a item in DB
$query = "INSERT INTO `xf_owner`(indicator, status, owner_type, owner_no, own_type, own_no) VALUES('$indicator', '$status', '$owner_type', '$owner_no', '$own_type', '$own_no')";
$result = xfx_exe_que($query);
//Receive information from DB
$result = xfx_fnd_ite("xf_owner", "`indicator`='$indicator' AND `owner_type`='$owner_type' AND `owner_no`='$owner_no'");
$xf_owner = xfx_prs_res($result);
//Return information about Owner
return $xf_owner;
}
//3.2. Find
function xfo_find_items($container) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Find items in [xF]Owner
CALL:
xfo_find_items("");
RETURN:
<<RESULT OF QUERY>>
*/
$condtion = xfx_cvt_con($container); 
$result = xfx_fnd_ite("xf_owner", $condition);
return $result;
}
//3.3. Read
function xfo_read_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Read a item in [xF]User
CALL:
xfo_read_item(3);
RETURN:
$xf_owner['no'][0] = 3;
$xf_owner['indicator'][0] = 1349851283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "1";
$xf_owner['own_type'][0] = "xf_shelf";
$xf_owner['own_no'][0] = "34";
*/
//Make a condtion using a no
$condition = "`no` = '$no'";
$result = xfx_fnd_ite("xf_owner", $condition);
$xf_owner = xfx_prs_res($result);
//Return user information
return $xf_owner;
}
function xfo_read_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Read items in [xF]Owner
CALL:
xfo_read_items("1-3,7");
RETURN:
$xf_owner['no'][0] = 1;
$xf_owner['indicator'][0] = 1349851283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "1";
$xf_owner['own_type'][0] = "xf_shelf";
$xf_owner['own_no'][0] = "12";
$xf_owner['no'][0] = 2;
$xf_owner['indicator'][0] = 1397421283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "1";
$xf_owner['own_type'][0] = "xf_party";
$xf_owner['own_no'][0] = "7";
$xf_owner['no'][0] = 3;
$xf_owner['indicator'][0] = 1489211283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "1";
$xf_owner['own_type'][0] = "xf_shelf";
$xf_owner['own_no'][0] = "34";
$xf_owner['no'][0] = 7;
$xf_owner['indicator'][0] = 1541851283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "7";
$xf_owner['own_type'][0] = "xf_compass";
$xf_owner['own_no'][0] = "4";
*/
//Convert a range to condition
$condition = xfx_cvt_ran($range);
$result = xfx_fnd_ite("xf_owner", $condition);
$xf_owner = xfx_prs_res($result);
//Return user information
return $xf_owner;
}
//3.4. Edit
function xfo_edit_item($no, $status, $owner_type, $owner_no, $own_type, $own_no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Edit a item in [xF]Owner
CALL:
xfo_edit_item(3, 1, "xf_party", 1, "xf_shelf", 34);
RETURN:
$xf_owner['no'][0] = 3;
$xf_owner['indicator'][0] = 1489211283;
$xf_owner['status'][0] = 1;
$xf_owner['owner_type'][0] = "xf_party";
$xf_owner['owner_no'][0] = "1";
$xf_owner['own_type'][0] = "xf_shelf";
$xf_owner['own_no'][0] = "34";
*/
//Check by the rule

  //Edit
$query = "UPDATE `xf_owner` SET `status`='$status', `owner_type`='$owner_type', `owner_no`='$owner_no', `own_type`='$own_type', `own_no`='$own_no' WHERE `no`='$no';";
$result = xfx_exe_que($query);
$xf_owner = xfa_read_item($no);
return $xf_owner;
}
//3.5. Delete
function xfo_delete_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Delete a item in [xF]Owner
CALL:
xfo_delete_items(3);
RETURN:
<<RESULT OF QUERY>>
*/
$query = "DELETE FROM `xf_owner` WHERE `no`='$no'";
$result = xfx_exe_que($query);
//Return result
return $result;
}
function xfo_delete_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
23.Apr.2010.
DESCRIPTION:
Delete items in [xF]Owner
CALL:
xfo_delete_items("1-3,7");
RETURN:
<<RESULT OF QUERY>>
*/
$condition = xfx_cvt_ran($range);
$query = "DELETE FROM `xf_owner` WHERE $condition";
$result = xfx_exe_que($query);
//Return result
return $result;
}
//4. xfa
//4.1. Write
function xfa_write_item($status, $subject_type, $subject_no, $verb, $object_type, $object_no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
26.Apr.2010.
DESCRIPTION:
Write a item in [xF]Authority
CALL:
xfa_write_item(1, "xf_user", 1, xfa_find_item, "xf_authority", 1);
RESULT:
$xf_authority['no'][0] = 1;
$xf_authority['indicator'][0] = 1398594750;
$xf_authority['status'][0] = 1;
$xf_authority['subject_type'][0] = 1;
$xf_authority['subject_no'][0] = 1;
$xf_authority['verb'][0] = 1;
$xf_authority['object_type'][0] = 1;
$xf_authority['object_no'][0] = 1;
*/
$indicator = time();
$query = "INSERT INTO `xf_authority`(indicator, status, subject_type, subject_no, verb, object_type, object_no) VALUES('$indicator', $status', '$subject_type', '$subject_no', '$verb', '$object_type', '$object_no')";
$result = xfx_exe_que($query);
$result = xfx_fnd_ite("xf_authority", "`indicator`='$indicator' AND subject_no`='$subject_no' AND `object_no`='$object_no'");
$xf_authority = xfx_prs_res($result);
return $xf_authority;
}
//4.2. Find
function xfa_find_items($container) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Find items in [xF]Authority
CALL:
xfa_find_items("status=1;verb=xfa_find_item");
RETURN:
<<RESULT OF QUERY>>
*/
$condition = xfx_cvt_con($container);
$result = xfx_fnd_ite("xf_authority", $condition);
return $result;
}
//4.3. Read
function xfa_read_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Read a item in [xF]Authority
CALL:
xfa_read_item(5);
RETURN:
$xf_authority['no'] = 5;
$xf_authority['indicator'] = 1436879648;
$xf_authority['status'] = 3
$xf_authority['subject_type'] = "xf_party"; 
$xf_authority['subject_no'] = 3;
$xf_authority['verb'] = "xfs_write_item";
$xf_authority['object_type'] = "xf_shelf";
$xf_authority['object_no'] = 0;
*/
$result = xfx_fnd_ite("xf_authority", "`no`='$no'");
$xf_authority = xfx_prs_res($result);
return $xf_authority;
}
function xfa_read_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Read items in [xF]Authority
CALL:
xfa_read_items("1-3,5");
RETURN:
$xf_authority['no'] = 1;
$xf_authority['indicator'] = 1339429529;
$xf_authority['status'] = 1
$xf_authority['subject_type'] = "xf_party"; 
$xf_authority['subject_no'] = 3;
$xf_authority['verb'] = "xfs_write_item";
$xf_authority['object_type'] = "xf_shelf";
$xf_authority['object_no'] = 0;
$xf_authority['no'] = 2;
$xf_authority['indicator'] = 1358829841;
$xf_authority['status'] = 0
$xf_authority['subject_type'] = "xf_party"; 
$xf_authority['subject_no'] = 3;
$xf_authority['verb'] = "xfs_write_item";
$xf_authority['object_type'] = "xf_shelf";
$xf_authority['object_no'] = 0;
$xf_authority['no'] = 3;
$xf_authority['indicator'] = 1397172184;
$xf_authority['status'] = 2
$xf_authority['subject_type'] = "xf_party"; 
$xf_authority['subject_no'] = 3;
$xf_authority['verb'] = "xfs_write_item";
$xf_authority['object_type'] = "xf_shelf";
$xf_authority['object_no'] = 0;
$xf_authority['no'] = 5;
$xf_authority['indicator'] = 1436879648;
$xf_authority['status'] = 3
$xf_authority['subject_type'] = "xf_party"; 
$xf_authority['subject_no'] = 3;
$xf_authority['verb'] = "xfs_write_item";
$xf_authority['object_type'] = "xf_shelf";
$xf_authority['object_no'] = 0;
*/
$condition = xfx_cvt_ran($range);
$result = xfx_fnd_ite("xf_authority", $condition);
$xf_authority = xfx_prs_res($result);
return $xf_authority;
}
//4.4. Edit
function xfa_edit_item($no, $status, $subject_type, $subject_no, $verb, $object_type, $object_no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Edit a item in [xF]Authority
CALL:
xfa_edit_item(5, 3, "xf_party", 3, "xfs_write_item", "xf_shelf", 0);
RETURN:
$xf_authority['no'] = 5;
$xf_authority['indicator'] = 1436879648;
$xf_authority['status'] = 3
$xf_authority['subject_type'] = "xf_party"; 
$xf_authority['subject_no'] = 3;
$xf_authority['verb'] = "xfs_write_item";
$xf_authority['object_type'] = "xf_shelf";
$xf_authority['object_no'] = 0;
*/
$query = "UPDATE `xf_authority` SET `status`='$status', `subject_type`='$subject_type', `subject_no`='$subject_no', `verb`='$verb', `object_type`='$object_type', `object_no`='$object_no' WHERE `no`='$no';";
$result = xfx_exe_que($query);
$xf_authority = xfa_read_item($no);
return $xf_authority;
}
//4.5. Delete
function xfa_delete_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Delete a item in [xF]Authority
CALL:
xfa_delete_items(3);
RETURN:
<<RESULT OF QUERY>>
*/
$query = "DELETE FROM `xf_authority` WHERE `no`='$no'";
$result = xfx_exe_que($query);
//Return result
return $result;
}
function xfa_delete_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
25.Apr.2010.
DESCRIPTION:
Delete items in [xF]Authority
CALL:
xfa_delete_items("1-3,7");
RETURN:
<<RESULT OF QUERY>>
*/
$condition = xfx_cvt_ran($range);
$query = "DELETE FROM `xf_authority` WHERE $condition";
$result = xfx_exe_que($query);
//Return result
return $result;
}
//5. xfr
//5.1. Write
function xfr_write_item($status, $referer_type, $referer_no, $reference_type, $reference_no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
28.Apr.2010.
DESCRIPTION:
Write an item in [xF]Referer
CALL:
xfr_write_item(1, "xf_party", 5, "xf_timeline", 7);
RETURN:
$xf_referer['no'][0] = 3;
$xf_referer['indicator'][0] = 1239559924;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_party";
$xf_referer['referer_no'][0] = 5;
$xf_referer['reference_type'][0] = "xf_timeline";
$xf_referer['reference_no'][0] = 7;
*/

  //Write a new item
$indicator = time();
$query = "INSERT INTO `xf_referer`(indicator, status, referer_type, referer_no, reference_type, reference_no) VALUES('$indicator', '$status', '$referer_type', '$referer_no', $reference_type', '$reference_no')"; 
$result = xfx_exe_que($query);
//Bring information about a item which has just written
$result = xfx_fnd_ite("xf_referer", "`indicator`='$indicator' AND `reference_type`='$reference_type' AND `reference_no`='$reference_no'");
$xf_referer = xfx_prs_res($result);
//Return information
return $xf_referer;
}
//5.2. Find
function xfr_find_items($container) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
28.Apr.2010.
DESCRIPTION:
Find items in [xF]Referer
CALL:
xfr_find_items("referer_type=xf_party;reference_type=xf_timeline");
RETURN:
<<RESULT OF QUERY>>
*/
//Convert a container to a condition
$condition = xfx_cvt_con($container);
$result = xfx_fnd_ite("xf_referer", $container);
return $result;
}
//5.3. Read
function xfr_read_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
28.Apr.2010.
DESCRIPTION:
Read a item in [xF]Referer
CALL:
xfr_read_item(3);
RETURN:
$xf_referer['no'][0] = 3;
$xf_referer['indicator'][0] = 1239559924;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_party";
$xf_referer['referer_no'][0] = 5;
$xf_referer['reference_type'][0] = "xf_timeline";
$xf_referer['reference_no'][0] = 7;
*/
$result = xfx_fnd_ite("xf_referer", "`no`='$no'");
$xf_referer = xfx_prs_res($result);
return $xf_referer;
}
function xfr_read_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
DESCRIPTION:
Read items in [xF]Referer
CALL:
xfr_read_item("1-3,7");
RETURN:
$xf_referer['no'][0] = 1;
$xf_referer['indicator'][0] = 1239559924;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_party";
$xf_referer['referer_no'][0] = 5;
$xf_referer['reference_type'][0] = "xf_timeline";
$xf_referer['reference_no'][0] = 7;
$xf_referer['no'][0] = 2;
$xf_referer['indicator'][0] = 1310293983;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_timeline";
$xf_referer['referer_no'][0] = 10;
$xf_referer['reference_type'][0] = "xf_shelf";
$xf_referer['reference_no'][0] = 7;
$xf_referer['no'][0] = 3;
$xf_referer['indicator'][0] = 1372039747;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_shelf";
$xf_referer['referer_no'][0] = 7;
$xf_referer['reference_type'][0] = "xf_timeline";
$xf_referer['reference_no'][0] = 10;
$xf_referer['no'][0] = 7;
$xf_referer['indicator'][0] = 1482938748;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_party";
$xf_referer['referer_no'][0] = 8;
$xf_referer['reference_type'][0] = "xf_timeline";
$xf_referer['reference_no'][0] = 14;
*/
//Convert a range to a condition
$condition = xfx_cvt_ran($range) ;
$result = xfx_fnd_ite("xf_referer", $condition);
$xf_referer = xfx_prs_res($result);
//Return Information
return $xf_referer;
}
//5.4. Edit
function xfr_edit_item($no, $status, $referer_type, $referer_no, $reference_type, $reference_no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
28.Apr.2010.
DESCRIPTION:
Edit an item in [xF]Referer
CALL:
xfr_edit_item(3, 1, "xf_party", 5, "xf_timeline", 7);
RETURN:
$xf_referer['no'][0] = 3;
$xf_referer['indicator'][0] = 1239559924;
$xf_referer['status'][0] = 1;
$xf_referer['referer_type'][0] = "xf_party";
$xf_referer['referer_no'][0] = 5;
$xf_referer['reference_type'][0] = "xf_timeline";
$xf_referer['reference_no'][0] = 7;
*/
$query = "UPDATE SET `status`='$status, `referer_type`='$referer_type', `referer_no`='$referer_no', `reference_type`='$reference_type', `refererence_no`='$reference_no' WHERE `no`='$no';";
$result = xfx_exe_que($result);
$xf_referer = xfr_read_item($no);
return $xf_referer;
}
//5.5. Delete
function xfr_delete_item($no) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
28.Apr.2010.
DESCRIPTION:
Delete an item from [xF]Referer
CALL:
xfr_delete_item(3);
RETURN:
<<RESULT OF QUERY>>
*/
$condition = "`no`='$no'";
$query = "DELETE FROM `xf_referer` WHERE ".$condition;
$result = xfx_exe_que($query);
//Return a result
return $result;
}
function xfr_delete_items($range) {
/*
DEVELOPMENT:
Michael Son(michaelson@nate.com)
28.Apr.2010.
DESCRIPTION:
Delete items from [xF]Referer
CALL:
xfr_delete_items("1-3,7");
RETURN:
<<RESULT OF QUERY>>
*/
$condition = xfx_cvt_ran($range);
$query = "DELETE FROM `xf_referer` WHERE ".$condition;
$result = xfx_exe_que($query);
//Return a result
return $result;
}
//Part3. Data API
//6. xfp
//6.1. Write
function xfp_write_item($status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//6.2. Find
function xfp_find_items($container) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//6.3. Read
function xfp_read_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xfp_read_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//6.4. Edit
function xfp_edit_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//6.5. Delete
function xfp_delete_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xfp_delete_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//7. xfs
//7.1. Write
function xfs_write_item($status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//7.2. Find
function xfs_find_items($container) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//7.3. Read
function xfs_read_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xfs_read_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//7.4. Edit
function xfs_edit_item($no, $status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//7.5. Delete
function xfs_delete_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xfs_delete_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//8. xfc
//8.1. Write
function xfc_write_item($status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//8.2. Find
function xfc_find_items($container) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//8.3. Read
function xfc_read_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xfc_read_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//8.4. Edit
function xfc_edit_item($no, $status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//8.5. Delete
function xfc_delete_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xfc_delete_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//9. xft
//9.1. Write
function xft_write_item($status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//9.2. Find
function xft_find_items($container) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//9.3. Read
function xft_read_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xft_read_items($range) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//9.4. Edit
function xft_edit_item($no, $status) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
//9.5. Delete
function xft_delete_item($no) {
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}
function xft_delete_items($range){
/*
DEVELOPMENT:
DESCRIPTION:
CALL:
RETURN:
*/
}

'xFacility > Codes' 카테고리의 다른 글

container()  (0) 2010.06.08
xFacility^PHP > Internal API 3.0  (0) 2010.06.08
xFacility^PHP > Internal API 2.0  (0) 2010.05.17
Posted by 마이클