Esempio n. 1
0
 public function stack_save($data)
 {
     $this->_check_access();
     /* do the rename before any other changes */
     if (array_key_exists('name', $data)) {
         Stack::_unimplemented();
     }
     $this->file_db->beginTransaction();
     /* update the stack; security fields */
     $did_update_something = false;
     $sql = Stack::_sql_optional_update('cinsimp_stack', $data, array('cant_modify:bool', 'cant_delete:bool', 'cant_peek:bool', 'cant_abort:bool', 'user_level:uint8', 'private_access:bool'));
     if ($sql !== null) {
         $this->_check_authenticated();
         $stmt = $this->file_db->prepare($sql['sql']);
         $stmt->execute($sql['params']);
         $did_update_something = true;
     }
     /* update the stack; general fields */
     $sql = Stack::_sql_optional_update('cinsimp_stack', $data, array('card_width:uint16', 'card_height:uint16', 'script:text16'));
     if ($sql !== null) {
         $this->_check_mutability();
         $stmt = $this->file_db->prepare($sql['sql']);
         $stmt->execute($sql['params']);
         $did_update_something = true;
     }
     /* increment the record version */
     if ($did_update_something) {
         $this->file_db->exec('UPDATE cinsimp_stack SET record_version=record_version + 1');
     }
     $this->file_db->commit();
     /* reload essentials */
     $this->load_check_essentials();
     return $this->record_version;
 }