public function mysql_save_from_post($post) { $lid = parent::mysql_save_from_post($post); if ($this->id != 0) { $this->delete_object_links(TestVariable::get_mysql_table()); $i = 0; } $i = 0; if (array_key_exists("parameters", $post)) { foreach ($post["parameters"] as $param) { $p = json_decode($param); $var = new TestVariable(); $var->description = $p->description; $var->name = $p->name; $var->index = $i; $var->type = 0; $var->Test_id = $lid; $var->mysql_save(); $i++; } } if (array_key_exists("returns", $post)) { foreach ($post["returns"] as $ret) { $r = json_decode($ret); $var = new TestVariable(); $var->description = $r->description; $var->name = $r->name; $var->index = $i; $var->type = 1; $var->Test_id = $lid; $var->mysql_save(); $i++; } } if (array_key_exists("deleteLogs", $post)) { if ($post["deleteLogs"] == "*") { $sql = sprintf("DELETE FROM `%s` WHERE `Test_id`=%s", TestSessionLog::get_mysql_table(), $lid); if (!mysql_query($sql)) { return json_encode(array("result" => -6, "message" => mysql_error())); } } else { $logs = json_decode($post["deleteLogs"]); foreach ($logs as $log) { $log = TestSessionLog::from_mysql_id($log); if ($log != null) { $log->mysql_delete(); } } } } $obj = static::from_mysql_id($lid); if ($obj != null) { $xml_hash = $obj->calculate_xml_hash(); $obj->xml_hash = $xml_hash; $obj->mysql_save(); } return $lid; }
public static function create_session_log($type, $wid, $sid, $tid, $hash, $template, $template_workspace, $status, $message, $ip, $browser) { $log = new TestSessionLog(); $log->UserWorkspace_id = $wid; $log->IP = $ip; $log->Template_id = $template; $log->Template_UserWorkspace_id = $template_workspace; $log->TestSession_id = $sid; $log->Test_id = $tid; $log->browser = $browser; $log->hash = $hash; $log->message = $message; $log->status = $status; $log->type = $type; $log->mysql_save(); }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ if (!isset($ini)) { require_once '../../Ini.php'; $ini = new Ini(); } $logged_user = User::get_logged_user(); if ($logged_user == null) { echo json_encode(array()); exit; } $obj = Test::from_mysql_id($_GET['oid']); if ($obj == null) { echo json_encode(array()); exit; } $i = 0; echo "["; foreach (TestSessionLog::from_property(array("Test_id" => $obj->id), true, "`created` DESC") as $log) { if ($i > 0) { echo ","; } echo json_encode(array("id" => $log->id, "type" => $log->type, "IP" => $log->IP, "browser" => $log->browser, "created" => $log->created, "message" => $log->message)); $i++; } echo "]";