/**
  * Save patch info into database & save uploaded files into content folder
  * @access  public
  * @return  xml string
  * @author  Cindy Qi Li
  */
 function saveInfo()
 {
     global $db;
     if ($this->current_patch_id == 0) {
         $sql = "INSERT INTO %smyown_patches \n\t\t               (atutor_patch_id, \n\t\t                applied_version,\n\t\t                description,\n\t\t                sql_statement,\n\t\t                status,\n\t\t                last_modified)\n\t\t\t        VALUES ('%s', '%s', '%s', '%s', 'Created', now())";
         $result = queryDB($sql, array(TABLE_PREFIX, $this->patch_info_array["atutor_patch_id"], $this->patch_info_array["atutor_version_to_apply"], $this->patch_info_array["description"], $this->patch_info_array["sql_statement"]));
     } else {
         $sql = "UPDATE %smyown_patches \n\t\t\t           SET atutor_patch_id = '%s',\n\t\t\t               applied_version = '%s',\n\t\t\t               description = '%s',\n\t\t\t               sql_statement = '%s',\n\t\t\t               status = 'Created',\n\t\t\t               last_modified = now()\n\t\t\t         WHERE myown_patch_id = %d";
         $result = queryDB($sql, array(TABLE_PREFIX, $this->patch_info_array["atutor_patch_id"], $this->patch_info_array["atutor_version_to_apply"], $this->patch_info_array["description"], $this->patch_info_array["sql_statement"], $this->current_patch_id));
     }
     if ($this->current_patch_id == 0) {
         $this->current_patch_id = at_insert_id();
     } else {
         $sql = "DELETE FROM %smyown_patches_dependent WHERE myown_patch_id = %d";
         $result = queryDB($sql, array(TABLE_PREFIX, $this->current_patch_id));
         $sql = "DELETE FROM %smyown_patches_files WHERE myown_patch_id = %d";
         $result = queryDB($sql, array(TABLE_PREFIX, $this->current_patch_id));
     }
     // insert records into table myown_patches_dependent
     if (is_array($this->patch_info_array["dependent_patches"])) {
         foreach ($this->patch_info_array["dependent_patches"] as $dependent_patch) {
             $sql = "INSERT INTO %smyown_patches_dependent (myown_patch_id, dependent_patch_id) VALUES (%d, '%s')";
             $result = queryDB($sql, array(TABLE_PREFIX, $this->current_patch_id, $dependent_patch));
         }
     }
     // insert records into table myown_patches_files
     if (is_array($this->patch_info_array["files"])) {
         foreach ($this->patch_info_array["files"] as $file_info) {
             if ($file_info["upload_tmp_name"] != "") {
                 $upload_to = $this->saveFile($file_info);
             } else {
                 $upload_to = "";
             }
             $sql = "INSERT INTO %smyown_patches_files\n\t\t               (myown_patch_id, action, name, location, code_from, code_to, uploaded_file)\n\t\t\t            VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')";
             $result = queryDB($sql, array(TABLE_PREFIX, intval($this->current_patch_id), $file_info["action"], my_add_null_slashes($file_info["file_name"]), my_add_null_slashes($file_info["directory"]), my_add_null_slashes($file_info["code_from"]), my_add_null_slashes($file_info["code_to"]), my_add_null_slashes($upload_to)), FALSE, FALSE);
         }
     }
 }
Example #2
0
 /**
  * Insert record into table patches_files_actions
  * @access  private
  * @param   $patch_files_actions_array	alter file actions and contents
  * @author  Cindy Qi Li
  */
 function createPatchesFilesActionsRecord($patch_files_actions_array)
 {
     $sql = "INSERT INTO %spatches_files_actions(patches_files_id, action, code_from, code_to) VALUES (%d, '%s', '%s', '%s')";
     $result = queryDB($sql, array(TABLE_PREFIX, intval($this->patch_file_id), $patch_files_actions_array['type'], my_add_null_slashes($patch_files_actions_array['code_from']), my_add_null_slashes($patch_files_actions_array['code_to'])), FALSE, FALSE);
     return true;
 }