Ejemplo n.º 1
0
 public static function addVillage($obj_Village)
 {
     $db = config::dbconfig();
     $obj_retresult = new returnResult();
     $obj_Village->VillageId = DAL_manageVillage::getLastVillageId() + 1;
     $sql = "INSERT INTO tbl_village (VillageId,Name,VillageNumber,AgaDevision,District,Province,GeogrophyTypeId,ForestTypeId,ForestDescription,TraditionalKnowledge) \n\t\tVALUES (" . common::noSqlInject($obj_Village->VillageId) . "," . "'" . common::noSqlInject($obj_Village->Name) . "'" . "," . common::noSqlInject($obj_Village->VillageNumber) . "," . "'" . common::noSqlInject($obj_Village->AgaDevision) . "'" . "," . "'" . common::noSqlInject($obj_Village->District) . "'" . "," . "'" . common::noSqlInject($obj_Village->Province) . "'" . "," . common::noSqlInject($obj_Village->GeogrophyTypeId) . "," . common::noSqlInject($obj_Village->ForestTypeId) . "," . "'" . common::noSqlInject($obj_Village->ForestDescription) . "'" . "," . "'" . common::noSqlInject($obj_Village->TraditionalKnowledge) . "'" . ");";
     $rs = mysql_query($sql);
     if (mysql_affected_rows() > 0) {
         $obj_retresult->type = 1;
         $obj_retresult->msg = "success";
         $obj_retresult->data = $obj_Village;
     } else {
         $obj_retresult->type = 0;
         $obj_retresult->msg = "failed";
     }
     return $obj_retresult;
 }
Ejemplo n.º 2
0
 public static function isChildVillage($VillageId, $ChildVillageId)
 {
     $ischild = false;
     $obj_retResult = DAL_manageVillage::getVillageListByVillageId($ChildVillageId);
     //get child node
     if ($obj_retResult->type == 1) {
         $arr_VillageList = $obj_retResult->data;
         $obj_Village = $arr_VillageList[0];
         $arrParentIds = explode(",", $obj_Village->Url);
         foreach ($arrParentIds as $VillageParentId) {
             if ($VillageParentId == $VillageId) {
                 $ischild = true;
             }
         }
     }
     return $ischild;
 }
Ejemplo n.º 3
0
function updateVillage($sessionkey, $appcode, $Villagedata)
{
    $main_result = "<VPROFILERESULT>";
    $main_result .= "<AUTHSTATUS>0</AUTHSTATUS>";
    $userId = ValidateSession($sessionkey, $appcode);
    if ($userId > -1) {
        $main_result = "<AUTHSTATUS>1</AUTHSTATUS>";
        $obj_Village = new Village();
        foreach ($Userdata["[UPPERTEMPLATENAME"] as $key => $child) {
            switch ($key) {
                case "VILLAGEID":
                    $obj_Village->VillageId = $child;
                    break;
                case "NAME":
                    $obj_Village->Name = $child;
                    break;
                case "VILLAGENUMBER":
                    $obj_Village->VillageNumber = $child;
                    break;
                case "AGADEVISION":
                    $obj_Village->AgaDevision = $child;
                    break;
                case "DISTRICT":
                    $obj_Village->District = $child;
                    break;
                case "PROVINCE":
                    $obj_Village->Province = $child;
                    break;
                case "GEOGROPHYTYPEID":
                    $obj_Village->GeogrophyTypeId = $child;
                    break;
                case "FORESTTYPEID":
                    $obj_Village->ForestTypeId = $child;
                    break;
                case "FORESTDESCRIPTION":
                    $obj_Village->ForestDescription = $child;
                    break;
                case "TRADITIONALKNOWLEDGE":
                    $obj_Village->TraditionalKnowledge = $child;
                    break;
            }
        }
        $obj_retResult_Village = DAL_manageVillage::updateVillage($obj_Village);
        if ($obj_retResult_Village->type == 1) {
            $main_result .= "<RESULTSTATUS>1</RESULTSTATUS>";
            $main_result .= getVillageXml($obj_retResult_Village->data);
        } else {
            $main_result .= "<RESULTSTATUS>0</RESULTSTATUS>";
        }
    }
    $main_result .= "</VPROFILERESULT>";
    return $main_result;
}