Esempio n. 1
0
 public function mysql_save()
 {
     self::mysql_delete_obsolete();
     $this->id = parent::mysql_save();
     if (file_exists($this->temp_name)) {
         move_uploaded_file($this->temp_name, $this->get_source());
         $this->md5 = $this->get_calculated_md5();
         $this->mysql_save();
     }
     return $this->id;
 }
Esempio n. 2
0
 public function mysql_save()
 {
     $prev = UserShare::from_mysql_id($this->id);
     if ($this->id != 0 && $prev != null) {
         if ($this->UserWorkspace_id != $prev->UserWorkspace_id || $this->invitee_id != $prev->invitee_id) {
             $shares = UserShare::from_property(array("UserWorkspace_id" => $prev->UserWorkspace_id, "invitee_id" => $prev->invitee_id));
             $ws = $prev->get_UserWorkspace();
             if ($ws != null && count($shares) <= 1) {
                 $ws->revoke_privileges_db_user($prev->invitee_id);
             }
         }
     }
     $ws = UserWorkspace::from_mysql_id($this->UserWorkspace_id);
     if ($ws != null) {
         $ws->grant_privileges_db_user($this->invitee_id);
     }
     parent::mysql_save();
 }
Esempio n. 3
0
 public function mysql_save()
 {
     $new = false;
     if ($this->id == 0) {
         $new = true;
     }
     $lid = parent::mysql_save();
     if ($new) {
         $ts = TestSession::from_mysql_id($lid);
         $ts->hash = TestSession::generate_hash($lid);
         $ts->mysql_save();
     }
     return $lid;
 }
 public function create_db_user()
 {
     $user = Ini::$db_users_name_prefix . $this->id;
     $password = User::generate_password();
     $db_name = Ini::$db_users_db_name_prefix . $this->id;
     $sql = sprintf("CREATE USER '%s'@'localhost' IDENTIFIED BY '%s';", $user, $password);
     mysql_query($sql);
     $this->db_login = $user;
     $this->db_password = $password;
     $this->db_name = $db_name;
     parent::mysql_save();
     $sql = sprintf("CREATE DATABASE `%s` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", $db_name);
     mysql_query($sql);
     $sql = sprintf("GRANT ALL PRIVILEGES ON `%s`.* TO '%s'@'localhost'", $db_name, $user);
     mysql_query($sql);
     Ini::create_db_structure();
 }